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

Can't do sparselt.xr.apply if the input dataset's dimensions have the same name as the template dataset #2

Closed
LiamBindle opened this issue Nov 12, 2021 · 0 comments

Comments

@LiamBindle
Copy link
Owner

Reported by Joonhee.

The data I would like to regrid is 0.5x0.625 deg (361 lat, 576 lon) and I’d like to regrid this to 4x5 deg (46 lat, 72 lon). This is what the source data looks like below:

Steps:

  1. Generate grid description file for source
$ gridspec-create latlon 361 576 -pc -dc
  1. Generate grid descrption file for destination
$ gridspec-create latlon 46 72 -pc -dc
  1. Generate weights for transformation
$ ESMF_RegridWeightGen -s regular_lat_lon_361x576.nc -d regular_lat_lon_46x72.nc -m conserve -w regrid_weights_latlon361x576_to_ latlon46x72.nc
  1. Apply transformation
# Load dataset
ds = xr.open_dataset("AEIC_20190101.0.5x0.625.36L.nc")
print('Original dataset: {}\n\n'.format(str(ds)))

# Create SparseLinearTransform object from an ESMF weights file
transform = sparselt.esmf.load_weights(
    'regrid_weights_latlon361x576_to_ latlon46x72.nc',
    input_dims=[('lat', 'lon'), (361, 576)],
    output_dims=[('lat', 'lon'), (46, 72)]
)

# Open an output template dataset (optional)
output_template = xr.open_dataset('regular_lat_lon_46x72.nc')

# Apply the transform to ds
ds = sparselt.xr.apply(transform, ds, output_template)

print('Transformed dataset: {}\n\n'.format(str(ds)))

This is giving me an error at the sparselt.xr.apply step as “ValueError: inconsistent size for core dimension 'lat': 46 vs 361”.

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

1 participant