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

ENH: fnamesuffix #148

Merged
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions pyglider/ncprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ def extract_timeseries_profiles(inname, outdir, deploymentyaml):
timecalendar = 'gregorian'
dss.to_netcdf(outname, encoding={'time': {'units': timeunits,
'calendar': timecalendar},
'profile_time':
'profile_time':
{'units': timeunits}})

# add traj_strlen using bare ntcdf to make IOOS happy
with netCDF4.Dataset(outname, 'r+') as nc:
nc.renameDimension('string%d' % trajlen, 'traj_strlen')


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

Expand Down Expand Up @@ -241,7 +241,7 @@ def make_gridfiles(inname, outdir, deploymentyaml, dz=1):
'water_velocity_northward'])
dsout.attrs = ds.attrs

outname = outdir + '/' + ds.attrs['deployment_name'] + '_grid.nc'
outname = outdir + '/' + ds.attrs['deployment_name'] + '_grid' + fnamesuffix + '.nc'
_log.info('Writing %s', outname)
timeunits = 'seconds since 1970-01-01T00:00:00Z'
dsout.to_netcdf(outname, encoding={'time': {'units': timeunits}})
Expand Down
5 changes: 3 additions & 2 deletions pyglider/seaexplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ def _interp_pld_to_pld(pld, ds, val, indctd):


def raw_to_timeseries(indir, outdir, deploymentyaml, kind='raw',
profile_filt_time=100, profile_min_time=300):
profile_filt_time=100, profile_min_time=300,
fnamesuffix=''):
"""
A little different than above, for the 4-file version of the data set.
"""
Expand Down Expand Up @@ -455,7 +456,7 @@ def raw_to_timeseries(indir, outdir, deploymentyaml, kind='raw',
except:
pass
id0 = ds.attrs['deployment_name']
outname = outdir + id0 + '.nc'
outname = outdir + id0 + fnamesuffix + '.nc'
_log.info('writing %s', outname)
if 'units' in ds.time.attrs.keys():
ds.time.attrs.pop('units')
Expand Down
7 changes: 4 additions & 3 deletions pyglider/slocum.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,9 @@ def raw_to_timeseries(indir, outdir, deploymentyaml, *,


def binary_to_timeseries(indir, cachedir, outdir, deploymentyaml, *,
search='*.[D|E]BD', time_base='sci_water_temp',
profile_filt_time=100, profile_min_time=300):
search='*.[D|E]BD', fnamesuffix='',
time_base='sci_water_temp', profile_filt_time=100,
profile_min_time=300):
"""
Convert directly from binary files to netcdf timeseries file. Requires
dbdreader to be installed.
Expand Down Expand Up @@ -934,7 +935,7 @@ def binary_to_timeseries(indir, cachedir, outdir, deploymentyaml, *,
os.mkdir(outdir)
except:
pass
outname = (outdir + '/' + ds.attrs['deployment_name'] + '.nc')
outname = (outdir + '/' + ds.attrs['deployment_name'] + fnamesuffix + '.nc')
_log.info('writing %s', outname)
ds.to_netcdf(outname, 'w',
encoding={'time': {'units': 'seconds since 1970-01-01T00:00:00Z'}})
Expand Down