FFFF Update dimension ordering to match NetCDF-CF conventions · Issue #272 · google/Xee · GitHub
[go: up one dir, main page]

Skip to content

Update dimension ordering to match NetCDF-CF conventions #272

@jdbcode

Description

@jdbcode

Discussed in #196

Originally posted by tylere December 13, 2024
Most Python libraries that plot raster images use a (y, x) or (lat, lon) ordering of dimensions. This is the convention used by Matplotlib's pyplot with images, and many libraries that utilize it (Xarray, rasterio).

(lat, lon) ordering is also used for higher dimensional data that follows the netCDF-CF conventions, which are a standard for climate forecast data. Specifically:

https://ferret.pmel.noaa.gov/Ferret/documentation/coards-netcdf-conventions
Order of dimensions:
If any or all of the dimensions of a variable have the interpretations of "date or time" (a.k.a. "T"), "height or depth"(a.k.a. "Z"), "latitude" (a.k.a. "Y"), or "longitude" (a.k.a. "X") then those dimensions should appear in the relative order T, then Z, then Y, then X in the CDL definition corresponding to the file.

By contrast Xee currently creates an Xarray dataset with dimensions in the order (time, lon, lat) in which the lon and lat coordinates are swapped. This requires the user to process (transpose) the data before using Matplotlib or similar plotting libraries.

This convention difference may have contributed to several the the Xee issues that have been raised (#45, #171, #174).

I think it may be worth changing Xee's coordinate ordering to (time, lat, lon) in order to match the convention used by netCDF-CF and Matplotlib. I realize this will be a breaking change for some users, but it will make the library easier to use for future users.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0