Skip to content

Commit

Permalink
better handle of empty config and changing length of string
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptisteVandecrux committed Jul 8, 2024
1 parent eb341f5 commit 6b003b4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pypromice/process/L2toL3.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,13 @@ def thermistorDepth(df_in, site, station_config):
logger.info('Calculating thermistor depth')

# Convert maintenance_info to DataFrame for easier manipulation
maintenance_string = pd.DataFrame(station_config.get("string_maintenance",[]))
maintenance_string = pd.DataFrame(
station_config.get("string_maintenance",[]),
columns = ['date', 'installation_depths']
)
maintenance_string["date"] = pd.to_datetime(maintenance_string["date"])
maintenance_string = maintenance_string.sort_values(by='date', ascending=True)

temp_cols_name = ['t_i_'+str(i) for i in range(12) if 't_i_'+str(i) in df_in.columns]
num_therm = len(temp_cols_name)
depth_cols_name = ['d_t_i_'+str(i) for i in range(1,num_therm+1)]
Expand Down Expand Up @@ -647,7 +651,8 @@ def thermistorDepth(df_in, site, station_config):
new_depth = maintenance_string.loc[
maintenance_string.date == date
].installation_depths.values[0]
for i, col in enumerate(depth_cols_name):

for i, col in enumerate(depth_cols_name[:len(new_depth)]):
tmp = df_in[col].copy()
tmp.loc[date:] = (
new_depth[i]
Expand Down

0 comments on commit 6b003b4

Please sign in to comment.