[Git][debian-gis-team/trollimage][upstream] New upstream version 1.18.2

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Sun Mar 6 09:02:41 GMT 2022



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


Commits:
7adab2de by Antonio Valentino at 2022-03-06T08:51:57+00:00
New upstream version 1.18.2
- - - - -


5 changed files:

- CHANGELOG.md
- RELEASING.md
- trollimage/tests/test_image.py
- trollimage/version.py
- trollimage/xrimage.py


Changes:

=====================================
CHANGELOG.md
=====================================
@@ -1,3 +1,14 @@
+## Version 1.18.2 (2022/03/04)
+
+### Pull Requests Merged
+
+#### Bugs fixed
+
+* [PR 103](https://github.com/pytroll/trollimage/pull/103) - Fix geotiff scale/offset failing for non-linear enhancements
+
+In this release 1 pull request was closed.
+
+
 ## Version 1.18.1 (2022/02/28)
 
 ### Pull Requests Merged


=====================================
RELEASING.md
=====================================
@@ -6,7 +6,7 @@
 4. run `loghub` and update the `CHANGELOG.md` file:
 
    ```
-   loghub pytroll/trollimage --token $LOGHUB_GITHUB_TOKEN -st v<previous version> -plg bug "Bugs fixed" -plg enhancement "Features added" -plg documentation "Documentation changes" -plg backwards-incompatibility "Backward incompatible changes" -plg refactor "Refactoring"
+   loghub pytroll/trollimage --token $LOGHUB_GITHUB_TOKEN -st $(git tag --sort=-version:refname --list 'v*' | head -n 1) -plg bug "Bugs fixed" -plg enhancement "Features added" -plg documentation "Documentation changes" -plg backwards-incompatibility "Backward incompatible changes" -plg refactor "Refactoring"
    ```
 
    This uses a `LOGHUB_GITHUB_TOKEN` environment variable. This must be created


=====================================
trollimage/tests/test_image.py
=====================================
@@ -2193,10 +2193,10 @@ class TestXRImagePalettize:
                 np.testing.assert_allclose(new_brbg.colors, loaded_brbg.colors)
 
 
-class TestXRImageSaveScaleOffset(unittest.TestCase):
+class TestXRImageSaveScaleOffset:
     """Test case for saving an image with scale and offset tags."""
 
-    def setUp(self) -> None:
+    def setup_method(self) -> None:
         """Set up the test case."""
         from trollimage import xrimage
         data = xr.DataArray(np.arange(25).reshape(5, 5, 1), dims=[
@@ -2214,6 +2214,12 @@ class TestXRImageSaveScaleOffset(unittest.TestCase):
                 expected_tags,
                 include_scale_offset_tags=True)
 
+    def test_gamma_geotiff_scale_offset(self, tmp_path):
+        """Test that saving gamma-enhanced data to a geotiff doesn't fail."""
+        self.img.gamma(.5)
+        out_fn = str(tmp_path / "test.tif")
+        self.img.save(out_fn, scale_offset_tags=("scale", "offset"))
+
     def _save_and_check_tags(self, expected_tags, **kwargs):
         with NamedTemporaryFile(suffix='.tif') as tmp:
             self.img.save(tmp.name, **kwargs)


=====================================
trollimage/version.py
=====================================
@@ -23,9 +23,9 @@ def get_keywords():
     # setup.py/versioneer.py will grep for the variable names, so they must
     # each be defined on a line of their own. _version.py will just call
     # get_keywords().
-    git_refnames = " (HEAD -> main, tag: v1.18.1)"
-    git_full = "00cdfc459c7b24e512ae47d33e97b0c50c6288a8"
-    git_date = "2022-02-28 13:49:22 -0600"
+    git_refnames = " (HEAD -> main, tag: v1.18.2)"
+    git_full = "e5ddeb0ef5988f307c5f0baa6c8313d6e55a4b64"
+    git_date = "2022-03-04 09:37:18 -0600"
     keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
     return keywords
 


=====================================
trollimage/xrimage.py
=====================================
@@ -599,9 +599,7 @@ class XRImage(object):
         if colormap_tag and enhancement_colormap is not None:
             tags[colormap_tag] = enhancement_colormap.to_csv()
         if scale_offset_tags:
-            scale_label, offset_label = scale_offset_tags
-            scale, offset = self.get_scaling_from_history(data.attrs.get('enhancement_history', []))
-            tags[scale_label], tags[offset_label] = invert_scale_offset(scale, offset)
+            self._add_scale_offset_to_tags(scale_offset_tags, data, tags)
 
         # If we are changing the driver then use appropriate kwargs
         if driver == 'COG':
@@ -699,6 +697,15 @@ class XRImage(object):
             return delay.compute()
         return delay
 
+    def _add_scale_offset_to_tags(self, scale_offset_tags, data_arr, tags):
+        scale_label, offset_label = scale_offset_tags
+        try:
+            scale, offset = self.get_scaling_from_history(data_arr.attrs.get('enhancement_history', []))
+        except NotImplementedError:
+            logger.debug("Ignoring scale/offset tags for non-scaling enhancement operations")
+        else:
+            tags[scale_label], tags[offset_label] = invert_scale_offset(scale, offset)
+
     def get_scaling_from_history(self, history=None):
         """Merge the scales and offsets from the history.
 



View it on GitLab: https://salsa.debian.org/debian-gis-team/trollimage/-/commit/7adab2de434e77e7524678cb65d8ed5e00018720

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/trollimage/-/commit/7adab2de434e77e7524678cb65d8ed5e00018720
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/20220306/97b1963d/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list