wolfhece.irm_alaro

Module Contents

wolfhece.irm_alaro.OPENDATA_FORECASTS = 'forecasts'[source]
wolfhece.irm_alaro.OPENDATA_FTP_SERVER = 'opendata.meteo.be'[source]
wolfhece.irm_alaro.OPENDATA_ALARO_40L = 'alaro_40l'[source]
wolfhece.irm_alaro.FILE_PREFIX = 'alaro40l'[source]
wolfhece.irm_alaro._convert_col2date_str(col: str) str[source]

Create a string representation of the date from the column name.

wolfhece.irm_alaro._extract_dates_from_columnstr(col: str) list[datetime.datetime][source]

Extract the run date and forecast date from the column name.

wolfhece.irm_alaro.ArrayBelgium() wolfhece.wolf_array.WolfArray[source]

Create a WolfArray for the Belgium domain.

class wolfhece.irm_alaro.GribFiles(*args, **kwds)[source]

Bases: enum.Enum

Inheritance diagram of wolfhece.irm_alaro.GribFiles

Enum for Grib files used in IRM Alaro data.

FILE_10U = '10U.grb'[source]
FILE_10V = '10V.grb'[source]
FILE_MaxT2 = 'MaxT2.grb'[source]
FILE_MinT2 = 'MinT2.grb'[source]
FILE_2D = '2D.grb'[source]
FILE_2T = '2T.grb'[source]
FILE_RH2M = 'RH2M.grb'[source]
FILE_CR = 'CR.grb'[source]
FILE_CS = 'CS.grb'[source]
FILE_Z = 'Z.grb'[source]
FILE_IFCCC = 'IFCCC.grb'[source]
FILE_IFHCC = 'IFHCC.grb'[source]
FILE_IFLCC = 'IFLCC.grb'[source]
FILE_IFMCC = 'IFMCC.grb'[source]
FILE_IFTCC = 'IFTCC.grb'[source]
FILE_LSR = 'LSR.grb'[source]
FILE_LSS = 'LSS.grb'[source]
FILE_MSLP = 'MSLP.grb'[source]
FILE_R = 'R.grb'[source]
FILE_Q = 'Q.grb'[source]
FILE_MerGust = 'MerGust.grb'[source]
FILE_ZonGust = 'ZonGust.grb'[source]
FILE_SurfSWrad = 'SurfSWrad.grb'[source]
FILE_SurfLWrad = 'SurfLWrad.grb'[source]
FILE_SurfCape = 'SurfCape.grb'[source]
FILE_ST = 'ST.grb'[source]
FILE_ORO = 'ORO.grb'[source]
FILE_T = 'T.grb'[source]
FILE_TotPrecip = 'TotPrecip.grb'[source]
FILE_U = 'U.grb'[source]
FILE_V = 'V.grb'[source]
FILE_W = 'W.grb'[source]
FILE_WBPT = 'WBPT.grb'[source]
FILE_fzht = 'fzht.grb'[source]
class wolfhece.irm_alaro.IRM_Alaro(ftp_server: str = OPENDATA_FTP_SERVER, ftp_path: str = OPENDATA_FORECASTS)[source]

Class for handling IRM Alaro forecasts.

ftp_server = 'opendata.meteo.be'[source]
ftp_path = 'forecasts'[source]
_gdf = None[source]
_gdf_cache = None[source]
_gdf_diff = None[source]
_zones = None[source]
_array[source]
_available_run_dates = [][source]
_colormap = 'Blues'[source]
_cities[source]
_ftp_init()[source]

Initialize the FTP connection.

_ftp_close()[source]

Close the FTP connection.

list_run_dates_cached() list[source]

Return the cached list of available run dates.

list_run_dates() list[source]

List available data files on the FTP server.

property run_dates: list[source]

Return the available forecasts run dates.

property run_dates_str: str[source]

Return the available forecasts run dates as a string.

list_files_for_forecast(run_date: str) list[source]

List files for a specific forecast.

Parameters:

run_date – The forecast time.

_get_filename(file: GribFiles, run_date: str) str[source]

Generate the filename for a given Grib file and forecast.

Parameters:
  • file – The Grib file enum.

  • run_date – The forecast time.

property data_directory: pathlib.Path[source]

Return the data directory path.

download_data(filename: GribFiles | str, run_date: str) pathlib.Path[source]

Download data from the FTP server.

Parameters:
  • filename – The Grib file to download or a specific filename.

  • run_date – The forecast time.

download_TotalPrecipitations_available_files() list[pathlib.Path][source]

Download Cumulated rain, Temperature et 2m - files available on the FTP server.

download_all_available_files() list[pathlib.Path][source]

Download all files available on the FTP server.

_get_center_coordinates(filename: GribFiles, run_date: str, EPSG: str = 'EPSG:31370') tuple[numpy.ndarray, numpy.ndarray][source]

Load GRIB data and compute coordinates.

Parameters:
  • filename – The GRIB file to process.

  • forecast – The forecast time.

  • download – Whether to download the file if it doesn’t exist.

  • EPSG – The target EPSG code for the output coordinates.

Returns:

The center coordinates (x, y) for the given GRIB file and forecast.

_get_corners_coordinates(filename: GribFiles, run_date: str, EPSG: str = 'EPSG:31370') tuple[tuple[numpy.ndarray, numpy.ndarray]][source]

Load GRIB data and compute coordinates.

Parameters:
  • filename – The GRIB file to process.

  • forecast – The forecast time.

  • download – Whether to download the file if it doesn’t exist.

  • EPSG – The target EPSG code for the output coordinates.

Returns:

The coordinates (x, y) for (center, lower-left, lower-right, upper-right, upper-left).

_prepare_gdf_from_grib(filename: GribFiles, run_date: str, EPSG: str = 'EPSG:31370') geopandas.GeoDataFrame[source]

Prepare a GeoDataFrame from grib file.

Parameters:
  • filename – The GRIB file to process.

  • forecast – The forecast time.

  • EPSG – The target EPSG code for the output coordinates.

Returns:

The GeoDataFrame with polygons for each grid cell.

_prepare_Zones_from_grib(filename: GribFiles, run_date: str, EPSG: str = 'EPSG:31370') wolfhece.PyVertexvectors.Zones[source]

Prepare a Zones from brib file.

Parameters:
  • filename – The GRIB file to process.

  • forecast – The forecast time.

  • EPSG – The target EPSG code for the output coordinates.

Returns:

The Zones with polygons for each grid cell.

_load_grib_data(filename: GribFiles, run_dates: str | list[str]) geopandas.GeoDataFrame[source]

Load GRIB data from a file and add it to the GeoDataFrame.

Parameters:
  • filename – The GRIB file to process.

  • run_dates – The forecast run dates.

Returns:

The GeoDataFrame with added data.

reset_gdf()[source]

Reset the GeoDataFrame.

load_grib_data_to_gdf(filename: GribFiles, run_dates: str | list[str]) geopandas.GeoDataFrame[source]

Load GRIB data from a file and add it to the GeoDataFrame.

Parameters:
  • filename – The GRIB file to process.

  • run_dates – The forecast run dates.

Returns:

The GeoDataFrame with added data.

load_grib_data_to_Zones(filename: GribFiles, run_dates: str | list[str]) geopandas.GeoDataFrame[source]

Load GRIB data from a file and add it to the Zones.

Parameters:
  • filename – The GRIB file to process.

  • run_dates – The forecast run dates.

Returns:

The Zones with added data.

forecasts_to_arrays(forecasts: str | list[str] = None) list[wolfhece.wolf_array.WolfArray][source]

Set the forecasts to the WolfArray.

Parameters:

forecasts – List of forecast columns to convert to WolfArray. If None, all forecast columns are used.

get_forecast_columns(diff: bool = False) list[str][source]

Get the list of forecast columns in the GeoDataFrame.

Exclude ‘geometry’, ‘centroid_x’, ‘centroid_y’ columns.

Parameters:

diff – If True, get columns from the diff GeoDataFrame.

_compute_diff()[source]

Compute local rain by difference in total cumulated rainfall

_load_grib_metadata(filename: GribFiles, run_date: str) numpy.ndarray[source]

Load GRIB metadata from a file.

Parameters:
  • filename – The GRIB file to process.

  • run_date – The forecast run date.

_create_animation(filename: GribFiles, run_date: str, bounds: list[list[float], list[float]] | str = 'Belgium', vmin: float = None, vmax: float = None, factor: float = 1.0) matplotlib.animation.FuncAnimation[source]

Create a video from the GeoDataFrame data.

Parameters:
  • filename – The GRIB file to process.

  • run_date – The forecast run date to visualize.

  • bounds – Bounds for the plot. Can be ‘Belgium’ or a list of [xlim, ylim].

  • vmin – Minimum value for color scaling.

  • vmax – Maximum value for color scaling.

  • factor – Factor to multiply the data values for scaling.

Returns:

The animation object.

_create_comparison_animation(filename: GribFiles, run_dates: list[str], size=10, bounds: list[list[float], list[float]] | str = 'Belgium', vmin: float = None, vmax: float = None, factor: float = 1.0) matplotlib.animation.FuncAnimation[source]

Create a video from the GeoDataFrame data.

Parameters:
  • filename – The GRIB file to process.

  • run_dates – List of forecast run dates to compare.

  • size – Size of each subplot.

  • bounds – Bounds for the plot. Can be ‘Belgium’ or a list of [xlim, ylim].

  • vmin – Minimum value for color scaling.

  • vmax – Maximum value for color scaling.

  • factor – Factor to multiply the data values for scaling.

Returns:

The animation object.

_create_comparison_animation_diff(filename: GribFiles, run_dates: list[str], size=10, bounds: list[list[float], list[float]] | str = 'Belgium', vmin: float = None, vmax: float = None, factor: float = 1.0) matplotlib.animation.FuncAnimation[source]

Create a video from the GeoDataFrame data.

Parameters:
  • filename – The GRIB file to process.

  • run_dates – List of forecast run dates to compare.

  • size – Size of each subplot.

  • bounds – Bounds for the plot. Can be ‘Belgium’ or a list of [xlim, ylim].

  • vmin – Minimum value for color scaling.

  • vmax – Maximum value for color scaling.

  • factor – Factor to multiply the data values for scaling.

Returns:

The animation object.

video_cumulated_rain(run_date: str, output_file: pathlib.Path, fps: int = 2)[source]

Create a MP4 video comparison of cumulated rain forecasts.

Parameters:
  • forecast – The forecast date string.

  • output_file – The output MP4 file path.

  • fps – Frames per second for the video.

videos_cumulated_rain_allforecasts(output_dir: pathlib.Path, fps: int = 2, run_dates: str | list[str] = None) list[pathlib.Path] | None[source]

Create a MP4 video comparison of cumulated rain forecasts.

Parameters:
  • output_dir – The output directory for the MP4 files.

  • fps – Frames per second for the video.

video_gradient_cumulated_rain_compare(output_file: pathlib.Path, fps: int = 2, run_dates: str | list[str] = None) pathlib.Path | None[source]

Create a MP4 video comparison of cumulated rain forecasts.

Parameters:
  • output_file – The output MP4 file path.

  • fps – Frames per second for the video.

convert_gdf2dataframe(X: float, Y: float, use_diff: bool = False) pandas.DataFrame[source]

Convert the GeoDataFrame to a Pandas DataFrame for a given point (X, Y).

Parameters:
  • X – The X coordinate.

  • Y – The Y coordinate.

Returns:

The Pandas DataFrame with the data for the nearest grid cell.

_plot4XY(X: float, Y: float, factor: float = 1.0, size: tuple[int, int] = (10, 5), use_diff: bool = False, figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) matplotlib.pyplot.Figure[source]

Plot the data for a given point (X, Y).

Parameters:
  • X – The X coordinate.

  • Y – The Y coordinate.

  • factor – The factor to multiply the data values for scaling.

  • size – The size of the plot.

Returns:

The Matplotlib Figure object.

_bar4XY(X: float, Y: float, factor: float = 1.0, size: tuple[int, int] = (10, 5), use_diff: bool = False, figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) matplotlib.pyplot.Figure[source]

Plot the data for a given point (X, Y).

Parameters:
  • X – The X coordinate.

  • Y – The Y coordinate.

  • factor – The factor to multiply the data values for scaling.

  • size – The size of the plot.

Returns:

The Matplotlib Figure object.

plot_TotPrec4XY(X: float, Y: float, size: tuple[int, int] = (10, 5)) matplotlib.pyplot.Figure[source]

Plot the total precipitation data for a given point (X, Y).

Parameters:
  • X – The X coordinate.

  • Y – The Y coordinate.

  • size – The size of the plot.

Returns:

The Matplotlib Figure object.

plot_RainIntensity4XY(X: float, Y: float, size: tuple[int, int] = (10, 5)) matplotlib.pyplot.Figure[source]

Plot the rain intensity data for a given point (X, Y).

Parameters:
  • X – The X coordinate.

  • Y – The Y coordinate.

  • size – The size of the plot.

Returns:

The Matplotlib Figure object.

plot_Rain_and_TotPrecip4XY(X: float, Y: float, size: tuple[int, int] = (10, 10)) matplotlib.pyplot.Figure[source]

Plot the rain intensity and total precipitation data for a given point (X, Y).

Parameters:
  • X – The X coordinate.

  • Y – The Y coordinate.

  • size – The size of the plot.

Returns:

The Matplotlib Figure object.