Commit 4d1c2931 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Release 2020.4.1

parent 7f4e416f
# Change Log
## 2020.4.1
This is a minor version bringing some fixes in the application.
### Application
- In the HDF5-NX dataset file, the pixel size taken by nabu is now `magnified_pixel_size` instead of `pixel_size`. This will have notable consequences for phase retrieval (`delta_beta` will be much smaller to obtain the same effect).
- The `nabu-config` command line does not need the `--bootstrap` flag anymore, as it is not the default behavior.
- Configuration file: angles in `angles_files` have to be provided in degrees (as for `angles_offset`)
- Fixed some comments in configuration file
- A more helpful error will be returned if either flat/dark is missing from NX file.
## 2020.4.0
This is a version adds a number of features.
......
......@@ -23,9 +23,11 @@ def bootstrap():
do_convert = (args["convert"] != "")
no_comments = bool(args["nocomments"])
if (do_bootstrap ^ do_convert) == 0:
print("You must specify either --bootstrap or --convert")
exit(0)
if do_convert: # do_convert
print("The --convert option is deprecated. It will be removed in a future version")
exit(1)
if do_bootstrap:
print("The --bootstrap option is now the default behavior of the nabu-config command. This option is therefore not needed anymore.")
if path.isfile(args["output"]):
rep = input("File %s already exists. Overwrite ? [y/N]" % args["output"])
......@@ -33,18 +35,14 @@ def bootstrap():
print("Stopping")
exit(0)
if do_bootstrap:
prefilled_values = {}
if args["dataset"] != "":
prefilled_values["dataset"] = {}
prefilled_values["dataset"]["location"] = args["dataset"]
generate_nabu_configfile(
args["output"],
comments=not(no_comments),
options_level=args["level"],
prefilled_values=prefilled_values,
)
else: # do_convert
print("PyHST file converter is not implemented yet")
exit(1)
prefilled_values = {}
if args["dataset"] != "":
prefilled_values["dataset"] = {}
prefilled_values["dataset"]["location"] = args["dataset"]
generate_nabu_configfile(
args["output"],
comments=not(no_comments),
options_level=args["level"],
prefilled_values=prefilled_values,
)
......@@ -93,7 +93,7 @@ class DatasetAnalyzer(object):
"""
Return the pixel size in microns.
"""
return self.dataset_scanner.pixel_size * 1e6 # TODO X and Y pixel size
raise ValueError("Must be implemented by inheriting class")
@property
def binning(self):
......@@ -152,6 +152,15 @@ class EDFDatasetAnalyzer(DatasetAnalyzer):
# Not available in EDF dataset
return None
@property
def pixel_size(self):
"""
Return the pixel size in microns.
"""
# TODO X and Y pixel size
return self.dataset_scanner.pixel_size * 1e6
class HDF5DatasetAnalyzer(DatasetAnalyzer):
"""
......@@ -255,6 +264,22 @@ class HDF5DatasetAnalyzer(DatasetAnalyzer):
return self._get_dataset_hdf5_url()
@property
def pixel_size(self):
"""
Return the pixel size in microns.
"""
# TODO X and Y pixel size
try:
xs, yz = self.dataset_scanner._get_x_y_magnified_pixel_values()
ps = xs * 1e6
except AttributeError:
ps = self.dataset_scanner.pixel_size * 1e6
return ps
def analyze_dataset(dataset_path, processes_file=None, extra_options=None):
if not(os.path.isdir(dataset_path)):
if not(os.path.isfile(dataset_path)):
......
......@@ -99,6 +99,7 @@ class NabuValidator(object):
if angles_file is not None:
try:
angles = get_values_from_file(angles_file, n_values=n_angles)
angles = np.deg2rad(angles)
except ValueError:
print("Something wrong with angle file %s" % angles_file)
raise
......
......@@ -151,7 +151,7 @@ nabu_config = {
},
"angles_file": {
"default": "",
"help": "In the case you want to override the angles found in the files metadata",
"help": "In the case you want to override the angles found in the files metadata. The angles are in degree.",
"validator": optional_file_location_validator,
"type": "optional",
},
......@@ -285,7 +285,7 @@ nabu_config = {
},
"overwrite_results": {
"default": "0",
"help": "What to do in the case where the output file exists.\nBy default, the output data is never overwritten and the process is interrupted if the file already exists.\nSet this option to 1 if you want to overwrite without asking.",
"help": "What to do in the case where the output file exists.\nBy default, the output data is never overwritten and the process is interrupted if the file already exists.\nSet this option to 1 if you want to overwrite the output files.",
"validator": boolean_validator,
"type": "required",
},
......
......@@ -46,6 +46,7 @@ class NXFlatField:
self, data_url, image_keys, lookup_files=None, results_file=None,
dont_write_results=False, force_load_existing_results=False, logger=None,
flats_reduction="mean", darks_reduction="mean",
need_flats_and_darks=True,
):
"""
Initialize a FlatFieldLoader helper.
......@@ -84,6 +85,10 @@ class NXFlatField:
darks_reduction: str, optional
Reduction function to use for darks. Can be "mean", "median" or "sum".
Default is "mean".
need_flats_and_darks: bool, optional
Whether both flats and darks are needed to compute the final darks/flats.
If set to True and either no flat/dark is found, an error will be raised.
Default is True.
Warning
-------
......@@ -96,6 +101,7 @@ class NXFlatField:
self.results_file = results_file
self.dont_write_results = dont_write_results
self.force_load_existing_results = force_load_existing_results
self._need_flats_and_darks = need_flats_and_darks
self.logger = LoggerOrPrint(logger)
self.reduction_function = {}
self._set_reduction_method("flats", flats_reduction)
......@@ -330,7 +336,10 @@ class NXFlatField:
for what in res.keys():
img_slices = self.get_data_slices(self.image_keys, val_to_nxkey[what])
if img_slices == []:
self.logger.error("No %s found in %s" % (what, self.data_url.file_path()))
err_msg = "No %s found in %s" % (what, self.data_url.file_path())
self.logger.error(err_msg)
if self._need_flats_and_darks:
raise ValueError(err_msg)
res[what] = None
for data_slice in img_slices:
data_chunk = self.get_data_chunk(data_slice)
......
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