Helper methods

Helper methods#

Primary functions for poly-to-poly area-weighted mapping.

gdptools.helpers.build_subset(bounds: ndarray[Any, dtype[float64]], xname: str, yname: str, tname: str, toptobottom: bool, date_min: str, date_max: Optional[str] = None) Dict[str, object]#

Create a dictionary to use with xarray .sel() method to subset by time and space.

Parameters
  • bounds (np.ndarray) – _description_

  • xname (str) – _description_

  • yname (str) – _description_

  • tname (str) – _description_

  • toptobottom (bool) – _description_

  • date_min (str) – _description_

  • date_max (Optional[str], optional) – _description_. Defaults to None.

Returns

_description_

Return type

dict

gdptools.helpers.build_subset_tiff(bounds: ndarray[Any, dtype[float64]], xname: str, yname: str, toptobottom: bool, bname: str, band: int) Mapping[Any, Any]#

Create a dictionary to use with xarray .sel() method to subset by time and space.

Parameters
  • bounds (npt.NDArray[np.double]) – _description_

  • xname (str) – _description_

  • yname (str) – _description_

  • toptobottom (bool) – _description_

  • bname (str) – _description_

  • band (int) – _description_

Returns

_description_

Return type

Dict[str, object]

gdptools.helpers.build_subset_tiff_da(bounds: ndarray[Any, dtype[float64]], xname: str, yname: str, toptobottom: Union[int, bool]) Mapping[Any, Any]#

Create a dictionary to use with xarray .sel() method to subset by time and space.

Parameters
  • bounds (npt.NDArray[np.double]) – _description_

  • xname (str) – _description_

  • yname (str) – _description_

  • toptobottom (bool) – _description_

Returns

_description_

Return type

Dict[str, object]

gdptools.helpers.get_data_subset_climr_catalog(cat_dict: dict[str, dict[str, Any]], key: str, shp_file: Union[str, GeoDataFrame], begin_date: str, end_date: str) DataArray#

get_data_subset_climr_catalog Get xarray subset data.

_extended_summary_

Parameters
  • cat_dict (dict[str, dict[str, Any]]) – _description_

  • key (str) – _description_

  • shp_file (Union[str, gpd.GeoDataFrame]) – _description_

  • begin_date (str) – _description_

  • end_date (str) – _description_

Returns

_description_

Return type

xr.DataArray

gdptools.helpers.get_data_subset_odap_catalog(param_dict: dict[str, dict[str, Any]], grid_dict: dict[str, dict[str, Any]], key: str, shp_file: Union[str, GeoDataFrame], begin_date: str, end_date: str) DataArray#

get_data_subset_odap_catalog Get xarray subset data.

_extended_summary_

Parameters
  • param_dict (dict[str, dict[str, Any]]) – _description_

  • grid_dict (dict[str, dict[str, Any]]) – _description_

  • key (str) – _description_

  • shp_file (Union[str, gpd.GeoDataFrame]) – _description_

  • begin_date (str) – _description_

  • end_date (str) – _description_

Returns

_description_

Return type

xr.DataArray

gdptools.helpers.get_data_subset_user_catalog(cat_dict: dict[str, dict[str, Any]], key: str, shp_file: Union[str, GeoDataFrame], begin_date: str, end_date: str) DataArray#

get_data_subset_climr_catalog Get xarray subset data.

_extended_summary_

Parameters
  • cat_dict (dict[str, dict[str, Any]]) – _description_

  • key (str) – _description_

  • shp_file (Union[str, gpd.GeoDataFrame]) – _description_

  • begin_date (str) – _description_

  • end_date (str) – _description_

Returns

_description_

Return type

xr.DataArray