def test_Datasets(self, session): template = { 'entry:NXentry': { 'name': DeviceDataset('Exp', 'title'), 'def': ConstDataset('NXmonopd', 'string'), 'sry': DeviceDataset('sry', units=NXAttribute('deg', 'string')), }, } session.experiment.title = 'GurkenTitle' maw(session.getDevice('sry'), 23.7) session.experiment.setDetectors([ 'det', ]) setTemplate(template) self.setScanCounter(session, 46) count(t=.1) fin = h5py.File( path.join(session.experiment.datapath, 'test%sn000047.hdf' % year), 'r') ds = fin['entry/name'] assert (ds[0] == b'GurkenTitle') ds = fin['entry/def'] assert (ds[0] == b'NXmonopd') ds = fin['entry/sry'] assert (ds[0] == 23.7) assert (ds.attrs['units'] == b'deg') fin.close()
def test_Link(self, session): template = { 'entry:NXentry': { 'sry': DeviceDataset('sry'), }, 'data:NXdata': { 'srlink': NXLink('/entry/sry'), } } maw(session.getDevice('sry'), 77.7) session.experiment.setDetectors([ 'det', ]) setTemplate(template) self.setScanCounter(session, 50) count(t=.1) fin = h5py.File( path.join(session.experiment.datapath, 'test%sn000051.hdf' % year), 'r') ds = fin['entry/sry'] assert (ds[0] == 77.7) ds = fin['data/srlink'] assert (ds[0] == 77.7) assert (ds.attrs['target'] == b'/entry/sry') fin.close()
def test_Scan(self, session): template = { 'entry:NXentry': { 'time': DetectorDataset('timer', 'float32'), 'mon': DetectorDataset('mon1', 'uint32'), 'counts': ImageDataset(0, 0, signal=NXAttribute(1, 'int32')), 'sry': DeviceDataset('sry'), }, 'data:NXdata': { 'None': NXScanLink(), } } setTemplate(template) self.setScanCounter(session, 48) session.experiment.setDetectors([ 'det', ]) sry = session.getDevice('sry') scan(sry, 0, 1, 5, t=0.001) fin = h5py.File( path.join(session.experiment.datapath, 'test%sn000049.hdf' % year), 'r') ds = fin['entry/sry'] assert (len(ds) == 5) ds = fin['entry/time'] assert (len(ds) == 5) ds = fin['entry/mon'] assert (len(ds) == 5) ds = fin['entry/counts'] assert (len(ds) == 5) ds = fin['data/sry'] assert (len(ds) == 5) assert (ds[0] == 0) assert (ds[1] == 1) assert (ds[2] == 2) assert (ds[3] == 3) assert (ds.attrs['target'] == b'/entry/sry') fin.close()
def test_hierarchy(self, session): template = { 'instrument': 'test', 'entry:NXentry': {}, } setTemplate(template) session.experiment.setDetectors([ 'det', ]) self.setScanCounter(session, 44) count(t=0.1) fin = h5py.File( path.join(session.experiment.datapath, 'test%sn000045.hdf' % year), 'r') att = fin.attrs['instrument'] assert (att == b'test') g = fin['entry'] att = g.attrs['NX_class'] assert (att == b'NXentry') fin.close()
def test_Detector(self, session): template = { 'data:NXdata': { 'time': DetectorDataset('timer', 'float32'), 'mon': DetectorDataset('mon1', 'uint32'), 'counts': ImageDataset(0, 0, signal=NXAttribute(1, 'int32')), }, } setTemplate(template) self.setScanCounter(session, 49) session.experiment.setDetectors([ 'det', ]) count(t=.1) fin = h5py.File( path.join(session.experiment.datapath, 'test%sn000050.hdf' % year), 'r') ds = fin['data/time'] ds = fin['data/mon'] ds = fin['data/counts'] assert (ds.attrs['signal'] == 1) fin.close()
def test_Attributes(self, session): template = { 'entry:NXentry': { 'title': DeviceAttribute('Exp', 'title'), 'units': NXAttribute('mm', 'string'), } } session.experiment.title = 'GurkenTitle' setTemplate(template) self.setScanCounter(session, 47) session.experiment.setDetectors([ 'det', ]) count(t=.1) fin = h5py.File( path.join(session.experiment.datapath, 'test%sn000048.hdf' % year), 'r') g = fin['entry'] assert (g.attrs['title'] == b'GurkenTitle') assert (g.attrs['units'] == b'mm') fin.close()