-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is neededtodo
Description
The NetCDF data models allows storing attributes of dimensions.
This is helpful when it comes to store CF metadata of axis dimensions, e.g. unit and standard_name of axis air pressure. However, such attributes are currently ignored by open_dataset and savedataset:
using YAXArrays
using NetCDF
using Downloads
cf_example_file = Downloads.download("https://www.unidata.ucar.edu/software/netcdf/examples/sresa1b_ncar_ccsm3-example.nc", "example.nc")
ds_nc = NetCDF.open(cf_example_file)
ds_yax = open_dataset(cf_example_file)
ds_yax.plev # no metadata
# plev [100000.0, 92500.0, …, 2000.0, 1000.0]
ds_nc["plev"].atts # metadata
# Dict{Any, Any} with 5 entries:
# "units" => "Pa"
# "long_name" => "pressure"
# "axis" => "Z"
# "standard_name" => "air_pressure"
# "positive" => "down"This could be fixed by utilising the metadata field of the Lookup of the Dimension:
using DimensionalData.Lookups
plev_lookup = Sampled(ds_yax.axes[:plev].val; metadata=ds_nc["plev"].atts)
plev_dim = Dim{:plev}(plev_lookup)
ds_yax.axes[:plev] = plev_dim
metadata(plev_dim)
#Dict{Any, Any} with 5 entries:
# "units" => "Pa"
# "long_name" => "pressure"
# "axis" => "Z"
# "standard_name" => "air_pressure"
# "positive" => "down"olivierbonte
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is neededtodo