Unidata / UDUNITS-2

API and utility for arithmetic manipulation of units of physical quantities
http://www.unidata.ucar.edu/software/udunits
Other
62 stars 36 forks source link

Deal with salinity "units" #27

Open durack1 opened 9 years ago

durack1 commented 9 years ago

We've hit an issue where the "units" of salinity are tripping over some code of ours, we've documented this a little better at https://github.com/PCMDI/pcmdi_metrics/issues/162

It would be helpful for a number of software packages (noted above and also CMOR: https://github.com/PCMDI/cmor/issues/12) if UDUNITS-2 could deal with salinity equivalence.

How can we get some better coverage of salinity "units" into a future release of UDUNITS-2?

semmerson commented 9 years ago

What sort of units are you thinking of?Practical Salinity is unitless. Absolute Salinity is dimensionless and commonly has a unit of "1" or "1e-3".

durack1 commented 9 years ago

Thanks @semmerson, I've been looking at a number of observational products - which have been rewritten but their units were preserved from the source:

[durack1@oceanonly ~/141105_pcmdi_metrics]$ ls /clim_obs/obs/ocn/mo/sos/*/ac/*.nc
sos_pcmdi-metrics_Omon_JPL-Aquarius-v2_201108-201304-clim.nc
sos_pcmdi-metrics_Omon_NODC-WOA09_177201-200812-clim.nc
sos_pcmdi-metrics_Omon_UCSD-ARGO_200401-201212-clim.nc
[durack1@oceanonly ~/141105_pcmdi_metrics]$ ls /clim_obs/obs/ocn/mo/sos/*/ac/*.nc | xargs -n 1 ncdump -h | grep 'sos:units'
                sos:units = "1e-3" ;
                sos:units = "PSS-78" ;
                sos:units = "Practical Salinity Scale 78" ;

I suggest that any of the valid salinity "unit" variants 1e-3,g kg-1,g/kg,ppt,Practical Salinity Scale 1978,Practical Salinity Scale 78,pss78,PSS78,pss-78,PSS-78,psu,PSU and their equivalence should be noted by UDUNITS-2.

Practical Salinity is unitless (and is normally stored in PSS-78 "units" which is equivalent to parts per thousand/ppt/1e-3), however Absolute Salinity is not, it's stored as g kg-1 which is an SI unit of concentration. This is also true for Preformed Salinity and Reference Salinity which are two new TEOS-10 variables - these have all been added to the CF Standard Name table.

semmerson commented 9 years ago

The UDUNITS package already understands the unit specifications 1e-3, g/kg, g kg-1, etc.. Unfortunately, the unit "ppt" is ambiguous (parts per trillion?).

The strings Practical Salinity Scale 1978, Practical Salinity Scale 78, pss78, PSS78, pss-78, psu, and PSU aren't unit specifications (what would it mean to add 2 psu to 35 psu?). Instead, they specify that the associated values refer to the quantity Practical Salinity, which is an artificial (though important) construct. It is not, however, a physical quantity -- as that term is understood -- and has no units (not even parts-per-thousand). It would be a grave mistake to burden any units package with the responsibility for handling such non-units.

For malformed netCDF files, I recommend using the netCDF Markup Language (NcML) to create transparent yet correct views of the data.

durack1 commented 9 years ago

@semmerson fair enough, you raise some salient points..

In theory the "unit" PSU/PSS-78 is in fact an implied concentration (based off a conductivity measurement), and so if you have the volume/mass of both your salty water samples (with 2 PSU and 35 PSU as you note above) you should then be able to calculate the new concentration based on the new volume/mass and the input concentrations.

I wonder if UDUNITS-2 deals with any of these concentration calculations for gases?

semmerson commented 9 years ago

Calculate, yes, but not simply add. Units are appropriate for physical quantities whose mean or geometric mean can be computed in the usual way. Practical salinity doesn't pass this test: adding equal masses of 30 "psu" water and 40 "psu" water doesn't create 35 "psu" water.

The UDUNITS package does support the usual nine quantities that are quotients involving amount of substance, volume, or mass.

What is needed isn't an enhancement of the UDUNITS package, but rather a Physical Quantity package. Such a package could use the UDUNITS package, where appropriate, but could also know how to perform co-ordinate system transformations -- such as converting practical salinity values into absolute salinity or density values. This is the proper place for the capability you're seeking.

durack1 commented 9 years ago

@semmerson out of curiosity does an equivalent Physical Quantity package exist? I would be curious to see an example..

The Practical Salinity to Absolute Salinity conversion functionality does in fact exist in the TEOS-10 software packages, however these tools are observation specific as most CMIP-style models haven't implemented full TEOS-10 compliance (and consequently are oblivious to the seawater compositional effects that are present in the real world ocean).

semmerson commented 9 years ago

The Java-based VisAD package incorporates such a data-model. The website references several papers on the data-model.

Doug Lindholm of LASP has based much of his work on this model. I'm afraid I don't have a reference.