def test_rotation_scan_i04(master_h5): assert FormatNexusEigerDLS16M.understand(master_h5) expts = ExperimentListFactory.from_filenames( [master_h5], format_kwargs={"dynamic_shadowing": True}) imageset = expts[0].imageset assert imageset.get_format_class() == FormatNexusEigerDLS16M detector = imageset.get_detector() gonio = imageset.get_goniometer() scan = imageset.get_scan() beam = imageset.get_beam() panel = detector[0] assert panel.get_pixel_size() == (0.075, 0.075) assert panel.get_image_size() == (4148, 4362) assert panel.get_trusted_range() == (-1, 65535) assert panel.get_fast_axis() == (1, 0, 0) assert panel.get_slow_axis() == (0, -1, 0) assert panel.get_origin() == pytest.approx( (-166.07661632390744, 172.5371934106162, -200.0)) assert panel.get_distance() == 200 assert len(gonio.get_axes()) == 3 expected_axes = ((1, 0, 0), (0, 0, -1), (1, 0, 0)) for a1, a2 in zip(gonio.get_axes(), expected_axes): assert a1 == pytest.approx(a2, abs=5e-2) assert gonio.get_scan_axis() == 2 assert scan.get_oscillation() == (0, 0.2) assert scan.get_image_range() == (1, 900) assert beam.get_wavelength() == pytest.approx(0.979499) assert beam.get_s0() == pytest.approx((0, 0, -1 / beam.get_wavelength()))
def test_masked_i03_16bit(master_h5): assert FormatNexusEigerDLS16M.understand(master_h5) expts = ExperimentListFactory.from_filenames([master_h5]) imageset = expts[0].imageset assert flex.min(imageset[0][0]) == -1.0 assert flex.max(imageset[0][0]) != 0xFFFF
def test_grid_scan_i04(): master_h5 = "/dls/i04/data/2019/cm23004-1/20190109/Eiger/grid/Thaum/Thau_5/Thau_5_1_master.h5" assert FormatNexusEigerDLS16M.understand(master_h5) expts = ExperimentListFactory.from_filenames([master_h5]) imageset = expts[0].imageset assert imageset.get_format_class() == FormatNexusEigerDLS16M detector = imageset.get_detector() gonio = imageset.get_goniometer() scan = imageset.get_scan() beam = imageset.get_beam() panel = detector[0] assert panel.get_pixel_size() == (0.075, 0.075) assert panel.get_image_size() == (4148, 4362) assert panel.get_trusted_range() == (-1, 65535) assert panel.get_fast_axis() == (1, 0, 0) assert panel.get_slow_axis() == (0, -1, 0) assert panel.get_origin() == pytest.approx( (-167.44717577120824, 172.46833023184868, -350.0)) assert panel.get_distance() == 350 assert len(gonio.get_axes()) == 3 expected_axes = ((1, 0, 0), (0, 0, -1), (1, 0, 0)) for a1, a2 in zip(gonio.get_axes(), expected_axes): assert a1 == pytest.approx(a2, abs=5e-2) # assert gonio.get_scan_axis() == 2 if scan: osc = scan.get_oscillation() assert osc[0] == osc[1] assert beam.get_wavelength() == pytest.approx(0.979499) assert beam.get_s0() == pytest.approx((0, 0, -1 / beam.get_wavelength()))
def test_units(): master_h5 = "/dls/i04/data/2019/cm23004-1/20190114/Eiger/grid/Se_Thaum/Se_Thaum_12/Se_Thaum_12_2_master.h5" assert FormatNexusEigerDLS16M.understand(master_h5) datablocks = DataBlockFactory.from_filenames([master_h5]) imageset = datablocks[0].extract_imagesets()[0] assert imageset.get_format_class() == FormatNexusEigerDLS16M detector = imageset.get_detector() scan = imageset.get_scan() beam = imageset.get_beam() panel = detector[0] assert panel.get_pixel_size() == (0.075, 0.075) assert panel.get_fast_axis() == (1, 0, 0) assert panel.get_slow_axis() == (0, -1, 0) # XXX Need to check and update expected values here, however the ones # dxtbx is currently generating from the file are very wrong assert panel.get_origin() == pytest.approx( (-167.35570274412459, 172.4729262553403, -339.9887931971389)) assert panel.get_distance() == pytest.approx(339.9887931971389) assert scan is None assert beam.get_wavelength() == pytest.approx(0.979499) assert beam.get_s0() == pytest.approx((0, 0, -1 / beam.get_wavelength())) assert panel.get_beam_centre_px(beam.get_s0()) == pytest.approx( (2231.41, 2299.64))
def test_screening(dials_data): master_h5 = dials_data("thaumatin_eiger_screen").join("Therm_6_1_master.h5").strpath assert FormatNexusEigerDLS16M.understand(master_h5) expts = ExperimentListFactory.from_filenames([master_h5]) assert len(expts) == 3 imagesets = expts[0].imageset assert imagesets[0].get_format_class() == FormatNexusEigerDLS16M
def test_screening(): master_h5 = "/dls/i04/data/2019/cm23004-1/20190109/Eiger/gw-screen/Thaum/Thau_3/Thau_3_1_master.h5" assert FormatNexusEigerDLS16M.understand(master_h5) datablocks = DataBlockFactory.from_filenames([master_h5]) imagesets = datablocks[0].extract_imagesets() assert len(imagesets) == 3 assert imagesets[0].get_format_class() == FormatNexusEigerDLS16M
def test_do_not_understand_i24(tmp_path): nxs = tmp_path / "data.nxs" with h5py.File(nxs, mode="w") as fh: entry = fh.create_group("entry") instrument = entry.create_group("instrument") instrument.attrs["short_name"] = np.string_("DLS I24") name = instrument.create_dataset( "name", data=np.string_("DIAMOND BEAMLINE I24") ) name.attrs["short_name"] = np.string_("DLS I24") assert not FormatNexusEigerDLS16M.understand(nxs)
def test_understand_legacy(beamline, tmp_path): # See https://jira.diamond.ac.uk/browse/MXGDA-3624 nxs = tmp_path / "data.nxs" with h5py.File(nxs, mode="w") as fh: entry = fh.create_group("entry") instrument = entry.create_group("instrument") instrument.attrs["short_name"] = np.string_(f"{beamline}") name = instrument.create_dataset("name", data=np.string_(f"{beamline}")) name.attrs["short_name"] = np.string_(f"{beamline}") assert FormatNexusEigerDLS16M.understand(nxs) assert FormatNexusEigerDLS.understand(nxs)
def test_rotation_scan_i03_2019_run_4(master_h5): assert FormatNexusEigerDLS16M.understand(master_h5) expts = ExperimentListFactory.from_filenames( [master_h5], format_kwargs={"dynamic_shadowing": True}) imageset = expts[0].imageset assert imageset.get_format_class() == FormatNexusEigerDLS16M gonio = imageset.get_goniometer() assert list(gonio.get_angles()) == pytest.approx([45.0, 45.0, 45.0]) assert list(gonio.get_axes().as_double()) == pytest.approx( [1.0, -0.0025, 0.0056, -0.006, -0.0264, -0.9996, 1.0, 0.0, 0.0]) assert list(gonio.get_names()) == ["phi", "chi", "omega"] assert imageset.has_dynamic_mask() masker = imageset.masker() assert isinstance(masker, SmarGonShadowMasker) assert masker.get_mask(imageset.get_detector(), 0)[0].count(False) == 0 masker.get_mask(imageset.get_detector(), 50)[0].count(False) == 486717 assert masker.get_mask(imageset.get_detector(), 100)[0].count(False) == 1092226
def test_do_not_understand_name_none(tmp_path): nxs = tmp_path / "data.nxs" with h5py.File(nxs, mode="w") as fh: entry = fh.create_group("entry") entry.create_group("instrument") assert not FormatNexusEigerDLS16M.understand(nxs)