emaremes.ts

Functions to build time series using GeoDataFrame objects.

point

emaremes.ts.point.query_files(files: list[Path], geodata: GeoDataFrame) DataFrame

Parallelizes the extraction of point values from grib2 files. For a large number of files, this can be much faster than using xr.open_mfdataset.

Parameters:
  • files (list[Path]) – List of grib2 files to extract the point value from.

  • geodata (gpd.GeoDataFrame) – GeoDataFrame containing Points as geometries.

Returns:

Pandas dataframe with the extracted values. Rows are indexed by timestamp, columns are identified by the indexes in the geodata GeoDataFrame.

Return type:

pd.Dataframe

emaremes.ts.point.query_single_file(f: PathLike, geodata: GeoDataFrame) tuple[datetime64, dict[str, float]]

Extracts the nearest value of a grib2 file provided a latitude and longitude.

Parameters:
  • f (PathLike) – Path to the grib2 file.

  • geodata (gpd.GeoDataFrame) – GeoDataFrame containing Points as geometries.

Returns:

A tuple with the timestamp and values of the queried points.

Return type:

tuple[np.datetime64, dict[str, float]]

polygon

emaremes.ts.polygon.query_files(files: list[Path], geodata: GeoDataFrame, upsample: bool = False) DataFrame

Parallelizes the extraction of polygon values from grib2 files. For a large number of files, this can be much faster than using xr.open_mfdataset.

Parameters:
  • files (list[Path]) – List of grib2 files to extract the polygon value from.

  • geodata (gpd.GeoDataFrame) – Geopandas dataframe of polygons to extract the value from.

  • upsample (bool = False) – Whether to upsample the data to a finer grid, by default False.

Returns:

Pandas dataframe with the extracted values. Rows are indexed by timestamp, columns are identified by the indexes in the geodata GeoDataFrame.

Return type:

pd.Dataframe

emaremes.ts.polygon.query_single_file(file: Path, geodata: GeoDataFrame, upsample: bool = False) tuple[datetime64, dict[str, float]]

Queries a single grib2 file and calculates the mean value encompassed by each of the polygons in a GeoDataFrame.

Parameters:
  • file (PathLike) – Path to grib2 file to extract the polygon values from.

  • geodata (gpd.GeoDataFrame) – Geopandas dataframe of polygons to extract the value from.

  • upsample (bool, optional) – Whether to upsample the data to a finer grid, by default False.

Returns:

A tuple with the timestamp and values of the queried points.

Return type:

tuple[np.datetime64, dict[str, float]]