introduced raw data directory path

This commit is contained in:
2024-06-24 08:32:56 +02:00
parent d0504e25f1
commit 42e4defcca
5 changed files with 83 additions and 59 deletions

46
eos.py Normal file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/env python
"""
eos reduces measurements performed on Amor@SINQ, PSI
Author: Jochen Stahn (algorithms, python draft),
Artur Glavic (structuring and optimisation of code)
conventions (not strictly followed, yet):
- array names end with the suffix '_x[y]' with the meaning
_e = events
_tof
_l = lambda
_t = theta
_z = detector z
_lz = (lambda, detector z)
_q = q_z
"""
import logging
from libeos.command_line import command_line_options
from libeos.logconfig import setup_logging
from libeos.reduction import AmorReduction
#=====================================================================================================
# TODO:
# - calculate resolution using the chopperPhase
# - deal with background correction
# - format of 'call' + add '-Y' if not supplied
#=====================================================================================================
def main():
setup_logging()
logging.warning('######## eos - data reduction for Amor ########')
# read command line arguments and generate classes holding configuration parameters
config = command_line_options()
# Create reducer with these arguments
reducer = AmorReduction(config)
# Perform actual reduction
reducer.reduce()
logging.info('######## eos - finished ########')
if __name__ == '__main__':
main()

View File

@@ -24,10 +24,14 @@ def commandLineArgs():
default = Defaults.normalisationFileIdentifier,
nargs = '+',
help = "file number(s) of normalisation measurement")
input_data.add_argument("--raw",
type = str,
default = Defaults.raw,
help = "relative path to directory with .hdf files")
input_data.add_argument("-d", "--dataPath",
type = str,
default = Defaults.dataPath,
help = "relative path to directory with .hdf files")
help = "relative path for output")
input_data.add_argument("-Y", "--year",
default = Defaults.year,
type = int,
@@ -166,6 +170,7 @@ def command_line_options():
reader_config = ReaderConfig(
year = clas.year,
raw = clas.raw,
dataPath = clas.dataPath
)
experiment_config = ExperimentConfig(

View File

@@ -78,21 +78,35 @@ class AmorData:
self.lamda_e = _lamda_e
self.wallTime_e = _wallTime_e
#-------------------------------------------------------------------------------------------------
#def path_generator(self, number):
# fileName = f'amor{self.reader_config.year}n{number:06d}.hdf'
# if os.path.exists(os.path.join(self.reader_config.dataPath,fileName)):
# path = self.reader_config.dataPath
# elif os.path.exists(fileName):
# path = '.'
# elif os.path.exists(os.path.join('.','raw', fileName)):
# path = os.path.join('.','raw')
# elif os.path.exists(os.path.join('..','raw', fileName)):
# path = os.path.join('..','raw')
# elif os.path.exists(f'/afs/psi.ch/project/sinqdata/{self.reader_config.year}/amor/{int(number/1000)}/{fileName}'):
# path = f'/afs/psi.ch/project/sinqdata/{self.reader_config.year}/amor/{int(number/1000)}'
# else:
# sys.exit(f'# ERROR: the file {fileName} is nowhere to be found!')
# return os.path.join(path, fileName)
#-------------------------------------------------------------------------------------------------
def path_generator(self, number):
fileName = f'amor{self.reader_config.year}n{number:06d}.hdf'
if os.path.exists(os.path.join(self.reader_config.dataPath,fileName)):
path = self.reader_config.dataPath
elif os.path.exists(fileName):
path = '.'
elif os.path.exists(os.path.join('.','raw', fileName)):
path = os.path.join('.','raw')
elif os.path.exists(os.path.join('..','raw', fileName)):
path = os.path.join('..','raw')
elif os.path.exists(f'/afs/psi.ch/project/sinqdata/{self.reader_config.year}/amor/{int(number/1000)}/{fileName}'):
path = f'/afs/psi.ch/project/sinqdata/{self.reader_config.year}/amor/{int(number/1000)}'
else:
sys.exit(f'# ERROR: the file {fileName} is nowhere to be found!')
path = ''
for rawd in self.reader_config.raw:
if os.path.exists(os.path.join(rawd,fileName)):
path = rawd
break
if not path:
if os.path.exists(f'/afs/psi.ch/project/sinqdata/{self.reader_config.year}/amor/{int(number/1000)}/{fileName}'):
path = f'/afs/psi.ch/project/sinqdata/{self.reader_config.year}/amor/{int(number/1000)}'
else:
sys.exit(f'# ERROR: the file {fileName} can not be found in {self.reader_config.raw}!')
return os.path.join(path, fileName)
#-------------------------------------------------------------------------------------------------
def expand_file_list(self, short_notation):

View File

@@ -10,6 +10,7 @@ class Defaults:
#fileIdentifier
normalisationFileIdentifier = []
dataPath = '.'
raw = ['.', './raw', '../raw', '../../raw']
year = datetime.now().year
#subtract
outputName = "fromEOS"
@@ -40,6 +41,7 @@ class Defaults:
class ReaderConfig:
year: int
dataPath: str
raw: Tuple[str]
startTime: Optional[float] = 0
@dataclass
@@ -102,6 +104,8 @@ class EOSConfig:
inpt += f' -Y {datetime.now().year}'
if self.reader_config.dataPath != '.':
inpt += f' --dataPath {self.reader_config.dataPath}'
if self.reader_config.raw != '.':
inpt = f' --rawd {self.reader_config.raw}'
if self.reduction_config.subtract:
inpt += f' -subtract {self.reduction_config.subtract}'
if self.reduction_config.normalisationFileIdentifier:

46
neos.py
View File

@@ -1,46 +0,0 @@
#!/usr/bin/env python
"""
eos reduces measurements performed on Amor@SINQ, PSI
Author: Jochen Stahn (algorithms, python draft),
Artur Glavic (structuring and optimisation of code)
conventions (not strictly followed, yet):
- array names end with the suffix '_x[y]' with the meaning
_e = events
_tof
_l = lambda
_t = theta
_z = detector z
_lz = (lambda, detector z)
_q = q_z
"""
import logging
from libeos.command_line import command_line_options
from libeos.logconfig import setup_logging
from libeos.reduction import AmorReduction
#=====================================================================================================
# TODO:
# - calculate resolution using the chopperPhase
# - deal with background correction
# - format of 'call' + add '-Y' if not supplied
#=====================================================================================================
def main():
setup_logging()
logging.warning('######## eos - data reduction for Amor ########')
# read command line arguments and generate classes holding configuration parameters
config = command_line_options()
# Create reducer with these arguments
reducer = AmorReduction(config)
# Perform actual reduction
reducer.reduce()
logging.info('######## eos - finished ########')
if __name__ == '__main__':
main()

1
neos.py Symbolic link
View File

@@ -0,0 +1 @@
eos.py