Repurposed the role of the config_file.py. Now it only provides functions to select the file_readers based on group id and produce a created_at timestamp.

This commit is contained in:
2024-04-03 13:55:54 +02:00
parent 5cd19979b6
commit 719e9d6672

View File

@ -14,85 +14,32 @@ import pygit2 as pygit
author = pygit.Signature('Florez Ospina Juan Felipe', 'juan.florez-ospina@psi.ch')
committer = pygit.Signature('Florez Ospina Juan Felipe', 'juan.florez-ospina@psi.ch')
group_id = 'smog_chamber'
#group_id = '5505'
output_filename_tempate = lambda group_id, timestamp,user_initials : '_'.join(['unified_file',group_id,timestamp,user_initials])+'.h5'
def created_at():
now = datetime.now()
# Populate now object with time zone infotmation obtained from the local system
now_tz_aware = now.astimezone()
tz = now_tz_aware.strftime('%z')
#created_at = now_tz_aware.strftime('%Y-%m-%d_%H-%M-%S')+'_utcoffset_' + tz
created_at = now_tz_aware.strftime('%Y-%m-%d')+'_UTC-OFST_' + tz
# Make created at timestamp with tz information
#created_at = now.isoformat()
usecase = 1
if usecase == 1:
group_id == 'smog_chamber'
user_initials = 'NG'
#from smog_chamber_file_reader import read_txt_files_as_dict
#from g5505_file_reader import copy_file_in_group
#select_dir_keywords = ['htof','ams', 'ptr', 'gas','smps']
inputfile_dir = '\\\\fs03\\Iron_Sulphate'
inputfile_dir = '//fs03/Iron_Sulphate'
#select_dir_keywords = ['gas','smps\\20220726','htof\\2022.07.26','ptr\\2022.07.26','ams\\2022.07.26']
select_dir_keywords = ['gas','smps/20220726']#,'htof/2022.07.26','ptr/2022.07.26','ams/2022.07.26']
select_file_keywords = ['20220726','2022.07.26']
outputfile_dir = 'output_files'
output_filename = output_filename_tempate(group_id,created_at,user_initials) #'test_smog_chamber_v14.h5'
#output_filename = 'unified_file_smog_chamber_2024-03-19_UTC-OFST_+0100_NG.h5'
now = datetime.now()
# Populate now object with time zone infotmation obtained from the local system
now_tz_aware = now.astimezone()
tz = now_tz_aware.strftime('%z')
#created_at = now_tz_aware.strftime('%Y-%m-%d_%H-%M-%S')+'_utcoffset_' + tz
created_at = now_tz_aware.strftime('%Y-%m-%d')+'_UTC-OFST_' + tz
# Make created at timestamp with tz information
#created_at = now.isoformat()
return created_at
ext_to_reader_dict = {'.txt': scf_reader.read_txt_files_as_dict,
def select_file_readers(group_id):
if group_id == '5505':
ext_to_reader_dict = {'.ibw': g5505f_reader.read_xps_ibw_file_as_dict,
'.txt': g5505f_reader.read_txt_files_as_dict,
'.dat': g5505f_reader.read_txt_files_as_dict,
'.h5': g5505f_reader.copy_file_in_group}
elif group_id == 'smog_chamber':
ext_to_reader_dict = {'.txt': scf_reader.read_txt_files_as_dict,
'.TXT': scf_reader.read_txt_files_as_dict,
'.h5': g5505f_reader.copy_file_in_group}
elif usecase == 2 :
group_id == '5505'
user_initials = 'TBR'
outputfile_dir = 'output_files'
#output_filename = 'test_sls_data_v8.h5'
inputfile_dir = '//fs101/5505/People/Juan/TypicalBeamTime'
select_file_keywords=[]
select_dir_keywords = ['NEXAFS', 'Notes', 'Photos', 'Pressure', 'RGA', 'SES']
output_filename = output_filename_tempate(group_id,created_at,user_initials)
#output_filename = 'unified_file_5505_2024-03-19_UTC-OFST_+0100_TBR.h5'
ext_to_reader_dict = {'.ibw': g5505f_reader.read_xps_ibw_file_as_dict,
'.txt': g5505f_reader.read_txt_files_as_dict,
'.dat': g5505f_reader.read_txt_files_as_dict,
'.h5': g5505f_reader.copy_file_in_group}
elif usecase == 3:
user_initials = 'LL'
outputfile_dir = 'output_files'
output_filename = output_filename_tempate(group_id,created_at,user_initials)
inputfile_dir = '//fs101/5505/Data'
#select_dir_keywords = ['Lopap', 'Humidity_Sensors', 'ICAD/HONO', 'ICAD/NO2', 'T200_NOX', 'T360U_CO2']
# TODO: make sure in the code composite keywords are broken down into single keywords
##select_dir_keywords = ['Humidity_Sensors','ICAD/HONO','ICAD/NO2']
select_dir_keywords = ['Humidity_Sensors/2022','ICAD/HONO/2022','ICAD/NO2/2022', '2022/01_Jan', '2022/02_Feb', '2022/03_März']
dates = pd.read_excel(os.path.abspath(os.path.join('input_files','date_experiments_for Juan.xlsx')))
select_file_keywords=[item.strftime('%Y-%m-%d') for item in dates.loc[0:2,'experiment_date']]
select_file_keywords= select_file_keywords + [item.strftime('%Y%m%d') for item in dates.loc[0:2,'experiment_date']]
ext_to_reader_dict = {'.ibw': g5505f_reader.read_xps_ibw_file_as_dict,
'.txt': g5505f_reader.read_txt_files_as_dict,
'.dat': g5505f_reader.read_txt_files_as_dict,
'.h5': g5505f_reader.copy_file_in_group}
return ext_to_reader_dict