Skip to content

Commit

Permalink
FIX: time in profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
C-PROOF committed May 20, 2024
1 parent f49bd2c commit 960eff1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pyglider/ncprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def extract_timeseries_profiles(inname, outdir, deploymentyaml):
with open(deploymentyaml) as fin:
deployment = yaml.safe_load(fin)
meta = deployment['metadata']

with xr.open_dataset(inname) as ds:
_log.info('Extracting profiles: opening %s', inname)
profiles = np.unique(ds.profile_index)
Expand Down Expand Up @@ -78,6 +77,12 @@ def extract_timeseries_profiles(inname, outdir, deploymentyaml):
dss['profile_id'].attrs = profile_meta['profile_id']
dss['profile_time'] = dss.time.mean()
dss['profile_time'].attrs = profile_meta['profile_time']
# remove units so they can be encoded later:
try:
del dss.profile_time.attrs['units']
del dss.profile_time.attrs['calendar']
except ValueError:
pass
dss['profile_lon'] = dss.longitude.mean()
dss['profile_lon'].attrs = profile_meta['profile_lon']
dss['profile_lat'] = dss.latitude.mean()
Expand All @@ -87,7 +92,7 @@ def extract_timeseries_profiles(inname, outdir, deploymentyaml):
dss['lon'] = dss['longitude']
dss['platform'] = np.NaN
comment = (meta['glider_model'] + ' operated by ' +
meta['institution'])
meta['institution'])
dss['platform'].attrs['comment'] = comment
dss['platform'].attrs['id'] = (
meta['glider_name'] + meta['glider_serial'])
Expand All @@ -111,7 +116,7 @@ def extract_timeseries_profiles(inname, outdir, deploymentyaml):

# ancillary variables::
to_fill = ['temperature', 'pressure', 'conductivity',
'salinity', 'density', 'lon', 'lat', 'depth']
'salinity', 'density', 'lon', 'lat', 'depth']
for name in to_fill:
dss[name].attrs['ancillary_variables'] = name + '_qc'
# outname = outdir + '/' + utils.get_file_id(dss) + '.nc'
Expand All @@ -131,7 +136,6 @@ def extract_timeseries_profiles(inname, outdir, deploymentyaml):
with netCDF4.Dataset(outname, 'r+') as nc:
nc.renameDimension('string%d' % trajlen, 'traj_strlen')


def make_gridfiles(inname, outdir, deploymentyaml, *, fnamesuffix='', dz=1):
"""
Turn a timeseries netCDF file into a vertically gridded netCDF.
Expand Down

0 comments on commit 960eff1

Please sign in to comment.