def test_image(self, iwsi, save_dataset): """Test saving an image.""" from satpy.writers.ninjotiff import NinjoTIFFWriter ntw = NinjoTIFFWriter() dataset = xr.DataArray([1, 2, 3], attrs={'units': 'K'}) img = FakeImage(dataset, 'L') ret = ntw.save_image(img, filename='bla.tif', compute=False) self.assertIsInstance(ret, Delayed)
def test_dataset(self, uconv, iwsd): """Test saving a dataset.""" from satpy.writers.ninjotiff import NinjoTIFFWriter ntw = NinjoTIFFWriter() dataset = xr.DataArray([1, 2, 3], attrs={'units': 'K'}) ntw.save_dataset(dataset, physic_unit='CELSIUS') uconv.assert_called_once_with(dataset, 'K', 'CELSIUS') self.assertEqual(iwsd.call_count, 1)
def test_P_image_is_uint8(self, iwsi, save_dataset): """Test that a P-mode image is converted to uint8s.""" nt = pyninjotiff_mock.ninjotiff nt.reset_mock() from satpy.writers.ninjotiff import NinjoTIFFWriter ntw = NinjoTIFFWriter() dataset = xr.DataArray([1, 2, 3]).astype(int) img = FakeImage(dataset, 'P') ntw.save_image(img, filename='bla.tif', compute=False) assert nt.save.mock_calls[0][1][0].data.dtype == np.uint8
def test_dataset_skip_unit_conversion(self, iwsd): """Test saving a dataset without unit conversion.""" from satpy.writers.ninjotiff import NinjoTIFFWriter ntw = NinjoTIFFWriter() dataset = xr.DataArray([1, 2, 3], attrs={'units': 'K'}) with mock.patch('satpy.writers.ninjotiff.convert_units') as uconv: ntw.save_dataset(dataset, physic_unit='CELSIUS', convert_temperature_units=False) uconv.assert_not_called() self.assertEqual(iwsd.call_count, 1)
def test_image(self, iwsi, save_dataset): """Test saving an image.""" import pyninjotiff.ninjotiff as nt from satpy.writers.ninjotiff import NinjoTIFFWriter ntw = NinjoTIFFWriter() dataset = xr.DataArray([1, 2, 3], attrs={'units': 'K'}) img = FakeImage(dataset, 'L') ret = ntw.save_image(img, filename='bla.tif', compute=False) nt.save.assert_called() assert (nt.save.mock_calls[0][2]['compute'] is False) assert (nt.save.mock_calls[0][2]['ch_min_measurement_unit'] < nt.save.mock_calls[0][2]['ch_max_measurement_unit']) assert (ret == nt.save.return_value)
def test_init(self): """Test the init.""" from satpy.writers.ninjotiff import NinjoTIFFWriter ninjo_tags = {40000: 'NINJO'} ntw = NinjoTIFFWriter(tags=ninjo_tags) self.assertDictEqual(ntw.tags, ninjo_tags)
def test_init(self): from satpy.writers.ninjotiff import NinjoTIFFWriter NinjoTIFFWriter()