Add option to append Rqz datasets
Some checks failed
Unit Testing / test (3.10) (push) Has been cancelled
Unit Testing / test (3.11) (push) Has been cancelled
Unit Testing / test (3.12) (push) Has been cancelled
Unit Testing / test (3.8) (push) Has been cancelled
Unit Testing / test (3.9) (push) Has been cancelled
Some checks failed
Unit Testing / test (3.10) (push) Has been cancelled
Unit Testing / test (3.11) (push) Has been cancelled
Unit Testing / test (3.12) (push) Has been cancelled
Unit Testing / test (3.8) (push) Has been cancelled
Unit Testing / test (3.9) (push) Has been cancelled
This commit is contained in:
@@ -543,6 +543,14 @@ class ReflectivityOutputConfig(ArgParsable):
|
||||
},
|
||||
)
|
||||
|
||||
append: bool = field(
|
||||
default=False,
|
||||
metadata={
|
||||
'group': 'output',
|
||||
'help': 'if file already exists, append result as additional ORSO dataset (only Rqz.ort)',
|
||||
},
|
||||
)
|
||||
|
||||
def _output_format_list(self, outputFormat):
|
||||
format_list = []
|
||||
if OutputFomatOption.ort in outputFormat\
|
||||
|
||||
@@ -329,8 +329,23 @@ class ReflectivityReduction:
|
||||
def save_Rqz(self):
|
||||
fname = os.path.join(self.config.output.outputPath, f'{self.config.output.outputName}.Rqz.ort')
|
||||
logging.warning(f' {fname}')
|
||||
theSecondLine = f' {self.header.experiment.title} | {self.header.experiment.start_date} | sample {self.header.sample.name} | R(q_z)'
|
||||
fileio.save_orso(self.datasetsRqz, fname, data_separator='\n', comment=theSecondLine)
|
||||
if os.path.exists(fname) and self.config.output.append:
|
||||
logging.info(' file already exists, append as new dataset')
|
||||
with open(fname, 'r') as f:
|
||||
f.readline()
|
||||
theSecondLine = f.readline()[3:]
|
||||
prev_data = fileio.load_orso(fname)
|
||||
prev_names = [di.info.data_set for di in prev_data]
|
||||
for i, di in enumerate(self.datasetsRqz):
|
||||
while di.info.data_set in prev_names:
|
||||
if di.info.data_set.startswith('Nr '):
|
||||
di.info.data_set = f'Nr {i+len(prev_data)} :'+di.info.data_set.split(':', 1)[1]
|
||||
break
|
||||
di.info.data_set = di.info.data_set+'_'
|
||||
fileio.save_orso(prev_data+self.datasetsRqz, fname, data_separator='\n', comment=theSecondLine)
|
||||
else:
|
||||
theSecondLine = f' {self.header.experiment.title} | {self.header.experiment.start_date} | sample {self.header.sample.name} | R(q_z)'
|
||||
fileio.save_orso(self.datasetsRqz, fname, data_separator='\n', comment=theSecondLine)
|
||||
|
||||
def save_Rtl(self):
|
||||
fname = os.path.join(self.config.output.outputPath, f'{self.config.output.outputName}.Rlt.ort')
|
||||
|
||||
Reference in New Issue
Block a user