Skip to content

Commit

Permalink
Compute Rayleigh correction with original data precision
Browse files Browse the repository at this point in the history
  • Loading branch information
lahtinep committed Oct 24, 2024
1 parent 0e4a3f5 commit 965c1b4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions satpy/modifiers/atmosphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def __call__(self, projectables, optional_datasets=None, **info):
projectables = projectables + (optional_datasets or [])
if len(projectables) != 6:
vis, red = self.match_data_arrays(projectables)
sata, satz, suna, sunz = get_angles(vis)
# Adjust the angle data precision to match the data
# This does not affect the accuracy visibly
sata, satz, suna, sunz = [d.astype(vis.dtype) for d in get_angles(vis)]
else:
vis, red, sata, satz, suna, sunz = self.match_data_arrays(projectables)
# First make sure the two azimuth angles are in the range 0-360:
Expand Down Expand Up @@ -116,14 +118,14 @@ 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)

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

0 comments on commit 965c1b4

Please sign in to comment.