An error occurred while loading the file. Please try again.
-
Pierre-Antoine Rouby authored52c4eec7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from extreme_estimator.estimator.full_estimator.abstract_full_estimator import SmoothMarginalsThenUnitaryMsp, \
FullEstimatorInASingleStepWithSmoothMargin
from extreme_estimator.estimator.max_stable_estimator.abstract_max_stable_estimator import MaxStableEstimator
from extreme_estimator.extreme_models.margin_model.smooth_margin_model import LinearAllParametersAllDimsMarginModel, \
ConstantMarginModel
from extreme_estimator.extreme_models.max_stable_model.abstract_max_stable_model import \
AbstractMaxStableModelWithCovarianceFunction, CovarianceFunction
from extreme_estimator.extreme_models.max_stable_model.max_stable_models import Smith, BrownResnick, Schlather, \
Geometric, ExtremalT, ISchlather
from experiment.meteo_france_SCM_study.safran.safran import Safran
from spatio_temporal_dataset.coordinates.spatial_coordinates.alps_station_3D_coordinates import \
AlpsStation3DCoordinatesWithAnisotropy
from spatio_temporal_dataset.coordinates.spatial_coordinates.generated_spatial_coordinates import \
CircleSpatialCoordinates
from spatio_temporal_dataset.coordinates.spatio_temporal_coordinates.generated_spatio_temporal_coordinates import \
UniformSpatioTemporalCoordinates
from spatio_temporal_dataset.coordinates.spatial_coordinates.coordinates_1D import UniformSpatialCoordinates
from spatio_temporal_dataset.coordinates.temporal_coordinates.generated_temporal_coordinates import ConsecutiveTemporalCoordinates
"""
Common objects to load for the test.
Sometimes it doesn't cover all the class (e.g margin_model, coordinates...)
In this case, unit test (at least on the constructor) must be ensured in the test relative to the class
"""
TEST_MAX_STABLE_MODEL = [Smith, BrownResnick, Schlather, Geometric, ExtremalT, ISchlather]
TEST_1D_AND_2D_SPATIAL_COORDINATES = [UniformSpatialCoordinates, CircleSpatialCoordinates]
TEST_3D_SPATIAL_COORDINATES = [AlpsStation3DCoordinatesWithAnisotropy]
TEST_TEMPORAL_COORDINATES = [ConsecutiveTemporalCoordinates]
TEST_SPATIO_TEMPORAL_COORDINATES = [UniformSpatioTemporalCoordinates]
TEST_MARGIN_TYPES = [ConstantMarginModel, LinearAllParametersAllDimsMarginModel][:]
TEST_MAX_STABLE_ESTIMATOR = [MaxStableEstimator]
TEST_FULL_ESTIMATORS = [SmoothMarginalsThenUnitaryMsp, FullEstimatorInASingleStepWithSmoothMargin][:]
def load_test_full_estimators(dataset, margin_model, max_stable_model):
return [full_estimator(dataset=dataset, margin_model=margin_model, max_stable_model=max_stable_model) for
full_estimator in TEST_FULL_ESTIMATORS]
def load_test_max_stable_estimators(dataset, max_stable_model):
return [max_stable_estimator(dataset, max_stable_model) for max_stable_estimator in TEST_MAX_STABLE_ESTIMATOR]
def load_smooth_margin_models(coordinates):
return [margin_class(coordinates=coordinates) for margin_class in TEST_MARGIN_TYPES]
def load_test_max_stable_models(only_one_covariance_function=False):
default_covariance_function = CovarianceFunction.cauchy
# Load all max stable model
max_stable_models = []
for max_stable_class in TEST_MAX_STABLE_MODEL:
if issubclass(max_stable_class, AbstractMaxStableModelWithCovarianceFunction):
if only_one_covariance_function:
max_stable_models.append(max_stable_class(covariance_function=default_covariance_function))
else:
max_stable_models.extend([max_stable_class(covariance_function=covariance_function)
for covariance_function in CovarianceFunction])
else:
max_stable_models.append(max_stable_class())
return max_stable_models
def load_test_spatial_coordinates(nb_points, coordinate_types, train_split_ratio=None):
return [coordinate_class.from_nb_points(nb_points=nb_points, train_split_ratio=train_split_ratio)
for coordinate_class in coordinate_types]
def load_test_1D_and_2D_spatial_coordinates(nb_points, train_split_ratio=None):
return load_test_spatial_coordinates(nb_points, TEST_1D_AND_2D_SPATIAL_COORDINATES,
train_split_ratio=train_split_ratio)
def load_test_3D_spatial_coordinates(nb_points):
return load_test_spatial_coordinates(nb_points, TEST_3D_SPATIAL_COORDINATES)
def load_test_temporal_coordinates(nb_steps, train_split_ratio=None):
return [coordinate_class.from_nb_temporal_steps(nb_steps, train_split_ratio) for coordinate_class in
TEST_TEMPORAL_COORDINATES]
def load_test_spatiotemporal_coordinates(nb_points, nb_steps, train_split_ratio=None):
return [coordinate_class.from_nb_points_and_nb_steps(nb_points=nb_points, nb_steps=nb_steps,
train_split_ratio=train_split_ratio)
for coordinate_class in TEST_SPATIO_TEMPORAL_COORDINATES]
def load_safran_objects():
nb_days_list = [1, 3, 5][:1]
safran_altitude_list = [1800, 2400][:1]
return [Safran(safran_altitude, nb_days) for safran_altitude in safran_altitude_list for nb_days in nb_days_list]