bluesky / area-detector-handlers

https://pypi.org/project/area-detector-handlers
Other
1 stars 11 forks source link

Add eiger #5

Closed danielballan closed 4 years ago

danielballan commented 4 years ago

This PR ports the key component from https://github.com/NSLS-II/eiger-io/blob/master/eiger_io/fs_handler.py, but using dask instead of pims. The complexity has been substantially reduced, and it seems to produce the same results. Tested interactively against one representative run:

import databroker
import databroker.v0
import eiger_io.fs_handler
import numpy

UID = '6a1aeba4'
FIELD = 'eiger4m_single_image'

# Load data using v2.
catalog = databroker.catalog.chx()
dataset = catalog[UID].primary.to_dask()
data_array = dataset[FIELD]
data_array.load()

# Load data using v0 and check equality.
db = databroker.v0.Broker.named('chx')
db.reg.register_handler("AD_EIGER2", eiger_io.fs_handler.EigerHandler)
array_from_v0 = numpy.array(list(db[UID].data(FIELD)))
assert numpy.allclose(data_array.data, array_from_v0)
danielballan commented 4 years ago

To be clear, this interactive test is promising, but this should also have a unit test before it is merged.

danielballan commented 4 years ago

For the test, we can imitate the pattern used here.

https://github.com/bluesky/area-detector-handlers/blob/5d963d7969ba702bd9ea0fc51531a45339505c91/area_detector_handlers/tests/conftest.py#L56-L79

In this case we'll need to create at least two files within the fixture, a "master" file and one or two "data" files.

danielballan commented 4 years ago

@ke-zhang-rd added a test in a PR to my branch, which I have approved and merged. I would like one more review, from a third person, perhaps a re-review from @mrakitin, before we merge.

mrakitin commented 4 years ago

👍 I'll do it tomorrow.

mrakitin commented 4 years ago

Thanks for accepting my suggestions, @ke-zhang-rd and @danielballan!