Skip to content

Commit

Permalink
Fix scipy 1.14 compatibility and trapz usage
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Jun 27, 2024
1 parent ff4400d commit adde5c1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pyspectral/radiance_tb_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@
from numbers import Number

import numpy as np
from scipy import integrate

from pyspectral.blackbody import C_SPEED, H_PLANCK, K_BOLTZMANN, blackbody, blackbody_wn
from pyspectral.rsr_reader import RelativeSpectralResponse
from pyspectral.utils import BANDNAMES, WAVE_LENGTH, WAVE_NUMBER, convert2wavenumber, get_bandname_from_wavelength

try:
from scipy.integrate import trapezoid
except ImportError:
from scipy.integrate import trapz as trapezoid

LOG = logging.getLogger(__name__)

BLACKBODY_FUNC = {WAVE_LENGTH: blackbody,
Expand Down Expand Up @@ -221,9 +225,9 @@ def tb2radiance(self, tb_, **kwargs):

planck = self.blackbody_function(self.wavelength_or_wavenumber, tb_) * self.response
if normalized:
radiance = integrate.trapz(planck, self.wavelength_or_wavenumber) / self.rsr_integral
radiance = trapezoid(planck, self.wavelength_or_wavenumber) / self.rsr_integral
else:
radiance = integrate.trapz(planck, self.wavelength_or_wavenumber)
radiance = trapezoid(planck, self.wavelength_or_wavenumber)

return {'radiance': radiance,
'unit': unit,
Expand Down

0 comments on commit adde5c1

Please sign in to comment.