Modified hardcoded paths to adapt with respect to the parent directory

This commit is contained in:
2024-06-11 17:30:58 +02:00
parent e7ed6145f0
commit cbca94390f
2 changed files with 18 additions and 12 deletions

View File

@ -116,7 +116,12 @@ from collections import Counter
def read_txt_files_as_dict(filename : str , work_with_copy : bool = True ):
with open('src/instruments/text_data_sources.yaml','r') as stream:
# Get the directory of the current module
module_dir = os.path.dirname(__file__)
# Construct the relative file path
instrument_configs_path = os.path.join(module_dir, 'instruments', 'text_data_sources.yaml')
with open(instrument_configs_path,'r') as stream:
try:
config_dict = yaml.load(stream, Loader=yaml.FullLoader)
except yaml.YAMLError as exc:
@ -140,7 +145,8 @@ def read_txt_files_as_dict(filename : str , work_with_copy : bool = True ):
datetime_format = config_dict[key].get('datetime_format',[])
description_dict = {}
link_to_description = config_dict[key].get('link_to_description',[]).replace('/',os.sep)
#link_to_description = config_dict[key].get('link_to_description',[]).replace('/',os.sep)
link_to_description = os.path.join(module_dir,config_dict[key].get('link_to_description',[]).replace('/',os.sep))
with open(link_to_description,'r') as stream:
try:
description_dict = yaml.load(stream, Loader=yaml.FullLoader)

View File

