From a7e88db4253401348ef6d4e005009f5213169437 Mon Sep 17 00:00:00 2001 From: Artur Glavic Date: Tue, 24 Sep 2024 14:51:27 +0200 Subject: [PATCH] Update test cases and make old datafile work --- libeos/file_reader.py | 7 +++++-- tests/test_full_analysis.py | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/libeos/file_reader.py b/libeos/file_reader.py index e7b7dbd..8217533 100644 --- a/libeos/file_reader.py +++ b/libeos/file_reader.py @@ -352,11 +352,14 @@ class AmorData: self.pixelID_e = np.array(self.hdf['/entry1/Amor/detector/data/event_id'][:], dtype=int) self.dataPacket_p = np.array(self.hdf['/entry1/Amor/detector/data/event_index'][:], dtype=np.uint64) #self.dataPacketTime_p = np.array(self.hdf['/entry1/Amor/detector/data/event_time_zero'][:], dtype=np.uint64)/1e9 - self.dataPacketTime_p = np.array(self.hdf['/entry1/Amor/detector/data/event_time_zero'][:], dtype=int) + self.dataPacketTime_p = np.array(self.hdf['/entry1/Amor/detector/data/event_time_zero'][:], dtype=float) try: self.currentTime = np.array(self.hdf['entry1/Amor/detector/proton_current/time'][:], dtype=int) self.current = np.array(self.hdf['entry1/Amor/detector/proton_current/value'][:,0], dtype=float) - self.monitorType = 'protonCharge' + if len(self.current)>0: + self.monitorType = 'protonCharge' + else: + self.monitorType = 'countingTime' except(KeyError, IndexError): self.monitorType = 'countingTime' diff --git a/tests/test_full_analysis.py b/tests/test_full_analysis.py index 44a6878..9eff6d0 100644 --- a/tests/test_full_analysis.py +++ b/tests/test_full_analysis.py @@ -6,6 +6,8 @@ from libeos import options, reduction, logconfig logconfig.setup_logging() logconfig.update_loglevel(True, False) +# TODO: add test for new features like proton charge normalization + class FullAmorTest(TestCase): @classmethod def setUpClass(cls): @@ -19,7 +21,9 @@ class FullAmorTest(TestCase): self.pr.enable() self.reader_config = options.ReaderConfig( year=2023, - dataPath=os.path.join('..', "test_data")) + dataPath=os.path.join('..', "test_data"), + raw=(os.path.join('..', "test_data"),) + ) def tearDown(self): self.pr.disable() @@ -37,14 +41,16 @@ class FullAmorTest(TestCase): yRange=(11., 41.), lambdaRange=(2., 15.), qzRange=(0.005, 0.30), - offSpecular=False, + incidentAngle=options.Defaults.incidentAngle, mu=0, nu=0, muOffset=0.0, sampleModel='air | 10 H2O | D2O' ) reduction_config = options.ReductionConfig( + normalisationMethod=options.Defaults.normalisationMethod, qResolution=0.01, + qzRange=options.Defaults.qzRange, thetaRange=(-12., 12.), thetaRangeR=(-12., 12.), fileIdentifier=["610"], @@ -72,19 +78,21 @@ class FullAmorTest(TestCase): yRange=(11., 41.), lambdaRange=(2., 15.), qzRange=(0.005, 0.30), - offSpecular=False, + incidentAngle=options.Defaults.incidentAngle, mu=0, nu=0, muOffset=0.0 ) reduction_config = options.ReductionConfig( qResolution=0.01, + qzRange=options.Defaults.qzRange, + normalisationMethod=options.Defaults.normalisationMethod, thetaRange=(-12., 12.), thetaRangeR=(-12., 12.), fileIdentifier=["610", "611", "608,612-613", "609"], scale=[1], normalisationFileIdentifier=["614"], - autoscale=(0.005, 0.008) + autoscale=(True, True) ) output_config = options.OutputConfig( outputFormats=["Rqz.ort"],