Commit 89bedd41 authored by payno's avatar payno
Browse files

Merge branch 'rename_ref_titles_to_flat_titles' into 'master'

[h52nx] rename some remaining `ref_titles` to `flat_titles`.

See merge request !83
parents a1fca226 ba4e3517
Pipeline #62983 passed with stages
in 6 minutes and 17 seconds
......@@ -153,7 +153,7 @@ an option from command line
Titles corresponding to zserie init scans
--dark_titles DARK_TITLES, --dark-titles DARK_TITLES
Titles corresponding to dark scans
--ref_titles REF_TITLES, --ref-titles REF_TITLES
--flat_titles --flat_titles --ref_titles FLAT_TITLES, --ref-titles FLAT_TITLES
Titles corresponding to ref scans
--proj_titles PROJ_TITLES, --proj-titles PROJ_TITLES
Titles corresponding to projection scans
......
......@@ -82,7 +82,7 @@ Application to convert a bliss-hdf5 tomography dataset to Nexus - NXtomo (hdf5)
Titles corresponding to zserie init scans
--dark_titles DARK_TITLES, --dark-titles DARK_TITLES
Titles corresponding to dark scans
--ref_titles REF_TITLES, --ref-titles REF_TITLES
--flat_titles --flat-titles --ref_titles REF_TITLES, --ref-titles FLAT_TITLES
Titles corresponding to ref scans
--proj_titles PROJ_TITLES, --proj-titles PROJ_TITLES
Titles corresponding to projection scans
......@@ -303,10 +303,11 @@ def main(argv):
help="Titles corresponding to dark scans",
)
parser.add_argument(
"--ref_titles",
"--flat_titles" "--flat-titles" "--ref_titles",
"--ref-titles",
default=None,
help="Titles corresponding to ref scans",
dest="flat_titles",
)
parser.add_argument(
"--proj_titles",
......
......@@ -80,7 +80,7 @@ Application to convert a tomo dataset written in bliss- hdf5 - 3D-XRD into and h
Titles corresponding to zserie init scans
--dark_titles DARK_TITLES, --dark-titles DARK_TITLES
Titles corresponding to dark scans
--ref_titles REF_TITLES, --ref-titles REF_TITLES
--flat-titles --flat_titles --ref_titles REF_TITLES, --ref-titles FLAT_TITLES
Titles corresponding to ref scans
--proj_titles PROJ_TITLES, --proj-titles PROJ_TITLES
Titles corresponding to projection scans
......@@ -293,10 +293,13 @@ def main(argv):
help="Titles corresponding to dark scans",
)
parser.add_argument(
"--flat_titles",
"--flat-titles",
"--ref_titles",
"--ref-titles",
default=None,
help="Titles corresponding to ref scans",
dest="flat_titles",
)
parser.add_argument(
"--proj_titles",
......
......@@ -82,7 +82,8 @@ H5_DARK_TITLES = Tomo.H5.DARK_TITLES
H5_INIT_TITLES = Tomo.H5.INIT_TITLES
H5_ZSERIE_INIT_TITLES = Tomo.H5.ZSERIE_INIT_TITLES
H5_PROJ_TITLES = Tomo.H5.PROJ_TITLES
H5_REF_TITLES = Tomo.H5.REF_TITLES
H5_FLAT_TITLES = Tomo.H5.FLAT_TITLES
H5_REF_TITLES = H5_FLAT_TITLES
H5_Y_ROT_KEY = Tomo.H5.Y_ROT_KEY
H5_DIODE_KEYS = Tomo.H5.DIODE_KEYS
......@@ -90,7 +91,7 @@ DEFAULT_SCAN_TITLES = H5ScanTitles(
H5_INIT_TITLES,
H5_ZSERIE_INIT_TITLES,
H5_DARK_TITLES,
H5_REF_TITLES,
H5_FLAT_TITLES,
H5_PROJ_TITLES,
H5_ALIGNMENT_TITLES,
)
......@@ -759,7 +760,7 @@ def h5_to_nx(
configuration.init_titles = scan_titles.init_titles
configuration.zserie_init_titles = scan_titles.init_zserie_titles
configuration.dark_titles = scan_titles.dark_titles
configuration.flat_titles = scan_titles.ref_titles
configuration.flat_titles = scan_titles.flat_titles
configuration.projections_titles = scan_titles.proj_titles
configuration.alignment_titles = scan_titles.align_titles
......
......@@ -53,7 +53,7 @@ H5ScanTitles = namedtuple(
"init_titles",
"init_zserie_titles",
"dark_titles",
"ref_titles",
"flat_titles",
"proj_titles",
"align_titles",
],
......
......@@ -192,7 +192,9 @@ class TomoHDF5Config:
DARK_TITLES_DK = "dark_titles"
REF_TITLES_DK = "ref_titles"
FLAT_TITLES_DK = "flat_titles"
FLAT_TILES_ALIASES = ("ref_titles",)
PROJ_TITLES_DK = "proj_titles"
......@@ -213,7 +215,7 @@ class TomoHDF5Config:
INIT_TITLES_DK: "List of title to consider the group/entry as a initialization (sequence start). Ignored if dark_groups, flat_groups, projection_groups ... are provided.",
ZSERIE_INIT_TITLES_DK: "List of title to consider the group/entry as a zserie initialization (sequence start). Ignored if dark_groups, flat_groups, projection_groups ... are provided.",
DARK_TITLES_DK: "List of title to consider the group/entry as a dark. Ignored if dark_groups, flat_groups, projection_groups ... are provided.",
REF_TITLES_DK: "List of title to consider the group/entry as a reference / flat. Ignored if dark_groups, flat_groups, projection_groups ... are provided.",
FLAT_TITLES_DK: "List of title to consider the group/entry as a reference / flat. Ignored if dark_groups, flat_groups, projection_groups ... are provided.",
PROJ_TITLES_DK: "List of title to consider the group/entry as a projection. Ignored if dark_groups, flat_groups, projection_groups ... are provided.",
ALIGNMENT_TITLES_DK: "List of title to consider the group/entry as an alignment. Ignored if dark_groups, flat_groups, projection_groups ... are provided.",
X_PIXEL_SIZE_KEYS_DK: "List of keys / paths to look for the x pixel size",
......@@ -327,7 +329,7 @@ class TomoHDF5Config:
self._init_titles = settings.Tomo.H5.INIT_TITLES
self._zserie_init_titles = settings.Tomo.H5.ZSERIE_INIT_TITLES
self._dark_titles = settings.Tomo.H5.DARK_TITLES
self._flat_titles = settings.Tomo.H5.REF_TITLES
self._flat_titles = settings.Tomo.H5.FLAT_TITLES
self._projection_titles = settings.Tomo.H5.PROJ_TITLES
self._alignment_titles = settings.Tomo.H5.ALIGNMENT_TITLES
self._x_pixel_size_paths = settings.Tomo.H5.X_PIXEL_SIZE
......@@ -877,7 +879,7 @@ class TomoHDF5Config:
TomoHDF5Config.INIT_TITLES_DK: self.init_titles or "",
TomoHDF5Config.ZSERIE_INIT_TITLES_DK: self.zserie_init_titles or "",
TomoHDF5Config.DARK_TITLES_DK: self.dark_titles or "",
TomoHDF5Config.REF_TITLES_DK: self.flat_titles or "",
TomoHDF5Config.FLAT_TITLES_DK: self.flat_titles or "",
TomoHDF5Config.PROJ_TITLES_DK: self.projections_titles or "",
TomoHDF5Config.ALIGNMENT_TITLES_DK: self.alignment_titles or "",
},
......@@ -1092,10 +1094,30 @@ class TomoHDF5Config:
dark_titles = convert_str_to_tuple(dark_titles, none_if_empty=True)
self.dark_titles = dark_titles
# handle ref titles. empty string is consider as a valid value
flat_titles = dict_.get(TomoHDF5Config.REF_TITLES_DK, None)
if flat_titles is not None:
flat_titles = convert_str_to_tuple(flat_titles, none_if_empty=True)
self.flat_titles = flat_titles
flat_titles_dks = [
TomoHDF5Config.FLAT_TITLES_DK,
]
flat_titles_dks.extend(TomoHDF5Config.FLAT_TILES_ALIASES)
flat_title_key_picked = None
## handle flat titles
for alias in flat_titles_dks:
flat_titles = dict_.get(alias, None)
if flat_titles is not None:
if flat_title_key_picked is not None:
_logger.warning(
f"flat titles are provided twice under {flat_title_key_picked} and {alias}. Please clean your configuration file. {flat_title_key_picked} will be used"
)
else:
flat_titles = convert_str_to_tuple(flat_titles, none_if_empty=True)
self.flat_titles = flat_titles
flat_title_key_picked = alias
if (
flat_title_key_picked is not None
and flat_title_key_picked != TomoHDF5Config.FLAT_TITLES_DK
):
_logger.warning(
f"{flat_title_key_picked} will be removed in the future. Please use {TomoHDF5Config.FLAT_TITLES_DK} instead"
)
# handle projection titles. empty string is consider as a valid value
proj_titles = dict_.get(TomoHDF5Config.PROJ_TITLES_DK, None)
if proj_titles is not None:
......
......@@ -250,7 +250,7 @@ class TomoHDF5ConfigHandler(BaseHDF5ConfigHandler):
self.get_tuple_of_keys_from_cmd,
),
"dark_titles": ("dark_titles", self.get_tuple_of_keys_from_cmd),
"ref_titles": ("flat_titles", self.get_tuple_of_keys_from_cmd),
"flat_titles": ("flat_titles", self.get_tuple_of_keys_from_cmd),
"proj_titles": ("projections_titles", self.get_tuple_of_keys_from_cmd),
"align_titles": ("alignment_titles", self.get_tuple_of_keys_from_cmd),
"set_params": ("param_already_defined", _extract_param_value),
......@@ -279,7 +279,7 @@ class TomoHDF5ConfigHandler(BaseHDF5ConfigHandler):
"set_params",
"align_titles",
"proj_titles",
"ref_titles",
"flat_titles",
"dark_titles",
"init_zserie_titles",
"init_titles",
......@@ -361,7 +361,7 @@ class XRD3DHDF5ConfigHandler(BaseHDF5ConfigHandler):
self.get_tuple_of_keys_from_cmd,
),
"dark_titles": ("dark_titles", self.get_tuple_of_keys_from_cmd),
"ref_titles": ("flat_titles", self.get_tuple_of_keys_from_cmd),
"flat_titles": ("flat_titles", self.get_tuple_of_keys_from_cmd),
"proj_titles": ("projections_titles", self.get_tuple_of_keys_from_cmd),
"align_titles": ("alignment_titles", self.get_tuple_of_keys_from_cmd),
"set_params": ("param_already_defined", _extract_param_value),
......@@ -390,7 +390,7 @@ class XRD3DHDF5ConfigHandler(BaseHDF5ConfigHandler):
"set_params",
"align_titles",
"proj_titles",
"ref_titles",
"flat_titles",
"dark_titles",
"init_zserie_titles",
"init_titles",
......
......@@ -70,7 +70,7 @@ class TestH5Config(unittest.TestCase):
titles_dict[TomoHDF5Config.PROJ_TITLES_DK], settings.Tomo.H5.PROJ_TITLES
)
self.assertEqual(
titles_dict[TomoHDF5Config.REF_TITLES_DK], settings.Tomo.H5.REF_TITLES
titles_dict[TomoHDF5Config.FLAT_TITLES_DK], settings.Tomo.H5.FLAT_TITLES
)
self.assertEqual(
titles_dict[TomoHDF5Config.DARK_TITLES_DK], settings.Tomo.H5.DARK_TITLES
......@@ -147,7 +147,7 @@ class TestH5Config(unittest.TestCase):
TomoHDF5Config.PROJ_TITLES_DK,
TomoHDF5Config.ZSERIE_INIT_TITLES_DK,
TomoHDF5Config.INIT_TITLES_DK,
TomoHDF5Config.REF_TITLES_DK,
TomoHDF5Config.FLAT_TITLES_DK,
TomoHDF5Config.DARK_TITLES_DK,
):
with self.subTest(key=key):
......
......@@ -47,7 +47,7 @@ class _ARParseMock(object):
self.set_params = None
self.align_titles = None
self.proj_titles = None
self.ref_titles = None
self.flat_titles = None
self.dark_titles = None
self.init_zserie_titles = None
self.init_titles = None
......
......@@ -89,7 +89,7 @@ class Tomo:
DARK_TITLES = ("dark images", "dark")
"""if a scan starts by one of those string then is considered as
dark scan"""
REF_TITLES = ("flat", "reference images", "ref", "refend")
FLAT_TITLES = ("flat", "reference images", "ref", "refend")
"""if a scan starts by one of those string then is considered as
reference scan"""
PROJ_TITLES = ("projections", "ascan rot 0 ", "ascan diffrz 0 180 1600 0.1")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment