diff --git a/pyglider/seaexplorer.py b/pyglider/seaexplorer.py index 6451af7..3a6a422 100644 --- a/pyglider/seaexplorer.py +++ b/pyglider/seaexplorer.py @@ -302,8 +302,7 @@ def _remove_fill_values(df, fill_value=9999): def raw_to_timeseries(indir, outdir, deploymentyaml, kind='raw', - profile_filt_time=100, profile_min_time=300, - fnamesuffix=''): + profile_filt_time=100, profile_min_time=300, interpolate=False, fnamesuffix=''): """ A little different than above, for the 4-file version of the data set. """ @@ -339,7 +338,11 @@ def raw_to_timeseries(indir, outdir, deploymentyaml, kind='raw', indctd = np.where(~np.isnan(vals))[0] ds['time'] = (('time'), sensor.select('time').to_numpy()[indctd, 0], attr) thenames = list(ncvar.keys()) - for i in ['time', 'timebase', 'keep_variables']: + # Check yaml to see if interpolate has been set to True + if "interpolate" in thenames: + if ncvar["interpolate"]: + interpolate = True + for i in ['time', 'timebase', 'keep_variables', 'interpolate']: if i in thenames: thenames.remove(i) for name in thenames: @@ -371,7 +374,21 @@ def raw_to_timeseries(indir, outdir, deploymentyaml, kind='raw', )[:-1, :] val2 = sensor_sub_grouped.select(sensorname).to_numpy()[:, 0] val = _interp_gli_to_pld(sensor_sub_grouped, sensor, val2, indctd) - val = val[indctd] + if interpolate and not np.isnan(val).all(): + time_original = sensor.select('time').to_numpy()[:, 0] + time_var = time_original[np.where(~np.isnan(val))[0]] + var_non_nan = val[np.where(~np.isnan(val))[0]] + time_timebase = sensor.select('time').to_numpy()[indctd, 0] + if val.dtype == "= \ + np.count_nonzero(~np.isnan(test_data_raw[var].values)) + else: + dt0 = output_interp_raw[var].values - np.datetime64('2000-01-01') + dt1 = test_data_raw[var].values - np.datetime64('2000-01-01') + assert np.allclose( + np.array(dt0, dtype='float64'), + np.array(dt1, dtype='float64')) + + # Create an L0 timeseries from slocum data and test that the resulting netcdf is # identical to the test data cacdir = str(example_dir / 'example-slocum/cac/') + '/'