def test_convert_with_profile(): cfgpath = setup_config(pxsize=1.34e-6, medium_index=1.346, wavelength=554.2e-9) _, path_in, path_out = setup_test_data() argsadd = argparse.Namespace(subparser_name="add", name="test_8440_prof_convert", path=cfgpath) profile.cli_profile(args=argsadd) try: # perform conversion h5data = cli_convert(path=path_in, ret_data=True, profile="test_8440_prof_convert") cfg = config.ConfigFile(path_out) assert np.allclose(cfg["meta"]["medium index"], 1.346) assert np.allclose(cfg["meta"]["pixel size um"], 1.34) assert np.allclose(cfg["meta"]["wavelength nm"], 554.2) with qpimage.QPSeries(h5file=h5data, h5mode="r") as qps: assert np.allclose(qps[0]["medium index"], 1.346) assert np.allclose(qps[0]["pixel size"], 1.34e-6) assert np.allclose(qps[0]["wavelength"], 554.2e-9) except BaseException: raise finally: # cleanup argsrem = argparse.Namespace(subparser_name="remove", name="test_8440_prof_convert") profile.cli_profile(args=argsrem)
def test_extract_meta_data(): """qpformat can automatically transfer the metadata from QPSeries files to the dataset which DryMass makes use of. """ _qpi, path_in, path_out = setup_test_data(pxsize=1.3e-6, medium_index=1.345, wavelength=555e-9, num=2, write_config=False) cli_convert(path=path_in) cfg = config.ConfigFile(path_out) assert cfg["meta"]["medium index"] == 1.345 assert cfg["meta"]["pixel size um"] == 1.3 assert cfg["meta"]["wavelength nm"] == 555
def test_base(): qpi, path_in, path_out = setup_test_data(num=2) h5data = cli_convert(path=path_in, ret_data=True) with qpimage.QPSeries(h5file=h5data, h5mode="r") as qps: assert np.allclose(qpi.pha, qps[0].pha) assert np.allclose(qpi.amp, qps[0].amp)
def test_bg_corr_index(): _qpi, path_in, path_out = setup_test_data(num=2) cfg = config.ConfigFile(path_out) cfg.set_value(section="bg", key="phase data", value=1) cfg.set_value(section="bg", key="amplitude data", value=1) h5data = cli_convert(path=path_in, ret_data=True) with qpimage.QPSeries(h5file=h5data, h5mode="r") as qps: assert np.all(qps[0].pha == 0) assert np.all(qps[0].amp == 1)
def test_bg_corr_file_relative(): _bgqpi, bg_path_in, bg_path_out = setup_test_data(num=1) _qpi, path_in, path_out = setup_test_data(num=2) cfg = config.ConfigFile(path_out) cfg.set_value(section="bg", key="phase data", value=str(bg_path_in.relative_to(path_in.parent))) cfg.set_value(section="bg", key="amplitude data", value=str(bg_path_in.relative_to(path_in.parent))) h5data = cli_convert(path=path_in, ret_data=True) with qpimage.QPSeries(h5file=h5data, h5mode="r") as qps: assert np.all(qps[0].pha == 0) assert np.all(qps[0].amp == 1)