From 79ead57817d3462212becfd82d95063debfd2b6b Mon Sep 17 00:00:00 2001 From: Kat Kolman Date: Tue, 18 Dec 2018 16:04:21 -0600 Subject: [PATCH] Update test_viirs --- satpy/tests/enhancement_tests/test_viirs.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/satpy/tests/enhancement_tests/test_viirs.py b/satpy/tests/enhancement_tests/test_viirs.py index 6ff5d62bf3..532eda8e8a 100644 --- a/satpy/tests/enhancement_tests/test_viirs.py +++ b/satpy/tests/enhancement_tests/test_viirs.py @@ -4,7 +4,7 @@ import unittest import numpy as np import xarray as xr -from .test_enhancements import TestEnhancementStretch +import dask.array as da class TestVIIRSEnhancement(unittest.TestCase): @@ -51,8 +51,22 @@ def test_viirs(self): from satpy.enhancements.viirs import water_detection expected = [[[1, 7, 8, 8, 8, 9, 10, 11, 14, 8], [20, 23, 26, 10, 12, 15, 18, 21, 24, 27]]] - TestEnhancementStretch._test_enhancement(self, water_detection, self.da, - expected, palettes=self.palette) + self._test_enhancement(water_detection, self.da, expected, + palettes=self.palette) + + def _test_enhancement(self, func, data, expected, **kwargs): + from trollimage.xrimage import XRImage + + pre_attrs = data.attrs + img = XRImage(data) + func(img, **kwargs) + + self.assertIsInstance(img.data.data, da.Array) + self.assertListEqual(sorted(pre_attrs.keys()), + sorted(img.data.attrs.keys()), + "DataArray attributes were not preserved") + + np.testing.assert_allclose(img.data.values, expected, atol=1.e-6, rtol=0) def tearDown(self): """Clean up"""