diff --git a/doc/config.rst b/doc/config.rst index 14cc0200..ccd49c4b 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -107,10 +107,10 @@ Signature-specific options include (see Aquadopp for others): :language: yaml :linenos: -d|wave ------- +RBR instruments +--------------- -d|wave-specific options include: +Options specific to RBR instruments exported from the Ruskin software include: - ``basefile``: the input filename without extension or data type. For example, if your exported text files are named ``055170_20190219_1547_burst.txt``, ``055170_20190219_1547_data.txt``, etc., ``basefile`` will be ``055170_20190219_1547``. - ``wp_min``, ``wp_max``: min/max allowable wave period, in seconds @@ -122,6 +122,11 @@ d|wave-specific options include: :language: yaml :linenos: +When an RBR instrument is used in ``CONTINUOUS`` mode as a profiling instrument (e.g., twisting the endcap to start/stop a profile), include the following line in your configuration file: + +- ``featureType: 'profile'``: this `CF-compliant `_ ``featureType`` instructs stglib to process these data as a profile dataset. +- ``latitude: [36.959, 41.533, 27.764]``, ``longitude: [-122.056, -70.651, -82.638]``: these values can each be specified as a YAML list of latitudes and longitudes, each element in the lists corresponding to a profile. +27.764, -82.638 EXO --- diff --git a/stglib/rsk/cdf2nc.py b/stglib/rsk/cdf2nc.py index c79c15a4..41cb969a 100755 --- a/stglib/rsk/cdf2nc.py +++ b/stglib/rsk/cdf2nc.py @@ -64,7 +64,26 @@ def cdf_to_nc(cdf_filename, atmpres=None, writefile=True, format="NETCDF4"): ds = utils.add_start_stop_time(ds) - if not is_profile: + if is_profile: + if "latitude" in ds: + ds["latitude"].attrs.update( + { + "units": "degree_north", + "axis": "Y", + "standard_name": "latitude", + } + ) + + if "longitude" in ds: + ds["longitude"].attrs.update( + { + "units": "degree_east", + "axis": "X", + "standard_name": "longitude", + } + ) + + else: ds = utils.ds_add_lat_lon(ds) ds = utils.ds_coord_no_fillvalue(ds) @@ -89,6 +108,9 @@ def cdf_to_nc(cdf_filename, atmpres=None, writefile=True, format="NETCDF4"): ): nc_filename = ds.attrs["filename"] + "cont-cal.nc" + elif is_profile: + nc_filename = ds.attrs["filename"] + "prof-cal.nc" + else: nc_filename = ds.attrs["filename"] + "-a.nc" diff --git a/stglib/rsk/csv2cdf.py b/stglib/rsk/csv2cdf.py index c2a45755..d4be125e 100644 --- a/stglib/rsk/csv2cdf.py +++ b/stglib/rsk/csv2cdf.py @@ -138,6 +138,23 @@ def csv_to_cdf(metadata): pr["rowSize"].attrs["sample_dimension"] = "obs" pr["rowSize"].encoding["dtype"] = "i4" + if "latitude" in ds.attrs and "longitude" in ds.attrs: + if len(ds.attrs["latitude"]) == len(rowsize) and len( + ds.attrs["longitude"] + ) == len(rowsize): + ds["latitude"] = xr.DataArray( + np.array(ds.attrs["latitude"]).astype(float), dims="profile" + ) + ds["longitude"] = xr.DataArray( + np.array(ds.attrs["longitude"]).astype(float), dims="profile" + ) + ds.attrs.pop("latitude") + ds.attrs.pop("longitude") + else: + raise ValueError( + f"size of latitude ({len(ds.attrs['latitude'])}) and longitude ({len(ds.attrs['longitude'])}) does not match number of profiles ({len(rowsize)})" + ) + # dscp = ds.copy(deep=True) ds["obs"] = xr.DataArray(range(len(ds["time"])), dims="obs") ds["obs"].encoding["dtype"] = "i4"