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

UxDataArray.inverse_distance_weighted_remap returns UxDataset #776

Open
ahijevyc opened this issue May 6, 2024 · 10 comments
Open

UxDataArray.inverse_distance_weighted_remap returns UxDataset #776

ahijevyc opened this issue May 6, 2024 · 10 comments
Labels
question Further information is requested

Comments

@ahijevyc
Copy link
Collaborator

ahijevyc commented May 6, 2024

Version

2024.04.0

How did you install UXarray?

Conda

What happened?

When I used plot.rasterize or plot.polygon on a UxDataArray, I got an error
AttributeError: Unsupported Plotting Method: 'polygon'

What did you expect to happen?

Does UxDataArray.inverse_distance_weighted_remap have to return a UxDataset? I was wondering if it could return a UxDataArray, given a UxDataArray to begin with.

I noticed the change to UxDataset when trying to plot a smoothed UxDataArray. See code below.

Can you provide a MCVE to repoduce the bug?

import uxarray

grid_path = "/glade/campaign/mmm/parc/schwartz/MPAS/480km_mesh/x1.2562.grid.nc"
data_path = "/glade/campaign/mmm/parc/schwartz/MPAS/480km_mesh/x1.2562.static.nc"
uxds = uxarray.open_dataset(
    grid_path,
    data_path,
)
# UxDataArray from UxDataset
var = uxds["landmask"]
var.inverse_distance_weighted_remap(destination_obj=var).plot.polygon()
# .inverse_distance_weighted_remap returns UxDataset, not UxDataArray
@ahijevyc ahijevyc added the question Further information is requested label May 6, 2024
@philipc2
Copy link
Member

philipc2 commented May 6, 2024

Hi @ahijevyc

Can you try running the following?

var.inverse_distance_weighted_remap(destination_obj=var.uxgrid).plot.polygon()

This should return a UxDataArray

When you pass through the UxDataArray as the destination_obj, we are attempting to store both the remapped and original variable together in a single dataset. Doing it the above way always will return a new UxDataArray

Let me know if this works!

@ahijevyc
Copy link
Collaborator Author

ahijevyc commented May 6, 2024 via email

@philipc2
Copy link
Member

philipc2 commented May 6, 2024

You want to set remap_to='face centers' to have the result stored on each face.

var.inverse_distance_weighted_remap(destination_obj=var.uxgrid, remap_to='face centers').plot.polygon()

@ahijevyc
Copy link
Collaborator Author

ahijevyc commented May 6, 2024 via email

@philipc2
Copy link
Member

philipc2 commented May 6, 2024

I was able to get this generated on Casper.

uxds["landmask"].remap.inverse_distance_weighted(destination_obj=uxds.uxgrid, remap_to='face centers').plot.polygons()
image

Can you give that a try?

@philipc2
Copy link
Member

philipc2 commented May 6, 2024

It looks like the remapping isn't actually doing anything though. Looking into it further.

@ahijevyc
Copy link
Collaborator Author

ahijevyc commented Jun 4, 2024 via email

@philipc2
Copy link
Member

philipc2 commented Jun 5, 2024

Do you have a workaround for this?

On Mon, May 6, 2024 at 5:36 PM Philip Chmielowiec @.> wrote: It appears that the remapping is functioning normally (new values are returned in the data array), but the plotting functions are using the existing value of the data variable (i.e. landmask) and is not plotting the new one. I'll get a fix for this out, it's an issue with some of our internal caching. — Reply to this email directly, view it on GitHub <#776 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIPI2DRUV7J7S6DQCZ4CM3ZBAHY3AVCNFSM6AAAAABHJI4FEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJXGA4TONJVGM . You are receiving this because you were mentioned.Message ID: @.>

Thanks for the follow up. Pinging @aaronzedwick and we can take a look into it this week.

@philipc2
Copy link
Member

philipc2 commented Jun 5, 2024

@aaronzedwick

I noticed the change to UxDataset when trying to plot a smoothed UxDataArray. See code below.

This is related to what we talked about on Monday when we met, there appear to be issues when running IDW on the same source and destination grid.

@aaronzedwick
Copy link
Member

@aaronzedwick

I noticed the change to UxDataset when trying to plot a smoothed UxDataArray. See code below.

This is related to what we talked about on Monday when we met, there appear to be issues when running IDW on the same source and destination grid.

Could it be that when we try and remap the variable to the same dataset, it is using the same exact variable name, so there is an error because it already exists and thus tries to overwrite it, at the same time as it is being read from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
Status: 📚 Backlog
Development

No branches or pull requests

3 participants