From 2b5815bf14a755a9c5320fa5946bca939e09c370 Mon Sep 17 00:00:00 2001 From: Jakob Wessel Date: Sun, 24 Sep 2023 16:26:59 +0100 Subject: [PATCH] Fixed isort checks. --- ibicus/debias/_isimip.py | 9 +++++---- ibicus/debias/_scaled_distribution_mapping.py | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ibicus/debias/_isimip.py b/ibicus/debias/_isimip.py index da1802c..1181107 100644 --- a/ibicus/debias/_isimip.py +++ b/ibicus/debias/_isimip.py @@ -842,7 +842,7 @@ def _step6_adjust_values_between_thresholds( cm_future_sorted_entries_between_thresholds.size == 1 or obs_future_sorted_entries_between_thresholds.size <= 1 ): - logger.warning( + logger.info( "ISIMIP step 6: There are too few values between thresholds in cm_future or the pseudo-future observations for a parametric CDF fit. Instead using nonparametric quantile mapping, between the values in cm_future and the pseudo future observations to calculate the values between threshold." ) @@ -886,7 +886,7 @@ def _step6_adjust_values_between_thresholds( except Exception as e: # If cdf-fits fail quantile map parametrically instead - logger.warning( + logger.info( "ISIMIP step 6: Parametric CDF fit to the cm_future values between thresholds or the pseudo future observations between thresholds failed. This might be due to too few datapoints in each category or numerical optimization issues. Applying nonparametric quantile mapping instead. Error: %s" % e ) @@ -1264,8 +1264,9 @@ def step6(self, obs_hist, obs_future, cm_hist, cm_future): self._get_values_between_thresholds(cm_future_sorted), ) else: - warnings.warn( - """ISIMIP step6: no pseudo-future observations between thresholds to quantile map to. Leaving %s values unadjusted.""" + logger = get_library_logger() + logger.warning( + """ISIMIP step 6: no pseudo-future observations between thresholds to quantile map to. Leaving %s values unadjusted.""" % mask_for_entries_not_set_to_either_bound.sum(), stacklevel=2, ) diff --git a/ibicus/debias/_scaled_distribution_mapping.py b/ibicus/debias/_scaled_distribution_mapping.py index 510a6b1..ae6c146 100644 --- a/ibicus/debias/_scaled_distribution_mapping.py +++ b/ibicus/debias/_scaled_distribution_mapping.py @@ -6,7 +6,6 @@ # granted to it by virtue of its status as an intergovernmental organisation # nor does it submit to any jurisdiction. -import warnings from typing import Union import attrs @@ -16,6 +15,7 @@ from ..utils import ( StatisticalModel, + get_library_logger, interp_sorted_cdf_vals_on_given_length, threshold_cdf_vals, ) @@ -190,7 +190,6 @@ def for_precipitation(cls, pr_lower_threshold=0.1 / 86400, **kwargs): return cls.from_variable("pr", pr_lower_threshold=pr_lower_threshold, **kwargs) def apply_location_relative_sdm(self, obs, cm_hist, cm_future): - # Preparation: sort arrays obs = np.sort(obs) cm_hist = np.sort(cm_hist) @@ -231,7 +230,8 @@ def apply_location_relative_sdm(self, obs, cm_hist, cm_future): ) if expected_nr_rainy_days_cm_future > mask_rainy_days_cm_future.sum(): - warnings.warn( + logger = get_library_logger() + logger.warning( """The relative ScaledDistributionMapping does not currently support adjusting the number of rainy days upwards: so to transform dry days into rainy ones in cm_future. The number of dry and rainy days is left unadjusted.""", stacklevel=2, @@ -320,7 +320,6 @@ def apply_location_relative_sdm(self, obs, cm_hist, cm_future): return cm_future[reverse_sorting_idx] def apply_location_absolute_sdm(self, obs, cm_hist, cm_future): - # Step 1 obs_detrended = detrend(obs, type="constant") cm_hist_detrended = detrend(cm_hist, type="constant")