Skip to content

NVlabs/earth2grid

Folders and files

NameName
Last commit message
Last commit date
Aug 24, 2024
Sep 16, 2024
Jan 19, 2025
Sep 19, 2024
Jan 19, 2025
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Sep 6, 2024
Jun 1, 2024
Jun 1, 2024
Sep 16, 2024
Jun 1, 2024
Feb 7, 2025
Jun 1, 2024
Sep 16, 2024

Repository files navigation

Earth2 Grid Utilities

img

Utilities for working geographic data defined on various grids.

Features:

  • regridding
  • Permissively licensed python healpix utilities

Grids currently supported:

  • regular lat lon
  • HealPIX

Install

git clone https://github.com/NVlabs/earth2grid.git
pip install --no-build-isolation ./earth2grid

Example

>>> import earth2grid
>>> import torch
... # level is the resolution
... level = 6
... hpx = earth2grid.healpix.Grid(level=level, pixel_order=earth2grid.healpix.XY())
... src = earth2grid.latlon.equiangular_lat_lon_grid(32, 64)
... z_torch = torch.cos(torch.deg2rad(torch.tensor(src.lat)))
... z_torch = z_torch.broadcast_to(src.shape)
>>> regrid = earth2grid.get_regridder(src, hpx)
>>> z_hpx = regrid(z_torch)
>>> z_hpx.shape
torch.Size([49152])
>>> nside = 2**level
... reshaped = z_hpx.reshape(12, nside, nside)
... lat_r = hpx.lat.reshape(12, nside, nside)
... lon_r = hpx.lon.reshape(12, nside, nside)
>>> reshaped.shape
torch.Size([12, 64, 64])