Skip to main content

Top-level package for xedocs.

Project description

XeDocs manages tracking versioned detector numbers, replacing CMT and ideally all hard-coded values. XeDocs both looks up data from its own online database, and uses straxen URL-style lookup to find other resources. To upload data to the XeDocs database, you must submit it as a PR to https://github.com/XENONnT/corrections

What does Xedocs give you

Data reading

  • Read data from multiple formats (e.g. mongodb, pandas) and locations with a simple unified interface.

  • Custom logic implemented on the document class, e.g. creating a tensorflow model from the data etc.

  • Multiple APIs for reading data, fun functional, ODM style, pandas and xarray.

  • Read data as objects, dataframes, dicts, json.

Writing data

  • Write data to multiple storage backends with the same interface

  • Custom per-collection rules for data insertion, deletion and updating.

  • Schema validation and type coercion so storage has uniform and consistent data.

Other

  • Custom panel widgets for graphical representation of data, web client

  • Auto-generated API server and client + openapi documentation

  • CLI for viewing and downloading data

Basic Usage

Explore the available schemas

import xedocs

>>> xedocs.list_schemas()
>>> ['detector_numbers',
    'fax_configs',
    'plugin_lineages',
    'context_lineages',
    'pmt_area_to_pes',
    'global_versions',
    'electron_drift_velocities',
    ...]

>>> xedocs.help('pmt_area_to_pes')

>>>
        Schema name: pmt_area_to_pes
        Index fields: ['version', 'time', 'detector', 'pmt']
        Column fields: ['created_date', 'comments', 'value']

Read/write data from the shared development database, this database is writable from the default analysis username/password

import xedocs

db = xedocs.development_db()

docs = db.pmt_area_to_pes.find_docs(version='v1', pmt=[1,2,3,5], time='2021-01-01T00:00:00', detector='tpc')
to_pes = [doc.value for doc in docs]

# passing a run_id will attempt to fetch the center time of that run from the runs db
doc = db.pmt_area_to_pes.find_one(version='v1', pmt=1, run_id=25000, detector='tpc')
to_pe = doc.value

Read from the straxen processing database, this database is read-only for the default analysis username/password

import xedocs

db = xedocs.straxen_db()

...

Read from the the corrections gitub repository, this database is read-only

import xedocs

db = xedocs.corrections_repo(branch="master")

...

If you cloned the corrections gitub repo to a local folder, this database can be read too

import xedocs

db = xedocs.local_folder(PATH_TO_REPO_FOLDER)

...

Read data from alternative data sources specified by path, e.g csv files which will be loaded by pandas.

from xedocs.schemas import DetectorNumber

g1_doc = DetectorNumber.find_one(datasource='/path/to/file.csv', version='v1', field='g1')
g1_value = g1_doc.value
g1_error = g1_doc.uncertainty

The path can also be a github URL or any other URL supported by fsspec.

from xedocs.schemas import DetectorNumber

g1_doc = DetectorNumber.find_one(
                         datasource='github://org:repo@/path/to/file.csv',
                         version='v1',
                         field='g1')

Supported data sources

  • MongoDB collections

  • TinyDB tables

  • JSON files

  • REST API clients

Please open an issue on rframe if you want support for an additional data format.

If you want a new datasource to be available from a schema class, you can register it to the class:

from xedocs.schemas import DetectorNumber

DetectorNumber.register_datasource('github://org:repo@/path/to/file.csv', name='github_repo')

# The source will now be available under the given name:

g1_doc = DetectorNumber.github_repo.find_one(version='v1', field='g1')

Documentation

Full documentation hosted by Readthedocs

Credits

This package was created with Cookiecutter and the briggySmalls/cookiecutter-pypackage project template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xedocs-0.2.31.tar.gz (46.6 kB view details)

Uploaded Source

Built Distribution

xedocs-0.2.31-py3-none-any.whl (68.9 kB view details)

Uploaded Python 3

File details

Details for the file xedocs-0.2.31.tar.gz.

File metadata

  • Download URL: xedocs-0.2.31.tar.gz
  • Upload date:
  • Size: 46.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for xedocs-0.2.31.tar.gz
Algorithm Hash digest
SHA256 cca9d03bf4611cd9f4587796a6f477729492d9dfc8c64afdaf5047b346aa85ef
MD5 9ad76d0d35bd7c1da96dd32a098fe96e
BLAKE2b-256 7c0e6a4d08e54e2964c0014f45d43492592fe31cb60fa65c5cfb5d6bc74aab2d

See more details on using hashes here.

File details

Details for the file xedocs-0.2.31-py3-none-any.whl.

File metadata

  • Download URL: xedocs-0.2.31-py3-none-any.whl
  • Upload date:
  • Size: 68.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for xedocs-0.2.31-py3-none-any.whl
Algorithm Hash digest
SHA256 b59f09d42d32d9ac4447fd6ff474677af0d459bc7b72a31778a0ad508c65ed43
MD5 bb6577e49eebafe9730b654b4cf798d2
BLAKE2b-256 29b4bc56fadb9f39baeec5b60508a23300ed79ec001489d8a13f27147e23eeaa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page