From adde5c16722bfe2384d6eb182e0509082b3e2faf Mon Sep 17 00:00:00 2001 From: David Hoese Date: Thu, 27 Jun 2024 09:32:49 -0500 Subject: [PATCH] Fix scipy 1.14 compatibility and trapz usage --- pyspectral/radiance_tb_conversion.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pyspectral/radiance_tb_conversion.py b/pyspectral/radiance_tb_conversion.py index ca6a2f5..8521b8e 100644 --- a/pyspectral/radiance_tb_conversion.py +++ b/pyspectral/radiance_tb_conversion.py @@ -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, @@ -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,