-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
today's exercise:
- Generate a 'start' document with some metadata about a spectrum, an 'event' document with the spectrum, and the other required documents.
- Insert them into a development, disposable MongoDB database (
mongodb://xf08id-ca1:27017/dev_analyzed_data). - Access the saved metadata and data (as
xarray.Dataset). - Search for the saved spectra based on recency, element metadata, and
E0metadata.
The following needs to be wrapped into an easy-to-use function:
from event_model import compose_run
compose_run()
compose_run?
bundle = compose_run(metadata={'Sample_name': 'Pt', 'compound': 'Pt', 'Element' : 'Pt', 'Edge' : 'L3', 'E0': 11564})
bundle
bundle.start_doc
from suitcase.mongo_normalized import Serializer
ser = Serializer('mongodb://xf08id-ca1:27017/dev_analyzed_data', 'mongodb://xf08id-ca1:27017/dev_analyzed_data')
ser
ser('start', bundle.start_doc)
bundle.compose_descriptor(data_keys={'Energy' : {'dtype' : 'array', 'source' : '', 'shape' : [-1]},''})
bundle.compose_descriptor(data_keys={'Energy' : {'dtype' : 'array', 'source' : '', 'shape' : [-1]}, 'mu_norm' : {'dtype' : 'array', 'source' : '', 'shape' : [-1]}})
bundle2 = bundle.compose_descriptor(data_keys={'Energy' : {'dtype' : 'array', 'source' : '', 'shape' : [-1]}, 'mu_norm' : {'dtype' : 'array', 'source' : '', 'shape' : [-1]}}, name='primary')
bundle2
ser('descriptor', bundle2.descriptor_doc)
bundle2.compose_event(data={'Energy' : [1,2,3], 'mu_norm' : [0.1, 0.2, 0.3]}, timestamps={'Energy':0, 'mu_norm' : 0})
ser('event', _22)
bundle.compose_stop()
ser('stop', _24)
from databroker._drivers.mongo_normalized import BlueskyMongoCatalog
uri = "mongodb://xf08id-ca1:27017/dev_analyzed_data"
catalog = BlueskyMongoCatalog(uri, uri)
catalog
catalog[-1]
catalog[-1].primary
catalog[-1].primary.read()
len(catalog.search({'Element':'Pt'}))
len(catalog.search({'Element':'Co'}))
catalog[-1].metadata
len(catalog.search({'E0':{'$lt' : 10000}}))
len(catalog.search({'E0':{'$gt' : 10000}}))mrakitin
Metadata
Metadata
Assignees
Labels
No labels