@@ -46,21 +46,49 @@ def processL1a(fp, outFilePath):
4646
4747
4848 ## Test filename for station/cast
49- match1 = re .search (r'\d{8}_\d{6}' , file .split ('/' )[- 1 ])
50- match2 = re .search (r'\d{4}S' , file .split ('/' )[- 1 ])
51- match3 = re .search (r'\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}' , file .split ('/' )[- 1 ])
52- if match1 is not None :
53- a_name = match1 .group ()
54- elif match2 is not None :
55- a_name = match2 .group ()
56- elif match3 is not None :
57- a_name = match3 .group ()
58- else :
49+
50+ def parse_filename (data ):
51+ dates = []
52+ for pattern in [
53+ r'\d{8}.\d{6}' ,
54+ r'\d{4}.\d{2}.\d{2}.\d{2}.\d{2}.\d{2}' ,
55+ r'\d{8}.\d{2}.\d{2}.\d{2}' ,
56+ r'\d{4}.\d{2}.\d{2}.\d{6}' ,
57+ r'\d{4}S' ,
58+ ]:
59+ match = re .search (pattern , data )
60+ if match is not None :
61+ dates .append (match .group (0 ))
62+
63+ if len (dates ) == 0 :
64+ raise IndexError
65+
66+ return dates [0 ]
67+
68+ try :
69+ a_name = parse_filename (file .split ('/' )[- 1 ])
70+ except IndexError :
5971 print (" ERROR: no identifier recognized in TRIOS L0 file name" )
6072 print (" L0 filename should have a cast to identify triplet instrument" )
6173 print (" ending in 4 digits before S.mlb " )
6274 return None ,None
6375
76+ # match1 = re.search(r'\d{8}_\d{6}', file.split('/')[-1])
77+ # match2 = re.search(r'\d{4}S', file.split('/')[-1])
78+ # match3 = re.search(r'\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}', file.split('/')[-1])
79+ # # string except for serial number will be the same for a triplet
80+ # if match1 is not None:
81+ # a_name = match1.group()
82+ # elif match2 is not None:
83+ # a_name = match2.group()
84+ # elif match3 is not None:
85+ # a_name = match3.group()
86+ # else:
87+ # print(" ERROR: no identifier recognized in TRIOS L0 file name" )
88+ # print(" L0 filename should have a cast to identify triplet instrument")
89+ # print(" ending in 4 digits before S.mlb ")
90+ # return None,None
91+
6492 # acq_time.append(a_cast)
6593 acq_name .append (a_name )
6694
@@ -114,8 +142,8 @@ def processL1a(fp, outFilePath):
114142
115143 try :
116144 new_name = file .split ('/' )[- 1 ].split ('.mlb' )[0 ].split (f'SAM_{ name } _RAW_SPECTRUM_' )[1 ]
117- if match2 is not None :
118- new_name = new_name + '_' + str (start )
145+ if re . search ( r'\d{4}S' , file . split ( '/' )[ - 1 ]) is not None :
146+ new_name = new_name + '_' + str (start ) # I'm not sure what match2 was supposed to find in ACRI's code - AR
119147 except IndexError as err :
120148 print (err )
121149 msg = "possibly an error in naming of Raw files"
0 commit comments