From cebcb49b4008485bff0456ec346692bc9cea6367 Mon Sep 17 00:00:00 2001 From: Akira Sewnath Date: Wed, 17 Apr 2024 14:23:10 -0400 Subject: [PATCH] Resolve pandas warnings (#322) * pandas warning fix * define hofx layout explicitly --------- Co-authored-by: dooruk --- src/swell/deployment/create_experiment.py | 2 +- src/swell/test/suite_tests/hofx-tier1.yaml | 2 ++ src/swell/utilities/gsi_record_parser.py | 7 +++++-- src/swell/utilities/observing_system_records.py | 17 +++++++++-------- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/swell/deployment/create_experiment.py b/src/swell/deployment/create_experiment.py index 83760c2d..42a8f481 100644 --- a/src/swell/deployment/create_experiment.py +++ b/src/swell/deployment/create_experiment.py @@ -446,7 +446,7 @@ def prepare_cylc_suite_jinja2(logger, swell_suite_path, exp_suite_path, experime account = 'g0613' qos = 'allnccs' partition = None - constraint = 'cas' + constraint = 'cas|sky' # Extract from slurm global file if 'qos' in slurm_global: diff --git a/src/swell/test/suite_tests/hofx-tier1.yaml b/src/swell/test/suite_tests/hofx-tier1.yaml index 6150e89c..9f0e5fff 100644 --- a/src/swell/test/suite_tests/hofx-tier1.yaml +++ b/src/swell/test/suite_tests/hofx-tier1.yaml @@ -3,6 +3,8 @@ save_geovals: true models: geos_atmosphere: horizontal_resolution: '91' + npx_proc: 2 + npy_proc: 2 observations: - aircraft - airs_aqua diff --git a/src/swell/utilities/gsi_record_parser.py b/src/swell/utilities/gsi_record_parser.py index c0b8a9aa..50862b43 100644 --- a/src/swell/utilities/gsi_record_parser.py +++ b/src/swell/utilities/gsi_record_parser.py @@ -26,7 +26,10 @@ def __init__(self): def get_channel_list(self, start): channel_list = [] rows = self.instr_df.loc[self.instr_df["start"] == start] - [channel_list.extend(i) for i in rows["channels"].values] + for row_ch_list in rows["channels"].values: + ch_list = eval(row_ch_list) + channel_list.extend(ch_list) + channel_list = list(set(channel_list)) channel_list.sort(key=int) return channel_list @@ -62,7 +65,7 @@ def run(self, instr_df): start_df = self.instr_df.loc[self.instr_df['start'] == main_start] if (len(start_df) == 1): # Only one row to process - channel_list = start_df['channels'].values[0] + channel_list = eval(start_df['channels'].values[0]) comment = start_df['comments'].values[0] self.update_return_df(main_start, main_end, channel_list, comment) done.append(main_start) diff --git a/src/swell/utilities/observing_system_records.py b/src/swell/utilities/observing_system_records.py index e840c53d..e0f40e30 100644 --- a/src/swell/utilities/observing_system_records.py +++ b/src/swell/utilities/observing_system_records.py @@ -43,15 +43,15 @@ def read_sat_db(path_to_sat_db, column_names): 'end': [''], 'instr': [''], 'channel_num': [0], - 'channels': [[]], + 'channels': [''], 'comments': ['']}) df = pd.concat([df, new_row], ignore_index=True) - df['sat'][idx] = line_parts[0] - df['start'][idx] = line_parts[1]+line_parts[2] - df['end'][idx] = line_parts[3]+line_parts[4] - df['instr'][idx] = line_parts[5] - df['channel_num'][idx] = line_parts[6] + df.loc[idx, 'sat'] = line_parts[0] + df.loc[idx, 'start'] = line_parts[1]+line_parts[2] + df.loc[idx, 'end'] = line_parts[3]+line_parts[4] + df.loc[idx, 'instr'] = line_parts[5] + df.loc[idx, 'channel_num'] = line_parts[6] comment_present = next((i for i, x in enumerate(line_parts) if x == '#'), None) @@ -61,11 +61,12 @@ def read_sat_db(path_to_sat_db, column_names): comment_str = ' '.join(comment) # Accounting for no comment if (len(comment_str) != 1): - df['comments'][idx] = comment_str + df.loc[idx, 'comments'] = comment_str else: channel_list = line_parts[7:] - df['channels'][idx] = channel_list + # convert channel list to string + df.loc[idx, 'channels'] = str(channel_list) idx += 1 return df