[Git][debian-gis-team/pyspectral][upstream] New upstream version 0.12.5+ds

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Sat Sep 23 11:49:27 BST 2023



Antonio Valentino pushed to branch upstream at Debian GIS Project / pyspectral


Commits:
5f5bd2c6 by Antonio Valentino at 2023-09-23T09:36:28+00:00
New upstream version 0.12.5+ds
- - - - -


22 changed files:

- .gitignore
- .pre-commit-config.yaml
- + .readthedocs.yaml
- CHANGELOG.md
- MANIFEST.in
- RELEASING.md
- doc/conf.py
- + doc/rtd_environment.yaml
- doc/rtd_requirements.txt
- plot_some_band.py
- pyproject.toml
- pyspectral/__init__.py
- pyspectral/blackbody.py
- pyspectral/rayleigh.py
- pyspectral/tests/test_rayleigh.py
- pyspectral/tests/test_utils.py
- pyspectral/utils.py
- rsr_convert_scripts/agri_rsr.py
- rsr_convert_scripts/avhrr1_rsr.py
- rsr_convert_scripts/msu_gs_reader.py
- setup.cfg
- setup.py


Changes:

=====================================
.gitignore
=====================================
@@ -38,3 +38,5 @@ nosetests.xml
 .mr.developer.cfg
 .project
 .pydevproject
+
+pyspectral/version.py
\ No newline at end of file


=====================================
.pre-commit-config.yaml
=====================================
@@ -7,7 +7,7 @@ repos:
     - id: flake8
       additional_dependencies: [flake8-docstrings, flake8-debugger, flake8-bugbear]
 -   repo: https://github.com/pycqa/isort
-    rev: 5.10.1
+    rev: 5.12.0
     hooks:
       - id: isort
         language_version: python3


=====================================
.readthedocs.yaml
=====================================
@@ -0,0 +1,17 @@
+# Read the Docs configuration file
+# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
+version: 2
+# Build documentation in the docs/ directory with Sphinx
+sphinx:
+  configuration: doc/conf.py
+  fail_on_warning: true
+
+# Optionally build your docs in additional formats such as PDF and ePub
+formats: all
+
+build:
+  os: "ubuntu-22.04"
+  tools:
+    python: "mambaforge-4.10"
+conda:
+  environment: doc/rtd_environment.yaml


