DocOtak / gsw-xarray

Wrapper for gsw that will add CF attributes to xarray.DataArray outputs
https://gsw-xarray.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
23 stars 3 forks source link

What attributes to keep? #21

Closed rcaneill closed 2 years ago

rcaneill commented 2 years ago

gsw keeps attributes from the function parameters. What attributes should be kept, and what should be removed? As a short list, I think that:

I am working on PR #20 to implement all functions, I'll keep the way I do for the moment and I'll replace what is needed depending on what we decide here.

DocOtak commented 2 years ago

My thoughts so far:

rcaneill commented 2 years ago

About the reference_scale, I don't think that we necessary need to constraint to CF, if it is a common attribute we can add it.

DocOtak commented 2 years ago

In some play around tests, I found that the name of the returned xr.DataArray retains the "name" attribute (the class instance attribute, not the attrs dict). We should probably replace that with something relevant. Perhaps the GSW name (e.g. the return from SA_from_SP would be a xr.DataArray with the name "SA")

The following is the current behavior using our testing example dataset:

>>> da = gsw.sigma0(SA=ds.SA, CT=ds.CT)
>>> da
<xarray.DataArray 'SA' (id: 3)>
array([27.17191038, 26.12820162, 24.03930887])
Coordinates:
  * id       (id) int64 0 1 2
Attributes:
    standard_name:  sea_water_sigma_t
    units:          kg m-3
>>> da.name
'SA'
rcaneill commented 2 years ago

This is indeed a problem... I'll add it along with the ideas of PR #22 it this suits implementation suits you