Fix some bugs from new options configuration and make test run again
This commit is contained in:
@@ -335,16 +335,14 @@ class ReductionConfig(ArgParsable):
|
||||
'help': '(list of) scaling factors, if less elements than files use the last one',
|
||||
},
|
||||
)
|
||||
# TODO: This made no sense, it is used as single bool.
|
||||
autoscale: bool = False
|
||||
#autoscale: Tuple[float, float] = field(
|
||||
# default_factory=lambda: [None, None],
|
||||
# metadata={
|
||||
# 'short': 'S',
|
||||
# 'group': 'data manicure',
|
||||
# 'help': '',
|
||||
# },
|
||||
# )
|
||||
autoscale: Tuple[float, float] = field(
|
||||
default=None,
|
||||
metadata={
|
||||
'short': 'S',
|
||||
'group': 'data manicure',
|
||||
'help': '',
|
||||
},
|
||||
)
|
||||
subtract: Optional[str] = field(
|
||||
default=None,
|
||||
metadata={
|
||||
@@ -359,7 +357,7 @@ class ReductionConfig(ArgParsable):
|
||||
'group': 'input data',
|
||||
'help': 'file number(s) of normalisation measurement'})
|
||||
timeSlize: Optional[List[float]] = field(
|
||||
default_factory=lambda: [None],
|
||||
default= None,
|
||||
metadata={
|
||||
'short': 'ts',
|
||||
'group': 'region of interest',
|
||||
|
||||
@@ -95,7 +95,7 @@ class AmorReduction:
|
||||
lamda_e = self.file_reader.lamda_e
|
||||
detZ_e = self.file_reader.detZ_e
|
||||
self.monitor = np.sum(self.file_reader.monitorPerPulse)
|
||||
logging.warning(f' monitor = {self.monitor:8.2f} {self.MONITOR_UNITS[self.experiment_config.monitorType]}')
|
||||
logging.warning(f' monitor = {self.monitor:8.2f} {MONITOR_UNITS[self.experiment_config.monitorType]}')
|
||||
qz_lz, qx_lz, ref_lz, err_lz, res_lz, lamda_lz, theta_lz, int_lz, self.mask_lz = self.project_on_lz(
|
||||
self.file_reader, self.norm_lz, self.normAngle, lamda_e, detZ_e)
|
||||
#if self.monitor>1 :
|
||||
@@ -211,7 +211,7 @@ class AmorReduction:
|
||||
detZ_e = self.file_reader.detZ_e[filter_e]
|
||||
filter_m = np.where((time<pulseTimeS) & (pulseTimeS<time+interval), True, False)
|
||||
self.monitor = np.sum(self.file_reader.monitorPerPulse[filter_m])
|
||||
logging.info(f' {ti:<4d} {time:6.0f} {self.monitor:7.2f} {self.MONITOR_UNITS[self.experiment_config.monitorType]}')
|
||||
logging.info(f' {ti:<4d} {time:6.0f} {self.monitor:7.2f} {MONITOR_UNITS[self.experiment_config.monitorType]}')
|
||||
|
||||
qz_lz, qx_lz, ref_lz, err_lz, res_lz, lamda_lz, theta_lz, int_lz, mask_lz = self.project_on_lz(
|
||||
self.file_reader, self.norm_lz, self.normAngle, lamda_e, detZ_e)
|
||||
|
||||
Binary file not shown.
@@ -1,16 +1,27 @@
|
||||
import os
|
||||
import cProfile
|
||||
from unittest import TestCase
|
||||
from dataclasses import fields, MISSING
|
||||
from libeos import options, reduction, logconfig
|
||||
|
||||
logconfig.setup_logging()
|
||||
logconfig.update_loglevel(True, False)
|
||||
logconfig.update_loglevel(1)
|
||||
|
||||
# TODO: add test for new features like proton charge normalization
|
||||
|
||||
class FullAmorTest(TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# generate map for option defaults
|
||||
cls._field_defaults = {}
|
||||
for opt in [options.ExperimentConfig, options.ReductionConfig, options.OutputConfig]:
|
||||
defaults = {}
|
||||
for field in fields(opt):
|
||||
if field.default not in [None, MISSING]:
|
||||
defaults[field.name] = field.default
|
||||
elif field.default_factory not in [None, MISSING]:
|
||||
defaults[field.name] = field.default_factory()
|
||||
cls._field_defaults[opt.__name__] = defaults
|
||||
cls.pr = cProfile.Profile()
|
||||
|
||||
@classmethod
|
||||
@@ -21,47 +32,45 @@ class FullAmorTest(TestCase):
|
||||
self.pr.enable()
|
||||
self.reader_config = options.ReaderConfig(
|
||||
year=2025,
|
||||
rawPath=(os.path.join('..', "test_data"),),
|
||||
rawPath=[os.path.join('..', "test_data")],
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
self.pr.disable()
|
||||
for fi in ['test.Rqz.ort', '614.norm']:
|
||||
for fi in ['../test_results/test.Rqz.ort', '../test_results/5952.norm']:
|
||||
try:
|
||||
os.unlink(os.path.join(self.reader_config.rawPath[0], fi))
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
def test_time_slicing(self):
|
||||
experiment_config = options.ExperimentConfig(
|
||||
chopperSpeed=options.Defaults.chopperSpeed,
|
||||
chopperSpeed=self._field_defaults['ExperimentConfig']['chopperSpeed'],
|
||||
chopperPhase=-13.5,
|
||||
chopperPhaseOffset=-5,
|
||||
monitorType=options.Defaults.monitorType,
|
||||
lowCurrentThreshold=options.Defaults.lowCurrentThreshold,
|
||||
monitorType=self._field_defaults['ExperimentConfig']['monitorType'],
|
||||
lowCurrentThreshold=self._field_defaults['ExperimentConfig']['lowCurrentThreshold'],
|
||||
yRange=(11., 41.),
|
||||
lambdaRange=(2., 15.),
|
||||
qzRange=(0.005, 0.30),
|
||||
incidentAngle=options.Defaults.incidentAngle,
|
||||
incidentAngle=self._field_defaults['ExperimentConfig']['incidentAngle'],
|
||||
mu=0,
|
||||
nu=0,
|
||||
muOffset=0.0,
|
||||
sampleModel='air | 10 H2O | D2O'
|
||||
)
|
||||
reduction_config = options.ReductionConfig(
|
||||
normalisationMethod=options.Defaults.normalisationMethod,
|
||||
normalisationMethod=self._field_defaults['ReductionConfig']['normalisationMethod'],
|
||||
qResolution=0.01,
|
||||
qzRange=options.Defaults.qzRange,
|
||||
qzRange=self._field_defaults['ReductionConfig']['qzRange'],
|
||||
thetaRange=(-12., 12.),
|
||||
thetaRangeR=(-12., 12.),
|
||||
fileIdentifier=["610"],
|
||||
fileIdentifier=["5980", "5981", "5983-5985"],
|
||||
scale=[1],
|
||||
normalisationFileIdentifier=[],
|
||||
timeSlize=[300.0]
|
||||
)
|
||||
output_config = options.OutputConfig(
|
||||
outputFormats=["Rqz.ort"],
|
||||
outputFormats=[options.OutputFomatOption.Rqz_ort],
|
||||
outputName='test',
|
||||
outputPath=os.path.join('..', 'test_results'),
|
||||
)
|
||||
@@ -76,32 +85,31 @@ class FullAmorTest(TestCase):
|
||||
|
||||
def test_noslicing(self):
|
||||
experiment_config = options.ExperimentConfig(
|
||||
chopperSpeed=options.Defaults.chopperSpeed,
|
||||
chopperSpeed=self._field_defaults['ExperimentConfig']['chopperSpeed'],
|
||||
chopperPhase=-13.5,
|
||||
chopperPhaseOffset=-5,
|
||||
monitorType=options.Defaults.monitorType,
|
||||
lowCurrentThreshold=options.Defaults.lowCurrentThreshold,
|
||||
monitorType=self._field_defaults['ExperimentConfig']['monitorType'],
|
||||
lowCurrentThreshold=self._field_defaults['ExperimentConfig']['lowCurrentThreshold'],
|
||||
yRange=(11., 41.),
|
||||
lambdaRange=(2., 15.),
|
||||
qzRange=(0.005, 0.30),
|
||||
incidentAngle=options.Defaults.incidentAngle,
|
||||
incidentAngle=self._field_defaults['ExperimentConfig']['incidentAngle'],
|
||||
mu=0,
|
||||
nu=0,
|
||||
muOffset=0.0
|
||||
)
|
||||
reduction_config = options.ReductionConfig(
|
||||
normalisationMethod=self._field_defaults['ReductionConfig']['normalisationMethod'],
|
||||
qResolution=0.01,
|
||||
qzRange=options.Defaults.qzRange,
|
||||
normalisationMethod=options.Defaults.normalisationMethod,
|
||||
qzRange=self._field_defaults['ReductionConfig']['qzRange'],
|
||||
thetaRange=(-12., 12.),
|
||||
thetaRangeR=(-12., 12.),
|
||||
fileIdentifier=["610", "611", "608,612-613", "609"],
|
||||
fileIdentifier=["5980"],
|
||||
scale=[1],
|
||||
normalisationFileIdentifier=["608"],
|
||||
autoscale=(True, True)
|
||||
normalisationFileIdentifier=["5952"],
|
||||
autoscale=(0.0, 0.05),
|
||||
)
|
||||
output_config = options.OutputConfig(
|
||||
outputFormats=["Rqz.ort"],
|
||||
outputFormats=[options.OutputFomatOption.Rqz_ort],
|
||||
outputName='test',
|
||||
outputPath=os.path.join('..', 'test_results'),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user