wolfhece.eva.pyseries
EXTREME VALUES ANALYSIS - EVA
@author : Pierre Archambeau - ULiege - HECE @date : 2023
Module Contents
- wolfhece.eva.pyseries.change_font_size(ax: matplotlib.axes.Axes, fontsize)[source]
Adapte la taille de police d’un graphique
- wolfhece.eva.pyseries.set_style(color: Literal[b, g, r, c, m, y, k], linestyle: Literal[solid, dotted, deshed, dashdot] = 'solid', linewidth=1) dict['color':str, 'linestyle':str, 'linewidth':int] [source]
- wolfhece.eva.pyseries.get_style(style: dict['color':str, 'linestyle':str, 'linewidth':int])[source]
- wolfhece.eva.pyseries.cunnane(r, n)[source]
Calcul de la fréquence empirique selon Cunnane(1979) MAJ de la formulation de Weibull a priori mieux adaptée aux problèmes hydrologiques
r : rang de la donnée 1<=r<=n n : nombre total de données dans l’échantillon
- wolfhece.eva.pyseries.weibull(r, n)[source]
Calcul de la fréquence empirique selon Weibull - loi “uniforme”
r : rang de la donnée 1<=r<=n n : nombre total de données dans l’échantillon
- wolfhece.eva.pyseries.filliben(r, n)[source]
Calcul de la fréquence empirique selon Filliben
r : rang de la donnée 1<=r<=n n : nombre total de données dans l’échantillon
- wolfhece.eva.pyseries.aic(mle, n, k=2, corrected=True)[source]
The Akaike information criterion (AIC) is a metric that is used to compare the fit of different regression models.
It is calculated as:
AIC = 2K – 2ln(L)
where:
K: The number of model parameters (including loc and scale) mle = ln(L): The log-likelihood of the model. This tells us how likely the model is, given the data.
https://fr.wikipedia.org/wiki/Crit%C3%A8re_d%27information_d%27Akaike https://www.statology.org/aic-in-python/
- wolfhece.eva.pyseries.bic(mle, n, k=2)[source]
the Bayesian information criterion (BIC) or Schwarz information criterion (also SIC, SBC, SBIC) is a criterion for model selection among a finite set of models Models with lower BIC are generally preferred. It is based, in part, on the likelihood function and it is closely related to the Akaike information criterion (AIC).
https://en.wikipedia.org/wiki/Bayesian_information_criterion https://fr.wikipedia.org/wiki/Crit%C3%A8re_d%27information_bay%C3%A9sien
- wolfhece.eva.pyseries._get_hist_params(X, bins, mhist='numpy')[source]
Get histogram of original data
- wolfhece.eva.pyseries.rss(data, pdf, bins=100)[source]
Residual sum of squares
based on pdf and data’s histogram
- wolfhece.eva.pyseries._generate_clusters(exceedances: pandas.Series, r: pandas.Timedelta | Any) Generator[pandas.Series, None, None] [source]
- wolfhece.eva.pyseries.LAWS_POPULAR = ['GEV', 'Log normale', 'Gumbel', 'Exponentielle', 'Pearson3', 'Gamma inverse', 'Weibull',...[source]
- class wolfhece.eva.pyseries.EVA_Serie(data, datetime_index=None, datetime_format='%Y%m%d%H%M%S', data_headers=('#DateHeure', 'Debit'), duration=1, startmonth_winter=10, startmonth_summer=4, hydrol=True, verbose=True)[source]
One time serie
- get_date_max(year, seasons=None) list [source]
Récupère la date du maximum de l’année “year” Possibilité de traiter plusieurs saisons
- get_one_maxevent(year, seasons=None) list [source]
Récupération de l’événement max pour une année spécifique Possibilité de traiter plusieurs saisons
- get_nb_maxevents(nbevents: int, seasons=None) dict[str, pandas.DataFrame] [source]
Récupère les nbevents lus grands pics de crue
- get_nb_max_hydro(nbevents: int, seasons=None) dict[str, pandas.DataFrame] [source]
Récupère les nbevents plus grands hydrogrammes de crue
- save_max_events(filename, years_bounds: list = None, seasons=None)[source]
Enregistrement des crues maximales dans un fichier CSV
- _get_dates(year=None, hydrol=True, season=None)[source]
Compute date for current year and season
- Parameters:
year (integer, optional) – If None, the complete interval will be used. Defaults to None.
hydrol (bool, optional) – Hydrological year or not. Defaults to True.
season ('annual', 'winter' or 'summer', optional) – None == ‘annual’. Defaults to None.
- _get_max(year=None, hydrol=True, season=None, method: Literal[BM, POT] = 'BM', threshold=0.0, r: pandas.Timedelta | Any = '24H')[source]
Find maxima in specific period
- save_fit_one_season(filename: str, method: Literal[BM, POT] = 'BM', season=None, fit_method='MLE', sep=';')[source]
- find_maxima(hydrol=True, excluded_years=[], method: Literal[BM, POT] = 'BM', threshold: float = 0.0, r: pandas.Timedelta | Any = '24H', verbose=True)[source]
Find maxima in whole data
- extract_oneevent(datecenter, before=1, after=2)[source]
Extract hydrograph around a date
- Parameters:
before – number of days before center
after – number of days after center
- extract_maxevents(before=1, after=2)[source]
Extract hydrograph for each maximum
- Parameters:
before – number of days before maximum
after – number of days after maximum
- _fit_multistarts(data, fdist, nb=0, method='MLE')[source]
Fit de la loi en adaptant éventuellement le point de départ Ceci n’est sans doute réellement utile que pour la loi de Weibull
- _evaluate_ci(data, fdist, nboot=500, method='MLE')[source]
Evaluate confidence interval based on bootstrap method
REMARK : CI for MLE can be analyzed by Fisher coefficients
- get_T_from_q(q: list, season: str = 'best', law: str = 'best', method: str = 'MLE', ic=False) pandas.DataFrame [source]
- get_q_from_T(return_periods: list = [5, 10, 15, 20, 25, 50, 75, 100, 200, 500, 1000], season: str = 'best', law: str = 'best', method: str = 'MLE', ic=False) pandas.DataFrame [source]
- save_q_from_T(filename: str = '', return_periods=[5, 10, 15, 20, 25, 50, 75, 100, 200, 500, 1000], season='best', law='best', method='MLE', ic=False)[source]
- save_T_from_q(filename: str = '', q=[5, 10, 15, 20, 25, 50, 75, 100, 200, 500, 1000], season='best', law='best', method='MLE', ic=False)[source]
- fit(seasons=None, laws=['GEV'], init_EVA=None, methods=['MLE'], ic=False, nboot=100, verbose=True)[source]
Fitting of selected laws
- distfit(seasons=None, laws='popular', smooth=0, bins=100)[source]
Laws can be ‘full’, ‘popular’
* Be carefull, fit of law is based on default scipy.stats parames. In our implementation, non-default initial conditions are used for specific laws, including GEV. *
https://erdogant.github.io/distfit/pages/html/Parametric.html https://erdogant.github.io/distfit
- set_mixture(laws=['GEV'], methods=['MLE'])[source]
Set mixture model based on “50-50” “winter-summer” fitted models
- set_joint(laws=['GEV'], methods=['MLE'])[source]
Set joint model based on product probability of fitted models
- compute_median_event(seasons=None, before: int = 1, after: int = 2)[source]
Evaluation de la crue mediane Stockage dans “self.maxima[curseason][‘median_event’]”
- get_median_event(seasons=None, before=1, after=2) dict[str, pandas.DataFrame] [source]
Get median hydrograph
- plot_median_event(scale: float, seasons=None, before=1, after=2, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, color: str = 'red', alpha=1.0) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Plot median hydrograph scale by constant
- plot_classified_flowrate_curve(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, label='', textvalues=True, show=False) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
- plot_ci(seasons=None, laws=['GEV'], methods=['MLE'], fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, alpha=0.1) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Plotting confidence interval
- plot_annual(years=None, hydrol=True, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, withdatemax=True) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Tracé en superposition des différentes années sur l’emprise d’une année civile ou hydrologique
- plot_serie(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, background=True, backcolor='lemonchiffon') tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Tracé de l’ensemble de la série pour toutes les années
- plot_cdf(seasons=None, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, n_bins=100) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Plotting empirical cdf
- plot_T_Qmaxima(seasons=None, empirical_func='Cunnane', fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, alpha=1.0, color_marker_label=None) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Plotting Q vs return period
- plot_maxevents(seasons=None, before=1, after=2, adim=True, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, alpha=0.2, nbevents=None) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Tracé des événements/hydrogrammes associés aux maxima identifiés Les ordonnées sont adimensionnaliées sur base de la valeur maximale
- plot_comp_maxevents(seasons=None, before=1, after=2, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, alpha=0.2, nbevents=None) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Tracé des événements médians Les ordonnées sont adimensionnaliées sur base de la valeur maximale
- plot_one_event(datecenter, before=1, after=2, adim=True, color='k', fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, alpha=0.2) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Tracé d’un événement quelconque autour d’une date
- plot_one_maxevents(season, year, before=1, after=2, adim=True, color='k', fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, alpha=0.2) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Tracé d’un événement spécifique associés au maxima identifié Les ordonnées sont adimensionnaliées sur base de la valeur maximale
- plot_fit(seasons=None, laws=['GEV'], methods=['MLE'], fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, alpha=1.0, styles: dict = None) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Plotting fitted models
- plot_qq(seasons=None, laws=['GEV'], methods=['MLE'], fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Q-Q Plot
Comparaison de la valeur théorique avec la mesure (attention scipy.probploit n’utilise pas Cunnane mais Filliben cf https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.probplot.html)
- plot_summary(seasons=None, nb_laws=None, forced_laws=[], sort: Literal[RSS, AICc, AIC, BIC] = 'RSS', fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
Plot summary results.
- Parameters:
n_top (int, optional) – Show the top number of results. The default is None.
figsize (tuple, optional (default: (10,8))) – The figure size.
ylim (Float, optional (default: None)) – Limit figure in y-axis.
fig (Figure, optional (default: None)) – Matplotlib figure
ax (Axes, optional (default: None)) – Matplotlib Axes object
- Return type:
tuple (fig, ax)
- class wolfhece.eva.pyseries.EVA_Series(data, datetime_index=None, datetime_format='%Y%m%d%H%M%S', data_headers=('#DateHeure', 'Debit'), startmonth_winter=10, startmonth_summer=4, hydrol=True)[source]
-
- plot_T_Qmaxima(seasons=None, empirical_func='Cunnane', fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, alpha=1.0, color_marker_label=None) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
- plot_fit(seasons=None, laws=['GEV'], methods=['MLE'], fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False, alpha=1.0, styles: dict = None) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
- get_q_from_T(return_periods: list = [5, 10, 15, 20, 25, 50, 75, 100, 200, 500, 1000], season: str = 'best', law: str = 'best', method: str = 'MLE', ic=False) pandas.DataFrame [source]
- get_T_from_q(q: list, season: str = 'best', law: str = 'best', method: str = 'MLE', ic=False) pandas.DataFrame [source]
- save_q_from_T(filename: str = '', return_periods=[5, 10, 15, 20, 25, 50, 75, 100, 200, 500, 1000], season='best', law='best', method='MLE', ic=False)[source]
- save_T_from_q(filename: str = '', q=[5, 10, 15, 20, 25, 50, 75, 100, 200, 500, 1000], season='best', law='best', method='MLE', ic=False)[source]
- find_maxima(excluded_years=[], hydrol=True, method: Literal[BM, POT] = 'BM', threshold: float = 0.0, r: pandas.Timedelta | Any = '24H', verbose=True)[source]
Recherche des maxima pour toutes les saisons et toutes les durées
- create_all_durations(durations=[1], verbose=True)[source]
Création des chroniques pour toutes les durées souhaitées [heures]
- bake_data(durations=[1], excluded_years=[], hydrol=True, method: Literal[BM, POT] = 'BM', threshold: float = 0.0, r: pandas.Timedelta | Any = '24H', verbose=True)[source]
- plot_series(durations=None, oneyear=True, show=False, background=True, backcolor='lemonchiffon')[source]
Viauslaisation des chroniques
- plots_spw(stationcode: str, fontsize: int = 12, width=20, height=10, durations=[1], backcolor='lemonchiffon')[source]
- eva(durations=[1], laws='popular', hydrol=True, excluded_years=[], plot=True, method: Literal[BM, POT] = 'BM', threshold: float = 0.0, r: pandas.Timedelta | Any = '24H', verbose=True, show=False) dict[str, tuple] [source]
Extreme Value Analysis
durations : (list) durations in hours - default [1] laws : (str) laws to fit - default ‘GEV’ hydrol : (bool) use hydrological year - default True excluded_years : (list) years to exclude plot : (bool) creation of different plots method : (str) selection of maxima - default ‘BM’ == Block Maxima
return : dict of tuples (fig,axes) of the plots
- evaluate_ci(seasons=None, durations=[1], laws=['GEV'], nboot=100, show=False) dict [source]
Intervalles de confiance
Retourne une liste contenant des tuples (fig,ax) pour chaque durée et chaque saison
La boucle principale est sur les durées La boucle interne est sur les saisons
- evaluate_ic(seasons=None, durations=[1], laws=['GEV'], nboot=100, show=False) dict [source]
alias evaluate_ci
- plot_qdf(seasons=None, durations=None, law='GEV', show=False)[source]
Graphique de toutes les relations fittées pour chaque durée sur une même figure
- select_best_func(season='mixture', law='GEV', method='MLE')[source]
Sélection de la fonction à retenir comme meilleur ajustement
- get_one_MFSH(rising_time: float = 6.0, return_period: float = 50.0, deltat: float = 1.0) wolfhece.eva.hydrogramme_mono.Hydro_HSMF [source]
- opti_mfsh(label, rising_time=6, return_period=[2, 5, 10, 25, 50, 100, 200, 500, 1000], deltat=1)[source]
## CALCUL DES HYDROGRAMMES ##
- plot_msfh(label, return_period=[2, 5, 10, 25, 50, 100, 200, 500, 1000], ref_season='annual', ylim=None, before=1, after=3, show=False) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes, matplotlib.axes.Axes] [source]
## GRAPHIQUES ##
- plot_msfh_mainplot(label, return_period=[2, 5, 10, 25, 50, 100, 200, 500, 1000], ref_season='annual', ylim=None, before=1, after=2, show=False) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] [source]
## GRAPHIQUES ##
- save_msfh(label, filename, return_period=[2, 5, 10, 25, 50, 100, 200, 500, 1000])[source]
## SAUVEGARDE ##