def test_accuracy_outside_range_raises_warning(self) -> None: ModelBehavior(accuracy=0) with warnings.catch_warnings(record=True) as warning: warnings.simplefilter("always") ModelBehavior(accuracy=np.nextafter(0, -1)) self.assertEqual(1, len(warning)) self.assertEqual(warning[-1].category, UserWarning) ModelBehavior(accuracy=0.01) with warnings.catch_warnings(record=True) as warning: warnings.simplefilter("always") ModelBehavior(accuracy=np.nextafter(0.01, 1)) self.assertEqual(1, len(warning)) self.assertEqual(warning[-1].category, UserWarning)
def test_ndarray_do_pseudo_sphere_raises_value_error(self) -> None: with self.assertRaises(ValueError): ModelBehavior(do_pseudo_sphere=np.zeros(5))
def test_user_optical_depths_defaults_to_false(self) -> None: self.assertEqual(False, ModelBehavior().user_optical_depths)
def test_user_angles_defaults_to_true(self) -> None: self.assertEqual(True, ModelBehavior().user_angles)
def test_radius_defaults_to_earth_radius(self) -> None: self.assertEqual(6371, ModelBehavior().radius)
def test_print_variables_defaults_to_list_of_false(self) -> None: prnt = [False, False, False, False, False] self.assertEqual(prnt, ModelBehavior().print_variables)
def test_only_fluxes_defaults_to_false(self) -> None: self.assertEqual(False, ModelBehavior().only_fluxes)
def test_incidence_beam_conditions_defaults_to_false(self) -> None: self.assertEqual(False, ModelBehavior().incidence_beam_conditions)
def test_ndarray_user_optical_depths_raises_value_error(self) -> None: with self.assertRaises(ValueError): ModelBehavior(user_optical_depths=np.zeros(5))
def test_ndarray_print_variables_is_ok(self) -> None: prnt = np.array([True, False, True, False, True]) ModelBehavior(print_variables=prnt)
def test_non_positive_radius_raises_value_error(self) -> None: with self.assertRaises(ValueError): ModelBehavior(radius=0) ModelBehavior(radius=np.nextafter(0, 1))
def test_4_print_variables_raises_value_error(self) -> None: prnt = [True, False, True, False] with self.assertRaises(ValueError): ModelBehavior(print_variables=prnt)
def test_ndarray_only_fluxes_raises_value_error(self) -> None: with self.assertRaises(ValueError): ModelBehavior(only_fluxes=np.zeros(5))
def test_ndarray_incidence_beam_conditions_raises_value_error(self) -> None: with self.assertRaises(ValueError): ModelBehavior(incidence_beam_conditions=np.zeros(5))
def test_header_defaults_to_empty_string(self) -> None: self.assertEqual('', ModelBehavior().header)
def test_accuracy_is_unchanged(self) -> None: mb = ModelBehavior(accuracy=0.001) self.assertEqual(0.001, mb.accuracy)
def test_incidence_beam_conditions_is_unchanged(self) -> None: mb = ModelBehavior(incidence_beam_conditions=True) self.assertEqual(True, mb.incidence_beam_conditions)
def test_accuracy_defaults_to_0(self) -> None: self.assertEqual(0, ModelBehavior().accuracy)
def test_only_fluxes_is_unchanged(self) -> None: mb = ModelBehavior(only_fluxes=True) self.assertEqual(True, mb.only_fluxes)
def test_delta_m_plus_is_unchanged(self) -> None: mb = ModelBehavior(delta_m_plus=True) self.assertEqual(True, mb.delta_m_plus)
def test_print_variables_is_unchanged(self) -> None: prnt = [True, False, True, False, False] mb = ModelBehavior(print_variables=prnt) self.assertEqual(prnt, mb.print_variables)
def test_delta_m_plus_defaults_to_False(self) -> None: self.assertEqual(False, ModelBehavior().delta_m_plus)
def test_radius_is_unchanged(self) -> None: mb = ModelBehavior(radius=3400) self.assertEqual(3400, mb.radius)
def test_do_pseudo_sphere_is_unchanged(self) -> None: mb = ModelBehavior(do_pseudo_sphere=True) self.assertEqual(True, mb.do_pseudo_sphere)
def test_user_angles_is_unchanged(self) -> None: mb = ModelBehavior(user_angles=False) self.assertEqual(False, mb.user_angles)
def test_do_pseudo_sphere_defaults_to_False(self) -> None: self.assertEqual(False, ModelBehavior().do_pseudo_sphere)
def test_user_optical_depths_is_unchanged(self) -> None: mb = ModelBehavior(user_optical_depths=False) self.assertEqual(False, mb.user_optical_depths)
def test_header_is_unchanged(self) -> None: mb = ModelBehavior(header='foo') self.assertEqual('foo', mb.header)
# variables here---you can just put them directly into the disort call---but I # thought it might be helpful. # Semi-new: another note, that many of these variables take a boolean or float # value. I made them optional, and use default values that disort_mulit uses incident_flux = IncidentFlux() fbeam = incident_flux.beam_flux fisot = incident_flux.isotropic_flux te = ThermalEmission() plank = te.thermal_emission btemp = te.bottom_temperature ttemp = te.top_temperature temis = te.top_emissivity mb = ModelBehavior() accur = mb.accuracy deltamplus = mb.delta_m_plus dopseudosphere = mb.do_pseudo_sphere header = mb.header ibcnd = mb.incidence_beam_conditions onlyfl = mb.only_fluxes prnt = mb.print_variables radius = mb.radius usrang = mb.user_angles usrtau = mb.user_optical_depths # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Make the output arrays # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ oa = OutputArrays(cp)
def test_ndarray_delta_m_plus_raises_value_error(self) -> None: with self.assertRaises(ValueError): ModelBehavior(delta_m_plus=np.zeros(5))