From 180a492ab6d8130a1852269a6e88f80bbd498daa Mon Sep 17 00:00:00 2001 From: Fabien Maussion Date: Thu, 2 Mar 2023 19:40:39 +0100 Subject: [PATCH] Rename prcp_fac --- docs/_code/prepare_climate.py | 4 +-- oggm/cfg.py | 17 +++++------ oggm/core/massbalance.py | 56 +++++++++++++++++------------------ oggm/params.cfg | 14 ++++----- oggm/tests/funcs.py | 12 ++++---- oggm/tests/test_benchmarks.py | 8 ++--- oggm/tests/test_graphics.py | 20 ++++++------- oggm/tests/test_models.py | 28 +++++++++--------- oggm/tests/test_prepro.py | 46 ++++++++++++++-------------- oggm/tests/test_shop.py | 2 +- oggm/tests/test_utils.py | 24 +++++++-------- oggm/tests/test_workflow.py | 6 ++-- oggm/utils/_workflow.py | 4 +-- oggm/workflow.py | 2 +- 14 files changed, 121 insertions(+), 122 deletions(-) diff --git a/docs/_code/prepare_climate.py b/docs/_code/prepare_climate.py index c04e7358b..a5ff853e4 100644 --- a/docs/_code/prepare_climate.py +++ b/docs/_code/prepare_climate.py @@ -36,8 +36,8 @@ tasks.catchment_width_correction(gdir) cfg.PARAMS['baseline_climate'] = 'HISTALP' cfg.PARAMS['use_tstar_calibration'] = True -cfg.PARAMS['use_winter_prcp_factor'] = False -cfg.PARAMS['prcp_scaling_factor'] = 2.5 +cfg.PARAMS['use_winter_prcp_fac'] = False +cfg.PARAMS['prcp_fac'] = 2.5 tasks.process_histalp_data(gdir) with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=FutureWarning) diff --git a/oggm/cfg.py b/oggm/cfg.py index 1aef7196c..c9c19194e 100644 --- a/oggm/cfg.py +++ b/oggm/cfg.py @@ -531,11 +531,11 @@ def initialize_minimal(file=None, logging_level='INFO', params=None, PARAMS['hydro_month_nh'] = cp.as_int('hydro_month_nh') PARAMS['hydro_month_sh'] = cp.as_int('hydro_month_sh') PARAMS['geodetic_mb_period'] = cp['geodetic_mb_period'] - PARAMS['use_winter_prcp_factor'] = cp.as_bool('use_winter_prcp_factor') + PARAMS['use_winter_prcp_fac'] = cp.as_bool('use_winter_prcp_fac') - k = 'winter_prcp_factor_ab' + k = 'winter_prcp_fac_ab' PARAMS[k] = [float(vk) for vk in cp.as_list(k)] - k = 'winter_prcp_factor_range' + k = 'winter_prcp_fac_range' PARAMS[k] = [float(vk) for vk in cp.as_list(k)] k = 'ref_mb_valid_window' PARAMS[k] = [int(vk) for vk in cp.as_list(k)] @@ -561,9 +561,9 @@ def initialize_minimal(file=None, logging_level='INFO', params=None, # Precip factor can be none try: - PARAMS['prcp_scaling_factor'] = cp.as_float('prcp_scaling_factor') + PARAMS['prcp_fac'] = cp.as_float('prcp_fac') except ValueError: - PARAMS['prcp_scaling_factor'] = None + PARAMS['prcp_fac'] = None # Delete non-floats ltr = ['working_dir', 'dem_file', 'climate_file', 'use_tar_shapefiles', @@ -582,11 +582,10 @@ def initialize_minimal(file=None, logging_level='INFO', params=None, 'free_board_marine_terminating', 'use_kcalving_for_inversion', 'error_when_glacier_reaches_boundaries', 'glacier_length_method', 'use_inversion_params_for_run', - 'tidewater_type', 'store_model_geometry', 'use_winter_prcp_factor', + 'tidewater_type', 'store_model_geometry', 'use_winter_prcp_fac', 'store_diagnostic_variables', 'store_fl_diagnostic_variables', - 'geodetic_mb_period', 'store_fl_diagnostics', 'winter_prcp_factor_ab', - 'winter_prcp_factor_range', 'prcp_scaling_factor', - 'downstream_line_shape'] + 'geodetic_mb_period', 'store_fl_diagnostics', 'winter_prcp_fac_ab', + 'winter_prcp_fac_range', 'prcp_fac', 'downstream_line_shape'] for k in ltr: cp.pop(k, None) diff --git a/oggm/core/massbalance.py b/oggm/core/massbalance.py index 3ffd4202c..a45d64445 100644 --- a/oggm/core/massbalance.py +++ b/oggm/core/massbalance.py @@ -65,10 +65,10 @@ def decide_winter_precip_factor(gdir): # from MB sandbox calibration to winter MB # using t_melt=-1, cte lapse rate, monthly resolution - a, b = cfg.PARAMS['winter_prcp_factor_ab'] + a, b = cfg.PARAMS['winter_prcp_fac_ab'] prcp_fac = a * np.log(w_prcp) + b # don't allow extremely low/high prcp. factors!!! - r0, r1 = cfg.PARAMS['winter_prcp_factor_range'] + r0, r1 = cfg.PARAMS['winter_prcp_fac_range'] return clip_scalar(prcp_fac, r0, r1) @@ -545,7 +545,7 @@ def monthly_melt_f(self): # after instantiation with properly changing the prcp time series @property def prcp_fac(self): - """Precipitation factor (default: cfg.PARAMS['prcp_scaling_factor']) + """Precipitation factor (default: cfg.PARAMS['prcp_fac']) Called factor to make clear that it is a multiplicative factor in contrast to the additive temperature bias @@ -1448,9 +1448,9 @@ def mb_calibration_from_scalar_mb(gdir, melt_f=None, melt_f_min=None, melt_f_max=None, - prcp_scaling_factor=None, - prcp_scaling_factor_min=None, - prcp_scaling_factor_max=None, + prcp_fac=None, + prcp_fac_min=None, + prcp_fac_max=None, temp_bias=0, temp_bias_min=None, temp_bias_max=None, @@ -1539,16 +1539,16 @@ def mb_calibration_from_scalar_mb(gdir, melt_f_max: float the maximum accepted value for the melt factor during optimisation. Defaults to cfg.PARAMS['melt_f_max']. - prcp_scaling_factor: float + prcp_fac: float the default value to use as precipitation scaling factor (or the starting value when optimizing MB). Defaults to the method chosen in `params.cfg` (winter prcp or global factor). - prcp_scaling_factor_min: float + prcp_fac_min: float the minimum accepted value for the precipitation scaling factor during - optimisation. Defaults to cfg.PARAMS['prcp_scaling_factor_min']. - prcp_scaling_factor_max: float + optimisation. Defaults to cfg.PARAMS['prcp_fac_min']. + prcp_fac_max: float the maximum accepted value for the precipitation scaling factor during - optimisation. Defaults to cfg.PARAMS['prcp_scaling_factor_max']. + optimisation. Defaults to cfg.PARAMS['prcp_fac_max']. temp_bias: float the default value to use as temperature bias (or the starting value when optimizing MB). Defaults to 0. @@ -1565,10 +1565,10 @@ def mb_calibration_from_scalar_mb(gdir, melt_f_min = cfg.PARAMS['melt_f_min'] if melt_f_max is None: melt_f_max = cfg.PARAMS['melt_f_max'] - if prcp_scaling_factor_min is None: - prcp_scaling_factor_min = cfg.PARAMS['prcp_scaling_factor_min'] - if prcp_scaling_factor_max is None: - prcp_scaling_factor_max = cfg.PARAMS['prcp_scaling_factor_max'] + if prcp_fac_min is None: + prcp_fac_min = cfg.PARAMS['prcp_fac_min'] + if prcp_fac_max is None: + prcp_fac_max = cfg.PARAMS['prcp_fac_max'] if melt_f is None: melt_f = cfg.PARAMS['melt_f'] if temp_bias_min is None: @@ -1620,21 +1620,21 @@ def mb_calibration_from_scalar_mb(gdir, 'you posted!') # Ok, regardless on how we want to calibrate, we start with defaults - if prcp_scaling_factor is None: - if cfg.PARAMS['use_winter_prcp_factor']: + if prcp_fac is None: + if cfg.PARAMS['use_winter_prcp_fac']: # Some sanity check - if cfg.PARAMS['prcp_scaling_factor'] is not None: - raise InvalidWorkflowError("Set PARAMS['prcp_scaling_factor'] " + if cfg.PARAMS['prcp_fac'] is not None: + raise InvalidWorkflowError("Set PARAMS['prcp_fac'] " "to None if using winter_prcp_factor") prcp_fac = decide_winter_precip_factor(gdir) else: - prcp_fac = cfg.PARAMS['prcp_scaling_factor'] + prcp_fac = cfg.PARAMS['prcp_fac'] if prcp_fac is None: - raise InvalidWorkflowError("Set either PARAMS['use_winter_prcp_factor'] " + raise InvalidWorkflowError("Set either PARAMS['use_winter_prcp_fac'] " "or PARAMS['winter_prcp_factor'].") else: - # if a prcp_scaling_factor is set, we will use it instead of the default option - prcp_fac = prcp_scaling_factor + # if a prcp_fac is set, we will use it instead of the default option + prcp_fac = prcp_fac # Create the MB model we will calibrate mb_mod = mb_model_class(gdir, @@ -1652,7 +1652,7 @@ def mb_calibration_from_scalar_mb(gdir, if calibrate_param1 == 'melt_f': min_range, max_range = melt_f_min, melt_f_max elif calibrate_param1 == 'prcp_fac': - min_range, max_range = prcp_scaling_factor_min, prcp_scaling_factor_max + min_range, max_range = prcp_fac_min, prcp_fac_max elif calibrate_param1 == 'temp_bias': min_range, max_range = temp_bias_min, temp_bias_max else: @@ -1685,7 +1685,7 @@ def to_minimize(x, model_attr): if calibrate_param2 == 'melt_f': min_range, max_range = melt_f_min, melt_f_max elif calibrate_param2 == 'prcp_fac': - min_range, max_range = prcp_scaling_factor_min, prcp_scaling_factor_max + min_range, max_range = prcp_fac_min, prcp_fac_max elif calibrate_param2 == 'temp_bias': min_range, max_range = temp_bias_min, temp_bias_max else: @@ -1712,7 +1712,7 @@ def to_minimize(x, model_attr): if calibrate_param3 == 'melt_f': min_range, max_range = melt_f_min, melt_f_max elif calibrate_param3 == 'prcp_fac': - min_range, max_range = prcp_scaling_factor_min, prcp_scaling_factor_max + min_range, max_range = prcp_fac_min, prcp_fac_max elif calibrate_param3 == 'temp_bias': min_range, max_range = temp_bias_min, temp_bias_max else: @@ -1964,7 +1964,7 @@ def fixed_geometry_mass_balance(gdir, ys=None, ye=None, years=None, precipitation_factor: float multiply a factor to the precipitation time series default is None and means that the precipitation factor from the - calibration is applied which is cfg.PARAMS['prcp_scaling_factor'] + calibration is applied which is cfg.PARAMS['prcp_fac'] mb_model_class : MassBalanceModel class the MassBalanceModel class to use, default is MonthlyTIModel """ @@ -2021,7 +2021,7 @@ def compute_ela(gdir, ys=None, ye=None, years=None, climate_filename='climate_hi precipitation_factor: float multiply a factor to the precipitation time series default is None and means that the precipitation factor from the - calibration is applied which is cfg.PARAMS['prcp_scaling_factor'] + calibration is applied which is cfg.PARAMS['prcp_fac'] mb_model_class : MassBalanceModel class the MassBalanceModel class to use, default is MonthlyTIModel """ diff --git a/oggm/params.cfg b/oggm/params.cfg index 09d183e71..8d99426ab 100644 --- a/oggm/params.cfg +++ b/oggm/params.cfg @@ -209,19 +209,19 @@ temp_bias_min = -10 temp_bias_max = 10 # precipitation correction: set to a float for a constant scaling factor -# Needs to be set empty if use_winter_prcp_factor is True -prcp_scaling_factor = +# Needs to be set empty if use_winter_prcp_fac is True +prcp_fac = # For calibration - set a range -prcp_scaling_factor_min = 0.1 -prcp_scaling_factor_max = 5 +prcp_fac_min = 0.1 +prcp_fac_max = 5 # Use a precipitation dependent factor (unique per glacier) # The values below have been calibrated on W5E5 data - they will work # less well on other datasets (but should be fine since it only corrects # total precipitation and should be less affected by temperature). -use_winter_prcp_factor = True -winter_prcp_factor_ab = -1.0614, 3.9200 -winter_prcp_factor_range = 0.1, 10 +use_winter_prcp_fac = True +winter_prcp_fac_ab = -1.0614, 3.9200 +winter_prcp_fac_range = 0.1, 10 # When matching geodetic MB on a glacier per glacier basis, which period diff --git a/oggm/tests/funcs.py b/oggm/tests/funcs.py index 079b8703e..65ee9ba3d 100644 --- a/oggm/tests/funcs.py +++ b/oggm/tests/funcs.py @@ -399,8 +399,8 @@ def init_hef(reset=False, border=40, logging_level='INFO', rgi_id=None, cfg.PATHS['working_dir'] = testdir cfg.PARAMS['trapezoid_lambdas'] = 1 cfg.PARAMS['border'] = border - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 hef_file = get_demo_file('Hintereisferner_RGI5.shp') entity = gpd.read_file(hef_file).iloc[0] @@ -503,8 +503,8 @@ def init_columbia(reset=False): cfg.PARAMS['border'] = 10 cfg.PARAMS['use_kcalving_for_inversion'] = True cfg.PARAMS['use_kcalving_for_run'] = True - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PARAMS['baseline_climate'] = 'CRU' entity = gpd.read_file(get_demo_file('01_rgi60_Columbia.shp')).iloc[0] @@ -542,8 +542,8 @@ def init_columbia_eb(dir_name, reset=False): cfg.PARAMS['border'] = 10 cfg.PARAMS['use_kcalving_for_inversion'] = True cfg.PARAMS['use_kcalving_for_run'] = True - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PARAMS['baseline_climate'] = 'CRU' entity = gpd.read_file(get_demo_file('01_rgi60_Columbia.shp')).iloc[0] diff --git a/oggm/tests/test_benchmarks.py b/oggm/tests/test_benchmarks.py index ee47a3807..9f8d87acd 100644 --- a/oggm/tests/test_benchmarks.py +++ b/oggm/tests/test_benchmarks.py @@ -50,8 +50,8 @@ def setUp(self): cfg.PATHS['working_dir'] = self.testdir cfg.PATHS['dem_file'] = get_demo_file('dem_SouthGlacier.tif') cfg.PARAMS['border'] = 10 - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PARAMS['baseline_climate'] = 'CRU' self.tf = get_demo_file('cru_ts4.01.1901.2016.SouthGlacier.tmp.dat.nc') @@ -474,8 +474,8 @@ def setUp(self): cfg.PATHS['working_dir'] = self.testdir cfg.PARAMS['use_kcalving_for_inversion'] = True cfg.PARAMS['use_kcalving_for_run'] = True - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PARAMS['baseline_climate'] = 'CRU' def tearDown(self): diff --git a/oggm/tests/test_graphics.py b/oggm/tests/test_graphics.py index 7928cd7cc..4e9c5235b 100644 --- a/oggm/tests/test_graphics.py +++ b/oggm/tests/test_graphics.py @@ -177,8 +177,8 @@ def test_multiple_inversion(): cfg.PARAMS['border'] = 40 cfg.PARAMS['baseline_climate'] = 'CUSTOM' cfg.PARAMS['trapezoid_lambdas'] = 1 - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PATHS['working_dir'] = testdir # Get the RGI ID @@ -262,8 +262,8 @@ def test_multiple_models(): cfg.PATHS['working_dir'] = testdir cfg.PARAMS['baseline_climate'] = 'CUSTOM' cfg.PARAMS['trapezoid_lambdas'] = 1 - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PARAMS['border'] = 40 # Get the RGI ID @@ -352,8 +352,8 @@ def test_chhota_shigri(): cfg.PARAMS['use_intersects'] = False cfg.PATHS['working_dir'] = testdir cfg.PARAMS['trapezoid_lambdas'] = 1 - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 hef_file = get_demo_file('divides_RGI50-14.15990.shp') df = gpd.read_file(hef_file) @@ -396,8 +396,8 @@ def test_ice_cap(): cfg.PARAMS['border'] = 60 cfg.PATHS['working_dir'] = testdir cfg.PARAMS['trapezoid_lambdas'] = 1 - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 df = gpd.read_file(get_demo_file('divides_RGI50-05.08389.shp')) df['Area'] = df.Area * 1e-6 # cause it was in m2 @@ -438,8 +438,8 @@ def test_coxe(): cfg.PARAMS['use_kcalving_for_inversion'] = True cfg.PARAMS['use_kcalving_for_run'] = True cfg.PARAMS['trapezoid_lambdas'] = 1 - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 hef_file = get_demo_file('rgi_RGI50-01.10299.shp') entity = gpd.read_file(hef_file).iloc[0] diff --git a/oggm/tests/test_models.py b/oggm/tests/test_models.py index fde000a3a..76dd5be79 100644 --- a/oggm/tests/test_models.py +++ b/oggm/tests/test_models.py @@ -232,8 +232,8 @@ def other_glacier_cfg(): cfg.set_intersects_db(get_demo_file('rgi_intersect_oetztal.shp')) cfg.PATHS['dem_file'] = get_demo_file('srtm_oetztal.tif') cfg.PATHS['climate_file'] = get_demo_file('histalp_merged_hef.nc') - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PARAMS['baseline_climate'] = 'CRU' @@ -446,7 +446,7 @@ def test_prcp_fac_temp_bias_update(self, hef_gdir): # save old precipitation/temperature time series prcp_old = mb_mod.prcp.copy() temp_old = mb_mod.temp.copy() - prcp_fac_old = cfg.PARAMS['prcp_scaling_factor'] + prcp_fac_old = cfg.PARAMS['prcp_fac'] temp_bias_old = 0 # basic checks assert mb_mod.prcp_fac == prcp_fac_old @@ -3590,7 +3590,7 @@ def test_run_dynamic_spinup(self, hef_gdir, minimise_for): } # change settings to match used prepro directory - cfg.PARAMS['prcp_scaling_factor'] = 1.6 + cfg.PARAMS['prcp_fac'] = 1.6 # TODO: update prepro_base_url to new v1.6, and simplify code below, # and could use different prepro_level @@ -3907,7 +3907,7 @@ def test_run_dynamic_melt_f_calibration_with_dynamic_spinup(self, # after the test old_use_kcalving_for_run = cfg.PARAMS['use_kcalving_for_run'] cfg.PARAMS['use_kcalving_for_run'] = False - cfg.PARAMS['prcp_scaling_factor'] = 1.6 + cfg.PARAMS['prcp_fac'] = 1.6 # TODO: update to prepro v1.6 # use a prepro dir as the hef_gdir climate data only goes to 2003 and @@ -4421,7 +4421,7 @@ def test_run_dynamic_melt_f_calibration_without_dynamic_spinup(self): # after the test old_use_kcalving_for_run = cfg.PARAMS['use_kcalving_for_run'] cfg.PARAMS['use_kcalving_for_run'] = False - cfg.PARAMS['prcp_scaling_factor'] = 1.6 + cfg.PARAMS['prcp_fac'] = 1.6 cfg.PARAMS['hydro_month_nh'] = 1 cfg.PARAMS['hydro_month_sh'] = 1 @@ -5056,7 +5056,7 @@ def test_hydro_dynamic_melt_f_with_dynamic_spinup(self, inversion_params, # after the test old_use_kcalving_for_run = cfg.PARAMS['use_kcalving_for_run'] cfg.PARAMS['use_kcalving_for_run'] = False - cfg.PARAMS['prcp_scaling_factor'] = 1.6 + cfg.PARAMS['prcp_fac'] = 1.6 cfg.PARAMS['hydro_month_nh'] = 1 cfg.PARAMS['hydro_month_sh'] = 1 @@ -5130,7 +5130,7 @@ def test_hydro_dynamic_melt_f_with_dynamic_spinup(self, inversion_params, assert_allclose(frac, 0, atol=0.05) # set back to previous values - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PARAMS['hydro_month_nh'] = 10 cfg.PARAMS['hydro_month_sh'] = 4 cfg.PARAMS['use_kcalving_for_run'] = old_use_kcalving_for_run @@ -5142,7 +5142,7 @@ def test_hydro_dynamic_melt_f_without_dynamic_spinup(self, inversion_params): # after the test old_use_kcalving_for_run = cfg.PARAMS['use_kcalving_for_run'] cfg.PARAMS['use_kcalving_for_run'] = False - cfg.PARAMS['prcp_scaling_factor'] = 1.6 + cfg.PARAMS['prcp_fac'] = 1.6 cfg.PARAMS['hydro_month_nh'] = 1 cfg.PARAMS['hydro_month_sh'] = 1 @@ -5214,7 +5214,7 @@ def test_hydro_dynamic_melt_f_without_dynamic_spinup(self, inversion_params): assert_allclose(frac, 0, atol=0.05) # set back to previous values - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PARAMS['hydro_month_nh'] = 10 cfg.PARAMS['hydro_month_sh'] = 4 cfg.PARAMS['use_kcalving_for_run'] = old_use_kcalving_for_run @@ -5394,8 +5394,8 @@ def test_hef_retreat(self, class_case_dir): cfg.PARAMS['baseline_climate'] = '' cfg.PARAMS['use_multiprocessing'] = False cfg.PARAMS['min_ice_thick_for_length'] = 5 - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 hef_file = get_demo_file('Hintereisferner_RGI5.shp') entity = gpd.read_file(hef_file).iloc[0] @@ -5488,9 +5488,9 @@ def merged_hef_cfg(class_case_dir): # should this be resetting working_dir at teardown? cfg.PATHS['working_dir'] = class_case_dir cfg.PARAMS['border'] = 100 - cfg.PARAMS['prcp_scaling_factor'] = 1.75 + cfg.PARAMS['prcp_fac'] = 1.75 cfg.PARAMS['temp_melt'] = -1.75 - cfg.PARAMS['use_winter_prcp_factor'] = False + cfg.PARAMS['use_winter_prcp_fac'] = False @pytest.mark.usefixtures('merged_hef_cfg') diff --git a/oggm/tests/test_prepro.py b/oggm/tests/test_prepro.py index 2e49f931d..0eda75452 100644 --- a/oggm/tests/test_prepro.py +++ b/oggm/tests/test_prepro.py @@ -791,8 +791,8 @@ def setUp(self): cfg.PARAMS['border'] = 10 cfg.PATHS['climate_file'] = get_demo_file('histalp_merged_hef.nc') cfg.PARAMS['baseline_climate'] = '' - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 def tearDown(self): self.rm_dir() @@ -1158,8 +1158,8 @@ def setUp(self): cfg.PATHS['climate_file'] = get_demo_file('histalp_merged_hef.nc') cfg.PARAMS['border'] = 10 cfg.PARAMS['baseline_climate'] = '' - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 def tearDown(self): self.rm_dir() @@ -1389,7 +1389,7 @@ def test_mb_calibration_from_scalar_mb(self): pdf = gdir.read_json('mb_calib') assert pdf['temp_bias'] == 0 assert pdf['melt_f'] != cfg.PARAMS['melt_f'] - assert pdf['prcp_fac'] == cfg.PARAMS['prcp_scaling_factor'] + assert pdf['prcp_fac'] == cfg.PARAMS['prcp_fac'] # Let's calibrate on temp_bias mb_calibration_from_scalar_mb(gdir, @@ -1409,7 +1409,7 @@ def test_mb_calibration_from_scalar_mb(self): pdf = gdir.read_json('mb_calib') assert pdf['temp_bias'] != 0 assert pdf['melt_f'] == cfg.PARAMS['melt_f'] - assert pdf['prcp_fac'] == cfg.PARAMS['prcp_scaling_factor'] + assert pdf['prcp_fac'] == cfg.PARAMS['prcp_fac'] # Let's calibrate on precip mb_calibration_from_scalar_mb(gdir, @@ -1429,7 +1429,7 @@ def test_mb_calibration_from_scalar_mb(self): pdf = gdir.read_json('mb_calib') assert pdf['temp_bias'] == 0 assert pdf['melt_f'] == cfg.PARAMS['melt_f'] - assert pdf['prcp_fac'] != cfg.PARAMS['prcp_scaling_factor'] + assert pdf['prcp_fac'] != cfg.PARAMS['prcp_fac'] # mbdf[['ref_mb', 'melt_mb', 'temp_mb', 'prcp_mb']].plot() # plt.show() @@ -1459,7 +1459,7 @@ def test_mb_calibration_from_scalar_mb(self): assert pdf['temp_bias'] < 0 assert pdf['melt_f'] != cfg.PARAMS['melt_f'] assert pdf['melt_f'] == cfg.PARAMS['melt_f_min'] - assert pdf['prcp_fac'] == cfg.PARAMS['prcp_scaling_factor'] + assert pdf['prcp_fac'] == cfg.PARAMS['prcp_fac'] # Very negative ref_mb = -10000 @@ -1485,7 +1485,7 @@ def test_mb_calibration_from_scalar_mb(self): assert pdf['temp_bias'] > 0 assert pdf['melt_f'] != cfg.PARAMS['melt_f'] assert pdf['melt_f'] == cfg.PARAMS['melt_f_max'] - assert pdf['prcp_fac'] == cfg.PARAMS['prcp_scaling_factor'] + assert pdf['prcp_fac'] == cfg.PARAMS['prcp_fac'] # Try with prcp_fac as variable 1 # Very positive @@ -1513,7 +1513,7 @@ def test_mb_calibration_from_scalar_mb(self): pdf = gdir.read_json('mb_calib') assert pdf['temp_bias'] < 0 assert pdf['melt_f'] == cfg.PARAMS['melt_f'] - assert pdf['prcp_fac'] > cfg.PARAMS['prcp_scaling_factor'] + assert pdf['prcp_fac'] > cfg.PARAMS['prcp_fac'] # Very negative ref_mb = -10000 @@ -1540,7 +1540,7 @@ def test_mb_calibration_from_scalar_mb(self): pdf = gdir.read_json('mb_calib') assert pdf['temp_bias'] > 0 assert pdf['melt_f'] == cfg.PARAMS['melt_f'] - assert pdf['prcp_fac'] < cfg.PARAMS['prcp_scaling_factor'] + assert pdf['prcp_fac'] < cfg.PARAMS['prcp_fac'] # Extremely negative ref_mb = -20000 @@ -1576,7 +1576,7 @@ def test_mb_calibration_from_scalar_mb(self): pdf = gdir.read_json('mb_calib') assert pdf['temp_bias'] == cfg.PARAMS['temp_bias_max'] assert pdf['melt_f'] > cfg.PARAMS['melt_f'] - assert pdf['prcp_fac'] == cfg.PARAMS['prcp_scaling_factor_min'] + assert pdf['prcp_fac'] == cfg.PARAMS['prcp_fac_min'] # Unmatchable positive ref_mb = 10000 @@ -1592,8 +1592,8 @@ def test_mb_calibration_from_scalar_mb(self): ref_mb = 1000 cfg.PARAMS['temp_bias_min'] = -0.5 cfg.PARAMS['temp_bias_max'] = 0.5 - cfg.PARAMS['prcp_scaling_factor_min'] = 2 - cfg.PARAMS['prcp_scaling_factor_max'] = 3 + cfg.PARAMS['prcp_fac_min'] = 2 + cfg.PARAMS['prcp_fac_max'] = 3 with pytest.raises(RuntimeError): mb_calibration_from_scalar_mb(gdir, ref_mb=ref_mb, @@ -1626,7 +1626,7 @@ def test_mb_calibration_from_scalar_mb(self): pdf = gdir.read_json('mb_calib') assert pdf['temp_bias'] == cfg.PARAMS['temp_bias_min'] assert pdf['melt_f'] < cfg.PARAMS['melt_f'] - assert pdf['prcp_fac'] == cfg.PARAMS['prcp_scaling_factor_max'] + assert pdf['prcp_fac'] == cfg.PARAMS['prcp_fac_max'] @pytest.mark.slow @@ -1756,8 +1756,8 @@ def setUp(self): cfg.PATHS['climate_file'] = get_demo_file('histalp_merged_hef.nc') cfg.PARAMS['baseline_climate'] = '' cfg.PARAMS['border'] = 10 - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 def tearDown(self): self.rm_dir() @@ -2301,8 +2301,8 @@ def setUp(self): cfg.PATHS['dem_file'] = get_demo_file('dem_RGI50-01.10299.tif') cfg.PATHS['working_dir'] = self.testdir cfg.PARAMS['border'] = 40 - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 def tearDown(self): self.rm_dir() @@ -2417,8 +2417,8 @@ def setUp(self): cfg.set_intersects_db(get_demo_file('rgi_intersect_oetztal.shp')) cfg.PARAMS['use_multiple_flowlines'] = False cfg.PARAMS['use_tar_shapefiles'] = False - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 def tearDown(self): self.rm_dir() @@ -2548,8 +2548,8 @@ def setUp(self): cfg.PATHS['dem_file'] = get_demo_file('hef_srtm.tif') cfg.PATHS['climate_file'] = '' cfg.PARAMS['border'] = 10 - cfg.PARAMS['use_winter_prcp_factor'] = False - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PARAMS['baseline_climate'] = 'CRU' def tearDown(self): diff --git a/oggm/tests/test_shop.py b/oggm/tests/test_shop.py index 5a3700431..22d403394 100644 --- a/oggm/tests/test_shop.py +++ b/oggm/tests/test_shop.py @@ -329,7 +329,7 @@ def test_process_gswp3_w5e5_data(self, class_case_dir): # no gradient for GSWP3-W5E5! # test climate statistics with winter_daily_mean_prcp - # they should be computed even if cfg.PARAMS['use_winter_prcp_factor'] is False! + # they should be computed even if cfg.PARAMS['use_winter_prcp_fac'] is False! df = utils.compile_climate_statistics([gdir], path=False, add_climate_period=[1999, 2010], add_raw_climate_statistics=True, diff --git a/oggm/tests/test_utils.py b/oggm/tests/test_utils.py index 4a98577b1..44fa5f378 100644 --- a/oggm/tests/test_utils.py +++ b/oggm/tests/test_utils.py @@ -731,8 +731,8 @@ def test_start_from_level_3(self): prepro_rgi_version='62', prepro_border=40) - cfg.PARAMS['prcp_scaling_factor'] = 2.5 - cfg.PARAMS['use_winter_prcp_factor'] = False + cfg.PARAMS['prcp_fac'] = 2.5 + cfg.PARAMS['use_winter_prcp_fac'] = False n_intersects = 0 for gdir in gdirs: @@ -1150,8 +1150,8 @@ def test_full_run_cru_centerlines(self): centerlines=True, override_params={'geodetic_mb_period': ref_period, 'baseline_climate': 'CRU', - 'use_winter_prcp_factor': False, - 'prcp_scaling_factor': 2.5, + 'use_winter_prcp_fac': False, + 'prcp_fac': 2.5, } ) @@ -1315,8 +1315,8 @@ def test_elev_bands_and_spinup_run_with_different_evolution_models(self): test_topofile=topof, elev_bands=True, override_params={'geodetic_mb_period':ref_period, 'baseline_climate': 'CRU', - 'use_winter_prcp_factor': False, - 'prcp_scaling_factor': 2.5, + 'use_winter_prcp_fac': False, + 'prcp_fac': 2.5, }) df = pd.read_csv(os.path.join(odir, 'RGI61', bstr, 'L0', 'summary', @@ -1449,8 +1449,8 @@ def test_geodetic_per_glacier_and_massredis_run(self): params = {'geodetic_mb_period': '2000-01-01_2010-01-01', 'baseline_climate': 'CRU', - 'use_winter_prcp_factor': False, - 'prcp_scaling_factor': 2.5, + 'use_winter_prcp_fac': False, + 'prcp_fac': 2.5, } # Remove bad actors rgidf = rgidf.loc[~rgidf.RGIId.str.contains('_d0')] @@ -1555,8 +1555,8 @@ def test_start_from_prepro(self): logging_level='INFO', max_level=5, elev_bands=True, override_params={'geodetic_mb_period': ref_period, 'baseline_climate': 'CRU', - 'use_winter_prcp_factor': False, - 'prcp_scaling_factor': 2.5, + 'use_winter_prcp_fac': False, + 'prcp_fac': 2.5, } ) @@ -1756,8 +1756,8 @@ def test_full_benchmark_run(self): 'use_multiprocessing': False, 'geodetic_mb_period': '2000-01-01_2010-01-01', 'baseline_climate': 'CRU', - 'use_winter_prcp_factor': False, - 'prcp_scaling_factor': 2.5, + 'use_winter_prcp_fac': False, + 'prcp_fac': 2.5, }) df = pd.read_csv(os.path.join(odir, 'benchmarks_b080.csv'), diff --git a/oggm/tests/test_workflow.py b/oggm/tests/test_workflow.py index c2ee9e5b7..f92aa7ad2 100644 --- a/oggm/tests/test_workflow.py +++ b/oggm/tests/test_workflow.py @@ -92,13 +92,13 @@ def up_to_climate(reset=False, use_mp=None): # Params cfg.PARAMS['border'] = 70 - cfg.PARAMS['prcp_scaling_factor'] = 1.75 + cfg.PARAMS['prcp_fac'] = 1.75 cfg.PARAMS['temp_melt'] = -1.75 cfg.PARAMS['use_kcalving_for_inversion'] = True cfg.PARAMS['geodetic_mb_period'] = '2000-01-01_2010-01-01' cfg.PARAMS['use_kcalving_for_run'] = True cfg.PARAMS['store_model_geometry'] = True - cfg.PARAMS['use_winter_prcp_factor'] = False + cfg.PARAMS['use_winter_prcp_fac'] = False cfg.PARAMS['baseline_climate'] = 'CRU' # Go @@ -164,7 +164,7 @@ def up_to_distrib(reset=False): if reset: # Use CRU - cfg.PARAMS['prcp_scaling_factor'] = 2.5 + cfg.PARAMS['prcp_fac'] = 2.5 cfg.PARAMS['baseline_climate'] = 'CRU' with warnings.catch_warnings(): # There is a warning from salem diff --git a/oggm/utils/_workflow.py b/oggm/utils/_workflow.py index fc5b3130a..84686e5ac 100644 --- a/oggm/utils/_workflow.py +++ b/oggm/utils/_workflow.py @@ -1753,7 +1753,7 @@ def compile_fixed_geometry_mass_balance(gdirs, filesuffix='', precipitation_factor: float multiply a factor to the precipitation time series default is None and means that the precipitation factor from the - calibration is applied which is cfg.PARAMS['prcp_scaling_factor'] + calibration is applied which is cfg.PARAMS['prcp_fac'] """ from oggm.workflow import execute_entity_task @@ -1828,7 +1828,7 @@ def compile_ela(gdirs, filesuffix='', path=True, csv=False, ys=None, ye=None, ye precipitation_factor: float multiply a factor to the precipitation time series default is None and means that the precipitation factor from the - calibration is applied which is cfg.PARAMS['prcp_scaling_factor'] + calibration is applied which is cfg.PARAMS['prcp_fac'] """ from oggm.workflow import execute_entity_task from oggm.core.massbalance import compute_ela diff --git a/oggm/workflow.py b/oggm/workflow.py index cd1d6b43b..f260bb0f5 100644 --- a/oggm/workflow.py +++ b/oggm/workflow.py @@ -370,7 +370,7 @@ def init_glacier_directories(rgidf=None, *, reset=False, force=False, "parameters: {}".format(url)) if ('oggm_v1.4' in url and from_prepro_level >= 3 and - not cfg.PARAMS['prcp_scaling_factor']): + not cfg.PARAMS['prcp_fac']): log.warning('You seem to be using v1.4 directories with a more ' 'recent version of OGGM. While this is possible, be ' 'aware that some defaults parameters have changed. '