From 082d96510b5ca69e513d369964888090255b45ed Mon Sep 17 00:00:00 2001 From: jochenstahn Date: Mon, 8 Sep 2025 16:53:52 +0200 Subject: [PATCH] reorganised file expansion --- libeos/command_line.py | 115 ----------------------------------------- libeos/options.py | 16 ++++-- libeos/reduction.py | 23 +++++++-- 3 files changed, 32 insertions(+), 122 deletions(-) diff --git a/libeos/command_line.py b/libeos/command_line.py index 949a5e6..5c44a96 100644 --- a/libeos/command_line.py +++ b/libeos/command_line.py @@ -35,124 +35,9 @@ def commandLineArgs(): f'--{cpc.argument}', **cpc.add_argument_args ) - # - # output = clas.add_argument_group('output') - # output.add_argument("-o", "--outputName", - # default = Defaults.outputName, - # help = "output file name (withot suffix)") - # output.add_argument("-op", "--outputPath", - # type = str, - # default = Defaults.outputPath, - # help = "path for output") - # output.add_argument("-of", "--outputFormat", - # nargs = '+', - # default = Defaults.outputFormat, - # help = "one of [Rqz.ort, Rlt.ort]") - # output.add_argument("-ai", "--incidentAngle", - # type = str, - # default = Defaults.incidentAngle, - # help = "calulate alpha_i from [alphaF, mu, nu]", - # ) - # output.add_argument("-r", "--qResolution", - # default = Defaults.qResolution, - # type = float, - # help = "q_z resolution") - # output.add_argument("-ts", "--timeSlize", - # nargs = '+', - # type = float, - # help = "time slizing ,[ [,stop]]") - # output.add_argument("-s", "--scale", - # nargs = '+', - # default = Defaults.scale, - # type = float, - # help = "scaling factor for R(q_z)") - # output.add_argument("-S", "--autoscale", - # nargs = 2, - # type = float, - # help = "scale to 1 in the given q_z range") - # - # masks = clas.add_argument_group('masks') - # masks.add_argument("-l", "--lambdaRange", - # default = Defaults.lambdaRange, - # nargs = 2, - # type = float, - # help = "wavelength range") - # masks.add_argument("-t", "--thetaRange", - # default = Defaults.thetaRange, - # nargs = 2, - # type = float, - # help = "absolute theta range") - # masks.add_argument("-T", "--thetaRangeR", - # default = Defaults.thetaRangeR, - # nargs = 2, - # type = float, - # help = "relative theta range") - # masks.add_argument("-y", "--yRange", - # default = Defaults.yRange, - # nargs = 2, - # type = int, - # help = "detector y range") - # masks.add_argument("-q", "--qzRange", - # default = Defaults.qzRange, - # nargs = 2, - # type = float, - # help = "q_z range") - # masks.add_argument("-ct", "--lowCurrentThreshold", - # default = Defaults.lowCurrentThreshold, - # type = float, - # help = "proton current threshold for discarding neutron pulses") - # - # - # overwrite = clas.add_argument_group('overwrite') - # overwrite.add_argument("-cs", "--chopperSpeed", - # default = Defaults.chopperSpeed, - # type = float, - # help = "chopper speed in rpm") - # overwrite.add_argument("-cp", "--chopperPhase", - # default = Defaults.chopperPhase, - # type = float, - # help = "chopper phase") - # overwrite.add_argument("-co", "--chopperPhaseOffset", - # default = Defaults.chopperPhaseOffset, - # type = float, - # help = "phase offset between chopper opening and trigger pulse") - # overwrite.add_argument("-m", "--muOffset", - # default = Defaults.muOffset, - # type = float, - # help = "mu offset") - # overwrite.add_argument("-mu", "--mu", - # default = Defaults.mu, - # type = float, - # help ="value of mu") - # overwrite.add_argument("-nu", "--nu", - # default = Defaults.nu, - # type = float, - # help = "value of nu") - # overwrite.add_argument("-sm", "--sampleModel", - # default = Defaults.sampleModel, - # type = str, - # help = "1-line orso sample model description") - return clas.parse_args() -def expand_file_list(short_notation): - """Evaluate string entry for file number lists""" - #log().debug('Executing get_flist') - file_list=[] - for i in short_notation.split(','): - if '-' in i: - if ':' in i: - step = i.split(':', 1)[1] - file_list += range(int(i.split('-', 1)[0]), int((i.rsplit('-', 1)[1]).split(':', 1)[0])+1, int(step)) - else: - step = 1 - file_list += range(int(i.split('-', 1)[0]), int(i.split('-', 1)[1])+1, int(step)) - else: - file_list += [int(i)] - - return sorted(file_list) - def command_line_options(): clas = commandLineArgs() diff --git a/libeos/options.py b/libeos/options.py index 83b7035..72535e9 100644 --- a/libeos/options.py +++ b/libeos/options.py @@ -442,13 +442,21 @@ class OutputConfig(ArgParsable): def _output_format_list(self, outputFormat): format_list = [] - if OutputFomatOption.ort in outputFormat or OutputFomatOption.Rqz_ort in outputFormat or OutputFomatOption.Rqz in outputFormat: + if OutputFomatOption.ort in outputFormat\ + or OutputFomatOption.Rqz_ort in outputFormat\ + or OutputFomatOption.Rqz in outputFormat: format_list.append(OutputFomatOption.Rqz_ort) - if OutputFomatOption.ort in outputFormat or OutputFomatOption.Rlt_ort in outputFormat or OutputFomatOption.Rlt in outputFormat: + if OutputFomatOption.ort in outputFormat\ + or OutputFomatOption.Rlt_ort in outputFormat\ + or OutputFomatOption.Rlt in outputFormat: format_list.append(OutputFomatOption.Rlt_ort) - if OutputFomatOption.orb in outputFormat or OutputFomatOption.Rqz_orb in outputFormat or OutputFomatOption.Rqz in outputFormat: + if OutputFomatOption.orb in outputFormat\ + or OutputFomatOption.Rqz_orb in outputFormat\ + or OutputFomatOption.Rqz in outputFormat: format_list.append(OutputFomatOption.Rqz_orb) - if OutputFomatOption.orb in outputFormat or OutputFomatOption.Rlt_orb in outputFormat or OutputFomatOption.Rlt in outputFormat: + if OutputFomatOption.orb in outputFormat\ + or OutputFomatOption.Rlt_orb in outputFormat\ + or OutputFomatOption.Rlt in outputFormat: format_list.append(OutputFomatOption.Rlt_orb) return sorted(format_list, reverse=True) diff --git a/libeos/reduction.py b/libeos/reduction.py index c7722fd..c4634cb 100644 --- a/libeos/reduction.py +++ b/libeos/reduction.py @@ -5,7 +5,6 @@ import sys import numpy as np from orsopy import fileio -from .command_line import expand_file_list from .file_reader import AmorData from .header import Header from .options import EOSConfig, IncidentAngle, MonitorType, NormalisationMethod @@ -242,7 +241,7 @@ class AmorReduction: self.datasetsRqz.append(orso_data) # reset normal logging behavior #logging.StreamHandler.terminator = "\n" - logging.info(f' done {time+interval:5.0f}') + logging.info(f' done {min(time+interval, pulseTimeS[-1]):5.0f}') def save_Rqz(self): fname = os.path.join(self.output_config.outputPath, f'{self.output_config.outputName}.Rqz.ort') @@ -331,9 +330,27 @@ class AmorReduction: return q_q, Sq_q, dS_q, fileName + def expand_file_list(short_notation): + """Evaluate string entry for file number lists""" + #log().debug('Executing get_flist') + file_list=[] + for i in short_notation.split(','): + if '-' in i: + if ':' in i: + step = i.split(':', 1)[1] + file_list += range(int(i.split('-', 1)[0]), int((i.rsplit('-', 1)[1]).split(':', 1)[0])+1, int(step)) + else: + step = 1 + file_list += range(int(i.split('-', 1)[0]), int(i.split('-', 1)[1])+1, int(step)) + else: + file_list += [int(i)] + + return sorted(file_list) + + def create_normalisation_map(self, short_notation): outputPath = self.output_config.outputPath - normalisation_list = expand_file_list(short_notation) + normalisation_list = self.expand_file_list(short_notation) name = str(normalisation_list[0]) for i in range(1, len(normalisation_list), 1): name = f'{name}_{normalisation_list[i]}'