def test_twolayer_defaults( update_expected_files, test_rcmip_forcings_scmrun, test_twolayer_output_dir, run_model_output_comparison, ): twolayer_default = TwoLayerModel() res = twolayer_default.run_scenarios(test_rcmip_forcings_scmrun) expected = os.path.join(test_twolayer_output_dir, "test_twolayer_defaults.csv") run_model_output_comparison(res, expected, update_expected_files)
def test_twolayer_plus_efficacy( update_expected_files, test_rcmip_forcings_scmrun, test_twolayer_output_dir, run_model_output_comparison, ): twolayer_plus_efficacy = TwoLayerModel(efficacy=1.2 * ur("dimensionless")) res = twolayer_plus_efficacy.run_scenarios(test_rcmip_forcings_scmrun) expected = os.path.join(test_twolayer_output_dir, "test_twolayer_plus_efficacy.csv") run_model_output_comparison(res, expected, update_expected_files)
def test_twolayer_plus_state_dependence( update_expected_files, test_rcmip_forcings_scmrun, test_twolayer_output_dir, run_model_output_comparison, ): twolayer_plus_state_dependence = TwoLayerModel(a=0.05 * ur("W/m^2/delta_degC^2")) res = twolayer_plus_state_dependence.run_scenarios(test_rcmip_forcings_scmrun) expected = os.path.join( test_twolayer_output_dir, "test_twolayer_plus_state_dependence.csv" ) run_model_output_comparison(res, expected, update_expected_files)
def test_two_layer_impulse_response_equivalence(two_layer_config): time = np.arange(1750, 2501) forcing = 0.3 * np.sin(time / 15 * 2 * np.pi) + 3.0 * time / time.max() inp = ScmRun( data=forcing, index=time, columns={ "scenario": "test_scenario", "model": "unspecified", "climate_model": "junk input", "variable": "Effective Radiative Forcing", "unit": "W/m^2", "region": "World", }, ) twolayer = TwoLayerModel(**two_layer_config) res_twolayer = twolayer.run_scenarios(inp) impulse_response = ImpulseResponseModel( **twolayer.get_impulse_response_parameters()) res_impulse_response = impulse_response.run_scenarios(inp) assert (res_twolayer["time"] == res_impulse_response["time"]).all() npt.assert_allclose( res_twolayer.filter(variable="Effective Radiative Forcing").values, res_impulse_response.filter( variable="Effective Radiative Forcing").values, ) npt.assert_allclose( res_twolayer.filter(variable="Heat Uptake").values, res_impulse_response.filter(variable="Heat Uptake").values, atol=0.1, # numerical errors? ) npt.assert_allclose( res_twolayer.filter(variable="Surface Temperature|Upper").values, res_impulse_response.filter(variable="Surface Temperature").values, atol=0.1, # numerical errors? )