Skip to content
Snippets Groups Projects
Commit c271db81 authored by lukas leufen's avatar lukas leufen
Browse files

bootstraps calculation can be skipped or already calculated data can be used...

bootstraps calculation can be skipped or already calculated data can be used for the boot skill scores
parent 72f2cb4d
No related branches found
No related tags found
3 merge requests!90WIP: new release update,!89Resolve "release branch / CI on gpu",!61Resolve "REFAC: clean-up bootstrap workflow"
Pipeline #32455 passed
...@@ -38,7 +38,8 @@ class ExperimentSetup(RunEnvironment): ...@@ -38,7 +38,8 @@ class ExperimentSetup(RunEnvironment):
experiment_path=None, plot_path=None, forecast_path=None, overwrite_local_data=None, sampling="daily", experiment_path=None, plot_path=None, forecast_path=None, overwrite_local_data=None, sampling="daily",
create_new_model=None, bootstrap_path=None, permute_data_on_training=False, transformation=None, create_new_model=None, bootstrap_path=None, permute_data_on_training=False, transformation=None,
train_min_length=None, val_min_length=None, test_min_length=None, extreme_values=None, train_min_length=None, val_min_length=None, test_min_length=None, extreme_values=None,
extremes_on_right_tail_only=None, evaluate_bootstraps=True, plot_list=None, number_of_bootstraps=None): extremes_on_right_tail_only=None, evaluate_bootstraps=True, plot_list=None, number_of_bootstraps=None,
create_new_bootstraps=None):
# create run framework # create run framework
super().__init__() super().__init__()
...@@ -130,6 +131,8 @@ class ExperimentSetup(RunEnvironment): ...@@ -130,6 +131,8 @@ class ExperimentSetup(RunEnvironment):
# set post-processing instructions # set post-processing instructions
self._set_param("evaluate_bootstraps", evaluate_bootstraps, scope="general.postprocessing") self._set_param("evaluate_bootstraps", evaluate_bootstraps, scope="general.postprocessing")
create_new_bootstraps = max([self.data_store.get("trainable", "general"), create_new_bootstraps or False])
self._set_param("create_new_bootstraps", create_new_bootstraps, scope="general.postprocessing")
self._set_param("number_of_bootstraps", number_of_bootstraps, default=20, scope="general.postprocessing") self._set_param("number_of_bootstraps", number_of_bootstraps, default=20, scope="general.postprocessing")
self._set_param("plot_list", plot_list, default=DEFAULT_PLOT_LIST, scope="general.postprocessing") self._set_param("plot_list", plot_list, default=DEFAULT_PLOT_LIST, scope="general.postprocessing")
......
...@@ -54,12 +54,12 @@ class PostProcessing(RunEnvironment): ...@@ -54,12 +54,12 @@ class PostProcessing(RunEnvironment):
# bootstraps # bootstraps
if self.data_store.get("evaluate_bootstraps", "general.postprocessing"): if self.data_store.get("evaluate_bootstraps", "general.postprocessing"):
# bootstrap_path = self.data_store.get("bootstrap_path", "general.postprocessing")
# number_of_bootstraps = self.data_store.get("number_of_bootstraps", "general.postprocessing")
# BootStraps(self.test_data, bootstrap_path, number_of_bootstraps)
with TimeTracking(name="split (refac_1): create_boot_straps_refac_2()"): with TimeTracking(name="split (refac_1): create_boot_straps_refac_2()"):
bootstrap_path = self.data_store.get("bootstrap_path", "general.postprocessing") create_new_bootstraps = self.data_store.get("create_new_bootstraps", "general.postprocessing")
number_of_bootstraps = self.data_store.get("number_of_bootstraps", "general.postprocessing") self.bootstrap_postprocessing(create_new_bootstraps)
BootStraps(self.test_data, bootstrap_path, number_of_bootstraps)
self.create_boot_straps()
self.bootstrap_skill_scores = self.calculate_bootstrap_skill_scores()
# skill scores # skill scores
self.skill_scores = self.calculate_skill_scores() self.skill_scores = self.calculate_skill_scores()
...@@ -67,6 +67,20 @@ class PostProcessing(RunEnvironment): ...@@ -67,6 +67,20 @@ class PostProcessing(RunEnvironment):
# plotting # plotting
self.plot() self.plot()
def bootstrap_postprocessing(self, create_new_bootstraps, _iter=0):
try:
if create_new_bootstraps:
self.create_boot_straps()
self.bootstrap_skill_scores = self.calculate_bootstrap_skill_scores()
except FileNotFoundError:
if _iter != 0:
raise RuntimeError("bootstrap_postprocessing is called for the 2nd time. This means, that calling"
"create_boot_straps() couldn't solve the FileNotFoundError. Therefore, please check"
"manually the reason for the failure.")
logging.info("Couldn't load all files, restart bootstrap postprocessing with create_new_bootstraps=True.")
self.bootstrap_postprocessing(True, _iter=1)
def create_boot_straps(self): def create_boot_straps(self):
# forecast # forecast
with TimeTracking(name="boot predictions"): with TimeTracking(name="boot predictions"):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment