Skip to content

Commit

Permalink
minor changes needed to run on aws-vm-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Jul 3, 2024
1 parent f79edbf commit 05f0a23
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/pypromice/process/join_l3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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 = {}
Expand Down
6 changes: 5 additions & 1 deletion src/pypromice/process/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 05f0a23

Please sign in to comment.