=====================================
CHANGELOG.md
=====================================
@@ -1,3 +1,36 @@
+## Version <v0.12.5> (2023/09/21)
+
+### Pull Requests Merged
+
+#### Bugs fixed
+
+* [PR 195](https://github.com/pytroll/pyspectral/pull/195) - Fix rayleigh not preserving input dtype
+
+In this release 1 pull request was closed.
+
+
+## Version <v0.12.4> (2023/09/20)
+
+### Issues Closed
+
+* [Issue 177](https://github.com/pytroll/pyspectral/issues/177) - Unit Convert Error in the Doc. ([PR 180](https://github.com/pytroll/pyspectral/pull/180) by [@adybbroe](https://github.com/adybbroe))
+
+In this release 1 issue was closed.
+
+### Pull Requests Merged
+
+#### Bugs fixed
+
+* [PR 197](https://github.com/pytroll/pyspectral/pull/197) - Overhaul build process with setuptools_scm and written version file
+* [PR 180](https://github.com/pytroll/pyspectral/pull/180) - Bugfix in function doc header ([177](https://github.com/pytroll/pyspectral/issues/177))
+
+#### Documentation changes
+
+* [PR 180](https://github.com/pytroll/pyspectral/pull/180) - Bugfix in function doc header ([177](https://github.com/pytroll/pyspectral/issues/177))
+
+In this release 3 pull requests were closed.
+
+
 ## Version <v0.12.3> (2022/11/22)
 
 ### Issues Closed


=====================================
MANIFEST.in
=====================================
@@ -1,6 +1,17 @@
-include pyspectral/etc/*
-include pyspectral/data/e490_00a.dat
-include pyspectral/data/MSG_SEVIRI_Spectral_Response_Characterisation.XLS
+prune *
+exclude *
+graft doc
+recursive-exclude doc/_build *
+graft pyspectral
+graft bin
+recursive-exclude pyspectral/data/modis *
 include LICENSE.txt
-include versioneer.py
+include README.md
+include AUTHORS.md
+include CHANGELOG.md
+include CHANGELOG_RSR_DATA.rst
 include pyspectral/version.py
+include pyproject.toml
+include setup.py
+include setup.cfg
+global-exclude *.py[cod]


=====================================
RELEASING.md
=====================================
@@ -9,7 +9,7 @@ prerequisites: `pip install setuptools twine`
 4. run `loghub` and update the `CHANGELOG.md` file:
 
 ```
-loghub pytroll/pyspectral --token <personal access token (see https://github.com/settings/tokens)>  -st v<previous version> -plg bug "Bugs fixed" -plg enhancement "Features added" -plg documentation "Documentation changes"
+loghub pytroll/pyspectral --token <personal access token (see https://github.com/settings/tokens)>  -st $(git tag --sort=-version:refname --list 'v*' | head -n 1) -plg bug "Bugs fixed" -plg enhancement "Features added" -plg documentation "Documentation changes"
 ```
 
 Don't forget to commit!


=====================================
doc/conf.py
=====================================
@@ -1,19 +1,8 @@
 # -*- coding: utf-8 -*-
-#
-# Pyspectral documentation build configuration file, created by
-# sphinx-quickstart on Tue Oct 15 13:31:45 2013.
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
+"""Sphinx documentation configuration file."""
 
-import sys
 import os
-from pkg_resources import get_distribution
+import sys
 
 # PYTHONPATH = docs/source
 DOC_SOURCES_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -24,62 +13,16 @@ sys.path.insert(0, DOC_SOURCES_DIR)
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 sys.path.insert(0, os.path.abspath('../'))
-sys.path.insert(0, os.path.abspath('../pyspectral'))
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
-release = get_distribution('pyspectral').version
+from pyspectral import __version__ as release  # noqa
+
 # for example take major/minor
 version = '.'.join(release.split('.')[:2])
 
-
-class Mock(object):
-
-    """Mock class for doc/unit testing (on Travis)"""
-
-    __all__ = []
-
-    def __init__(self, *args, **kwargs):
-        pass
-
-    def __call__(self, *args, **kwargs):
-        return Mock()
-
-    @classmethod
-    def __getattr__(cls, name):
-        if name in ('__file__', '__path__'):
-            return '/dev/null'
-        elif name[0] == name[0].upper():
-            mockType = type(name, (), {})
-            mockType.__module__ = __name__
-            return mockType
-        elif name == "inf":
-            return 0
-        else:
-            return Mock()
-
-
-MOCK_MODULES = ['numpy', 'numpy.core',
-                'numpy.distutils.core', 'numpy.core.multiarray',
-                'dask',
-                'scipy', 'scipy.integrate', 'scipy.interpolate',
-                'scipy.interpolate.InterpolatedUnivariateSpline',
-                'geotiepoints', 'geotiepoints.multilinear',
-                'trollsift', 'trollsift.parser',
-                'h5py', 'tqdm', 'xlrd']
-
-for mod_name in MOCK_MODULES:
-    sys.modules[mod_name] = Mock()
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-# sys.path.insert(0, '/opt/lib/python2.5/site-packages')
-sys.path.insert(0, os.path.abspath('../pyspectral'))
-
-
 # -- General configuration -----------------------------------------------
 
 # If your documentation needs a minimal Sphinx version, state it here.


=====================================
doc/rtd_environment.yaml
=====================================
@@ -0,0 +1,19 @@
+name: readthedocs
+channels:
+  - conda-forge
+dependencies:
+  - python=3.11
+  - pip
+  - pytest
+  - sphinx
+  - sphinx_rtd_theme
+  - sphinxcontrib-apidoc
+  - dask
+  - scipy
+  - trollsift
+  - h5py
+  - tqdm
+  - xlrd
+  - pip:
+    - graphviz
+    - ..  # relative path to the satpy project


=====================================
doc/rtd_requirements.txt
=====================================
@@ -1,5 +1,5 @@
 python-geotiepoints>=1.1.1
-numpy>=1.5.1
+numpy>=1.22.2
 scipy>=0.14
 h5py>=2.5
 six


=====================================
plot_some_band.py
=====================================
@@ -19,14 +19,15 @@
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-"""Plot relative spectral responses for a list of sensors"""
+"""Plot relative spectral responses for a list of sensors."""
 
 import argparse
+
 import matplotlib.pyplot as plt
+import numpy as np
+
 from pyspectral.rsr_reader import RelativeSpectralResponse
 from pyspectral.utils import get_bandname_from_wavelength
-import numpy as np
 
 platforms = ['Himawari-8', 'GOES-16', 'Meteosat-10',
              'EOS-Aqua', 'Sentinel-3A', 'Sentinel-3A',


=====================================
pyproject.toml
=====================================
@@ -1,3 +1,10 @@
+[build-system]
+requires = ["setuptools>=60", "wheel", "setuptools_scm[toml]>=8.0"]
+build-backend = "setuptools.build_meta"
+
+[tool.setuptools_scm]
+write_to = "pyspectral/version.py"
+
 [tool.isort]
 sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
 profile = "black"


=====================================
pyspectral/__init__.py
=====================================
@@ -19,10 +19,10 @@
 
 """Pyspectral package init."""
 
-from pkg_resources import DistributionNotFound, get_distribution
-
 try:
-    __version__ = get_distribution(__name__).version
-except DistributionNotFound:
-    # package is not installed
-    pass
+    from pyspectral.version import version as __version__  # noqa
+except ModuleNotFoundError:
+    raise ModuleNotFoundError(
+        "No module named pyspectral.version. This could mean "
+        "you didn't install 'pyspectral' properly. Try reinstalling ('pip "
+        "install pyspectral').")


=====================================
pyspectral/blackbody.py
=====================================
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# Copyright (c) 2013-2022 Pytroll developers
+# Copyright (c) 2013-2023 Pytroll developers
 #
 #
 # This program is free software: you can redistribute it and/or modify
@@ -227,7 +227,7 @@ def blackbody_wn(wavenumber, temp):
             Unit = W/m^2 sr^-1 (m^-1)^-1 = W/m sr^-1
 
             Converting from SI units to mW/m^2 sr^-1 (cm^-1)^-1:
-            1.0 W/m^2 sr^-1 (m^-1)^-1 = 0.1 mW/m^2 sr^-1 (cm^-1)^-1
+            1.0 W/m^2 sr^-1 (m^-1)^-1 = 1.0e5 mW/m^2 sr^-1 (cm^-1)^-1
 
     """
     return planck(wavenumber, temp, wavelength=False)


=====================================
pyspectral/rayleigh.py
=====================================
@@ -220,6 +220,9 @@ class Rayleigh(RayleighConfigBaseClass):
                                         rayleigh_refl, reflectance_lut_filename):
         azid_coord, satz_sec_coord, sunz_sec_coord = get_reflectance_lut_from_file(
             reflectance_lut_filename)
+        azid_coord = azid_coord.astype(rayleigh_refl.dtype, copy=False)
+        satz_sec_coord = satz_sec_coord.astype(rayleigh_refl.dtype, copy=False)
+        sunz_sec_coord = sunz_sec_coord.astype(rayleigh_refl.dtype, copy=False)
 
         sun_zenith = _clip_angles_inside_coordinate_range(sun_zenith, sunz_sec_coord.max())
         sunzsec = 1. / np.cos(np.deg2rad(sun_zenith))
@@ -229,11 +232,10 @@ class Rayleigh(RayleighConfigBaseClass):
 
         smin = [sunz_sec_coord[0], azid_coord[0], satz_sec_coord[0]]
         smax = [sunz_sec_coord[-1], azid_coord[-1], satz_sec_coord[-1]]
-        orders = [
-            len(sunz_sec_coord), len(azid_coord), len(satz_sec_coord)]
+        orders = [len(sunz_sec_coord), len(azid_coord), len(satz_sec_coord)]
         f_3d_grid = np.atleast_2d(rayleigh_refl.ravel())
 
-        minterp = MultilinearInterpolator(smin, smax, orders)
+        minterp = MultilinearInterpolator(smin, smax, orders, dtype=rayleigh_refl.dtype)
         minterp.set_values(f_3d_grid)
         interp_points2 = np.vstack((sunzsec.ravel(), 180 - azidiff.ravel(), satzsec.ravel()))
         res = minterp(interp_points2)
@@ -248,6 +250,7 @@ class Rayleigh(RayleighConfigBaseClass):
         compute = da is not None and not isinstance(sun_zenith, da.Array)
 
         wvl, band_name = self._get_effective_wavelength_and_band_name(band_name_or_wavelength)
+        repr_arr = sun_zenith if redband is None else redband
         try:
             rayleigh_refl = _get_wavelength_adjusted_lut_rayleigh_reflectance(
                 self.reflectance_lut_filename, wvl)
@@ -255,15 +258,15 @@ class Rayleigh(RayleighConfigBaseClass):
             LOG.warning("Effective wavelength for band %s outside "
                         "nominal 400-800 nm range!", str(band_name))
             LOG.info("Setting the rayleigh/aerosol reflectance contribution to zero!")
-            repr_arr = sun_zenith if redband is None else redband
             zeros_like = np.zeros_like if isinstance(repr_arr, np.ndarray) else da.zeros_like
             res = zeros_like(repr_arr)
         else:
+            rayleigh_refl = rayleigh_refl.astype(repr_arr.dtype, copy=False)
             res = _map_blocks_or_direct_call(self._interp_rayleigh_refl_by_angles,
                                              sun_zenith, sat_zenith, azidiff, rayleigh_refl,
                                              self.reflectance_lut_filename,
-                                             meta=np.array((), dtype=rayleigh_refl.dtype),
-                                             dtype=rayleigh_refl.dtype,
+                                             meta=np.array((), dtype=repr_arr.dtype),
+                                             dtype=repr_arr.dtype,
                                              chunks=getattr(azidiff, "chunks", None))
 
         if redband is not None:


=====================================
pyspectral/tests/test_rayleigh.py
=====================================
@@ -158,26 +158,31 @@ class TestRayleighDask:
         np.testing.assert_allclose(refl_corr, TEST_RAYLEIGH_RESULT4)
         assert isinstance(refl_corr, da.Array)
 
-    def test_get_reflectance_dask(self, fake_lut_hdf5):
+    @pytest.mark.parametrize("dtype", [np.float32, np.float64])
+    def test_get_reflectance_dask(self, fake_lut_hdf5, dtype):
         """Test getting the reflectance correction with dask inputs."""
-        sun_zenith = da.array([67., 32.])
-        sat_zenith = da.array([45., 18.])
-        azidiff = da.array([150., 110.])
-        redband_refl = da.array([14., 5.])
+        sun_zenith = da.array([67., 32.], dtype=dtype)
+        sat_zenith = da.array([45., 18.], dtype=dtype)
+        azidiff = da.array([150., 110.], dtype=dtype)
+        redband_refl = da.array([14., 5.], dtype=dtype)
         rayl = _create_rayleigh()
         with mocked_rsr():
             refl_corr = rayl.get_reflectance(sun_zenith, sat_zenith, azidiff, 'ch3', redband_refl)
-        np.testing.assert_allclose(refl_corr, TEST_RAYLEIGH_RESULT1)
+        np.testing.assert_allclose(refl_corr, TEST_RAYLEIGH_RESULT1.astype(dtype), atol=4.0e-06)
         assert isinstance(refl_corr, da.Array)
+        assert refl_corr.dtype == dtype  # check that the dask array's dtype is equal
+        assert refl_corr.compute().dtype == dtype  # check that the final numpy array's dtype is equal
 
-        sun_zenith = da.array([60., 20.])
-        sat_zenith = da.array([49., 26.])
-        azidiff = da.array([140., 130.])
-        redband_refl = da.array([12., 8.])
+        sun_zenith = da.array([60., 20.], dtype=dtype)
+        sat_zenith = da.array([49., 26.], dtype=dtype)
+        azidiff = da.array([140., 130.], dtype=dtype)
+        redband_refl = da.array([12., 8.], dtype=dtype)
         with mocked_rsr():
             refl_corr = rayl.get_reflectance(sun_zenith, sat_zenith, azidiff, 'ch3', redband_refl)
-        np.testing.assert_allclose(refl_corr, TEST_RAYLEIGH_RESULT2)
+        np.testing.assert_allclose(refl_corr, TEST_RAYLEIGH_RESULT2.astype(dtype), atol=4.0e-06)
         assert isinstance(refl_corr, da.Array)
+        assert refl_corr.dtype == dtype  # check that the dask array's dtype is equal
+        assert refl_corr.compute().dtype == dtype  # check that the final numpy array's dtype is equal
 
     def test_get_reflectance_numpy_dask(self, fake_lut_hdf5):
         """Test getting the reflectance correction with dask inputs."""
@@ -282,7 +287,6 @@ class TestRayleigh:
 
     def test_rayleigh_getname(self):
         """Test logic for Rayleigh instrument selection."""
-
         with pytest.raises(ValueError):
             _create_rayleigh(platform='FY-4B')
 


=====================================
pyspectral/tests/test_utils.py
=====================================
@@ -33,7 +33,7 @@ import pytest
 import responses
 
 from pyspectral import utils
-from pyspectral.utils import bytes2string, check_and_adjust_instrument_name, are_instruments_identical, np2str
+from pyspectral.utils import are_instruments_identical, bytes2string, check_and_adjust_instrument_name, np2str
 
 TEST_RSR = {'20': {}, }
 TEST_RSR2 = {'20': {}, }


=====================================
pyspectral/utils.py
=====================================
@@ -383,7 +383,8 @@ def download_luts(aerosol_types=None, dry_run=False, aerosol_type=None):
 
 def _get_aerosol_types(aerosol_types, aerosol_type):
     if aerosol_type is not None:
-        warnings.warn("'aerosol_type' is deprecated, use 'aerosol_types' instead.", UserWarning)
+        warnings.warn("'aerosol_type' is deprecated, use 'aerosol_types' instead.", UserWarning,
+                      stacklevel=3)
         if isinstance(aerosol_type, (list, tuple, set)):
             aerosol_types = aerosol_type
         else:


=====================================
rsr_convert_scripts/agri_rsr.py
=====================================
@@ -80,7 +80,6 @@ class AGRIRSR(InstrumentRSR):
         self._get_options_from_config()
         self._get_bandfilenames()
 
-
         LOG.debug("Filenames: %s", str(self.filenames))
         if self.filenames[bandname] and os.path.exists(self.filenames[bandname]):
             self.requested_band_filename = self.filenames[bandname]


=====================================
rsr_convert_scripts/avhrr1_rsr.py
=====================================
@@ -22,15 +22,16 @@
 Data from NOAA: AVHRR1_SRF_only.xls
 """
 
+import logging
 import os
-from xlrd import open_workbook
-from pyspectral.config import get_config
-from pyspectral.utils import get_central_wave
+
+import h5py
 import numpy as np
 import pkg_resources
-import logging
-import h5py
+from xlrd import open_workbook
 
+from pyspectral.config import get_config
+from pyspectral.utils import get_central_wave
 
 LOG = logging.getLogger(__name__)
 


=====================================
rsr_convert_scripts/msu_gs_reader.py
=====================================
@@ -15,17 +15,20 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""Read the Electro-L N2 MSU-GS spectral response functions.
 
-"""Read the Electro-L N2 MSU-GS spectral response functions. Data from the NWPSAF:
+Data from the NWPSAF:
 https://nwp-saf.eumetsat.int/downloads/rtcoef_rttov13/ir_srf/rtcoef_electro-l_2_msugs_srf.html
 
 """
 
+import logging
 import os
+
 import numpy as np
-from pyspectral.utils import convert2hdf5 as tohdf5
+
 from pyspectral.raw_reader import InstrumentRSR
-import logging
+from pyspectral.utils import convert2hdf5 as tohdf5
 
 LOG = logging.getLogger(__name__)
 
@@ -40,12 +43,11 @@ _DEFAULT_LOG_FORMAT = '[%(levelname)s: %(asctime)s : %(name)s] %(message)s'
 
 
 class MsugsRSR(InstrumentRSR):
-    """Container for the Electro-L N2 MSU-GS relative spectral response data"""
+    """Container for the Electro-L N2 MSU-GS relative spectral response data."""
 
     def __init__(self, bandname, platform_name):
-
-        super(MsugsRSR, self).__init__(
-            bandname, platform_name, MSUGS_BAND_NAMES)
+        """Load files."""
+        super(MsugsRSR, self).__init__(bandname, platform_name, MSUGS_BAND_NAMES)
 
         self.instrument = 'msu-gs'
         self._get_options_from_config()
@@ -67,7 +69,7 @@ class MsugsRSR(InstrumentRSR):
         self.wavespace = 'wavelength'
 
     def _load(self, scale=10000.0):
-        """Load the MSU-GS RSR data for the band requested"""
+        """Load the MSU-GS RSR data for the band requested."""
         data = np.genfromtxt(self.requested_band_filename,
                              unpack=True,
                              names=['wavenumber',
@@ -84,7 +86,7 @@ class MsugsRSR(InstrumentRSR):
 
 
 def main():
-    """Main"""
+    """Run main script."""
     for platform_name in ['Electro-L-N2', ]:
         tohdf5(MsugsRSR, platform_name, MSUGS_BAND_NAMES)
 


=====================================
setup.cfg
=====================================
@@ -1,9 +1,3 @@
-[options]
-setup_requires =
-    setuptools_scm
-    setuptools_scm_git_archive
-
-
 [bdist_rpm]
 provides=pyspectral
 requires=numpy h5py python-geotiepoints dask PyYAML python-requests python-appdirs


=====================================
setup.py
=====================================
@@ -23,20 +23,11 @@ import os.path
 
 from setuptools import find_packages, setup
 
-try:
-    # HACK: https://github.com/pypa/setuptools_scm/issues/190#issuecomment-351181286
-    # Stop setuptools_scm from including all repository files
-    import setuptools_scm.integration
-    setuptools_scm.integration.find_files = lambda _: []
-except ImportError:
-    pass
-
-
 description = ('Reading and manipulaing satellite sensor spectral responses and the '
                'solar spectrum, to perfom various corrections to VIS and NIR band data')
 
 try:
-    with open('./README', 'r') as fd:
+    with open('./README.md', 'r') as fd:
         long_description = fd.read()
 except IOError:
     long_description = ''
@@ -62,8 +53,8 @@ setup(name=NAME,
                    'Topic :: Scientific/Engineering'],
       url='https://github.com/pytroll/pyspectral',
       long_description=long_description,
+      long_description_content_type="text/markdown",
       license='GPLv3',
-
       packages=find_packages(),
       include_package_data=True,
       package_data={
@@ -93,5 +84,4 @@ setup(name=NAME,
       tests_require=test_requires,
       python_requires='>=3.7',
       zip_safe=False,
-      use_scm_version=True
       )



View it on GitLab: https://salsa.debian.org/debian-gis-team/pyspectral/-/commit/5f5bd2c604920f1c8af2f975ca1696c01896309a

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/pyspectral/-/commit/5f5bd2c604920f1c8af2f975ca1696c01896309a
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20230923/2b3283a6/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list