Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helpers: load more modules and allow for loading single plt file without averaging #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions GABLS1/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import numpy as np
import xarray as xr
import glob
import os
from erftools.postprocessing import AveragedProfiles, Column

Tsim = 32400.

Expand Down Expand Up @@ -40,7 +43,8 @@ def load_erf_scm(dpath='.',dt=1.0,Tavg=3600.):
# load column data
df = Column(pltfiles).df
# ugly way to time-average starting from a multiindex
df = df.unstack().mean().unstack().T
if len(pltfiles) > 1:
df = df.unstack().mean().unstack().T
ds = df.to_xarray()
ds = ds.rename_vars(height='z').swap_dims(height='z')
ds['hvelmag'] = ('z', np.sqrt(ds['x_velocity']**2 + ds['y_velocity']**2).values)
Expand All @@ -63,4 +67,4 @@ def load_erf_scm(dpath='.',dt=1.0,Tavg=3600.):
# save
ds.to_netcdf(fpath)
finally:
return ds
return ds