Skip to content

Commit

Permalink
Merge pull request #86 from adybbroe/switch-from-versioneer
Browse files Browse the repository at this point in the history
Switch from versioneer
  • Loading branch information
adybbroe authored Oct 8, 2019
2 parents 4644125 + e233418 commit 34d0c2e
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 2,414 deletions.
1 change: 1 addition & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref-names: $Format:%D$
19 changes: 9 additions & 10 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import sys
import os
from pkg_resources import get_distribution

# PYTHONPATH = docs/source
DOC_SOURCES_DIR = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -34,6 +35,14 @@
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('satpy').version
# for example take major/minor
version = '.'.join(release.split('.')[:2])


class Mock(object):

Expand Down Expand Up @@ -108,16 +117,6 @@ def __getattr__(cls, name):
project = u'Pyspectral'
copyright = u'2013-2018, PyTroll'

# 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.
#
import pyspectral.version as current_version

# The full version, including alpha/beta/rc tags.
release = current_version.get_versions()['version']
# The short X.Y version.
version = ".".join(release.split(".")[: 2])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
11 changes: 7 additions & 4 deletions pyspectral/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2013 - 2018 PyTroll Community
# Copyright (c) 2013 - 2019 PyTroll Community


# Author(s):
Expand All @@ -24,6 +24,9 @@

"""Pyspectral package init"""

from .version import get_versions
__version__ = get_versions()['version']
del get_versions
from pkg_resources import get_distribution, DistributionNotFound
try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
pass
2 changes: 1 addition & 1 deletion pyspectral/blackbody.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def blackbody_rad2temp(wavelength, radiance):


def blackbody_wn_rad2temp(wavenumber, radiance):
"""Derive brightness temperatures from radiance using the Planck
"""Derive brightness temperatures from radiance using the Planck
function. Wavenumber space"""

if np.isscalar(radiance):
Expand Down
2 changes: 1 addition & 1 deletion pyspectral/raw_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Base class for reading raw instrument spectral responses
"""Base class for reading raw instrument spectral responses
"""

import os
Expand Down
7 changes: 3 additions & 4 deletions pyspectral/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

"""The tests package"""

import doctest
import os
from pyspectral import (blackbody,
near_infrared_reflectance,
solar)
Expand All @@ -32,17 +34,14 @@
test_solarflux,
test_utils,
test_rad_tb_conversions,
test_rsr_reader,
test_atm_correction_ir)
test_rsr_reader)

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

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

Expand Down
5 changes: 3 additions & 2 deletions pyspectral/tests/test_reflectance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2013-2018 Adam.Dybbroe
# Copyright (c) 2013-2019 Adam.Dybbroe

# Author(s):

Expand Down Expand Up @@ -109,7 +109,7 @@ def setUp(self):

def test_rsr_integral(self):
"""Test calculating the integral of the relative spectral response
function.
function.
"""
with patch('pyspectral.radiance_tb_conversion.RelativeSpectralResponse') as mymock:
instance = mymock.return_value
Expand Down Expand Up @@ -148,6 +148,7 @@ def test_reflectance(self):

with self.assertRaises(NotImplementedError):
dummy = Calculator('Suomi-NPP', 'viirs', 10.8)
del dummy

refl37 = Calculator('Suomi-NPP', 'viirs', 3.7)
self.assertEqual(refl37.bandwavelength, 3.7)
Expand Down
5 changes: 3 additions & 2 deletions pyspectral/tests/test_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) 2017, 2018 Adam.Dybbroe
# Copyright (c) 2017, 2018, 2019 Adam.Dybbroe

# Author(s):

Expand All @@ -23,6 +23,7 @@
"""Unit testing the generic rsr hdf5 reader
"""
import sys
import os.path
from pyspectral.rsr_reader import RelativeSpectralResponse
from pyspectral.utils import WAVE_NUMBER
from pyspectral.utils import RSR_DATA_VERSION
Expand Down Expand Up @@ -77,7 +78,7 @@

DIR_PATH_ITEMS = ['test', 'path', 'to', 'rsr', 'data']
TEST_CONFIG = {}
import os.path

TEST_RSR_DIR = os.path.join(*DIR_PATH_ITEMS)
TEST_CONFIG['rsr_dir'] = TEST_RSR_DIR

Expand Down
5 changes: 3 additions & 2 deletions pyspectral/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,17 @@ def sort_data(x_vals, y_vals):
no duplicates.
"""
# Sort data
# (This is needed in particular for EOS-Terra responses, as there are duplicates)
idxs = np.argsort(x_vals)
x_vals = x_vals[idxs]
y_vals = y_vals[idxs]

# De-duplicate data
mask = np.r_[True, (np.diff(x_vals) > 0)]
if not mask.all():
# what is this for?
numof_duplicates = np.repeat(mask, np.equal(mask, False)).shape[0]
del numof_duplicates
LOG.debug("Number of duplicates in the response function: %d - removing them",
numof_duplicates)
x_vals = x_vals[mask]
y_vals = y_vals[mask]

Expand Down
Loading

0 comments on commit 34d0c2e

Please sign in to comment.