wolfhece.irm_alaro ================== .. py:module:: wolfhece.irm_alaro Module Contents --------------- .. py:data:: OPENDATA_FORECASTS :value: 'forecasts' .. py:data:: OPENDATA_FTP_SERVER :value: 'opendata.meteo.be' .. py:data:: OPENDATA_ALARO_40L :value: 'alaro_40l' .. py:data:: FILE_PREFIX :value: 'alaro40l' .. py:function:: _convert_col2date_str(col: str) -> str Create a string representation of the date from the column name. .. py:function:: _extract_dates_from_columnstr(col: str) -> list[datetime.datetime] Extract the run date and forecast date from the column name. .. py:function:: ArrayBelgium() -> wolfhece.wolf_array.WolfArray Create a WolfArray for the Belgium domain. .. py:class:: GribFiles(*args, **kwds) Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: wolfhece.irm_alaro.GribFiles :parts: 1 :private-bases: Enum for Grib files used in IRM Alaro data. .. py:attribute:: FILE_10U :value: '10U.grb' .. py:attribute:: FILE_10V :value: '10V.grb' .. py:attribute:: FILE_MaxT2 :value: 'MaxT2.grb' .. py:attribute:: FILE_MinT2 :value: 'MinT2.grb' .. py:attribute:: FILE_2D :value: '2D.grb' .. py:attribute:: FILE_2T :value: '2T.grb' .. py:attribute:: FILE_RH2M :value: 'RH2M.grb' .. py:attribute:: FILE_CR :value: 'CR.grb' .. py:attribute:: FILE_CS :value: 'CS.grb' .. py:attribute:: FILE_Z :value: 'Z.grb' .. py:attribute:: FILE_IFCCC :value: 'IFCCC.grb' .. py:attribute:: FILE_IFHCC :value: 'IFHCC.grb' .. py:attribute:: FILE_IFLCC :value: 'IFLCC.grb' .. py:attribute:: FILE_IFMCC :value: 'IFMCC.grb' .. py:attribute:: FILE_IFTCC :value: 'IFTCC.grb' .. py:attribute:: FILE_LSR :value: 'LSR.grb' .. py:attribute:: FILE_LSS :value: 'LSS.grb' .. py:attribute:: FILE_MSLP :value: 'MSLP.grb' .. py:attribute:: FILE_R :value: 'R.grb' .. py:attribute:: FILE_Q :value: 'Q.grb' .. py:attribute:: FILE_MerGust :value: 'MerGust.grb' .. py:attribute:: FILE_ZonGust :value: 'ZonGust.grb' .. py:attribute:: FILE_SurfSWrad :value: 'SurfSWrad.grb' .. py:attribute:: FILE_SurfLWrad :value: 'SurfLWrad.grb' .. py:attribute:: FILE_SurfCape :value: 'SurfCape.grb' .. py:attribute:: FILE_ST :value: 'ST.grb' .. py:attribute:: FILE_ORO :value: 'ORO.grb' .. py:attribute:: FILE_T :value: 'T.grb' .. py:attribute:: FILE_TotPrecip :value: 'TotPrecip.grb' .. py:attribute:: FILE_U :value: 'U.grb' .. py:attribute:: FILE_V :value: 'V.grb' .. py:attribute:: FILE_W :value: 'W.grb' .. py:attribute:: FILE_WBPT :value: 'WBPT.grb' .. py:attribute:: FILE_fzht :value: 'fzht.grb' .. py:class:: IRM_Alaro(ftp_server: str = OPENDATA_FTP_SERVER, ftp_path: str = OPENDATA_FORECASTS) Class for handling IRM Alaro forecasts. .. py:attribute:: ftp_server :value: 'opendata.meteo.be' .. py:attribute:: ftp_path :value: 'forecasts' .. py:attribute:: _gdf :value: None .. py:attribute:: _gdf_cache :value: None .. py:attribute:: _gdf_diff :value: None .. py:attribute:: _zones :value: None .. py:attribute:: _array .. py:attribute:: _available_run_dates :value: [] .. py:attribute:: _colormap :value: 'Blues' .. py:attribute:: _cities .. py:method:: _ftp_init() Initialize the FTP connection. .. py:method:: _ftp_close() Close the FTP connection. .. py:method:: list_run_dates_cached() -> list Return the cached list of available run dates. .. py:method:: list_run_dates() -> list List available data files on the FTP server. .. py:property:: run_dates :type: list Return the available forecasts run dates. .. py:property:: run_dates_str :type: str Return the available forecasts run dates as a string. .. py:method:: list_files_for_forecast(run_date: str) -> list List files for a specific forecast. :param run_date: The forecast time. .. py:method:: _get_filename(file: GribFiles, run_date: str) -> str Generate the filename for a given Grib file and forecast. :param file: The Grib file enum. :param run_date: The forecast time. .. py:property:: data_directory :type: pathlib.Path Return the data directory path. .. py:method:: download_data(filename: GribFiles | str, run_date: str) -> pathlib.Path Download data from the FTP server. :param filename: The Grib file to download or a specific filename. :param run_date: The forecast time. .. py:method:: download_TotalPrecipitations_available_files() -> list[pathlib.Path] Download Cumulated rain, Temperature et 2m - files available on the FTP server. .. py:method:: download_all_available_files() -> list[pathlib.Path] Download all files available on the FTP server. .. py:method:: _get_center_coordinates(filename: GribFiles, run_date: str, EPSG: str = 'EPSG:31370') -> tuple[numpy.ndarray, numpy.ndarray] Load GRIB data and compute coordinates. :param filename: The GRIB file to process. :param forecast: The forecast time. :param download: Whether to download the file if it doesn't exist. :param EPSG: The target EPSG code for the output coordinates. :return: The center coordinates (x, y) for the given GRIB file and forecast. .. py:method:: _get_corners_coordinates(filename: GribFiles, run_date: str, EPSG: str = 'EPSG:31370') -> tuple[tuple[numpy.ndarray, numpy.ndarray]] Load GRIB data and compute coordinates. :param filename: The GRIB file to process. :param forecast: The forecast time. :param download: Whether to download the file if it doesn't exist. :param EPSG: The target EPSG code for the output coordinates. :return: The coordinates (x, y) for (center, lower-left, lower-right, upper-right, upper-left). .. py:method:: _prepare_gdf_from_grib(filename: GribFiles, run_date: str, EPSG: str = 'EPSG:31370') -> geopandas.GeoDataFrame Prepare a GeoDataFrame from grib file. :param filename: The GRIB file to process. :param forecast: The forecast time. :param EPSG: The target EPSG code for the output coordinates. :return: The GeoDataFrame with polygons for each grid cell. .. py:method:: _prepare_Zones_from_grib(filename: GribFiles, run_date: str, EPSG: str = 'EPSG:31370') -> wolfhece.PyVertexvectors.Zones Prepare a Zones from brib file. :param filename: The GRIB file to process. :param forecast: The forecast time. :param EPSG: The target EPSG code for the output coordinates. :return: The Zones with polygons for each grid cell. .. py:method:: _load_grib_data(filename: GribFiles, run_dates: str | list[str]) -> geopandas.GeoDataFrame Load GRIB data from a file and add it to the GeoDataFrame. :param filename: The GRIB file to process. :param run_dates: The forecast run dates. :return: The GeoDataFrame with added data. .. py:method:: reset_gdf() Reset the GeoDataFrame. .. py:method:: load_grib_data_to_gdf(filename: GribFiles, run_dates: str | list[str]) -> geopandas.GeoDataFrame Load GRIB data from a file and add it to the GeoDataFrame. :param filename: The GRIB file to process. :param run_dates: The forecast run dates. :return: The GeoDataFrame with added data. .. py:method:: load_grib_data_to_Zones(filename: GribFiles, run_dates: str | list[str]) -> geopandas.GeoDataFrame Load GRIB data from a file and add it to the Zones. :param filename: The GRIB file to process. :param run_dates: The forecast run dates. :return: The Zones with added data. .. py:method:: forecasts_to_arrays(forecasts: str | list[str] = None) -> list[wolfhece.wolf_array.WolfArray] Set the forecasts to the WolfArray. :param forecasts: List of forecast columns to convert to WolfArray. If None, all forecast columns are used. .. py:method:: get_forecast_columns(diff: bool = False) -> list[str] Get the list of forecast columns in the GeoDataFrame. Exclude 'geometry', 'centroid_x', 'centroid_y' columns. :param diff: If True, get columns from the diff GeoDataFrame. .. py:method:: _compute_diff() Compute local rain by difference in total cumulated rainfall .. py:method:: _load_grib_metadata(filename: GribFiles, run_date: str) -> numpy.ndarray Load GRIB metadata from a file. :param filename: The GRIB file to process. :param run_date: The forecast run date. .. py:method:: _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 Create a video from the GeoDataFrame data. :param filename: The GRIB file to process. :param run_date: The forecast run date to visualize. :param bounds: Bounds for the plot. Can be 'Belgium' or a list of [xlim, ylim]. :param vmin: Minimum value for color scaling. :param vmax: Maximum value for color scaling. :param factor: Factor to multiply the data values for scaling. :return: The animation object. .. py:method:: _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 Create a video from the GeoDataFrame data. :param filename: The GRIB file to process. :param run_dates: List of forecast run dates to compare. :param size: Size of each subplot. :param bounds: Bounds for the plot. Can be 'Belgium' or a list of [xlim, ylim]. :param vmin: Minimum value for color scaling. :param vmax: Maximum value for color scaling. :param factor: Factor to multiply the data values for scaling. :return: The animation object. .. py:method:: _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 Create a video from the GeoDataFrame data. :param filename: The GRIB file to process. :param run_dates: List of forecast run dates to compare. :param size: Size of each subplot. :param bounds: Bounds for the plot. Can be 'Belgium' or a list of [xlim, ylim]. :param vmin: Minimum value for color scaling. :param vmax: Maximum value for color scaling. :param factor: Factor to multiply the data values for scaling. :return: The animation object. .. py:method:: video_cumulated_rain(run_date: str, output_file: pathlib.Path, fps: int = 2) Create a MP4 video comparison of cumulated rain forecasts. :param forecast: The forecast date string. :param output_file: The output MP4 file path. :param fps: Frames per second for the video. .. py:method:: videos_cumulated_rain_allforecasts(output_dir: pathlib.Path, fps: int = 2, run_dates: str | list[str] = None) -> list[pathlib.Path] | None Create a MP4 video comparison of cumulated rain forecasts. :param output_dir: The output directory for the MP4 files. :param fps: Frames per second for the video. .. py:method:: video_gradient_cumulated_rain_compare(output_file: pathlib.Path, fps: int = 2, run_dates: str | list[str] = None) -> pathlib.Path | None Create a MP4 video comparison of cumulated rain forecasts. :param output_file: The output MP4 file path. :param fps: Frames per second for the video. .. py:method:: convert_gdf2dataframe(X: float, Y: float, use_diff: bool = False) -> pandas.DataFrame Convert the GeoDataFrame to a Pandas DataFrame for a given point (X, Y). :param X: The X coordinate. :param Y: The Y coordinate. :return: The Pandas DataFrame with the data for the nearest grid cell. .. py:method:: _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 Plot the data for a given point (X, Y). :param X: The X coordinate. :param Y: The Y coordinate. :param factor: The factor to multiply the data values for scaling. :param size: The size of the plot. :return: The Matplotlib Figure object. .. py:method:: _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 Plot the data for a given point (X, Y). :param X: The X coordinate. :param Y: The Y coordinate. :param factor: The factor to multiply the data values for scaling. :param size: The size of the plot. :return: The Matplotlib Figure object. .. py:method:: plot_TotPrec4XY(X: float, Y: float, size: tuple[int, int] = (10, 5)) -> matplotlib.pyplot.Figure Plot the total precipitation data for a given point (X, Y). :param X: The X coordinate. :param Y: The Y coordinate. :param size: The size of the plot. :return: The Matplotlib Figure object. .. py:method:: plot_RainIntensity4XY(X: float, Y: float, size: tuple[int, int] = (10, 5)) -> matplotlib.pyplot.Figure Plot the rain intensity data for a given point (X, Y). :param X: The X coordinate. :param Y: The Y coordinate. :param size: The size of the plot. :return: The Matplotlib Figure object. .. py:method:: plot_Rain_and_TotPrecip4XY(X: float, Y: float, size: tuple[int, int] = (10, 10)) -> matplotlib.pyplot.Figure Plot the rain intensity and total precipitation data for a given point (X, Y). :param X: The X coordinate. :param Y: The Y coordinate. :param size: The size of the plot. :return: The Matplotlib Figure object.