Skip to content

Commit

Permalink
Switch docs and tests to use default Solar irradiance file
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Nov 27, 2023
1 parent 14cdb4c commit 7830e7d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions doc/37_reflectance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions doc/rad_definitions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions pyspectral/near_infrared_reflectance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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])

Expand Down
5 changes: 2 additions & 3 deletions pyspectral/tests/test_solarflux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = {}
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 7830e7d

Please sign in to comment.