Skip to content

Commit

Permalink
Fix clipping of Rayleigh strength reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
lahtinep committed Oct 25, 2024
1 parent 965c1b4 commit 392fb77
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions satpy/modifiers/atmosphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __call__(self, projectables, optional_datasets=None, **info):
aerosol_type = self.attrs.get("aerosol_type", "marine_clean_aerosol")
reduce_lim_low = abs(self.attrs.get("reduce_lim_low", 70))
reduce_lim_high = abs(self.attrs.get("reduce_lim_high", 105))
reduce_strength = np.clip(self.attrs.get("reduce_strength", 0), 0, 1)
reduce_strength = np.clip(self.attrs.get("reduce_strength", 0), 0, 1).astype(vis.dtype)

logger.info("Removing Rayleigh scattering with atmosphere '%s' and "
"aerosol type '%s' for '%s'",
Expand All @@ -118,14 +118,15 @@ def __call__(self, projectables, optional_datasets=None, **info):
refl_cor_band = corrector.get_reflectance(sunz, satz, ssadiff,
vis.attrs["wavelength"][1],
red.data)

if reduce_strength > 0:
if reduce_lim_low > reduce_lim_high:
reduce_lim_low = reduce_lim_high
refl_cor_band = corrector.reduce_rayleigh_highzenith(sunz, refl_cor_band,
reduce_lim_low, reduce_lim_high, reduce_strength)

# Need to convert again to data precision, Rayleigh calculations always promote datatype to float64
proj = vis - refl_cor_band.astype(vis.dtype)
proj = vis - refl_cor_band
proj.attrs = vis.attrs
self.apply_modifier_info(vis, proj)
return proj
Expand Down

0 comments on commit 392fb77

Please sign in to comment.