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

FIX: make times floating point seconds, not integer seconds #177

Merged
merged 1 commit into from
Jul 17, 2024
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
12 changes: 8 additions & 4 deletions pyglider/slocum.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,12 +923,14 @@ def binary_to_timeseries(indir, cachedir, outdir, deploymentyaml, *,

# screen out-of-range times; these won't convert:
ds['time'] = ds.time.where((ds.time>0) & (ds.time<6.4e9), np.NaN)
ds['time'] = (('time'), (ds.time.values.astype('timedelta64[s]') +
np.datetime64('1970-01-01T00:00:00')).astype('datetime64[ns]'), attr)
# convert time to datetime64:
ds['time'] = (ds.time*1e9).astype('datetime64[ns]')
ds['time'].attrs = attr

ds = utils.fill_metadata(ds, deployment['metadata'], device_data)
start = ds['time'].values[0]
end = ds['time'].values[-1]

start = ds.time.values[0]
end = ds.time.values[0]
_log.debug('Long')
_log.debug(ds.longitude.values[-2000:])
ds.attrs['deployment_start'] = str(start)
Expand All @@ -947,6 +949,8 @@ def binary_to_timeseries(indir, cachedir, outdir, deploymentyaml, *,
pass
outname = (outdir + '/' + ds.attrs['deployment_name'] + fnamesuffix + '.nc')
_log.info('writing %s', outname)
# convert time back to float64 seconds for ERDDAP etc happiness, as they won't take ns
# as a unit:
ds.to_netcdf(outname, 'w',
encoding={'time': {'units': 'seconds since 1970-01-01T00:00:00Z',
'_FillValue': np.NaN,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading