diff --git a/experiment/eurocode_data/eurocode_region.py b/experiment/eurocode_data/eurocode_region.py index 722cc33dbc60ebbfca20f3aaa6f78a451d113a51..cb92c1abbe32274720a2512839a2802eac5fabf8 100644 --- a/experiment/eurocode_data/eurocode_region.py +++ b/experiment/eurocode_data/eurocode_region.py @@ -42,7 +42,7 @@ class AbstractEurocodeRegion(object): def plot_max_loading(self, ax, altitudes): ax.plot(altitudes, [self.eurocode_max_loading(altitude) for altitude in altitudes], - label='Eurocode limit') + label='Eurocode limit', color='k') class C1(AbstractEurocodeRegion): diff --git a/experiment/eurocode_data/eurocode_visualizer.py b/experiment/eurocode_data/eurocode_visualizer.py index b5231235247479290a877397e1889394760561b6..69c80f60b31f1e4c30aacb079d4951000e462e7a 100644 --- a/experiment/eurocode_data/eurocode_visualizer.py +++ b/experiment/eurocode_data/eurocode_visualizer.py @@ -9,7 +9,7 @@ from experiment.meteo_france_data.scm_models_data.visualization.utils import cre def plot_model_name_to_dep_to_ordered_return_level_uncertainties( - dep_to_model_name_to_ordered_return_level_uncertainties, show=True): + dep_to_model_name_to_ordered_return_level_uncertainties, altitudes, show=True): # Create a 9 x 9 plot axes = create_adjusted_axes(3, 3) axes = list(axes.flatten()) @@ -21,6 +21,7 @@ def plot_model_name_to_dep_to_ordered_return_level_uncertainties( ax_to_departement = dict(zip(axes, DEPARTEMENT_TYPES[::-1])) for ax, departement in ax_to_departement.items(): plot_dep_to_model_name_dep_to_ordered_return_level_uncertainties(ax, departement, + altitudes, dep_to_model_name_to_ordered_return_level_uncertainties[ departement] ) @@ -35,11 +36,11 @@ def plot_model_name_to_dep_to_ordered_return_level_uncertainties( def plot_dep_to_model_name_dep_to_ordered_return_level_uncertainties(ax, dep_class, + altitudes, model_name_to_ordered_return_level_uncertainties: Dict[str, List[ EurocodeLevelUncertaintyFromExtremes]]): colors = ['red', 'blue', 'green'] - altitudes = EUROCODE_ALTITUDES alpha = 0.2 # Display the EUROCODE return level dep_object = dep_class() @@ -48,10 +49,11 @@ def plot_dep_to_model_name_dep_to_ordered_return_level_uncertainties(ax, dep_cla for color, (model_name, ordered_return_level_uncertaines) in zip(colors, model_name_to_ordered_return_level_uncertainties.items()): mean = [r.posterior_mean for r in ordered_return_level_uncertaines] - ax.plot(altitudes, mean, '-', color=color) + ax.plot(altitudes, mean, '-', color=color, label=model_name) lower_bound = [r.poster_uncertainty_interval[0] for r in ordered_return_level_uncertaines] upper_bound = [r.poster_uncertainty_interval[1] for r in ordered_return_level_uncertaines] ax.fill_between(altitudes, lower_bound, upper_bound, color=color, alpha=alpha) + ax.legend() ax.set_title(str(dep_object)) - ax.set_ylabel('Maximum {} quantile (in N $m^-2$)'.format(EUROCODE_QUANTILE)) + ax.set_ylabel('Maximum {} quantile in 2017 (in N $m^-2$)'.format(EUROCODE_QUANTILE)) ax.set_xlabel('Altitude') diff --git a/experiment/eurocode_data/main_eurocode_drawing.py b/experiment/eurocode_data/main_eurocode_drawing.py index f556101796b0c321703782eefc6f58247da70077..af8a080098c3b32b2b0026464a279ddb202fbbb2 100644 --- a/experiment/eurocode_data/main_eurocode_drawing.py +++ b/experiment/eurocode_data/main_eurocode_drawing.py @@ -1,3 +1,4 @@ +import time from collections import OrderedDict from experiment.eurocode_data.eurocode_visualizer import plot_model_name_to_dep_to_ordered_return_level_uncertainties @@ -8,19 +9,19 @@ from experiment.meteo_france_data.scm_models_data.visualization.hypercube_visual AltitudeHypercubeVisualizer from experiment.meteo_france_data.scm_models_data.visualization.hypercube_visualization.utils_hypercube import \ load_altitude_visualizer -from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import StationaryStationModel, \ - NonStationaryLocationAndScaleModel +from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import StationaryTemporalModel, \ + NonStationaryLocationAndScaleTemporalModel from root_utils import get_display_name_from_object_type # Model class -def dep_to_ordered_return_level_uncertainties(model_class, last_year_for_the_data): - model_name = get_display_name_from_object_type(type(model_class)) + ' ' + str(last_year_for_the_data) +def dep_to_ordered_return_level_uncertainties(model_class, last_year_for_the_data, altitudes): + model_class_str = get_display_name_from_object_type(model_class).split('TemporalModel')[0] + model_name = model_class_str + ' 1958-' + str(last_year_for_the_data) # Load altitude visualizer - # todo: add last years attributes that enables to change the years - altitude_visualizer = load_altitude_visualizer(AltitudeHypercubeVisualizer, altitudes=EUROCODE_ALTITUDES, + altitude_visualizer = load_altitude_visualizer(AltitudeHypercubeVisualizer, altitudes=altitudes, last_starting_year=None, nb_data_reduced_for_speed=False, only_first_one=False, save_to_file=False, exact_starting_year=1958, @@ -30,7 +31,8 @@ def dep_to_ordered_return_level_uncertainties(model_class, last_year_for_the_dat # Loop on the data assert isinstance(altitude_visualizer.tuple_to_study_visualizer, OrderedDict) dep_to_ordered_return_level_uncertainty = {dep: [] for dep in DEPARTEMENT_TYPES} - for visualizer in altitude_visualizer.tuple_to_study_visualizer.values(): + for altitude, visualizer in altitude_visualizer.tuple_to_study_visualizer.items(): + print('{} processing altitude = {} '.format(model_name, altitude)) dep_to_return_level_uncertainty = visualizer.dep_class_to_eurocode_level_uncertainty(model_class, last_year_for_the_data) for dep, return_level_uncertainty in dep_to_return_level_uncertainty.items(): dep_to_ordered_return_level_uncertainty[dep].append(return_level_uncertainty) @@ -39,15 +41,25 @@ def dep_to_ordered_return_level_uncertainties(model_class, last_year_for_the_dat def main_drawing(): + # Select parameters + fast_plot = [True, False][1] model_class_and_last_year = [ - (StationaryStationModel, LAST_YEAR_FOR_EUROCODE), - (StationaryStationModel, 2017), - (NonStationaryLocationAndScaleModel, 2017), - ][:1] + (StationaryTemporalModel, LAST_YEAR_FOR_EUROCODE), + (StationaryTemporalModel, 2017), + (NonStationaryLocationAndScaleTemporalModel, 2017), + ][:] + altitudes = EUROCODE_ALTITUDES[:] + if fast_plot: + model_class_and_last_year = model_class_and_last_year[:1] + altitudes = altitudes[:2] + model_name_to_dep_to_ordered_return_level = {} for model_class, last_year_for_the_data in model_class_and_last_year: + start = time.time() model_name_to_dep_to_ordered_return_level.update( - dep_to_ordered_return_level_uncertainties(model_class, last_year_for_the_data)) + dep_to_ordered_return_level_uncertainties(model_class, last_year_for_the_data, altitudes)) + duration = time.time() - start + print(model_class, duration) # Transform the dictionary into the desired format dep_to_model_name_to_ordered_return_level_uncertainties = {} for dep in DEPARTEMENT_TYPES: @@ -56,7 +68,7 @@ def main_drawing(): dep_to_model_name_to_ordered_return_level_uncertainties[dep] = d2 # Plot graph plot_model_name_to_dep_to_ordered_return_level_uncertainties( - dep_to_model_name_to_ordered_return_level_uncertainties, show=True) + dep_to_model_name_to_ordered_return_level_uncertainties, altitudes, show=True) if __name__ == '__main__': diff --git a/experiment/eurocode_data/utils.py b/experiment/eurocode_data/utils.py index f293fdcdc09ab6fbe49aad97511fbc8f600379fb..c8476c6fb0346c020b9d88d394550aebfacfa5e3 100644 --- a/experiment/eurocode_data/utils.py +++ b/experiment/eurocode_data/utils.py @@ -2,7 +2,7 @@ # Eurocode quantile correspond to a 50 year return period EUROCODE_QUANTILE = 0.98 # Altitudes (between low and mid altitudes) < 2000m -EUROCODE_ALTITUDES = [900, 1200, 1500, 1800][:2] +EUROCODE_ALTITUDES = [900, 1200, 1500, 1800] # Last year taken into account for the Eurocode # Date of publication was 2014, therefore the winter 2013/2014 could not have been measured # Therefore, the winter 2012/2013 was the last one. Thus, 2012 is the last year for the Eurocode diff --git a/experiment/trend_analysis/non_stationary_trends.py b/experiment/trend_analysis/non_stationary_trends.py index ab4debc4f54722d021ee1e58805fcdc15ef7ccaa..2f62913ce7cd978fc6f7f6236597959f11ca5668 100644 --- a/experiment/trend_analysis/non_stationary_trends.py +++ b/experiment/trend_analysis/non_stationary_trends.py @@ -13,7 +13,7 @@ from extreme_fit.estimator.margin_estimator.abstract_margin_estimator import Lin from extreme_fit.model.margin_model.linear_margin_model.linear_margin_model import \ LinearStationaryMarginModel, LinearNonStationaryLocationMarginModel from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import \ - StationaryStationModel, NonStationaryLocationStationModel + StationaryTemporalModel, NonStationaryLocationTemporalModel from extreme_fit.model.margin_model.margin_function.linear_margin_function import LinearMarginFunction from extreme_fit.model.utils import OptimizationConstants from spatio_temporal_dataset.dataset.abstract_dataset import AbstractDataset @@ -179,8 +179,8 @@ class IndependenceLocationTrendTest(AbstractNonStationaryTrendTest): def __init__(self, station_name, *args, **kwargs): super().__init__(*args, **kwargs, estimator_class=LinearMarginEstimator, - stationary_margin_model_class=StationaryStationModel, - non_stationary_margin_model_class=NonStationaryLocationStationModel) + stationary_margin_model_class=StationaryTemporalModel, + non_stationary_margin_model_class=NonStationaryLocationTemporalModel) self.station_name = station_name @property diff --git a/experiment/trend_analysis/univariate_test/abstract_comparison_non_stationary_model.py b/experiment/trend_analysis/univariate_test/abstract_comparison_non_stationary_model.py index e7a64a34dca8ac73729c130d9b7febcac3270b2d..51f0cc77ef9248bf66a7b8716f9e7315cab26559 100644 --- a/experiment/trend_analysis/univariate_test/abstract_comparison_non_stationary_model.py +++ b/experiment/trend_analysis/univariate_test/abstract_comparison_non_stationary_model.py @@ -1,7 +1,7 @@ from experiment.trend_analysis.univariate_test.abstract_gev_trend_test import AbstractGevTrendTest from experiment.trend_analysis.univariate_test.gev_trend_test_two_parameters import GevLocationAndScaleTrendTest from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import \ - NonStationaryLocationStationModel, NonStationaryScaleStationModel + NonStationaryLocationTemporalModel, NonStationaryScaleTemporalModel import numpy as np @@ -28,10 +28,10 @@ class AbstractComparisonNonStationaryModelOneParameter(AbstractComparisonNonStat class ComparisonAgainstMu(AbstractComparisonNonStationaryModelOneParameter, GevLocationAndScaleTrendTest): def __init__(self, years, maxima, starting_year): - super().__init__(years, maxima, starting_year, constrained_model_class=NonStationaryLocationStationModel) + super().__init__(years, maxima, starting_year, constrained_model_class=NonStationaryLocationTemporalModel) class ComparisonAgainstSigma(AbstractComparisonNonStationaryModelOneParameter, GevLocationAndScaleTrendTest): def __init__(self, years, maxima, starting_year): - super().__init__(years, maxima, starting_year, constrained_model_class=NonStationaryScaleStationModel) + super().__init__(years, maxima, starting_year, constrained_model_class=NonStationaryScaleTemporalModel) diff --git a/experiment/trend_analysis/univariate_test/abstract_gev_trend_test.py b/experiment/trend_analysis/univariate_test/abstract_gev_trend_test.py index cbea66c2a8f10d8edaccc9a42652d5bab2c3f399..6a53254834d979067306d909cc1ec15ca5dbf889 100644 --- a/experiment/trend_analysis/univariate_test/abstract_gev_trend_test.py +++ b/experiment/trend_analysis/univariate_test/abstract_gev_trend_test.py @@ -11,7 +11,7 @@ from extreme_fit.estimator.margin_estimator.abstract_margin_estimator import Lin from extreme_fit.model.margin_model.linear_margin_model.abstract_temporal_linear_margin_model import \ AbstractTemporalLinearMarginModel from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import \ - StationaryStationModel + StationaryTemporalModel from extreme_fit.model.utils import SafeRunException from extreme_fit.distribution.gev.gev_params import GevParams from spatio_temporal_dataset.coordinates.abstract_coordinates import AbstractCoordinates @@ -24,7 +24,7 @@ class AbstractGevTrendTest(AbstractUnivariateTest): nb_years_for_quantile_evolution = 10 def __init__(self, years, maxima, starting_year, unconstrained_model_class, - constrained_model_class=StationaryStationModel, + constrained_model_class=StationaryTemporalModel, fit_method=AbstractTemporalLinearMarginModel.ISMEV_GEV_FIT_METHOD_STR): super().__init__(years, maxima, starting_year) self.fit_method = fit_method diff --git a/experiment/trend_analysis/univariate_test/gev_trend_test_one_parameter.py b/experiment/trend_analysis/univariate_test/gev_trend_test_one_parameter.py index 27e2322bbaf1ed058b8ab1e209d82914ddbbf70a..9883777ab4069d97d3f3b01afb8379d2330ccfa9 100644 --- a/experiment/trend_analysis/univariate_test/gev_trend_test_one_parameter.py +++ b/experiment/trend_analysis/univariate_test/gev_trend_test_one_parameter.py @@ -1,6 +1,6 @@ from experiment.trend_analysis.univariate_test.abstract_gev_trend_test import AbstractGevTrendTest from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import \ - NonStationaryLocationStationModel, NonStationaryScaleStationModel, NonStationaryShapeStationModel + NonStationaryLocationTemporalModel, NonStationaryScaleTemporalModel, NonStationaryShapeTemporalModel from extreme_fit.distribution.gev.gev_params import GevParams @@ -23,7 +23,7 @@ class GevLocationTrendTest(GevTrendTestOneParameter): def __init__(self, years, maxima, starting_year): super().__init__(years, maxima, starting_year, - NonStationaryLocationStationModel, GevParams.LOC) + NonStationaryLocationTemporalModel, GevParams.LOC) def _slope_strength(self): return self.non_stationary_constant_gev_params.quantile_strength_evolution(p=self.quantile_for_strength, @@ -44,7 +44,7 @@ class GevScaleTrendTest(GevTrendTestOneParameter): def __init__(self, years, maxima, starting_year): super().__init__(years, maxima, starting_year, - NonStationaryScaleStationModel, GevParams.SCALE) + NonStationaryScaleTemporalModel, GevParams.SCALE) def _slope_strength(self): return self.non_stationary_constant_gev_params.quantile_strength_evolution( @@ -67,4 +67,4 @@ class GevShapeTrendTest(GevTrendTestOneParameter): def __init__(self, years, maxima, starting_year): super().__init__(years, maxima, starting_year, - NonStationaryShapeStationModel, GevParams.SHAPE) + NonStationaryShapeTemporalModel, GevParams.SHAPE) diff --git a/experiment/trend_analysis/univariate_test/gev_trend_test_two_parameters.py b/experiment/trend_analysis/univariate_test/gev_trend_test_two_parameters.py index be3671dfa9afda80f54ac1d8addf8320fdd39b8b..8545642742a9f4ced0aaedb4805dbf174d5dd28f 100644 --- a/experiment/trend_analysis/univariate_test/gev_trend_test_two_parameters.py +++ b/experiment/trend_analysis/univariate_test/gev_trend_test_two_parameters.py @@ -1,6 +1,6 @@ from experiment.trend_analysis.univariate_test.abstract_gev_trend_test import AbstractGevTrendTest from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import \ - NonStationaryLocationAndScaleModel, StationaryStationModel + NonStationaryLocationAndScaleTemporalModel, StationaryTemporalModel from extreme_fit.distribution.gev.gev_params import GevParams @@ -13,9 +13,9 @@ class GevTrendTestTwoParameters(AbstractGevTrendTest): class GevLocationAndScaleTrendTest(GevTrendTestTwoParameters): - def __init__(self, years, maxima, starting_year, constrained_model_class=StationaryStationModel): + def __init__(self, years, maxima, starting_year, constrained_model_class=StationaryTemporalModel): super().__init__(years, maxima, starting_year, - NonStationaryLocationAndScaleModel, constrained_model_class=constrained_model_class) + NonStationaryLocationAndScaleTemporalModel, constrained_model_class=constrained_model_class) @property def mu1(self): diff --git a/extreme_fit/model/margin_model/linear_margin_model/temporal_linear_margin_models.py b/extreme_fit/model/margin_model/linear_margin_model/temporal_linear_margin_models.py index 1efcf41ad52678fbf911715ef58d21e4f5df364f..33d267bc8dd8667249101b13a0aab241c285e411 100644 --- a/extreme_fit/model/margin_model/linear_margin_model/temporal_linear_margin_models.py +++ b/extreme_fit/model/margin_model/linear_margin_model/temporal_linear_margin_models.py @@ -4,13 +4,13 @@ from extreme_fit.model.utils import r from extreme_fit.distribution.gev.gev_params import GevParams -class StationaryStationModel(AbstractTemporalLinearMarginModel): +class StationaryTemporalModel(AbstractTemporalLinearMarginModel): def load_margin_functions(self, gev_param_name_to_dims=None): super().load_margin_functions({}) -class NonStationaryLocationStationModel(AbstractTemporalLinearMarginModel): +class NonStationaryLocationTemporalModel(AbstractTemporalLinearMarginModel): def load_margin_functions(self, gev_param_name_to_dims=None): super().load_margin_functions({GevParams.LOC: [self.coordinates.idx_temporal_coordinates]}) @@ -20,7 +20,7 @@ class NonStationaryLocationStationModel(AbstractTemporalLinearMarginModel): return 1 -class NonStationaryScaleStationModel(AbstractTemporalLinearMarginModel): +class NonStationaryScaleTemporalModel(AbstractTemporalLinearMarginModel): def load_margin_functions(self, gev_param_name_to_dims=None): super().load_margin_functions({GevParams.SCALE: [self.coordinates.idx_temporal_coordinates]}) @@ -30,7 +30,7 @@ class NonStationaryScaleStationModel(AbstractTemporalLinearMarginModel): return 1 -class NonStationaryLogScaleStationModel(NonStationaryScaleStationModel): +class NonStationaryLogScaleTemporalModel(NonStationaryScaleTemporalModel): def load_margin_functions(self, gev_param_name_to_dims=None): super().load_margin_functions({GevParams.SCALE: [self.coordinates.idx_temporal_coordinates]}) @@ -40,7 +40,7 @@ class NonStationaryLogScaleStationModel(NonStationaryScaleStationModel): return r('exp') -class NonStationaryShapeStationModel(AbstractTemporalLinearMarginModel): +class NonStationaryShapeTemporalModel(AbstractTemporalLinearMarginModel): def load_margin_functions(self, gev_param_name_to_dims=None): super().load_margin_functions({GevParams.SHAPE: [self.coordinates.idx_temporal_coordinates]}) @@ -50,7 +50,7 @@ class NonStationaryShapeStationModel(AbstractTemporalLinearMarginModel): return 1 -class NonStationaryLocationAndScaleModel(AbstractTemporalLinearMarginModel): +class NonStationaryLocationAndScaleTemporalModel(AbstractTemporalLinearMarginModel): def load_margin_functions(self, gev_param_name_to_dims=None): super().load_margin_functions({GevParams.LOC: [self.coordinates.idx_temporal_coordinates], diff --git a/test/test_experiment/test_region_eurocode.py b/test/test_experiment/test_region_eurocode.py index 4aa64fb10b1e94ffa731f5ffe1d30e7b300bfe34..48db73b554cdc210f14e5e30305e0192a65d2dac 100644 --- a/test/test_experiment/test_region_eurocode.py +++ b/test/test_experiment/test_region_eurocode.py @@ -12,12 +12,21 @@ class TestCoordinateSensitivity(unittest.TestCase): def test_departement_eurocode_plot(self): # Create an example - example = EurocodeLevelUncertaintyFromExtremes(posterior_mean=1.0, + example1 = EurocodeLevelUncertaintyFromExtremes(posterior_mean=1.0, poster_uncertainty_interval=(0.5, 1.25)) + example2 = EurocodeLevelUncertaintyFromExtremes(posterior_mean=0.2, + poster_uncertainty_interval=(0.1, 0.35)) + example3 = EurocodeLevelUncertaintyFromExtremes(posterior_mean=0.4, + poster_uncertainty_interval=(0.25, 0.6)) + altitude_examples = EUROCODE_ALTITUDES[:2] dep_to_model_name_toreturn_level_uncertainty = { - dep: {"example": [example for _ in EUROCODE_ALTITUDES]} for dep in DEPARTEMENT_TYPES + dep: {"example1": [example1 for _ in altitude_examples], + "example2": [example2 for _ in altitude_examples], + "example3": [example3 for _ in altitude_examples], + } for dep in DEPARTEMENT_TYPES } plot_model_name_to_dep_to_ordered_return_level_uncertainties(dep_to_model_name_toreturn_level_uncertainty, + altitudes=altitude_examples, show=self.DISPLAY) diff --git a/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_temporal.py b/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_temporal.py index 097b17b28472190418b74180cc2419d64e0701b5..8e96aa051ad031d70a32c4b44b74d8884294079d 100644 --- a/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_temporal.py +++ b/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_temporal.py @@ -4,8 +4,8 @@ import numpy as np import pandas as pd from extreme_fit.estimator.margin_estimator.abstract_margin_estimator import LinearMarginEstimator -from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import StationaryStationModel, \ - NonStationaryLocationStationModel +from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import StationaryTemporalModel, \ + NonStationaryLocationTemporalModel from extreme_fit.model.utils import r, set_seed_r from spatio_temporal_dataset.coordinates.abstract_coordinates import AbstractCoordinates from spatio_temporal_dataset.coordinates.temporal_coordinates.abstract_temporal_coordinates import \ @@ -36,7 +36,7 @@ class TestGevTemporal(unittest.TestCase): def test_gev_temporal_margin_fit_stationary(self): # Create estimator - margin_model = StationaryStationModel(self.coordinates) + margin_model = StationaryTemporalModel(self.coordinates) estimator = LinearMarginEstimator(self.dataset, margin_model) estimator.fit() ref = {'loc': 0.0219, 'scale': 1.0347, 'shape': 0.8295} @@ -71,7 +71,7 @@ class TestGevTemporal(unittest.TestCase): self.assertNotEqual(mle_params_estimated_year5, mle_params_estimated_year3) def fit_non_stationary_estimator(self, starting_point): - margin_model = NonStationaryLocationStationModel(self.coordinates, starting_point=starting_point + self.start_year) + margin_model = NonStationaryLocationTemporalModel(self.coordinates, starting_point=starting_point + self.start_year) estimator = LinearMarginEstimator(self.dataset, margin_model) estimator.fit() return estimator diff --git a/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_temporal_bayesian.py b/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_temporal_bayesian.py index 9c85fdb3f68ab6edf3b46361bd6ef79cb0777d12..ddde2c1a7abd248352dfef76a347b20b64b8624e 100644 --- a/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_temporal_bayesian.py +++ b/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_temporal_bayesian.py @@ -8,8 +8,8 @@ from extreme_fit.distribution.gev.gev_params import GevParams from extreme_fit.estimator.margin_estimator.abstract_margin_estimator import LinearMarginEstimator from extreme_fit.model.margin_model.linear_margin_model.abstract_temporal_linear_margin_model import \ AbstractTemporalLinearMarginModel -from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import StationaryStationModel, \ - NonStationaryLocationStationModel, NonStationaryLocationAndScaleModel +from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import StationaryTemporalModel, \ + NonStationaryLocationTemporalModel, NonStationaryLocationAndScaleTemporalModel from extreme_fit.model.result_from_model_fit.result_from_extremes import ResultFromExtremes from extreme_fit.model.utils import r, set_seed_r from spatio_temporal_dataset.coordinates.abstract_coordinates import AbstractCoordinates @@ -42,7 +42,7 @@ class TestGevTemporalBayesian(unittest.TestCase): def test_gev_temporal_margin_fit_stationary(self): # Create estimator - estimator_fitted = fitted_linear_margin_estimator(StationaryStationModel, self.coordinates, self.dataset, + estimator_fitted = fitted_linear_margin_estimator(StationaryTemporalModel, self.coordinates, self.dataset, starting_year=0, fit_method=AbstractTemporalLinearMarginModel.EXTREMES_FEVD_BAYESIAN_FIT_METHOD_STR) ref = {'loc': 0.30440183718071845, 'scale': 1.301639258861012, 'shape': 0.303652401064773} @@ -53,7 +53,7 @@ class TestGevTemporalBayesian(unittest.TestCase): def test_gev_temporal_margin_fit_non_stationary_location(self): # Create estimator - estimator = fitted_linear_margin_estimator(NonStationaryLocationStationModel, self.coordinates, self.dataset, + estimator = fitted_linear_margin_estimator(NonStationaryLocationTemporalModel, self.coordinates, self.dataset, starting_year=0, fit_method=AbstractTemporalLinearMarginModel.EXTREMES_FEVD_BAYESIAN_FIT_METHOD_STR) mu1_values = estimator.result_from_model_fit.df_posterior_samples.iloc[:, 1] @@ -65,7 +65,7 @@ class TestGevTemporalBayesian(unittest.TestCase): def test_gev_temporal_margin_fit_non_stationary_location_and_scale(self): # Create estimator - estimator = fitted_linear_margin_estimator(NonStationaryLocationAndScaleModel, self.coordinates, self.dataset, + estimator = fitted_linear_margin_estimator(NonStationaryLocationAndScaleTemporalModel, self.coordinates, self.dataset, starting_year=0, fit_method=AbstractTemporalLinearMarginModel.EXTREMES_FEVD_BAYESIAN_FIT_METHOD_STR) mu1_values = estimator.result_from_model_fit.df_posterior_samples.iloc[:, 1] diff --git a/test/test_utils.py b/test/test_utils.py index e9536f80e8d996a2b42e33ff227c2b9e755333bc..c9faaed7165a98d4ae83363716e181dd36caa1d0 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -9,7 +9,7 @@ from extreme_fit.estimator.max_stable_estimator.abstract_max_stable_estimator im from extreme_fit.model.margin_model.linear_margin_model.linear_margin_model import LinearAllParametersAllDimsMarginModel, \ ConstantMarginModel from extreme_fit.model.margin_model.linear_margin_model.temporal_linear_margin_models import \ - NonStationaryLocationStationModel, NonStationaryScaleStationModel, NonStationaryShapeStationModel + NonStationaryLocationTemporalModel, NonStationaryScaleTemporalModel, NonStationaryShapeTemporalModel from extreme_fit.model.max_stable_model.abstract_max_stable_model import \ AbstractMaxStableModelWithCovarianceFunction, CovarianceFunction from extreme_fit.model.max_stable_model.max_stable_models import Smith, BrownResnick, Schlather, \ @@ -40,7 +40,7 @@ TEST_3D_SPATIAL_COORDINATES = [AlpsStation3DCoordinatesWithAnisotropy] TEST_TEMPORAL_COORDINATES = [ConsecutiveTemporalCoordinates] TEST_SPATIO_TEMPORAL_COORDINATES = [UniformSpatioTemporalCoordinates, LinSpaceSpatial2DSpatioTemporalCoordinates] TEST_MARGIN_TYPES = [ConstantMarginModel, LinearAllParametersAllDimsMarginModel][:] -TEST_NON_STATIONARY_TEMPORAL_MARGIN_TYPES = [NonStationaryLocationStationModel, NonStationaryScaleStationModel, NonStationaryShapeStationModel] +TEST_NON_STATIONARY_TEMPORAL_MARGIN_TYPES = [NonStationaryLocationTemporalModel, NonStationaryScaleTemporalModel, NonStationaryShapeTemporalModel] TEST_MAX_STABLE_ESTIMATOR = [MaxStableEstimator] TEST_FULL_ESTIMATORS = [SmoothMarginalsThenUnitaryMsp, FullEstimatorInASingleStepWithSmoothMargin][:]