liambindle / sparselt Goto Github PK
View Code? Open in Web Editor NEWA small library for regridding Earth system data with vectorized sparse linear transforms
License: MIT License
A small library for regridding Earth system data with vectorized sparse linear transforms
License: MIT License
Hi Liam--
I'm trying to re-grid some stretched grid simulations and am having a bit of a hard time figuring out how to do so since the input dimensions change, so its not clear to me how to input an x and y dim. I was wondering if this is possible with sparselt, or if there is a better way to work with stretched grid outputs?
Thanks!
Hi,
Good morning. I have been trying to use the sparselt library to regrid a C24 resolution GCHP output into 4x5 degree output. I was successful in creating "c24_gridspec.nc", "regular_lat_lon_45x72.nc", and "esmf_regrid_weights_c24_to_latlon45x72.nc" files. However, I am getting the following error when trying to apply the sparset library using the commands:
import xarray as xr
import sparselt.esmf
import sparselt.xr
ds = xr.open_dataset('trial.nc')
transform = sparselt.esmf.load_weights(
'esmf_regrid_weights_c24_to_latlon45x72.nc',
input_dims=[('nf', 'Ydim', 'Xdim'), (6, 24, 24)],
output_dims=[('lat', 'lon'), (45, 72)],
)
ds = sparselt.xr.apply(transform, ds)
ValueError: operand to apply_ufunc has required core dimensions ['nf', 'Ydim', 'Xdim'], but some of these dimensions are absent on an input variable: ['nf', 'Ydim', 'Xdim']
The dimension of my C24 GCHP file (trial.nc) looks ok to me. Do you have any insight into what might cause this issue? Unfortunately, I could not find a way to attach the NetCDF file ( trial.nc) for your consideration. I would highly appreciate it if you could share your suggestion on it. Thanks.
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:
$ gridspec-create latlon 361 576 -pc -dc
$ gridspec-create latlon 46 72 -pc -dc
$ ESMF_RegridWeightGen -s regular_lat_lon_361x576.nc -d regular_lat_lon_46x72.nc -m conserve -w regrid_weights_latlon361x576_to_ latlon46x72.nc
# 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”.
What about xESMF? xESMF is a terrific for regridding logically rectangular grids, however, it has limited support for higher-order grids like cubed-sphere grids (see here).
Are there any limitations that would prevent incorporating this into xESMF so that its support for cubed-sphere grids is expanded? Using xESMF is useful because it keeps the regridding tools all in one place.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.