def test_blackbody_wn(self): """Calculate the blackbody radiation from wavenumbers and temperatures """ wavenumber = 90909.1 # 11 micron band black = blackbody_wn((wavenumber, ), [300., 301]) self.assertEqual(black.shape[0], 2) self.assertAlmostEqual(black[0], WN_RAD_11MICRON_300KELVIN) self.assertAlmostEqual(black[1], WN_RAD_11MICRON_301KELVIN) temp1 = blackbody_wn_rad2temp(wavenumber, black[0]) self.assertAlmostEqual(temp1, 300.0, 4) temp2 = blackbody_wn_rad2temp(wavenumber, black[1]) self.assertAlmostEqual(temp2, 301.0, 4) t__ = blackbody_wn_rad2temp(wavenumber, [0.001, 0.0009]) expected = [290.3276916, 283.76115441] self.assertAlmostEqual(t__[0], expected[0]) self.assertAlmostEqual(t__[1], expected[1]) radiances = np.array([0.001, 0.0009, 0.0012, 0.0018]).reshape(2, 2) t__ = blackbody_wn_rad2temp(wavenumber, radiances) expected = np.array([290.3276916, 283.76115441, 302.4181330, 333.1414164]).reshape(2, 2) self.assertAlmostEqual(t__[1, 1], expected[1, 1], 5) self.assertAlmostEqual(t__[0, 0], expected[0, 0], 5) self.assertAlmostEqual(t__[0, 1], expected[0, 1], 5) self.assertAlmostEqual(t__[1, 0], expected[1, 0], 5) assertNumpyArraysEqual(t__, expected)
def test_blackbody_wn(self): """Calculate the blackbody radiation from wavenumbers and temperatures.""" wavenumber = 90909.1 # 11 micron band black = blackbody_wn((wavenumber, ), [300., 301]) self.assertEqual(black.shape[0], 2) self.assertAlmostEqual(black[0], WN_RAD_11MICRON_300KELVIN) self.assertAlmostEqual(black[1], WN_RAD_11MICRON_301KELVIN) temp1 = blackbody_wn_rad2temp(wavenumber, black[0]) self.assertAlmostEqual(temp1, 300.0, 4) temp2 = blackbody_wn_rad2temp(wavenumber, black[1]) self.assertAlmostEqual(temp2, 301.0, 4) t__ = blackbody_wn_rad2temp(wavenumber, [0.001, 0.0009]) expected = [290.3276916, 283.76115441] self.assertAlmostEqual(t__[0], expected[0]) self.assertAlmostEqual(t__[1], expected[1]) radiances = np.array([0.001, 0.0009, 0.0012, 0.0018]).reshape(2, 2) t__ = blackbody_wn_rad2temp(wavenumber, radiances) expected = np.array( [290.3276916, 283.76115441, 302.4181330, 333.1414164]).reshape(2, 2) self.assertAlmostEqual(t__[1, 1], expected[1, 1], 5) self.assertAlmostEqual(t__[0, 0], expected[0, 0], 5) self.assertAlmostEqual(t__[0, 1], expected[0, 1], 5) self.assertAlmostEqual(t__[1, 0], expected[1, 0], 5) assertNumpyArraysEqual(t__, expected)
def test_blackbody_wn_dask(self): """Test that blackbody rad2temp preserves dask arrays.""" import dask import dask.array as da wavenumber = 90909.1 # 11 micron band radiances = da.from_array([0.001, 0.0009, 0.0012, 0.0018], chunks=2).reshape(2, 2) with dask.config.set(scheduler=CustomScheduler(0)): t__ = blackbody_wn_rad2temp(wavenumber, radiances) self.assertIsInstance(t__, da.Array) t__ = t__.compute() expected = np.array( [290.3276916, 283.76115441, 302.4181330, 333.1414164]).reshape(2, 2) self.assertAlmostEqual(t__[1, 1], expected[1, 1], 5) self.assertAlmostEqual(t__[0, 0], expected[0, 0], 5) self.assertAlmostEqual(t__[0, 1], expected[0, 1], 5) self.assertAlmostEqual(t__[1, 0], expected[1, 0], 5) assertNumpyArraysEqual(t__, expected)
def test_get_correction(self): """Test getting the atm correction""" this = AtmosphericalCorrection('EOS-Terra', 'modis') atm_corr = this.get_correction(SATZ, None, TBS) assertNumpyArraysEqual(TBS, atm_corr)