JuliaDataCubes / YAXArrays.jl

Yet Another XArray-like Julia package
https://juliadatacubes.github.io/YAXArrays.jl/
Other
101 stars 17 forks source link

Data units is incorrectly infered #244

Open Balinus opened 1 year ago

Balinus commented 1 year ago

I have a seasonal prediction dataset with 16 variables. It seems that thay all inherit the same definition, which is one of the 16 variables.

What we should get:

for ivar in list(ds.keys()):
    print(ivar, ds[ivar].attrs)

rsn {'units': 'kg m**-3', 'long_name': 'Snow density'}
tclw {'units': 'kg m**-2', 'long_name': 'Total column cloud liquid water'}
tciw {'units': 'kg m**-2', 'long_name': 'Total column cloud ice water'}
sd {'units': 'm of water equivalent', 'long_name': 'Snow depth', 'standard_name': 'lwe_thickness_of_surface_snow_amount'}
lsp {'units': 'm', 'long_name': 'Large-scale precipitation', 'standard_name': 'lwe_thickness_of_stratiform_precipitation_amount'}
cp {'units': 'm', 'long_name': 'Convective precipitation', 'standard_name': 'lwe_thickness_of_convective_precipitation_amount'}
sf {'units': 'm of water equivalent', 'long_name': 'Snowfall', 'standard_name': 'lwe_thickness_of_snowfall_amount'}
u10 {'units': 'm s**-1', 'long_name': '10 metre U wind component'}
v10 {'units': 'm s**-1', 'long_name': '10 metre V wind component'}
t2m {'units': 'K', 'long_name': '2 metre temperature'}
d2m {'units': 'K', 'long_name': '2 metre dewpoint temperature'}
tp {'units': 'm', 'long_name': 'Total precipitation'}
fg10 {'units': 'm s**-1', 'long_name': '10 metre wind gust since previous post-processing'}
mx2t24 {'units': 'K', 'long_name': 'Maximum temperature at 2 metres in the last 24 hours'}
mn2t24 {'units': 'K', 'long_name': 'Minimum temperature at 2 metres in the last 24 hours'}
mean2t24 {'units': 'K', 'long_name': 'Mean temperature at 2 metres in the last 24 hours'}

What we get instead:


ds[Variable="t2m"].properties

Dict{String, Any} with 7 entries:
  "missing_value" => -32767
  "units"         => "K"
  "add_offset"    => 279.534
  "long_name"     => "Maximum temperature at 2 metres in the last 24 hours"
  "scale_factor"  => 0.00103738
  "standard_name" => "lwe_thickness_of_snowfall_amount"
  "_FillValue"    => -32767

ds[Variable="v10"].properties

Dict{String, Any} with 7 entries:
  "missing_value" => -32767
  "units"         => "K"
  "add_offset"    => 279.534
  "long_name"     => "Maximum temperature at 2 metres in the last 24 hours"
  "scale_factor"  => 0.00103738
  "standard_name" => "lwe_thickness_of_snowfall_amount"
  "_FillValue"    => -32767
Balinus commented 1 year ago

Seems to be a problem only for Cube type though. Just tested with a Dataset type and I get the correct properties. I guess this is expected from a Cube type?

ds.t2m.properties

Dict{String, Any} with 7 entries: "missing_value" => -32767 "units" => "K" "name" => "t2m" "add_offset" => 277.542 "long_name" => "2 metre temperature" "scale_factor" => 0.0010903 "_FillValue" => -32767

ds.v10.properties

Dict{String, Any} with 7 entries: "missing_value" => -32767 "units" => "m s**-1" "name" => "v10" "add_offset" => 1.18049 "long_name" => "10 metre V wind component" "scale_factor" => 0.00101462 "_FillValue" => -32767