Skip to content

Commit

Permalink
Revert np.nan_to_num usage on rayleigh correction array
Browse files Browse the repository at this point in the history
Use a correction of NaN instead of a correction of 0
  • Loading branch information
djhoese committed Oct 6, 2022
1 parent cdf25d6 commit 538df91
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyspectral/rayleigh.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def get_reflectance(self, sun_zenith, sat_zenith, azidiff,
dtype=res.dtype,
chunks=getattr(res, "chunks", None))

res = np.clip(np.nan_to_num(res), 0, 100)
res = np.clip(res, 0, 100)
if compute:
res = res.compute()
return res
Expand Down
3 changes: 3 additions & 0 deletions pyspectral/tests/test_rayleigh.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
TEST_RAYLEIGH_RESULT2 = np.array([9.653559, 8.464997], dtype='float32')
TEST_RAYLEIGH_RESULT3 = np.array([5.488735, 8.533125], dtype='float32')
TEST_RAYLEIGH_RESULT4 = np.array([0.0, 8.64748], dtype='float32')
TEST_RAYLEIGH_RESULT5 = np.array([9.653559, np.nan], dtype='float32')
TEST_RAYLEIGH_RESULT_R1 = np.array([16.66666667, 20.83333333, 25.], dtype='float32')
TEST_RAYLEIGH_RESULT_R2 = np.array([0., 6.25, 12.5], dtype='float32')

Expand Down Expand Up @@ -322,6 +323,8 @@ def test_get_reflectance_redband_outside_clip(self, fake_lut_hdf5):
TEST_RAYLEIGH_RESULT1),
(np.array([60., 20.]), np.array([49., 26.]), np.array([140., 130.]), np.array([12., 8.]),
TEST_RAYLEIGH_RESULT2),
(np.array([60., 20.]), np.array([49., 26.]), np.array([140., 130.]), np.array([12., np.nan]),
TEST_RAYLEIGH_RESULT5),
]
)
def test_get_reflectance(self, fake_lut_hdf5, sun_zenith, sat_zenith, azidiff, redband_refl, exp_result):
Expand Down

0 comments on commit 538df91

Please sign in to comment.