From 4235666d7e3bc8c2c7fd233bc637ffa8ad329102 Mon Sep 17 00:00:00 2001 From: jochenstahn Date: Wed, 6 Mar 2024 13:35:21 +0100 Subject: [PATCH] increased readebility --- libeos/command_line.py | 54 ++++++++++++++++++++++-------------------- libeos/header.py | 10 ++++++-- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/libeos/command_line.py b/libeos/command_line.py index 7fae9e5..7e5c8f9 100644 --- a/libeos/command_line.py +++ b/libeos/command_line.py @@ -1,5 +1,5 @@ import argparse -from datetime import datetime +from datetime import date from .logconfig import update_loglevel from .options import ReaderConfig, EOSConfig, ExperimentConfig, OutputConfig, ReductionConfig @@ -29,7 +29,7 @@ def commandLineArgs(): default = '.', help = "relative path to directory with .hdf files") input_data.add_argument("-Y", "--year", - default = datetime.year, + default = date.today().year, type = int, help = "year the measurement was performed") input_data.add_argument("-sub", "--subtract", @@ -161,33 +161,35 @@ def command_line_options(): update_loglevel(clas.verbose, clas.debug) reader_config = ReaderConfig( - year=clas.year, - dataPath=clas.dataPath) + year = clas.year, + dataPath = clas.dataPath + ) experiment_config = ExperimentConfig( - sampleModel=clas.sampleModel, - chopperPhase=clas.chopperPhase, - chopperPhaseOffset=clas.chopperPhaseOffset, - yRange=clas.yRange, - lambdaRange=clas.lambdaRange, - qzRange=clas.qzRange, - offSpecular=clas.offSpecular, - mu=clas.mu, - nu=clas.nu, - muOffset=clas.muOffset + sampleModel = clas.sampleModel, + chopperPhase = clas.chopperPhase, + chopperPhaseOffset = clas.chopperPhaseOffset, + yRange = clas.yRange, + lambdaRange = clas.lambdaRange, + qzRange = clas.qzRange, + offSpecular = clas.offSpecular, + mu = clas.mu, + nu = clas.nu, + muOffset = clas.muOffset ) reduction_config = ReductionConfig( - qResolution=clas.qResolution, - autoscale=clas.autoscale, - thetaRange=clas.thetaRange, - thetaRangeR=clas.thetaRangeR, - fileIdentifier=clas.fileIdentifier, - scale=clas.scale, - subtract=clas.subtract, - normalisationFileIdentifier=clas.normalisationFileIdentifier, - timeSlize=clas.timeSlize + qResolution = clas.qResolution, + autoscale = clas.autoscale, + thetaRange = clas.thetaRange, + thetaRangeR = clas.thetaRangeR, + fileIdentifier = clas.fileIdentifier, + scale = clas.scale, + subtract = clas.subtract, + normalisationFileIdentifier = clas.normalisationFileIdentifier, + timeSlize = clas.timeSlize ) output_config = OutputConfig( - outputFormats=output_format_list(clas.outputFormat), - outputName=clas.outputName + outputFormats = output_format_list(clas.outputFormat), + outputName = clas.outputName ) - return EOSConfig(reader_config, experiment_config, reduction_config, output_config) \ No newline at end of file + + return EOSConfig(reader_config, experiment_config, reduction_config, output_config) diff --git a/libeos/header.py b/libeos/header.py index e46fc5e..72b3ab5 100644 --- a/libeos/header.py +++ b/libeos/header.py @@ -25,7 +25,7 @@ class Header: self.reduction = fileio.Reduction( software = fileio.Software('eos', version=__version__), - call = ' '.join(sys.argv), + call = self.create_call_string(), computer = platform.node(), timestamp = datetime.now(), creator = None, @@ -54,7 +54,7 @@ class Header: fileio.ErrorColumn(error_of='Qz', error_type='resolution', distribution='gaussian', value_is='sigma'), ] return cols - + #------------------------------------------------------------------------------------------------- def orso_header(self, columns=None, extra_columns=[]): """ Generate ORSO header from a copy of this class' data. @@ -64,3 +64,9 @@ class Header: if columns is None: columns = self.columns() return fileio.Orso(ds, red, columns+extra_columns) + #------------------------------------------------------------------------------------------------- + def create_call_string(self): + callString = ' '.join(sys.argv) + if '-Y' not in callString: + callString += f' -Y {datetime.now().year}' + return callString