Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

how to regrid TLONG/TLAT pop data to regular Lon/Lat grid with python

mneedham

Michael Needham
New Member
Hello,

Is there a "best practice" way to regrid POP output from the TLONG/TLAT grid to a regular (e.g., 1x1 degree) grid?

My naive approach would be:
  • loop over all combinations of lats / lons on my desired 1x1 deg grid
  • collect all Tlong/Tlat gridcells within 0.5 deg of the given lat/lon
  • Perform an average (or some other operation) to give a single value at the new gridcell
However this will likely be slow...
 

mneedham

Michael Needham
New Member
Hi Gustavo, Thank you for the recommendation.

xESMF works great when I use

Code:
xesmf.Regridder(..., method='bilinear')

but fails with

Code:
xesmf.Regridder(..., method='conservative')

AttributeError: 'DataArray.cf' object has no attribute 'get_bounds'

It appears that POP output files do not have bounds for TLONG and TLAT dimensions. Do you have a recommendation of how to perform conservative regridding of POP output?
 

mneedham

Michael Needham
New Member
I don't see a way to explicitly pass the corner points to xesmf.Regridder. Do I need to update my input dataArray to include these corner points somehow?

Note, My input data looks like:

Python:
>>> print(dset.VNT)

<xarray.DataArray 'VNT' (z_t: 60, nlat: 384, nlon: 320)>
dask.array<getitem, shape=(60, 384, 320), dtype=float32, chunksize=(60, 384, 320), chunktype=numpy.ndarray>
Coordinates:
  * z_t      (z_t) float32 500.0 1.5e+03 2.5e+03 ... 5.125e+05 5.375e+05
    ULONG    (nlat, nlon) float64 dask.array<chunksize=(384, 320), meta=np.ndarray>
    ULAT     (nlat, nlon) float64 dask.array<chunksize=(384, 320), meta=np.ndarray>
    TLONG    (nlat, nlon) float64 dask.array<chunksize=(384, 320), meta=np.ndarray>
    TLAT     (nlat, nlon) float64 dask.array<chunksize=(384, 320), meta=np.ndarray>
    year     int64 1851
Dimensions without coordinates: nlat, nlon
Attributes:
    long_name:     Flux of Heat in grid-y direction
    units:         degC/s
    grid_loc:      3121
    cell_methods:  time: mean

But there are no lat/lon bounds for this data:

Python:
>>> print(dset.VNT.cf)

Coordinates:
- CF Axes:   X, Y, Z, T: n/a

- CF Coordinates:   longitude: ['TLONG', 'ULONG']
                    latitude: ['TLAT', 'ULAT']
                  * vertical: ['z_t']
                    time: n/a

- Cell Measures:   area, volume: n/a

- Standard Names:   n/a

- Bounds:   n/a
 
Top