From 7830e7d66fc6916b7c7f5d6cfc5568e1aeafacc1 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Mon, 27 Nov 2023 14:56:31 -0600 Subject: [PATCH] Switch docs and tests to use default Solar irradiance file --- doc/37_reflectance.rst | 4 ++-- doc/rad_definitions.rst | 8 ++++---- doc/usage.rst | 4 ++-- pyspectral/near_infrared_reflectance.py | 5 ++--- pyspectral/tests/test_solarflux.py | 5 ++--- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/doc/37_reflectance.rst b/doc/37_reflectance.rst index c048daaf..937b4ef3 100644 --- a/doc/37_reflectance.rst +++ b/doc/37_reflectance.rst @@ -123,9 +123,9 @@ would be: where :math:`S(\lambda)` is the spectral solar irradiance. >>> from pyspectral.rsr_reader import RelativeSpectralResponse - >>> from pyspectral.solar import (SolarIrradianceSpectrum, TOTAL_IRRADIANCE_SPECTRUM_2000ASTM) + >>> from pyspectral.solar import SolarIrradianceSpectrum >>> viirs = RelativeSpectralResponse('Suomi-NPP', 'viirs') - >>> solar_irr = SolarIrradianceSpectrum(TOTAL_IRRADIANCE_SPECTRUM_2000ASTM, dlambda=0.005) + >>> solar_irr = SolarIrradianceSpectrum(dlambda=0.005) >>> sflux = solar_irr.inband_solarflux(viirs.rsr['M12']) >>> print(np.round(sflux, 7)) 2.2428119 diff --git a/doc/rad_definitions.rst b/doc/rad_definitions.rst index 9ae227ae..a305ce49 100644 --- a/doc/rad_definitions.rst +++ b/doc/rad_definitions.rst @@ -156,8 +156,8 @@ TOA Solar irradiance and solar constant First, the TOA solar irradiance in wavelength space: - >>> from pyspectral.solar import (SolarIrradianceSpectrum, TOTAL_IRRADIANCE_SPECTRUM_2000ASTM) - >>> solar_irr = SolarIrradianceSpectrum(TOTAL_IRRADIANCE_SPECTRUM_2000ASTM, dlambda=0.0005) + >>> from pyspectral.solar import SolarIrradianceSpectrum + >>> solar_irr = SolarIrradianceSpectrum(dlambda=0.0005) >>> print("Solar irradiance = {}".format(round(solar_irr.solar_constant(), 3))) Solar irradiance = 1366.091 >>> solar_irr.plot('/tmp/solar_irradiance.png') @@ -201,8 +201,8 @@ In python code it may look like this: >>> from pyspectral.utils import convert2wavenumber, get_central_wave >>> seviri = RelativeSpectralResponse('Meteosat-8', 'seviri') >>> rsr, info = convert2wavenumber(seviri.rsr) - >>> from pyspectral.solar import (SolarIrradianceSpectrum, TOTAL_IRRADIANCE_SPECTRUM_2000ASTM) - >>> solar_irr = SolarIrradianceSpectrum(TOTAL_IRRADIANCE_SPECTRUM_2000ASTM, dlambda=0.0005, wavespace='wavenumber') + >>> from pyspectral.solar import SolarIrradianceSpectrum + >>> solar_irr = SolarIrradianceSpectrum(dlambda=0.0005, wavespace='wavenumber') >>> print("Solar Irradiance (SEVIRI band VIS008) = {sflux:12.6f}".format(sflux=solar_irr.inband_solarflux(rsr['VIS0.8']))) Solar Irradiance (SEVIRI band VIS008) = 63767.908405 diff --git a/doc/usage.rst b/doc/usage.rst index 25b96942..59c0e982 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -35,9 +35,9 @@ Now, you can work with the data as you wish, make some simple plot for instance: A simple use case: >>> from pyspectral.rsr_reader import RelativeSpectralResponse - >>> from pyspectral.solar import (SolarIrradianceSpectrum, TOTAL_IRRADIANCE_SPECTRUM_2000ASTM) + >>> from pyspectral.solar import SolarIrradianceSpectrum >>> modis = RelativeSpectralResponse('EOS-Aqua', 'modis') - >>> solar_irr = SolarIrradianceSpectrum(TOTAL_IRRADIANCE_SPECTRUM_2000ASTM, dlambda=0.005) + >>> solar_irr = SolarIrradianceSpectrum(dlambda=0.005) >>> sflux = solar_irr.inband_solarflux(modis.rsr['20']) >>> print("Solar flux over Band: {sflux}".format(sflux=round(sflux, 6))) Solar flux over Band: 2.002928 diff --git a/pyspectral/near_infrared_reflectance.py b/pyspectral/near_infrared_reflectance.py index 080e22b4..7cf693bd 100644 --- a/pyspectral/near_infrared_reflectance.py +++ b/pyspectral/near_infrared_reflectance.py @@ -38,7 +38,7 @@ from pyspectral.config import get_config from pyspectral.radiance_tb_conversion import RadTbConverter -from pyspectral.solar import TOTAL_IRRADIANCE_SPECTRUM_2000ASTM, SolarIrradianceSpectrum +from pyspectral.solar import SolarIrradianceSpectrum from pyspectral.utils import BANDNAMES, WAVE_LENGTH, get_bandname_from_wavelength LOG = logging.getLogger(__name__) @@ -161,8 +161,7 @@ def derive_rad39_corr(self, bt11, bt13, method='rosenfeld'): def _get_solarflux(self): """Derive the in-band solar flux from rsr over the Near IR band (3.7 or 3.9 microns).""" solar_spectrum = \ - SolarIrradianceSpectrum(TOTAL_IRRADIANCE_SPECTRUM_2000ASTM, - dlambda=0.0005, + SolarIrradianceSpectrum(dlambda=0.0005, wavespace=self.wavespace) self.solar_flux = solar_spectrum.inband_solarflux(self.rsr[self.bandname]) diff --git a/pyspectral/tests/test_solarflux.py b/pyspectral/tests/test_solarflux.py index a7441c3e..2d7b5bb2 100644 --- a/pyspectral/tests/test_solarflux.py +++ b/pyspectral/tests/test_solarflux.py @@ -24,7 +24,7 @@ import numpy as np -from pyspectral.solar import TOTAL_IRRADIANCE_SPECTRUM_2000ASTM, SolarIrradianceSpectrum +from pyspectral.solar import SolarIrradianceSpectrum TEST_RSR = {} TEST_RSR['det-1'] = {} @@ -59,8 +59,7 @@ class TestSolarflux(unittest.TestCase): def setUp(self): """Set up.""" - self.solar_irr = SolarIrradianceSpectrum(TOTAL_IRRADIANCE_SPECTRUM_2000ASTM, - dlambda=0.005) + self.solar_irr = SolarIrradianceSpectrum(dlambda=0.005) self.rsr = TEST_RSR def test_read(self):