ESMPy Tutorial

Lately I have been using a software package called ESMPy to interpolate weather data on one grid to another. There is a learning curve with this software and things are not as Pythonic as one might hope. The C backbone tends to show through in the syntax a bit. Overall, though, it is a nice tool and is less clunky than GEMPAK. Luckily for you I have put together a ESMPy tutorial in a Jupyter notebook. Come and see it on github.

5 thoughts on “ESMPy Tutorial

  1. Hi, I found your tutorial very helpful – much more so than the ESMPy documentation which is all over the place. I was wondering if you have tried to do conservative regridding. I am having errors with specifying corners, and I’m not sure what I’m going wrong.

    • Thank you. I am glad it was useful. Corners can be added to the grid using either the add_coords method in the Grid object you have. What we typically put for coordinates initially are those that go in the grid center. To add the corners, you can follow your usual procedure, but set staggerloc in the add_coords method to StaggerLoc.CORNER_VCENTER (which will be changing to StaggerLoc.CORNER in v7.1.0). Then you can add coordinates for a different location on the grid box. The other important thing to remember is that the corner coordinates will have one more point in each dimension. Getting the actual coordinates for the corners is the more challenging part if they are not already output by your model. If you do not have them, you should be able to create them using projection and grid spacing information about your grids along with the pyproj package. I’ll be working to get an example of this put into the tutorial as soon as I can. Hopefully this addresses the actual issue you were having. If not, don’t hesitate to email the ESMPy developers as they will be more helpful for the more technical issues.

  2. Thanks for adding the example! Much easier to follow compared to the ESMPy documentation.
    However I STILL cannot get the conservative regrid to work, even following exactly your tutorial.
    When I do (line 34 of tutorial):
    regrid_conserve = ESMF.Regrid(sourcefield_conserve, destfield_conserve, regrid_method = ESMF.RegridMethod.CONSERVE,
    unmapped_action = ESMF.UnmappedAction.IGNORE)
    I get:

    ValueError: ESMC_FieldRegridStore() failed with rc = 506. Please check the log files (named “*ESMF_LogFile”).

    from line 1379 of ESMF/interface/cbindings.pyc in ESMP_FieldRegridStore(srcField, dstField, srcMaskValues, dstMaskValues, regridmethod, polemethod, regridPoleNPnts, unmappedaction, srcFracField, dstFracField).

    Any idea what’s going on here?


Leave a Reply to Cynthia Randles Cancel reply

Your email address will not be published. Required fields are marked *