From 05f0a23ebc91f1a692409b408d7811f6e9a9fbe2 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 3 Jul 2024 11:08:01 +0000 Subject: [PATCH] minor changes needed to run on aws-vm-dev --- src/pypromice/process/join_l3.py | 18 +++++++++++++++++- src/pypromice/process/write.py | 6 +++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/pypromice/process/join_l3.py b/src/pypromice/process/join_l3.py index e062911c..47dbbfb2 100644 --- a/src/pypromice/process/join_l3.py +++ b/src/pypromice/process/join_l3.py @@ -202,7 +202,7 @@ def join_l3(config_folder, site, folder_l3, folder_gcnet, outpath, variables, me filepath = os.path.join(folder_l3, stid, stid+'_hour.nc') isNead = False - if station_info["project"].lower() in ["historical gc-net", "glaciobasis"]: + if station_info["project"].lower() in ["historical gc-net"]: filepath = os.path.join(folder_gcnet, stid+'.csv') isNead = True if not os.path.isfile(filepath): @@ -221,6 +221,22 @@ def join_l3(config_folder, site, folder_l3, folder_gcnet, outpath, variables, me for l3, station_info in sorted_list_station_data: stid = station_info["stid"] + # This is necessary in xarray < 2024.6.0: + for v in ['lat','lon','alt']: + if v in l3.keys(): + tmp = l3[v] + l3 = l3.drop_vars(v) + l3[v] = (tmp[v].data) + # lat lon and alt are set as coordinates to all variables in the l3 data + # this makes it impossible to concatenate with other datasets where + # lat lon alt are not coordinates + # I have tried .reset_coords(drop=True) and .drop_vars([...]) without success + # this was the only way they could be reset as 0-dimensional variables + # which are not coordinates. + # This will be removed in further updates because lat/lon/alt will become + # real time-dependent variables, and will not be specified anymore as coordinates + # in the variable.csv + if l3_merged is None: # saving attributes of stid st_attrs = {} diff --git a/src/pypromice/process/write.py b/src/pypromice/process/write.py index cc4d8fe5..3d7afa48 100644 --- a/src/pypromice/process/write.py +++ b/src/pypromice/process/write.py @@ -63,7 +63,11 @@ def prepare_and_write(dataset, outpath, vars_df=None, meta_dict=None, time='60mi d2 = roundValues(d2, vars_df) # Get variable names to write out - col_names = getColNames(vars_df, d2, remove_nan_fields=True) + if 'site_id' in d2.attrs.keys(): + remove_nan_fields = True + else: + remove_nan_fields = False + col_names = getColNames(vars_df, d2, remove_nan_fields=remove_nan_fields) # Define filename based on resample rate t = int(pd.Timedelta((d2['time'][1] - d2['time'][0]).values).total_seconds())