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

Interpolating onto a regular UTM grid resulting in "speckles" #284

Open
obentley02 opened this issue Aug 1, 2023 · 1 comment
Open

Interpolating onto a regular UTM grid resulting in "speckles" #284

obentley02 opened this issue Aug 1, 2023 · 1 comment

Comments

@obentley02
Copy link

Hi,
I've been using xesmf inorder to regrid xarray data from one coordinate system to a regular grid in a UTM zone. Looking at the original data there is no "speckling" and if using xarray.Dataset.interp to interpolate onto the points of the regular UTM grid transformed back into the native coordinate system there is also no "speckling". I was wondering if you might know what causes this and if there is a workaround?

    # Create the 2D meshgrid
    xx, yy = np.meshgrid(x_values, y_values)

    # Create a transformer to perform the coordinate transformation
    transformer = Transformer.from_crs(epsg, 4326, always_xy=True)

    # Perform the coordinate transformation
    new_xx, new_yy = transformer.transform(xx, yy)
    ds = ds.rename({'XLAT': 'lat', 'XLON': 'lon'})

    # Step 1: Create the regridder from the source grid (latitude-longitude) to the target grid (UTM)
    regridder = xe.Regridder(ds, xr.Dataset(data_vars={},
                                            coords={'lon': (['y', 'x'], new_xx),
                                            'lat': (['y', 'x'], new_yy)}),
                            'bilinear', periodic=True)

image

@aulemahal
Copy link
Collaborator

Interesting issue! Do you think, it would be possible to provide a complete working example ? What are x_values, y_values and Transformer ? I am asking because it might be an issue with the data, or at least that there's something with the data that xESMF doesn't like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants