lkilcher / dolfyn

A library for oceanographic doppler instruments such as Acoustic Doppler Profilers (ADPs, ADCPs) and Acoustic Doppler Velocimeters (ADVs).
BSD 3-Clause "New" or "Revised" License
41 stars 25 forks source link

CF conventions #102

Closed jessecusack closed 1 year ago

jessecusack commented 2 years ago

It doesn't seem like you follow CF conventions when assigning variable attributes in your xarray objects. It is super useful to do this, because it makes the data almost instantly archivable in national databases, and would also play better with some packages (e.g. https://cf-xarray.readthedocs.io/en/latest/index.html), including xarray itself. In practice it means giving each variable the appropriate standard_name and units (as defined by CF), and also a long_name for plotting or descriptions.

For example, the time variable from the most recent dataset that I loaded has the following attributes:

time
(time)
float64
1.622e+09 1.622e+09 ... 1.625e+09
description :
    seconds since 1970-01-01 00:00:00

To follow CF it should look something like:

time
(time)
float64
1.622e+09 1.622e+09 ... 1.625e+09
standard_name : 
    time
units :
    seconds since 1970-01-01 00:00:00
long_name : 
    Time
calendar : 
    gregorian

If time were specified in this way, xarray could then automatically parse the UNIX timestamps to datetimes, avoiding awkward conversions.

An issue to consider is that some of the standard names will change depending on the coordinate system, e.g. radial_sea_water_velocity_away_from_instrument ->eastward_sea_water_velocity.

jmcvey3 commented 2 years ago

It could be interesting to integrate tsdat (https://github.com/tsdat/tsdat) to this codebase, or follow a short-term solution and provide a how-to to standardize dolfyn datasets using tsdat.

jmcvey3 commented 1 year ago

Closing with #113