Skip to content

Commit

Permalink
Update test_viirs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kat Kolman committed Jan 8, 2019
1 parent db5f53a commit 79ead57
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions satpy/tests/enhancement_tests/test_viirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit 79ead57

Please sign in to comment.