Commit e67ea2fd authored by Henri Payno's avatar Henri Payno
Browse files

[app][dxfile2nx] allow to provide pixel size as a single value

close #66
parent fb24e3c8
Pipeline #55829 passed with stages
in 10 minutes and 47 seconds
......@@ -64,6 +64,24 @@ def convert_2elmts__tuple_to_float(input_str) -> tuple:
return float(v1), float(v2)
def _get_pixel_size(input_str) -> tuple:
try:
values = convert_2elmts__tuple_to_float(input_str)
except ValueError:
try:
value = float(input_str)
except Exception:
raise ValueError(
f"Unable to convert {input_str} to pixel size."
f"Should be provided as a tuple (x_pixel_size, y_pixel_size) "
f"or as a single value pixel_size"
)
else:
return value, value
else:
return values
def main(argv):
""" """
parser = argparse.ArgumentParser(
......@@ -103,7 +121,7 @@ def main(argv):
parser.add_argument(
"--pixel-size",
default=(None, None),
help="pixel size in meter as (x pixel size, y pixel size)",
help="pixel size in meter as (x pixel size, y pixel size) or as a single value",
)
parser.add_argument(
"--fov",
......@@ -167,7 +185,7 @@ def main(argv):
input_entry=options.input_entry,
output_entry=options.output_entry,
scan_range=convert_2elmts__tuple_to_float(options.scan_range),
pixel_size=convert_2elmts__tuple_to_float(options.pixel_size),
pixel_size=_get_pixel_size(options.pixel_size),
field_of_view=options.field_of_view,
distance=distance,
overwrite=options.overwrite,
......
Supports Markdown
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