-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support Two-Dimensional Coordinate Variables #605
Comments
We do support multi-dimensional coordinates already, and even read the It's definitely worth seeing if we can make |
Okay, somehow I missed that we're already doing this to some extent. I just ran across the code in @clarkfitzg - do you have any thoughts on how this could work? |
We could probably modify our |
Are the |
These latitude and longitude coordinates can't be dimensions because they need to be 2D. A good example would be simulation data on some sort of projected grid (like in @jhamman's example above). |
@shoyer - the idea of the coordinates convention is that we all ready know the x/y coordinate names. So we shouldn't need to supply them like this: In the plotting logic, we should just search to see if |
My hesitation with adding
A better way to handle this might be to write a |
@shoyer - For the most part, I'm in agreement here with you. A few comments (reference
I have two related PRs from today just to show which way we could go with all this: #606, #608. ncdump of domain file (xray_dev)Joes-iMac$ ncdump -h domain.lnd.wr50a_ar9v4.100920.nc
netcdf domain.lnd.wr50a_ar9v4.100920 {
dimensions:
n = 56375 ;
ni = 275 ;
nj = 205 ;
nv = 4 ;
variables:
double xc(nj, ni) ;
xc:long_name = "longitude of grid cell center" ;
xc:units = "degrees_east" ;
xc:bounds = "xv" ;
double yc(nj, ni) ;
yc:long_name = "latitude of grid cell center" ;
yc:units = "degrees_north" ;
yc:bounds = "yv" ;
double xv(nj, ni, nv) ;
xv:long_name = "longitude of grid cell verticies" ;
xv:units = "degrees_east" ;
double yv(nj, ni, nv) ;
yv:long_name = "latitude of grid cell verticies" ;
yv:units = "degrees_north" ;
int mask(nj, ni) ;
mask:long_name = "domain mask" ;
mask:note = "unitless" ;
mask:coordinates = "xc yc" ;
mask:comment = "0 value indicates cell is not active" ;
double area(nj, ni) ;
area:long_name = "area of grid cell in radians squared" ;
area:coordinates = "xc yc" ;
area:units = "radian2" ;
double frac(nj, ni) ;
frac:long_name = "fraction of grid cell that is active" ;
frac:coordinates = "xc yc" ;
frac:note = "unitless" ;
frac:filter1 = "error if frac> 1.0+eps or frac < 0.0-eps; eps = 0.1000000E-10" ;
frac:filter2 = "limit frac to [fminval,fmaxval]; fminval= 0.1000000E-02 fmaxval= 1.000000" ;
// global attributes:
:title = "CCSM domain data:" ;
:Conventions = "CF-1.0" ; xray representation of domain file In [1]: import xray
In [2]: xray.open_dataset('domain.lnd.wr50a_ar9v4.100920.nc')
Out[2]:
<xray.Dataset>
Dimensions: (ni: 275, nj: 205, nv: 4)
Coordinates:
xc (nj, ni) float64 189.2 189.4 189.6 189.7 189.9 190.1 190.2 ...
yc (nj, ni) float64 16.53 16.78 17.02 17.27 17.51 17.76 18.0 18.25 ...
* ni (ni) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...
* nj (nj) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...
* nv (nv) int64 0 1 2 3
Data variables:
xv (nj, ni, nv) float64 189.3 189.4 189.2 189.0 189.4 189.6 189.3 ...
yv (nj, ni, nv) float64 16.33 16.58 16.74 16.49 16.58 16.82 16.98 ...
mask (nj, ni) int32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
area (nj, ni) float64 2.579e-05 2.594e-05 2.611e-05 2.627e-05 ...
frac (nj, ni) float64 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ...
Attributes:
title: CCSM domain data:
Conventions: CF-1.0 |
In the case of calendars, the information ends up on the There are two reasons why we do this sort of thing:
These sort of ambiguous scenarios are the part that worry me. In particular, I worry that it leads us down a path of maintaining arbitrary metadata through operations. |
You are right, I had forgotten about this. My original statement has been amended accordingly. I think we're square on my points 2 and 3. Does my first point make sense? I'll open an issue regarding the coordinates encoding attribute. |
The CF Conventions supports the notion of a 2d coordinate variable in the case of irregularly spaced data. An example of this sort of dataset is below. The CF Convention is to add a "coordinates" attribute with a string describing the 2d coordinates.
I'd like to discuss how we could support this in xray. There motivating application for this is in plotting operations but it may also have application in other grouping and remapping operations (e.g. #324, #475, #486).
One option would just to honor the "coordinates" attr in plotting and use the specified coordinates as the x/y values.
ref: http://cfconventions.org/Data/cf-conventions/cf-conventions-1.6/build/cf-conventions.html#idp5559280
The text was updated successfully, but these errors were encountered: