wolfhece.irm_alaro
Module Contents
- 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
Enum for Grib files used in IRM Alaro data.
- class wolfhece.irm_alaro.IRM_Alaro(ftp_server: str = OPENDATA_FTP_SERVER, ftp_path: str = OPENDATA_FORECASTS)[source]
Class for handling IRM Alaro forecasts.
- 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.
- 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.
- 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.
- _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.