UXARRAY / uxarray

Xarray extension for unstructured climate and global weather data analysis and visualization.
https://uxarray.readthedocs.io/
Apache License 2.0
158 stars 32 forks source link

Update encode_as to switch coordinates #288

Open rajeeja opened 1 year ago

rajeeja commented 1 year ago

Requirement: cartesian data to latlon and vice-versa for a grid file.

The current function encode_as has an output grid type as the only argument. Can we add another argument that can change the grid from cartesian to spherical?

Current implementation:

    def encode_as(self, grid_type):
        """Encodes the grid as a new `xarray.Dataset` per grid format supplied
        in the `grid_type` argument.

        Parameters
        ----------
        grid_type : str, required
            Grid type of output dataset.
            Currently supported options are "ugrid", "exodus", and "scrip"

        Returns
        -------
        out_ds : xarray.Dataset
            The output `xarray.Dataset` that is encoded from the this grid.

New option:

def encode_as(self, grid_type, coord_type):
coord_type by default is the same as the original grid

if specified as something else, we can transform coordinates internally.

This would use helper functions such as:

node_xyz_to_lonlat_rad
erogluorhan commented 6 months ago

Just note, encode_as() will be deprecated, but to_xaray() is the replacement