@ -7,14 +7,14 @@ default:
RGA:
table_header : 'Time(s) Channel#1 Channel#2 Channel#3 Channel#4 Channel#5 Channel#6 Channel#7 Channel#8'
separator : '\t'
link_to_description: 'src/instruments/RGA.yaml'
link_to_description: 'instruments/RGA.yaml'
Pressure:
table_header : 'Date Time Vapore-Pressure 1 in Vapore-Pressure 2 in Baratron 1 in Baratron 2 in Baratron 3 in Baratron 4 in Temp. Ice-Sample in Temp. Heated-Sample in Temp. Cooler 1 in Temp. Cooler 2 in Flow Gas 1 in Pressure Chamber in X in Y in Z in None in Temp. Sealing in Flow Ice-Sample in'
separator : '\t'
timestamp: ['Date','Time']
datetime_format: '%d.%m.%Y %H:%M:%S'
link_to_description: 'src/instruments/Preassure.yaml'
link_to_description: 'instruments/Preassure.yaml'
Humidity_Sensors:
table_header : 'Date Time RH1[%] RH2[%] RH3[%] RH4[%] RH5[%] RH6[%] RH7[%] RH8[%] T1[°C] T2[°C] T3[°C] T4[°C] T5[°C] T6[°C] T7[°C] T8[°C] DP1[°C] DP2[°C] DP3[°C] DP4[°C] DP5[°C] DP6[°C] DP7[°C] DP8[°C]'
@ -22,7 +22,7 @@ Humidity_Sensors:
file_encoding : 'latin-1'
timestamp: ['Date','Time']
datetime_format: '%d.%m.%Y %H:%M:%S'
link_to_description: 'src/instruments/Humidity_Sensors.yaml'
link_to_description: 'instruments/Humidity_Sensors.yaml'
HONO: #ICAD/HONO:
table_header : 'Start Date/Time (UTC) Duration (s) NO2 (ppb) NO2 Uncertainty (ppb) HONO (ppb) HONO Uncertainty (ppb) H2O (ppb) H2O Uncertainty (ppb) O4 (ppb) O4 Uncertainty (ppb) File Number Light Intensity #ICEDOAS iter. Cell Pressure Ambient Pressure Cell Temp Spec Temp Lat Lon Height Speed GPSQuality 0-Air Ref. Time 0-Air Ref. Duration 0-Air Ref. File Number 0-Air Ref. Intensity 0-Air Ref. Rel Intensity 0-Air Ref. Intensity valid MeasMode SampleSource'
@ -30,7 +30,7 @@ HONO: #ICAD/HONO:
file_encoding : 'latin-1'
timestamp: ['Start Date/Time (UTC)']
datetime_format: '%Y-%m-%d %H:%M:%S.%f'
link_to_description: 'src/instruments/ICAD_HONO.yaml'
link_to_description: 'instruments/ICAD_HONO.yaml'
NO2: #ICAD/NO2:
table_header : 'Start Date/Time (UTC) Duration (s) NO2 (ppb) NO2 Uncertainty (ppb) H2O (ppb) H2O Uncertainty (ppb) CHOCHO (ppb) CHOCHO Uncertainty (ppb) File Number Light Intensity #ICEDOAS iter. Cell Pressure Ambient Pressure Cell Temp Spec Temp Lat Lon Height Speed GPSQuality 0-Air Ref. Time 0-Air Ref. Duration 0-Air Ref. File Number 0-Air Ref. Intensity 0-Air Ref. Rel Intensity 0-Air Ref. Intensity valid MeasMode SampleSource'
@ -38,7 +38,7 @@ NO2: #ICAD/NO2:
file_encoding : 'latin-1'
timestamp: ['Start Date/Time (UTC)']
datetime_format: '%Y-%m-%d %H:%M:%S.%f'
link_to_description: 'src/instruments/ICAD_NO2.yaml'
link_to_description: 'instruments/ICAD_NO2.yaml'
Lopap:
#table_header : 'Date;Time;Ch1;490.1;500.2;510.0;520.0;530.1;540.0;550.7;603.2;700.3;800.0;Ch2;500.5;510.3;520.5;530.7;540.8;550.5;550.8;560.9;570.9;581.2;586.2;591.2;596.1;601.1;606.4;611.3;'
@ -47,7 +47,7 @@ Lopap:
file_encoding : 'latin-1'
timestamp: ['Date','Time']
datetime_format: '%d.%m.%Y %H:%M:%S'
link_to_description: 'src/instruments/Lopap.yaml'
link_to_description: 'instruments/Lopap.yaml'
T200_NOx:
table_header : 'Date Time NO NO2 NOx'
@ -55,7 +55,7 @@ T200_NOx:
file_encoding : 'latin-1'
timestamp: ['Date','Time']
datetime_format: '%d.%m.%Y %H:%M:%S'
link_to_description: 'src/instruments/T200_NOx.yaml'
link_to_description: 'instruments/T200_NOx.yaml'
T360U_CO2:
table_header : 'Date Time CO2'
@ -63,7 +63,7 @@ T360U_CO2:
file_encoding : 'latin-1'
timestamp: ['Date','Time']
datetime_format: '%d.%m.%Y %H:%M:%S'
link_to_description: 'src/instruments/T360U_CO2.yaml'
link_to_description: 'instruments/T360U_CO2.yaml'
smps:
table_header: 'Sample # Date Start Time Sample Temp (C) Sample Pressure (kPa) Relative Humidity (%) Mean Free Path (m) Gas Viscosity (Pa*s) Diameter Midpoint (nm) 15.7 16.3 16.8 17.5 18.1 18.8 19.5 20.2 20.9 21.7 22.5 23.3 24.1 25.0 25.9 26.9 27.9 28.9 30.0 31.1 32.2 33.4 34.6 35.9 37.2 38.5 40.0 41.4 42.9 44.5 46.1 47.8 49.6 51.4 53.3 55.2 57.3 59.4 61.5 63.8 66.1 68.5 71.0 73.7 76.4 79.1 82.0 85.1 88.2 91.4 94.7 98.2 101.8 105.5 109.4 113.4 117.6 121.9 126.3 131.0 135.8 140.7 145.9 151.2 156.8 162.5 168.5 174.7 181.1 187.7 194.6 201.7 209.1 216.7 224.7 232.9 241.4 250.3 259.5 269.0 278.8 289.0 299.6 310.6 322.0 333.8 346.0 358.7 371.8 385.4 399.5 414.2 429.4 445.1 461.4 478.3 495.8 514.0 532.8 552.3 572.5 593.5 615.3 637.8 Scan Time (s) Retrace Time (s) Scan Resolution (Hz) Scans Per Sample Sheath Flow (L/min) Aerosol Flow (L/min) Bypass Flow (L/min) Low Voltage (V) High Voltage (V) Lower Size (nm) Upper Size (nm) Density (g/cm³) td + 0.5 (s) tf (s) D50 (nm) Neutralizer'
@ -71,7 +71,7 @@ smps:
file_encoding : 'latin-1'
timestamp: ['1_Date','2_Start Time']
datetime_format: '%d/%m/%Y %H:%M:%S'
link_to_description: 'src/instruments/smps.yaml'
link_to_description: 'instruments/smps.yaml'
gas:
table_header : 'Date_Time HoribaNO HoribaNOy Thermo42C_NO Thermo42C_NOx APHA370 CH4 APHA370THC HygroclipRH HygroclipT ML9850SO2 ozone49c PAMrh PAMt xxxal xxxal xxxal xxxal ThermoCouple0 ThermoCouple1 ThermoCouple2 ThermoCouple3 xxxTC xxxTC xxxTC xxxTC xxxTC xxxTC xxxTC xxxTC xxxTC xxxTC xxxTC xxxTC CPC xxx LicorH2Odelta LicorCO2delta xxx 2BO2 xxx xxx HoribaCO xxx'
@ -79,4 +79,4 @@ gas:
file_encoding : 'utf-8'
timestamp: ['0_Date_Time']
datetime_format: '%Y.%m.%d %H:%M:%S'
link_to_description: 'src/instruments/gas.yaml'
link_to_description: 'instruments/gas.yaml'