pixcdust.dggs.dggs_converter

Functions

prepare_dataset_h3(→ xarray.Dataset)

Convert a Dataset with latitude and longitude coordinates into an H3-indexed grid.

prepare_dataset_healpix(→ xarray.Dataset)

Convert a Dataset with latitude and longitude coordinates into an HEALPix-indexed grid.

Module Contents

pixcdust.dggs.dggs_converter.prepare_dataset_h3(ds: xarray.Dataset, resolution: int, interp: bool = False, method: str = 'linear') xarray.Dataset[source]

Convert a Dataset with latitude and longitude coordinates into an H3-indexed grid.

This function computes H3 hexagonal grid indices for each latitude/longitude pair in the dataset, applies the H3 indexing, and projects the data to the new H3 grid. It also fills a bounding box with H3 indices and interpolates the dataset accordingly.

Args:

ds: The input dataset with latitude (‘latitude’) and longitude (‘longitude’) coordinates. resolution: The resolution of the H3 grid. Valid values are from 0 (coarse) to 15 (fine). interp: If True, the data will be interpolated onto the H3 grid, which may be more precise but computationally expensive.

If False (default), values will be averaged per H3 cell.

method: (‘nearest’, ‘linear’, ‘cubic’) The interpolation method used by`scippy.interpolate.griddata`.

Returns:

A new dataset with data variables interpolated onto the H3 grid. The output dataset includes: - h3_lon: longitudes of H3 grid centers. - h3_lat: latitudes of H3 grid centers. - cell_ids: unique H3 pixel indices. The dataset retains any global attributes from the original dataset and stores additional metadata on the H3 grid.

pixcdust.dggs.dggs_converter.prepare_dataset_healpix(ds: xarray.Dataset, resolution: int = 8, interp: bool = False, method: str = 'linear') xarray.Dataset[source]

Convert a Dataset with latitude and longitude coordinates into an HEALPix-indexed grid.

This function computes Healpix grid indices for each latitude/longitude pair in the dataset, applies the HEALPix indexing, and projects the data to the new HEALPix grid.

Args:

ds: The input dataset with latitude (‘latitude’) and longitude (‘longitude’) coordinates. resolution: The resolution of the HEALPix grid. interp: If True, the data will be interpolated onto the HEALPix grid, which may be more precise but computationally expensive.

If False (default), values will be averaged per HEALPix cell.

method: (‘nearest’, ‘linear’, ‘cubic’) The interpolation method used by`scippy.interpolate.griddata`.

Returns:

A new dataset with data variables interpolated onto the HEALPix grid. The output dataset includes: - healpix_lon: longitudes of HEALPix grid centers. - healpix_lat: latitudes of HEALPix grid centers. - cell_ids: unique HEALPix pixel indices. The dataset retains any global attributes from the original dataset and stores additional metadata on the HEALPix grid.