Skip to content

Support model initialization time + ensemble member + forecast_tau axes #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ahuang11 opened this issue Jan 26, 2021 · 11 comments · Fixed by #151
Closed

Support model initialization time + ensemble member + forecast_tau axes #140

ahuang11 opened this issue Jan 26, 2021 · 11 comments · Fixed by #151
Labels
opinion wanted User input requested

Comments

@ahuang11
Copy link
Member

Title

@dcherian
Copy link
Contributor

An example use case would help here.

If there is an associated standard_name, some stuff should already work. I guess I don't know what you're asking for :) Please add examples.

@dcherian dcherian changed the title Does cf-xarray have plans to support model initialization time + ensemble member coordinates? Support model initialization time + ensemble member coordinates Jan 26, 2021
@dcherian dcherian changed the title Support model initialization time + ensemble member coordinates Support model initialization time + ensemble member + forecast_tau coordinates Jan 26, 2021
@ahuang11
Copy link
Member Author

ahuang11 commented Jan 26, 2021

To start, I would love if it can label and standardize the coordinates in this dataset (although I know the conventions say IRIDL lol, but in general, forecast datasets with lead and initializations).

import xarray as xr
import cf_xarray
ds = xr.open_dataset('http://iridl.ldeo.columbia.edu/SOURCES/.Models/.NMME/.NCEP-CFSv2/.HINDCAST/.MONTHLY/.sst/dods', decode_cf=False)
ds.cf.coordinates

image

Once that's done, it'd be nice to have something like verification time alignment where it's able to automatically align a verification dataset with a forecast. https://github.com/mktippett/ENSO/blob/master/ForecastVerification.ipynb

cfsv2_ds["o"] = (( "L", "S"), o.sel(T=T))
cfsv2_ds

To me, it sounds like it's within the scope of cf_xarray since I think cf_xarray already handles rolling longitudes across the edges if I am not mistaken? So maybe a new accessor method: verf_ds.cf.align(model_ds)

@dcherian dcherian added the opinion wanted User input requested label Jan 26, 2021
@ahuang11
Copy link
Member Author

ahuang11 commented Jan 26, 2021

Maybe the title should state "axes" instead of "coordinates" since these dimensions are usually 1D besides verification time
which consists of (Initialization, Lead), or more generally initialization_time + forecast_lead = verification_target, or I guess it can also be the other way around: verification_target - initialization_time = forecast_lead

ini (ini)
tau (tau)
time (ini, tau)
ini (ini)
time (time)
tau (time, ini)

@dcherian dcherian changed the title Support model initialization time + ensemble member + forecast_tau coordinates Support model initialization time + ensemble member + forecast_tau axes Jan 26, 2021
@dcherian
Copy link
Contributor

dcherian commented Jan 26, 2021

Can you expand the attributes for the coordinate variables in your screenshot please?

I am sympathetic to some form of this request.

  1. We need to come up with nice names and criteria for these dimensions though.
  2. OTOH, I imagine that we'd only be matching standard_name, maybe its enough to generalize _get_axis_coord to do just that.

@ahuang11
Copy link
Member Author

image

@dcherian
Copy link
Contributor

So you want to be able to do ds.cf.mean("realization") and ds.cf.rename(realization="ensemble_member")?

@ahuang11
Copy link
Member Author

ahuang11 commented Jan 26, 2021

Sure plus:
ds.cf.rename_like -> verf_ds.cf.align_like(fcst_ds)
where
verf_ds contains target/valid time
and
fcst_ds contains initialization/tau
which xarray does with
cfsv2_ds["o"] = (( "L", "S"), o.sel(T=T))

@dcherian
Copy link
Contributor

Sure plus: ds.cf.rename_like -> verf_ds.cf.align_like(fcst_ds) where verf_ds contains target/valid time and fcst_ds contains initialization/tau

This is a little too specialized but we should add support for dims other than x,y,z,t,latitude,longitude,vertical,time. With support for standard_name you could be doing o.cf.sel(target_time=fct_ds.cf["initialization_time"]) assuming target_time and initialization_time are the appropriate standard names.

@ahuang11
Copy link
Member Author

ahuang11 commented Jan 26, 2021

Does rolling handle taking the means across the edges of the dataset e.g. sphere wraps around, or is it simply the equivalent of doing ds.rolling.mean(lon=5)? https://cf-xarray.readthedocs.io/en/latest/examples/introduction.html#Rolling-&-coarsen

Maybe I was mistaken.

@dcherian
Copy link
Contributor

No it does not. Right now all its doing is rewriting args, kwargs to let you make use of attributes.

@ahuang11
Copy link
Member Author

ahuang11 commented Jan 26, 2021

Okay then what I requested in my latter comment is out of scope for now~ but eventually that'd be ideal!

I thought since it was able to detect it's a longitude, make full use of it.
pydata/xarray#2007

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
opinion wanted User input requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants