Skip to content

Commit

Permalink
integrated changes requested by Mike
Browse files Browse the repository at this point in the history
  • Loading branch information
TomBlock committed Aug 23, 2019
1 parent 2b5a0b4 commit b98fa91
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
6 changes: 6 additions & 0 deletions fiduceo/fcdr/test/read_write/avhrr_iotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ def add_global_attributes(self, dataset):
dataset.attrs["history"] = "new"
dataset.attrs["references"] = "myself"
dataset.attrs["comment"] = "should define a test version of this set"
dataset.attrs["Ch3a_Ch3b_split_file"] = "maybe"
dataset.attrs["Ch3a_only"] = "nope"
dataset.attrs["Ch3b_only"] = "dunno"
dataset.attrs["UUID"] = "abcdefghi"
dataset.attrs["sensor"] = "yo"
dataset.attrs["platform"] = "up there"

def add_geolocation_data(self, dataset):
for x in range(0, PRODUCT_WIDTH):
Expand Down
27 changes: 27 additions & 0 deletions fiduceo/fcdr/test/writer/templates/avhrr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ def test_add_original_variables(self):
self.assertEqual("Acquisition time in seconds since 1970-01-01 00:00:00", time.attrs["long_name"])
self.assertEqual("s", time.attrs["units"])

rel_azimuth = ds.variables["relative_azimuth_angle"]
self.assertEqual((5, 409), rel_azimuth.shape)
self.assertTrue(np.isnan(rel_azimuth.data[1, 6]))
self.assertEqual("relative_azimuth_angle", rel_azimuth.attrs["standard_name"])
self.assertEqual("degree", rel_azimuth.attrs["units"])
self.assertEqual(18000, rel_azimuth.attrs["valid_max"])
self.assertEqual(-18000, rel_azimuth.attrs["valid_min"])
self.assertEqual("longitude latitude", rel_azimuth.attrs["coordinates"])
self.assertEqual(np.int16, rel_azimuth.encoding['dtype'])
self.assertEqual(DefaultData.get_default_fill_value(np.int16), rel_azimuth.encoding['_FillValue'])
self.assertEqual(0.01, rel_azimuth.encoding['scale_factor'])
self.assertEqual(0.0, rel_azimuth.encoding['add_offset'])
self.assertEqual(CHUNKING, rel_azimuth.encoding["chunksizes"])

sat_zenith = ds.variables["satellite_zenith_angle"]
self.assertEqual((5, 409), sat_zenith.shape)
self.assertTrue(np.isnan(sat_zenith.data[0, 5]))
Expand Down Expand Up @@ -349,6 +363,19 @@ def test_add_template_key(self):

self.assertEqual("AVHRR", ds.attrs["template_key"])

def test_add_specific_global_metadata(self):
ds = xr.Dataset()

AVHRR.add_specific_global_metadata(ds)

self.assertIsNone(ds.attrs["Ch3a_Ch3b_split_file"])
self.assertIsNone(ds.attrs["Ch3a_only"])
self.assertIsNone(ds.attrs["Ch3b_only"])
self.assertIsNone(ds.attrs["UUID"])
self.assertIsNone(ds.attrs["comment"])
self.assertIsNone(ds.attrs["sensor"])
self.assertIsNone(ds.attrs["platform"])

def _assert_earth_counts_pdf(self, ds, name):
variable = ds.variables[name]
self.assertEqual("digitised_gaussian", variable.attrs["pdf_shape"])
Expand Down
8 changes: 7 additions & 1 deletion fiduceo/fcdr/writer/templates/avhrr.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ def add_original_variables(dataset, height, srf_size=None):

@staticmethod
def add_specific_global_metadata(dataset):
pass
dataset.attrs["Ch3a_Ch3b_split_file"] = None
dataset.attrs["Ch3a_only"] = None
dataset.attrs["Ch3b_only"] = None
dataset.attrs["UUID"] = None
dataset.attrs["comment"] = None
dataset.attrs["sensor"] = None
dataset.attrs["platform"] = None

@staticmethod
def get_swath_width():
Expand Down

0 comments on commit b98fa91

Please sign in to comment.