@@ -117,7 +117,7 @@ def extract_timeseries_profiles(inname, outdir, deploymentyaml):
117
117
118
118
# outname = outdir + '/' + utils.get_file_id(dss) + '.nc'
119
119
_log .info ('Writing %s' , outname )
120
- timeunits = 'seconds since 1970-01-01T00:00:00Z'
120
+ timeunits = 'nanoseconds since 1970-01-01T00:00:00Z'
121
121
timecalendar = 'gregorian'
122
122
dss .to_netcdf (outname , encoding = {'time' : {'units' : timeunits ,
123
123
'calendar' : timecalendar },
@@ -164,7 +164,7 @@ def make_gridfiles(inname, outdir, deploymentyaml, *, fnamesuffix='', dz=1):
164
164
deployment = yaml .safe_load (fin )
165
165
profile_meta = deployment ['profile_variables' ]
166
166
167
- ds = xr .open_dataset (inname )
167
+ ds = xr .open_dataset (inname , decode_times = True )
168
168
_log .info (f'Working on: { inname } ' )
169
169
_log .debug (str (ds ))
170
170
_log .debug (str (ds .time [0 ]))
@@ -183,8 +183,9 @@ def make_gridfiles(inname, outdir, deploymentyaml, *, fnamesuffix='', dz=1):
183
183
dsout = xr .Dataset (
184
184
coords = {'depth' : ('depth' , depths ),
185
185
'profile' : ('time' , profiles )})
186
+ print ('Booo' , ds .time , ds .temperature )
186
187
ds ['time_1970' ] = ds .temperature .copy ()
187
- ds ['time_1970' ].values = ds .time .values .astype (np .float64 )/ 1e9
188
+ ds ['time_1970' ].values = ds .time .values .astype (np .float64 )
188
189
for td in ('time_1970' , 'longitude' , 'latitude' ):
189
190
good = np .where (~ np .isnan (ds [td ]) & (ds ['profile_index' ] % 1 == 0 ))[0 ]
190
191
dat , xedges , binnumber = stats .binned_statistic (
@@ -193,7 +194,7 @@ def make_gridfiles(inname, outdir, deploymentyaml, *, fnamesuffix='', dz=1):
193
194
bins = [profile_bins ])
194
195
if td == 'time_1970' :
195
196
td = 'time'
196
- dat = dat .astype ('timedelta64[s ]' ) + np .datetime64 ('1970-01-01T00:00:00' )
197
+ dat = dat .astype ('timedelta64[ns ]' ) + np .datetime64 ('1970-01-01T00:00:00' )
197
198
_log .info (f'{ td } { len (dat )} ' )
198
199
dsout [td ] = (('time' ), dat , ds [td ].attrs )
199
200
ds .drop ('time_1970' )
@@ -249,8 +250,8 @@ def make_gridfiles(inname, outdir, deploymentyaml, *, fnamesuffix='', dz=1):
249
250
250
251
outname = outdir + '/' + ds .attrs ['deployment_name' ] + '_grid' + fnamesuffix + '.nc'
251
252
_log .info ('Writing %s' , outname )
252
- timeunits = 'seconds since 1970-01-01T00:00:00Z'
253
- dsout .to_netcdf (outname , encoding = { 'time' : { 'units' : timeunits }} )
253
+ # timeunits = 'nanoseconds since 1970-01-01T00:00:00Z'
254
+ dsout .to_netcdf (outname )
254
255
_log .info ('Done gridding' )
255
256
256
257
return outname
0 commit comments