Copernicus - FWI module

class pyro_risks.datasets.fwi.GwisFwi(days_list: Optional[List[str]] = None)[source]

Bases: pandas.core.frame.DataFrame

GWIS FWI dataframe (8 km resolution) on French territory based on 2019-2020 data.

pyro_risks.datasets.fwi.create_departement_df(day_data: pandas.core.frame.DataFrame)pandas.core.frame.DataFrame[source]

Create dataframe with lon, lat coordinates and corresponding departments.

Load json with the department polygons and run function include_department to get the name of departments corresponding to each row of input data, typically one day of FWI data got with load_data. This may take a few minutes due to the shapely process. :param day_data: df with longitudes and latitudes :type day_data: pd.Dataframe

Returns

dataframe with lat, lon and department

Return type

pd.DataFrame

pyro_risks.datasets.fwi.get_fwi_data(source_path: str, day: Optional[str] = '20190101')pandas.core.frame.DataFrame[source]

Load and handle netcdf data for selected day.

Return pandas dataframe with longitude, latitude, day and fwi indices (fwi, ffmc, dmc, dc, isi, bui, dsr, dr). :param source_path: path with unzipped netcdf fwi data, usually got from load_data. :type source_path: str :param day: which day to load. Defaults to ‘20190101’. :type day: str, optional

Returns

dataframe with all fwi indices for selected day

Return type

pd.DataFrame

pyro_risks.datasets.fwi.get_fwi_data_for_predict(date: str)pandas.core.frame.DataFrame[source]

Run CDS API queries for dates required by the model and return fwi dataset for predict step.

This takes care principally of the lags required for the modelling step.

Parameters

date (str) –

Returns

pd.DataFrame

pyro_risks.datasets.fwi.get_fwi_from_api(date: str)geopandas.geodataframe.GeoDataFrame[source]

Call the CDS API and return all fwi variables as a dataframe with geo coordinates and departments.

When calling the API we get a zip file that must be extracted (in a tmp directory), then handle each queried variable which is in a separate netcdf file. A dataframe is created with all the variables and then finally we join codes and departments with geopandas.

Parameters

date (str) –

Returns

pd.DataFrame

pyro_risks.datasets.fwi.include_department(row: pandas.core.series.Series, polygons_json: Dict[str, Any])str[source]

Given a row of a dataframe containing longitude and latitude returns name of french department.

This function makes use of shapely to return if a polygon contains a point. :param row: row of dataframe :type row: pd.Series :param polygons_json: dict with polygons of the departments :type polygons_json: dict

Returns

name of department or empty string

Return type

str

pyro_risks.datasets.fwi.load_data(output_path: str)None[source]

Load FWI zipped data from github repo and unzip data in folder output_path.

Parameters

output_path (str) – absolute, relative or temporary path