xarray-contrib / xwrf

A lightweight interface for working with the Weather Research and Forecasting (WRF) model output in Xarray.
https://xwrf.readthedocs.io/
Apache License 2.0
56 stars 16 forks source link

[FEATURE]: Add functionality to organize WRF data into a DataTree #110

Open jthielen opened 1 year ago

jthielen commented 1 year ago

Description

WRF output can easily have a couple hundred data variables in a dataset, which is not ideal for interactive exploration of a dataset's contents. With DataTree, we would have a tree-like hierarchical data structure for xarray which could be used for this.

From @lpilz in https://github.com/xarray-contrib/xwrf/issues/10:

  • Which diagnostics do we want to provide and do we want to expose them in a DataTree eventually?

One suggestion might be:

DataTree("root")
|-- DataNode("2d_variables")
|   |-- DataArrayNode("sea_surface_temperature")
|   |-- DataArrayNode("surface_temperature")
|   |-- DataArrayNode("surface_air_pressure")
|   |-- DataArrayNode("air_pressure_at_sea_level")
|   |-- DataArrayNode("air_temperature_at_2m") (?)
|   ....
|-- DataNode("3d_variables")
    |-- DataArrayNode("air_temperature")
    |-- DataArrayNode("air_pressure")
    |-- DataArrayNode("northward_wind")
    |-- DataArrayNode("eastward_wind")
    ....

Implementation

This would likely become a new accessor method, such as .xwrf.organize().

Tests

After xwrf.postprocess(), we have a post processed dataset (with likely many data variables). Then, after xwrf.organize(), we would have a DataTree with (a yet to be decided) tree-like grouping of data variables. Calling xwrf.organize() without xwrf.postprocess() would fail.

Questions

What form of heirarchy would we want to have and how deep?