Skip to content

Commit

Permalink
Merge pull request pytroll#69 from adybbroe/feature-rayleigh-catch-ex…
Browse files Browse the repository at this point in the history
…ception

Feature rayleigh catch exception
  • Loading branch information
adybbroe committed Apr 11, 2019
2 parents 4cd9266 + 46b279c commit 897c86a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions pyspectral/rayleigh.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2016-2018 Pytroll
# Copyright (c) 2016-2019 Pytroll

# Author(s):

Expand Down Expand Up @@ -171,7 +171,10 @@ def get_effective_wavelength(self, bandname):
LOG.warning(
"Effective wavelength is set to the requested band wavelength = %f", bandname)
return bandname
return None

msg = ("Can't get effective wavelength for band %s on platform %s and sensor %s" %
(str(bandname), self.platform_name, self.sensor))
raise KeyError(msg)

if isinstance(bandname, str):
bandname = BANDNAMES.get(self.sensor, BANDNAMES['generic']).get(bandname, bandname)
Expand Down Expand Up @@ -220,15 +223,9 @@ def get_reflectance(self, sun_zenith, sat_zenith, azidiff, bandname, redband=Non
wvl = bandname * 1000.0
else:
wvl = self.get_effective_wavelength(bandname)
if wvl is None:
LOG.error("Can't get effective wavelength for band %s on platform %s and sensor %s",
str(bandname), self.platform_name, self.sensor)
return None
else:
wvl = wvl * 1000.0
wvl = wvl * 1000.0

rayl, wvl_coord, azid_coord, satz_sec_coord, sunz_sec_coord = \
self.get_reflectance_lut()
rayl, wvl_coord, azid_coord, satz_sec_coord, sunz_sec_coord = self.get_reflectance_lut()

# force dask arrays
compute = False
Expand All @@ -255,8 +252,7 @@ def get_reflectance(self, sun_zenith, sat_zenith, azidiff, bandname, redband=Non
LOG.info(
"Set the rayleigh/aerosol reflectance contribution to zero!")
if HAVE_DASK:
chunks = sun_zenith.chunks if redband is None \
else redband.chunks
chunks = sun_zenith.chunks if redband is None else redband.chunks
res = zeros(shape, chunks=chunks)
return res.compute() if compute else res
else:
Expand Down

0 comments on commit 897c86a

Please sign in to comment.