Remap coords fix by erogluorhan · Pull Request #1455 · UXARRAY/uxarray · GitHub
Skip to content

Remap coords fix#1455

Merged
erogluorhan merged 7 commits into
mainfrom
remap_coords_fix
Feb 17, 2026
Merged

Remap coords fix#1455
erogluorhan merged 7 commits into
mainfrom
remap_coords_fix

Conversation

@erogluorhan

@erogluorhan erogluorhan commented Feb 11, 2026

Copy link
Copy Markdown
Member

Closes #1445

Overview

While looking into #1445, I noticed that the coordinates in a variable (UxDataArray) were never handled properly as part of our remapping functions in remap/utils/_construct_remapped_ds(). There was only an attempt to remove coords matching the destination dimension as follows, but even that didn't work since so-called destination_dim was redesigned to be remap_to in the past, and its Literals wouldn't be in destination_coords. Also, it doesn't seem like the best way to handle the source coords.

destination_coords = deepcopy(source.coords)
    if destination_dim in destination_coords:
        del destination_coords[destination_dim]

This PR now introduces a new module spatial_coords_remap.py with the class SpatialCoordsRemapper to perform the following logic to handle remapping of coordinate variables in UxDataArray accordingly with the selected remap_to:

1.  If `remap_to` matches the `source` dimension (e.g. `source` on face centers` and `remap_to="faces"` etc.)
    - Swap values of spatial coords with values of the corresponding coords from `destination_grid`

2. Else (if `remap_to` doesn't match `source` dim (e.g. `source` on face centers but `remap_to="nodes"` etc.))
    - Swap values of spatial coords with values of the coords from `destination_grid` that are defined on the `remap_to` dimension.
        - Rename these coords to reflect new element type (e.g. 'face_x' → 'node_x')

These could be done under remap/utils.py, but since it involves several helper functions, doing it through a separate module and class made more sense to me.

Expected Usage

No expected usage of additional code, but when our remap functions are called, the coordinate variables under data variable will now be remapped properly.

Results

See below comment for before and after of the changes here.

PR Checklist

General

  • An issue is linked created and linked
  • Add appropriate labels
  • Filled out Overview and Expected Usage (if applicable) sections

Testing

  • Adequate tests are created if there is new functionality
  • Tests cover all possible logical paths in your function
  • Tests are not too basic (such as simply calling a function and nothing else)

Documentation

  • Docstrings have been added to all new functions
  • Docstrings have updated with any function changes
  • Internal functions have a preceding underscore (_) and have been added to docs/internal_api/index.rst
  • User functions have been added to docs/user_api/index.rst

Examples

  • Any new notebook examples added to docs/examples/ folder
  • Clear the output of all cells before committing
  • New notebook files added to docs/examples.rst toctree
  • New notebook files added to new entry in docs/gallery.yml with appropriate thumbnail photo in docs/_static/thumbnails/

@erogluorhan erogluorhan added bug Something isn't working redesign Content relating to the ongoing redesign labels Feb 11, 2026
@erogluorhan erogluorhan marked this pull request as ready for review February 11, 2026 23:46
@erogluorhan

erogluorhan commented Feb 11, 2026

Copy link
Copy Markdown
Member Author

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@erogluorhan erogluorhan merged commit 4aea046 into main Feb 17, 2026
13 checks passed
@erogluorhan erogluorhan deleted the remap_coords_fix branch February 18, 2026 20:51
@rajeeja

rajeeja commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

this is a good fix, only worry is the incomplete spatial coord coverage in remap outputs for *_z; maybe that is fine as this focusses on lon/lat and x/y remap metadata only?

@erogluorhan

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working redesign Content relating to the ongoing redesign

Projects

None yet

Development

Successfully merging this pull request may close these issues.

conflicting sizes for dimension 'n_face' when regridding

2 participants