uxarray icon indicating copy to clipboard operation
uxarray copied to clipboard

Update encode_as to switch coordinates

Open rajeeja opened this issue 1 year ago • 1 comments

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

rajeeja avatar Apr 20 '23 17:04 rajeeja