From 82f0550e558717cb9a19da58f45bd16d218b2551 Mon Sep 17 00:00:00 2001 From: Callum Rollo Date: Fri, 26 Jul 2024 10:25:37 +0200 Subject: [PATCH] standarise time encoding to seconds since 1970 --- pyglider/ncprocess.py | 5 +++-- pyglider/seaexplorer.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pyglider/ncprocess.py b/pyglider/ncprocess.py index a8c81c8..63b20eb 100644 --- a/pyglider/ncprocess.py +++ b/pyglider/ncprocess.py @@ -290,8 +290,9 @@ def make_gridfiles(inname, outdir, deploymentyaml, *, fnamesuffix='', dz=1, star outname = outdir + '/' + ds.attrs['deployment_name'] + '_grid' + fnamesuffix + '.nc' _log.info('Writing %s', outname) - # timeunits = 'nanoseconds since 1970-01-01T00:00:00Z' - dsout.to_netcdf(outname) + dsout.to_netcdf(outname, + encoding={'time': {'units': 'seconds since 1970-01-01T00:00:00Z', + 'dtype': 'float64'}}) _log.info('Done gridding') return outname diff --git a/pyglider/seaexplorer.py b/pyglider/seaexplorer.py index c25e57f..451b6f6 100644 --- a/pyglider/seaexplorer.py +++ b/pyglider/seaexplorer.py @@ -495,7 +495,8 @@ def raw_to_timeseries(indir, outdir, deploymentyaml, kind='raw', if 'units' in ds.ad2cp_time.attrs.keys(): ds.ad2cp_time.attrs.pop('units') ds.to_netcdf(outname, 'w', - encoding={'time': {'units': 'milliseconds since 1970-01-01T00:00:00Z'}}) + encoding={'time': {'units': 'seconds since 1970-01-01T00:00:00Z', + 'dtype': 'float64'}}) return outname