Skip to content

Commit

Permalink
Merge branch 'main' into sen2c
Browse files Browse the repository at this point in the history
  • Loading branch information
adybbroe committed Sep 24, 2024
2 parents 85fa080 + 604bd6d commit 72f08bc
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-sdist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Publish package to PyPI
if: github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@v1.8.14
uses: pypa/gh-action-pypi-publish@v1.9.0
with:
user: __token__
password: ${{ secrets.pypi_password }}
81 changes: 66 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,54 @@
## Version <v0.13.1> (2024/05/07)
## Version v0.13.4 (2024/08/14)

### Issues Closed

* [Issue 229](https://github.com/pytroll/pyspectral/issues/229) - Deprecate old scipy and remove use of trapz (numpy and scipy) ([PR 233](https://github.com/pytroll/pyspectral/pull/233) by [@djhoese](https://github.com/djhoese))

In this release 1 issue was closed.

### Pull Requests Merged

#### Bugs fixed

* [PR 233](https://github.com/pytroll/pyspectral/pull/233) - Replace deprecated numpy trapezoid/trapz usage with scipy trapezoid ([229](https://github.com/pytroll/pyspectral/issues/229))
* [PR 232](https://github.com/pytroll/pyspectral/pull/232) - Cleanup unused dependencies and deprecated code

In this release 2 pull requests were closed.


## Version v0.13.3 (2024/07/17)

### Pull Requests Merged

#### Bugs fixed

* [PR 231](https://github.com/pytroll/pyspectral/pull/231) - Updated the file name for the FY-3F Mersi-3 RSRs

#### Features added

* [PR 226](https://github.com/pytroll/pyspectral/pull/226) - Add RSR script for MERSI-3 onboard FY-3F

In this release 2 pull requests were closed.


## Version v0.13.2 (2024/06/27)

### Issues Closed

* [Issue 227](https://github.com/pytroll/pyspectral/issues/227) - Pyspectral 0.13.1 not compatible with SciPy 1.14.x -> update dependencies ([PR 228](https://github.com/pytroll/pyspectral/pull/228) by [@djhoese](https://github.com/djhoese))

In this release 1 issue was closed.

### Pull Requests Merged

#### Bugs fixed

* [PR 228](https://github.com/pytroll/pyspectral/pull/228) - Fix scipy 1.14 compatibility and trapz usage ([227](https://github.com/pytroll/pyspectral/issues/227))

In this release 1 pull request was closed.


## Version v0.13.1 (2024/05/07)

### Issues Closed

Expand All @@ -20,7 +70,7 @@ In this release 2 issues were closed.
In this release 5 pull requests were closed.


## Version <v0.13.0> (2023/11/27)
## Version v0.13.0 (2023/11/27)

### Issues Closed

Expand All @@ -43,7 +93,7 @@ In this release 2 issues were closed.
In this release 6 pull requests were closed.


## Version <v0.12.5> (2023/09/21)
## Version 0.12.5 (2023/09/21)

### Pull Requests Merged

Expand All @@ -54,7 +104,7 @@ In this release 6 pull requests were closed.
In this release 1 pull request was closed.


## Version <v0.12.4> (2023/09/20)
## Version v0.12.4 (2023/09/20)

### Issues Closed

Expand All @@ -76,7 +126,7 @@ In this release 1 issue was closed.
In this release 3 pull requests were closed.


## Version <v0.12.3> (2022/11/22)
## Version v0.12.3 (2022/11/22)

### Issues Closed

Expand All @@ -102,7 +152,7 @@ In this release 5 issues were closed.
In this release 3 pull requests were closed.


## Version <v0.12.2> (2022/10/24)
## Version 0.12.2 (2022/10/24)

### Issues Closed

Expand All @@ -119,7 +169,7 @@ In this release 1 issue was closed.
In this release 1 pull request was closed.


## Version <v0.12.1> (2022/10/20)
## Version v0.12.1 (2022/10/20)


### Pull Requests Merged
Expand All @@ -135,7 +185,7 @@ In this release 1 pull request was closed.
In this release 2 pull requests were closed.


## Version <v0.12.0> (2022/10/11)
## Version v0.12.0 (2022/10/11)

### Issues Closed

Expand Down Expand Up @@ -170,7 +220,7 @@ In this release 1 issue was closed.
In this release 13 pull requests were closed.


## Version <v0.11.0> (2022/03/01)
## Version v0.11.0 (2022/03/01)


### Pull Requests Merged
Expand All @@ -183,7 +233,7 @@ In this release 13 pull requests were closed.
In this release 2 pull requests were closed.


## Version <v0.10.6> (2021/12/22)
## Version v0.10.6 (2021/12/22)

### Issues Closed

Expand All @@ -209,7 +259,7 @@ In this release 2 issues were closed.
In this release 6 pull requests were closed.


## Version <v0.10.5> (2021/04/29)
## Version v0.10.5 (2021/04/29)

### Pull Requests Merged

Expand All @@ -228,7 +278,7 @@ In this release 6 pull requests were closed.
In this release 2 pull requests were closed.


## Version <v0.10.4> (2020/12/07)
## Version v0.10.4 (2020/12/07)


### Pull Requests Merged
Expand All @@ -240,15 +290,16 @@ In this release 2 pull requests were closed.
In this release 1 pull request was closed.


## Version <v0.10.3> (2020/12/04)
## Version v0.10.3 (2020/12/04)

### Issues Closed

* [Issue 89](https://github.com/pytroll/pyspectral/issues/89) - GK2A AMI RSR wavelengths are reversed

In this release 1 issue was closed.

## Version <v0.10.2> (2020/11/20)

## Version v0.10.2 (2020/11/20)

### Issues Closed

Expand Down Expand Up @@ -279,7 +330,7 @@ In this release 1 issue was closed.
In this release 9 pull requests were closed.


## Version <v0.10.1> (2020/10/06)
## Version v0.10.1 (2020/10/06)

### Issues Closed

Expand Down
10 changes: 0 additions & 10 deletions doc/rtd_requirements.txt

This file was deleted.

3 changes: 3 additions & 0 deletions pyspectral/blackbody.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def blackbody_rad2temp(wavelength, radiance):
The derived temperature in Kelvin.
"""
if getattr(wavelength, "dtype", None) != radiance.dtype:
# avoid a wavelength numpy scalar upcasting radiances (ex. 32-bit to 64-bit float)
wavelength = radiance.dtype.type(wavelength)
with np.errstate(invalid='ignore'):
return PLANCK_C1 / (wavelength * np.log(PLANCK_C2 / (radiance * wavelength**5) + 1.0))

Expand Down
2 changes: 1 addition & 1 deletion pyspectral/near_infrared_reflectance.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def reflectance_from_tbs(self, sun_zenith, tb_near_ir, tb_thermal, **kwargs):
mu0 = np.cos(np.deg2rad(sunz))

# mu0 = np.where(np.less(mu0, 0.1), 0.1, mu0)
self._solar_radiance = self.solar_flux * mu0 / np.pi
self._solar_radiance = (self.solar_flux * mu0 / np.pi).astype(tb_nir.dtype)

# CO2 correction to the 3.9 radiance, only if tbs of a co2 band around
# 13.4 micron is provided:
Expand Down
8 changes: 4 additions & 4 deletions pyspectral/radiance_tb_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from numbers import Number

import numpy as np
from scipy import integrate
from scipy.integrate import trapezoid

from pyspectral.blackbody import C_SPEED, H_PLANCK, K_BOLTZMANN, blackbody, blackbody_wn
from pyspectral.rsr_reader import RelativeSpectralResponse
Expand Down Expand Up @@ -155,7 +155,7 @@ def _get_rsr(self):
self._wave_si_scale)
self.response = self.rsr[self.bandname][self.detector]['response']
# Get the integral of the spectral response curve:
self.rsr_integral = np.trapz(self.response, self.wavelength_or_wavenumber)
self.rsr_integral = trapezoid(self.response, self.wavelength_or_wavenumber)

def _getsatname(self):
"""Get the satellite name used in the rsr-reader, from the platform and number."""
Expand Down Expand Up @@ -221,9 +221,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
6 changes: 3 additions & 3 deletions pyspectral/rsr_reader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014-2022 Pytroll developers
# Copyright (c) 2014-2024 Pytroll developers
#
#
# This program is free software: you can redistribute it and/or modify
Expand All @@ -24,7 +24,7 @@
from glob import glob
from os.path import expanduser

import numpy as np
from scipy.integrate import trapezoid

from pyspectral.bandnames import BANDNAMES
from pyspectral.config import get_config
Expand Down Expand Up @@ -214,7 +214,7 @@ def integral(self, bandname):
for det in self.rsr[bandname].keys():
wvl = self.rsr[bandname][det]['wavelength']
resp = self.rsr[bandname][det]['response']
intg[det] = np.trapz(resp, wvl)
intg[det] = trapezoid(resp, wvl)
return intg

def convert(self):
Expand Down
9 changes: 5 additions & 4 deletions pyspectral/solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from pathlib import Path

import numpy as np
from scipy.integrate import trapezoid

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -121,9 +122,9 @@ def _load(self):
def solar_constant(self):
"""Calculate the solar constant."""
if self.wavenumber is not None:
return np.trapz(self.irradiance, self.wavenumber)
return trapezoid(self.irradiance, self.wavenumber)
if self.wavelength is not None:
return np.trapz(self.irradiance, self.wavelength)
return trapezoid(self.irradiance, self.wavelength)

raise TypeError('Neither wavelengths nor wavenumbers available!')

Expand Down Expand Up @@ -204,10 +205,10 @@ def _band_calculations(self, rsr, flux, scale, **options):

# Calculate the solar-flux: (w/m2)
if flux:
return np.trapz(irr * resp_ipol, wvl)
return trapezoid(irr * resp_ipol, wvl)

# Divide by the equivalent band width:
return np.trapz(irr * resp_ipol, wvl) / np.trapz(resp_ipol, wvl)
return trapezoid(irr * resp_ipol, wvl) / trapezoid(resp_ipol, wvl)

def interpolate(self, **options):
"""Interpolate Irradiance to a specified evenly spaced resolution/grid.
Expand Down
42 changes: 3 additions & 39 deletions pyspectral/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,19 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# Copyright (c) 2013-2022 Pytroll Developers
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""The tests package."""

import doctest
import os
import sys

from pyspectral import blackbody, near_infrared_reflectance, solar

if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest

TRAVIS = os.environ.get("TRAVIS", False)
APPVEYOR = os.environ.get("APPVEYOR", False)


def suite():
"""Perform the unit testing."""
mysuite = unittest.TestSuite()
if not TRAVIS and not APPVEYOR:
# Test sphinx documentation pages:
mysuite.addTests(doctest.DocFileSuite('../../doc/usage.rst'))
mysuite.addTests(doctest.DocFileSuite('../../doc/rad_definitions.rst'))
# mysuite.addTests(doctest.DocFileSuite('../../doc/seviri_example.rst'))
mysuite.addTests(doctest.DocFileSuite('../../doc/37_reflectance.rst'))
# Test the documentation strings
mysuite.addTests(doctest.DocTestSuite(solar))
mysuite.addTests(doctest.DocTestSuite(near_infrared_reflectance))
mysuite.addTests(doctest.DocTestSuite(blackbody))

return mysuite


if __name__ == '__main__':
unittest.TextTestRunner(verbosity=2).run(suite())
Loading

0 comments on commit 72f08bc

Please sign in to comment.