Skip to content
Commits on Source (4)
[bumpversion]
current_version = 1.2.0
current_version = 1.2.1
commit = True
tag = True
......
language: python
python:
- "2.7_with_system_site_packages"
- "3.7"
# command to install dependencies, e.g.
install:
- pip install -r requirements.txt
......
## Version 1.2.1 (2019/11/15)
### Pull Requests Merged
#### Bugs fixed
* [PR 37](https://github.com/pytroll/pygac/pull/37) - Fixing geotiepoints attribute error for python2.7
* [PR 36](https://github.com/pytroll/pygac/pull/36) - Fix update of missing scanlines
#### Features added
* [PR 38](https://github.com/pytroll/pygac/pull/38) - Fix tests for python 3
In this release 3 pull requests were closed.
## Version 1.2.0 (2019/10/17)
### Issues Closed
* [Issue 33](https://github.com/pytroll/pygac/issues/33) - Make use of pytroll geotiepoints instead of using a deprecated copy
* [Issue 7](https://github.com/pytroll/pygac/issues/7) - Project URL points to wrong domain
In this release 1 issue was closed.
In this release 2 issues were closed.
### Pull Requests Merged
......@@ -14,10 +30,12 @@ In this release 1 issue was closed.
#### Features added
* [PR 35](https://github.com/pytroll/pygac/pull/35) - Changed azimuth angle range to ]-180, 180]
* [PR 34](https://github.com/pytroll/pygac/pull/34) - Use the geotiepoints library
* [PR 32](https://github.com/pytroll/pygac/pull/32) - Updated documentation about azimuth angles
* [PR 31](https://github.com/pytroll/pygac/pull/31) - Refactor I/O
In this release 3 pull requests were closed.
In this release 5 pull requests were closed.
## Version 1.1.0 (2019/06/12)
......
pygac (1.2.1-1) UNRELEASED; urgency=medium
* New upstream release.
* debian/patches:
- drop 0003-fix-import-mock.patch (applied upstream)
- refresh remaining patches
-- Antonio Valentino <antonio.valentino@tiscali.it> Sun, 17 Nov 2019 06:54:29 +0000
pygac (1.2.0-1) unstable; urgency=medium
* New upstream release.
......
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Sun, 7 Jul 2019 21:49:26 +0200
Subject: fix import mock
---
pygac/tests/test_io.py | 2 +-
pygac/tests/test_reader.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pygac/tests/test_io.py b/pygac/tests/test_io.py
index e3cea78..dcd462d 100644
--- a/pygac/tests/test_io.py
+++ b/pygac/tests/test_io.py
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
-import mock
+from unittest import mock
import numpy as np
import numpy.testing
import pygac.gac_io as gac_io
diff --git a/pygac/tests/test_reader.py b/pygac/tests/test_reader.py
index 6fea775..be9447a 100644
--- a/pygac/tests/test_reader.py
+++ b/pygac/tests/test_reader.py
@@ -20,7 +20,7 @@
import datetime
import unittest
-import mock
+from unittest import mock
import numpy as np
import numpy.testing
from pygac.gac_reader import GACReader
0001-Temporary-disable-broken-tests.patch
0002-Fix-config.patch
0003-fix-import-mock.patch
......@@ -41,7 +41,7 @@ from pyorbital.orbital import Orbital
from pyorbital import astronomy
import datetime
from pygac.calibration import calibrate_solar, calibrate_thermal
import pygac.geotiepoints as gtp
import pygac.pygac_geotiepoints as gtp
LOG = logging.getLogger(__name__)
......@@ -792,7 +792,7 @@ class GACReader(six.with_metaclass(ABCMeta)):
# find the missing line numbers.
ideal = set(range(1, self.scans['scan_line_number'][-1] + 1))
missing = sorted(ideal.difference(set(self.scans['scan_line_number'])))
return np.array(missing)
return np.array(missing, dtype=int)
def mask_tsm_pixels(self, channels):
"""Mask pixels affected by the scan motor issue."""
......
......@@ -21,8 +21,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/>.
"""Interpolation of geographical tiepoints.
"""
"""Interpolation of geographical tiepoints."""
import geotiepoints as gtp
......@@ -30,12 +29,13 @@ import geotiepoints as gtp
import numpy as np
def Gac_Lat_Lon_Interpolator(lons_subset, lats_subset):
"""Interpolate lat-lon values in the AVHRR GAC data from every eigth pixel to all pixels.
"""Interpolate lat-lon values in the AVHRR GAC data.
Each GAC row has 409 pixels.
But lat-lon values are provided for every eigth pixel,
ranging from 5 to 405. Interpolate to full resolution.
Each GAC row has total 409 pixels. But lat-lon values are provided for every eigth pixel
starting from pixel 5 and ending at pixel 405.
"""
# cols_subset = np.arange(0, 404, 8)
# cols_full = np.arange(405)
......
......@@ -17,9 +17,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Test the I/O."""
import unittest
try:
import mock
except ImportError:
from unittest import mock
import numpy as np
import numpy.testing
import pygac.gac_io as gac_io
......@@ -27,17 +31,19 @@ import pygac.utils as utils
class TestIO(unittest.TestCase):
"""Test the gac_io module"""
"""Test the gac_io module."""
longMessage = True
def test_strip_invalid_lat(self):
"""Test stripping the invalid lats."""
lats = np.array([np.nan, 1, np.nan, 2, np.nan])
start, end = utils.strip_invalid_lat(lats)
self.assertEqual(start, 1)
self.assertEqual(end, 3)
def test_update_scanline(self):
"""Test updating the scanlines."""
test_data = [{'new_start_line': 100, 'new_end_line': 200,
'scanline': 110, 'scanline_exp': 10},
{'new_start_line': 100, 'new_end_line': 200,
......@@ -50,6 +56,7 @@ class TestIO(unittest.TestCase):
self.assertEqual(scanline, scanline_exp)
def test_update_missing_scanlines(self):
"""Test updating the missing scanlines."""
qual_flags = np.array([[1, 2, 4, 5, 6, 8, 9, 11, 12]]).transpose()
miss_lines = np.array([3, 7, 10])
test_data = [{'start_line': 0, 'end_line': 8,
......@@ -62,7 +69,18 @@ class TestIO(unittest.TestCase):
miss_lines=miss_lines, qual_flags=qual_flags, **t)
numpy.testing.assert_array_equal(miss_lines, miss_lines_exp)
# If intersection of miss_lines and qual_flags is not empty
# (here: extra "1" in miss_lines), make sure that items are
# not added twice.
miss_lines = utils._update_missing_scanlines(
miss_lines=np.array([1, 3, 7, 10]),
qual_flags=qual_flags,
start_line=3, end_line=6)
numpy.testing.assert_array_equal(miss_lines,
[1, 2, 3, 4, 7, 10, 11, 12])
def test_slice(self):
"""Test slices."""
ch = np.array([[1, 2, 3, 4, 5]]).transpose()
sliced_exp = np.array([[2, 3, 4]]).transpose()
......@@ -134,6 +152,7 @@ class TestIO(unittest.TestCase):
self.assertEqual(midn_line_new, 0)
def test_check_user_scanlines(self):
"""Check the scanlines."""
# All scanlines
start, end = utils.check_user_scanlines(0, 0, 100, 200)
self.assertEqual(start, 0)
......@@ -170,8 +189,9 @@ class TestIO(unittest.TestCase):
@mock.patch('pygac.gac_io.avhrrGAC_io')
@mock.patch('pygac.gac_io.slice_channel')
@mock.patch('pygac.gac_io.check_user_scanlines')
def test_save_gac(self, check_user_scanlines, slice_channel, avhrrGAC_io,
def test_save_gac(self, check_user_scanlines, slice_channel, avhrr_gac_io,
strip_invalid_lat):
"""Test saving."""
# Test scanline selection
mm = mock.MagicMock()
kwargs = dict(
......@@ -234,11 +254,11 @@ class TestIO(unittest.TestCase):
'midnight',
'miss'
]
avhrrGAC_io.assert_called_with(*expected_args)
avhrr_gac_io.assert_called_with(*expected_args)
def suite():
"""The suite for test_io"""
"""Test suite for test_io."""
loader = unittest.TestLoader()
mysuite = unittest.TestSuite()
mysuite.addTest(loader.loadTestsFromTestCase(TestIO))
......
......@@ -17,10 +17,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Test the readers."""
import datetime
import unittest
try:
import mock
except ImportError:
from unittest import mock
import numpy as np
import numpy.testing
from pygac.gac_reader import GACReader
......@@ -34,6 +38,7 @@ class TestGacReader(unittest.TestCase):
@mock.patch.multiple('pygac.gac_reader.GACReader',
__abstractmethods__=set())
def setUp(self, *mocks):
"""Set up the tests."""
self.reader = GACReader()
def test_to_datetime64(self):
......@@ -111,6 +116,21 @@ class TestGacReader(unittest.TestCase):
for method in methods:
method.asser_not_called()
@mock.patch('pygac.gac_reader.GACReader._get_corrupt_mask')
@mock.patch('pygac.gac_reader.GACReader._adjust_clock_drift')
@mock.patch('pygac.gac_reader.GACReader._get_lonlat')
def test_interpolate(self, _get_lonlat, _adjust_clock_drift,
_get_corrupt_mask):
"""Test interpolate method in get_lonlat."""
self.lons = None
self.lats = None
lons = 90 * np.random.rand(17, 51)
lats = 90 * np.random.rand(17, 51)
_get_lonlat.return_value = lons, lats
self.interpolate_coors = True
lons, lats = self.reader.get_lonlat()
self.assertEqual(lons.shape[1], 409)
@mock.patch('pygac.gac_reader.GACReader._get_corrupt_mask')
def test_get_corrupt_mask(self, get_corrupt_mask):
"""Test common computation of corrupt scanline mask."""
......@@ -146,8 +166,10 @@ class TestGacReader(unittest.TestCase):
self.reader.scans = np.zeros(
len(lines), dtype=[('scan_line_number', 'i2')])
self.reader.scans['scan_line_number'] = lines
self.assertTrue((self.reader.get_miss_lines() == miss_lines_ref).all(),
miss_lines = self.reader.get_miss_lines()
self.assertTrue((miss_lines == miss_lines_ref).all(),
msg='Missing scanlines not detected correctly')
self.assertEqual(miss_lines.dtype, int)
def test_tle2datetime64(self, *mocks):
"""Test conversion from TLE timestamps to datetime64."""
......@@ -267,6 +289,7 @@ class TestGacReader(unittest.TestCase):
Returns:
Corrupted and corrected scanline numbers.
"""
along_track = 12000
scans = np.zeros(12000, dtype=[("scan_line_number", ">u2")])
......@@ -320,7 +343,7 @@ class TestGacReader(unittest.TestCase):
def suite():
"""The suite for test_reader"""
"""Test suite for test_reader."""
loader = unittest.TestLoader()
mysuite = unittest.TestSuite()
mysuite.addTest(loader.loadTestsFromTestCase(TestGacReader))
......
......@@ -30,6 +30,14 @@ def check_user_scanlines(start_line, end_line, first_valid_lat=None,
"""Check user-defined scanlines.
Can be used by both pygac and satpy.
Args:
start_line: User-defined start line (afer stripping, if enabled)
end_line: User-defined end line (afer stripping, if enabled)
first_valid_lat: First scanline with valid latitudes
last_valid_lat: Last scanline with valid latitudes
along_track: Number of scanlines (only needed if stripping
is disabled)
"""
if first_valid_lat is not None and last_valid_lat is not None:
num_valid_lines = last_valid_lat - first_valid_lat + 1
......@@ -155,7 +163,7 @@ def _update_missing_scanlines(miss_lines, qual_flags, start_line, end_line):
start_line: New start line of the slice
end_line: New end line of the slice
"""
return np.sort(np.array(
return np.sort(np.unique(
qual_flags[0:start_line, 0].tolist() +
miss_lines.tolist() +
qual_flags[end_line + 1:, 0].tolist()
......
......@@ -22,4 +22,4 @@
"""Just holding the version of the pygac module."""
__version__ = '1.2.0'
__version__ = '1.2.1'