Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing xarray.DataArray grids through data processing functions should preserve dimension names #1819

Open
weiji14 opened this issue Mar 15, 2022 · 0 comments
Labels
feature request New feature wanted help wanted Helping hands are appreciated longterm Long standing issues that need to be resolved
Milestone

Comments

@weiji14
Copy link
Member

weiji14 commented Mar 15, 2022

Description of the desired feature

Currently, the dimension names of the xarray.DataArray grid outputs appear to be hardcoded to 'x', 'y' and 'z', instead of using the original dimension names of the input xarray.DataArray. To illustrate

grid = xr.DataArray(
    data=[
        [0, 1, 2],
        [3, 4, 5],
        [6, 7, 8],
    ],
    coords=dict(height=[1.5, 2.5, 3.5], width=[4.5, 5.5, 6.5]),
    dims=["height", "width"],
)
print(grid)
# <xarray.DataArray (height: 3, width: 3)>
# array([[0, 1, 2],
#        [3, 4, 5],
#        [6, 7, 8]])
# Coordinates:
#   * height   (height) float64 1.5 2.5 3.5
#   * width    (width) float64 4.5 5.5 6.5

Run it through a data processing function like grdhisteq.equalize_grid

newgrid = pygmt.grdhisteq.equalize_grid(grid=grid)
print(newgrid)
# <xarray.DataArray 'z' (y: 3, x: 3)>
# array([[ 0.,  4.,  6.],
#        [ 8.,  8., 11.],
#        [13., 15., 15.]], dtype=float32)
# Coordinates:
#   * x        (x) float64 4.5 5.5 6.5
#   * y        (y) float64 1.5 2.5 3.5
# Attributes:
#     long_name:     z
#     actual_range:  [ 0. 15.]

Ideally, the newgrid.dims should be ('height', 'width') instead of ('y', 'x').

Are you willing to help implement and maintain this feature? Yes, but happy to let someone take this up too!

@weiji14 weiji14 added help wanted Helping hands are appreciated feature request New feature wanted labels Mar 15, 2022
@weiji14 weiji14 added this to the 0.7.0 milestone Mar 15, 2022
@seisman seisman modified the milestones: 0.7.0, 0.8.0 Jun 23, 2022
@seisman seisman modified the milestones: 0.8.0, 0.9.0 Dec 11, 2022
@weiji14 weiji14 modified the milestones: 0.9.0, 1.0.0 Mar 6, 2023
@weiji14 weiji14 added the longterm Long standing issues that need to be resolved label Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted help wanted Helping hands are appreciated longterm Long standing issues that need to be resolved
Projects
None yet
Development

No branches or pull requests

2 participants