xarray-contrib/cf-xarray

should 'X', 'Y' be synonyms for 'longitude', 'latitude'?

Closed this issue · 5 comments

I am very unsure about this. Originally, they were synonyms. In 21c0387 I undid that.

Here is the current state of affairs

coordinate_criteria: dict = {
"standard_name": {
"T": ("time",),
"time": ("time",),
"Z": (
"air_pressure",
"height",
"geopotential_height",
"altitude",
"model_level_number",
"atmosphere_ln_pressure_coordinate",
"atmosphere_sigma_coordinate",
"atmosphere_hybrid_sigma_pressure_coordinate",
"atmosphere_hybrid_height_coordinate",
"atmosphere_sleve_coordinate",
"height_above_geopotential_datum",
"height_above_reference_ellipsoid",
"height_above_mean_sea_level",
),
"latitude": ("latitude",),
"longitude": ("longitude",),
},
"_CoordinateAxisType": {
"T": ("Time",),
"Z": ("GeoZ", "Height", "Pressure"),
"Y": ("GeoY",),
"latitude": ("Lat",),
"X": ("GeoX",),
"longitude": ("Lon",),
},
"axis": {"T": ("T",), "Z": ("Z",), "Y": ("Y",), "X": ("X",)},
"positive": {"Z": ("up", "down"), "vertical": ("up", "down")},
"units": {
"latitude": (
"degree_north",
"degree_N",
"degreeN",
"degrees_north",
"degrees_N",
"degreesN",
),
"longitude": (
"degree_east",
"degree_E",
"degreeE",
"degrees_east",
"degrees_E",
"degreesE",
),
},
# "regular_expression": {
# "time": r"time[0-9]*",
# "vertical": (
# r"(lv_|bottom_top|sigma|h(ei)?ght|altitude|depth|isobaric|pres|"
# r"isotherm)[a-z_]*[0-9]*"
# ),
# "y": r"y",
# "latitude": r"x?lat[a-z0-9]*",
# "x": r"x",
# "longitude": r"x?lon[a-z0-9]*",
# },
}
coordinate_criteria["standard_name"]["vertical"] = coordinate_criteria["standard_name"][
"Z"
]

Note that 'Z', 'T' are synonymous with 'vertical', 'time'.

This would be a good place for someone to chime in.

Based on what we've found in MetPy and in my own frequent use-case of gridded atmospheric data in projected spaces, I would argue that 'X', 'Y' should not be synonyms for 'longitude', 'latitude' in general. It is not uncommon that an 'X'/'Y' axis is present as a coordinate variable (CF terminology)/dimension coordinate (xarray terminology), but they are not 'longitude'/'latitude' (which is instead a 2D auxiliary coordinate variable/non-dimension coordinate). Both these types of coordinates are separately useful, and so, should ideally be available independently (although, in the special case of the plate carrée/latitude_longitude projection, they would be synonyms). The Independent Latitude, Longitude, Vertical, and Time Axes and Two-Dimensional Latitude, Longitude, Coordinate Variables examples in the CF Conventions were most helpful for me in interpreting these. Elsewhere in the conventions, it at times seems implied that axes of 'X', 'Y' are synonyms for 'longitude', 'latitude', but that is clearly not the case based on these two examples. I wish the conventions were clearer in regards to these non-longitude/latitude horizontal coordinate variables/dimension coordinates.

For some background, these were quasi-synonymous in MetPy (i.e. 'X' could access 'longitude' even if >1D, but would default to a suitable dimension coordinate if present), but that was changed with Unidata/MetPy#1090 / Unidata/MetPy#1236. I've been quite happy with how MetPy's been handling it since the change.

Thanks for taking the time to comment @jthielen .

I agree with the reasoning you outlined. I'll keep the issue open for visibility.

I agree with the reasoning you outlined. I'll keep the issue open for visibility.

@dcherian Sounds great, thanks! In writing up my comment, I was stuck by the difference in terminology between xarray and the CF conventions, so I also just submitted an issue for a doc page that may be worth considering (#25). I would be able to help with that at some point, but perhaps not immediately.

This may be useful to have for reference: cf-convention/cf-conventions#133

Also related: pyproj4/pyproj#536