Rename attribute station --> station_abbr

This commit is contained in:
2025-04-11 11:20:48 +02:00
parent e7863078aa
commit 4408514439
4 changed files with 17 additions and 17 deletions

View File

@ -210,8 +210,8 @@ def main(data_file, calibration_file):
dataManager.extract_and_load_dataset_metadata() dataManager.extract_and_load_dataset_metadata()
dataset_metadata_df = dataManager.dataset_metadata_df.copy() dataset_metadata_df = dataManager.dataset_metadata_df.copy()
STATION = load_project_yaml_files(projectPath,'campaignDescriptor.yaml')['station'] STATION_ABBR = load_project_yaml_files(projectPath,'campaignDescriptor.yaml')['station_abbr']
keywords = ['ACSM_TOFWARE/', f'ACSM_{STATION}_', '_timeseries.txt/data_table'] keywords = ['ACSM_TOFWARE/', f'ACSM_{STATION_ABBR}_', '_timeseries.txt/data_table']
find_keyword = [all(keyword in item for keyword in keywords) for item in dataset_metadata_df['dataset_name']] find_keyword = [all(keyword in item for keyword in keywords) for item in dataset_metadata_df['dataset_name']]
if sum(find_keyword) != 1: if sum(find_keyword) != 1:

View File

@ -238,14 +238,14 @@ def main(data_file, flag_type):
dataManager.extract_and_load_dataset_metadata() dataManager.extract_and_load_dataset_metadata()
dataset_metadata_df = dataManager.dataset_metadata_df.copy() dataset_metadata_df = dataManager.dataset_metadata_df.copy()
STATION = load_project_yaml_files(projectPath,'campaignDescriptor.yaml')['station'] STATION_ABBR = load_project_yaml_files(projectPath,'campaignDescriptor.yaml')['station_abbr']
# Find dataset associated with diagnostic channels # Find dataset associated with diagnostic channels
if flag_type == 'diagnostics': if flag_type == 'diagnostics':
keywords = [f'ACSM_{STATION}_','_meta.txt/data_table'] keywords = [f'ACSM_{STATION_ABBR}_','_meta.txt/data_table']
find_keyword = [all(keyword in item for keyword in keywords) for item in dataset_metadata_df['dataset_name']] find_keyword = [all(keyword in item for keyword in keywords) for item in dataset_metadata_df['dataset_name']]
if flag_type == 'species': if flag_type == 'species':
keywords = [f'ACSM_{STATION}_','_timeseries.txt/data_table'] keywords = [f'ACSM_{STATION_ABBR}_','_timeseries.txt/data_table']
find_keyword = [all(keyword in item for keyword in keywords) for item in dataset_metadata_df['dataset_name']] find_keyword = [all(keyword in item for keyword in keywords) for item in dataset_metadata_df['dataset_name']]
# Specify source dataset to be extracted from input hdf5 data file # Specify source dataset to be extracted from input hdf5 data file

View File

@ -186,7 +186,7 @@ def main(paths_to_processed_files : list, path_to_flags : str, month : int = Non
campaignDescriptorDict = load_project_yaml_files(projectPath, 'campaignDescriptor.yaml') campaignDescriptorDict = load_project_yaml_files(projectPath, 'campaignDescriptor.yaml')
# Validate required fields # Validate required fields
station = validate_required_field(campaignDescriptorDict, 'station') STATION_ABBR = validate_required_field(campaignDescriptorDict, 'station_abbr')
instrument_name = validate_required_field(campaignDescriptorDict, 'instrument_name') instrument_name = validate_required_field(campaignDescriptorDict, 'instrument_name')
year = validate_required_field(campaignDescriptorDict, 'year') year = validate_required_field(campaignDescriptorDict, 'year')
@ -194,8 +194,8 @@ def main(paths_to_processed_files : list, path_to_flags : str, month : int = Non
output_dir = os.path.join(projectPath, 'data') output_dir = os.path.join(projectPath, 'data')
os.makedirs(output_dir, exist_ok=True) os.makedirs(output_dir, exist_ok=True)
output_file1 = os.path.join(output_dir, f'{station}_{instrument_name}_{year}.txt') output_file1 = os.path.join(output_dir, f'{STATION_ABBR}_{instrument_name}_{year}.txt')
output_file2 = os.path.join(output_dir, f'{station}_{instrument_name}_FLAGS_{year}.txt') output_file2 = os.path.join(output_dir, f'{STATION_ABBR}_{instrument_name}_FLAGS_{year}.txt')
#output_file1 = os.path.join(output_dir, f'JFJ_ACSM-017_2024_month{args.month}.txt' if args.month else 'JFJ_ACSM-017_2024.txt') #output_file1 = os.path.join(output_dir, f'JFJ_ACSM-017_2024_month{args.month}.txt' if args.month else 'JFJ_ACSM-017_2024.txt')
#output_file2 = os.path.join(output_dir, f'JFJ_ACSM-017_FLAGS_2024_month{args.month}.txt' if args.month else 'JFJ_ACSM-017_FLAGS_2024.txt') #output_file2 = os.path.join(output_dir, f'JFJ_ACSM-017_FLAGS_2024_month{args.month}.txt' if args.month else 'JFJ_ACSM-017_FLAGS_2024.txt')

View File

@ -39,7 +39,7 @@ def load_yaml(path):
actris_metadata = { actris_metadata = {
'originator': metadata['originator'], 'originator': metadata['originator'],
'submitter': metadata['submitter'], 'submitter': metadata['submitter'],
'station': metadata['station'], 'station_abbr': metadata['station_abbr'],
} }
actris_metadata['originator_name'] = metadata['originator'].get('name', '') actris_metadata['originator_name'] = metadata['originator'].get('name', '')
actris_metadata['submitter_name'] = metadata['submitter'].get('name', '') actris_metadata['submitter_name'] = metadata['submitter'].get('name', '')
@ -60,11 +60,11 @@ def main(data_descriptor_path, dry_run = None):
metadata = load_yaml(data_descriptor_path) metadata = load_yaml(data_descriptor_path)
print(metadata) print(metadata)
station = metadata.get('station', None) STATION_ABBR = metadata.get('station_abbr', None)
if not station: if not STATION_ABBR:
raise RuntimeError( raise RuntimeError(
f'"station" is not defined in {data_descriptor_path}. ' f'"station_abbr" is not defined in {data_descriptor_path}. '
'Make sure you specify it as station: "JFJ" or station: "PAY"' 'Make sure you specify it as station_abbr: "JFJ" or station_abbr: "PAY"'
) )
# Define header paths # Define header paths
@ -78,11 +78,11 @@ def main(data_descriptor_path, dry_run = None):
"PAY": "third_party/acsmProcessingSoftware/src/cfg/actris_header/PAY_ACSM_092.actris_header", "PAY": "third_party/acsmProcessingSoftware/src/cfg/actris_header/PAY_ACSM_092.actris_header",
} }
if station not in header_template_map: if STATION_ABBR not in header_template_map:
raise RuntimeError(f'Station "{station}" is not supported. Choose from: {list(header_template_map)}') raise RuntimeError(f'Attribute station_abbr "{STATION_ABBR}" is not supported. Choose from: {list(header_template_map)}')
#projectPath = resolve_project_path() #projectPath = resolve_project_path()
header_path = os.path.join(projectPath, header_template_map[station]) header_path = os.path.join(projectPath, header_template_map[STATION_ABBR])
if not os.path.exists(header_path): if not os.path.exists(header_path):
raise FileNotFoundError(f"Header template not found at: {header_path}") raise FileNotFoundError(f"Header template not found at: {header_path}")
@ -95,7 +95,7 @@ def main(data_descriptor_path, dry_run = None):
out_path = "output.test.ext" out_path = "output.test.ext"
print("[DRY RUN] Target header was not overwritten.") print("[DRY RUN] Target header was not overwritten.")
else: else:
out_path = os.path.join(projectPath, header_uptate_map[station]) out_path = os.path.join(projectPath, header_uptate_map[STATION_ABBR])
print("[LIVE RUN] Target header will be updated.") print("[LIVE RUN] Target header will be updated.")
print(f"Writing to: {out_path}") print(f"Writing to: {out_path}")