introduced raw data directory path
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user