class Calibration(): def setUp(self): # Get the configuration section config_file, section = self.config_file, self.section config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "netcdf/%s" % config_file) config = CalibrationConfig(config_file, section) # Build the calibrator time_axis = api.Timeaxis(config.model_config.start_time, config.model_config.run_time_step, config.model_config.number_of_steps) self.calibrator = Calibrator(config) self.calibrator.init(time_axis) def test_calibration(self): calibr_results = self.calibrator.calibrate(tol=1.0e-5) # print("calibrated results:", calibr_results) expected_results = { 'wind_const': 1.0, 'max_albedo': 0.9, 'p_corr_scale_factor': 1.0, 'fast_albedo_decay_rate': 10.0, 'TX': -0.5, 'glacier_albedo': 0.4, 'surface_magnitude': 30.0, 'snowfall_reset_depth': 5.0, 'wind_scale': 3.5, 'slow_albedo_decay_rate': 30.0, 'ae_scale_factor': 1.5, 'c3': -0.1, 'c2': 1.0, 'c1': -0.5, 'snow_cv': 0.4, 'min_albedo': 0.6, 'max_water': 0.1} # Check that the results are as expected for key, val in calibr_results.iteritems(): assert val == expected_results[key] np.testing.assert_allclose(np.float64(val), np.float64(expected_results[key]), rtol=1e-2)
def setUp(self): # Get the configuration section config_file, section = self.config_file, self.section config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "netcdf/%s" % config_file) config = CalibrationConfig(config_file, section) # Build the calibrator time_axis = api.Timeaxis(config.model_config.start_time, config.model_config.run_time_step, config.model_config.number_of_steps) self.calibrator = Calibrator(config) self.calibrator.init(time_axis)