Coder Social home page Coder Social logo

liambindle / sparselt Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 3.0 37 KB

A small library for regridding Earth system data with vectorized sparse linear transforms

License: MIT License

Python 100.00%
earth-system-model regridding esmf high-dimensional-data sparse-matrices

sparselt's Issues

Question: regridding stretched grid

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!

Error while regridding a file

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.

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

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”.

Question: can this be incorporated into xESMF?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.