JuliaDataCubes / JuliaDataCubes/YAXArrays.jl

Add axis metadata

Open
#393 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted todo
Dominant language
Julia
Stars
132
Forks
25
PR merge metrics
No merged PRs in 30d

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"

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the open_dataset and savedataset entry points and inspect how NetCDF dimension attributes are currently handled. Use the shown NetCDF pressure-axis example and DimensionalData.Lookups metadata approach as a guide; done means axis attributes are preserved when opening and saving datasets.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.