def test_gdt40_computed(self): fname = tests.get_data_path(('GRIB', 'gaussian', 'regular_gg.grib2')) with open(fname, 'rb') as grib_fh: self.grib_id = gribapi.grib_new_from_file(grib_fh) section = Section(self.grib_id, None, []) latitudes = section.get_computed_key('latitudes') self.assertTrue(88.55 < latitudes[0] < 88.59)
def test_array(self): section = Section(self.grib_id, None, self.keys) for key in self.keys: value = section[key] self.assertIsInstance(value, np.ndarray) self.assertEqual(value.shape, (1,))
def test_invalid(self): section = Section(self.grib_id, None, ['Ni']) with self.assertRaisesRegexp(KeyError, 'Nii'): section['Nii']
def test_numberOfSection(self): n = 4 section = Section(self.grib_id, n, ['numberOfSection']) self.assertEqual(section['numberOfSection'], n)
def test_typeOfFirstFixedSurface(self): section = Section(self.grib_id, None, ['typeOfFirstFixedSurface']) self.assertEqual(section['typeOfFirstFixedSurface'], 100)
def test_array(self): section = Section(self.grib_id, None, ['codedValues']) codedValues = section['codedValues'] self.assertEqual(codedValues.shape, (1551,)) self.assertArrayAlmostEqual(codedValues[:3], [-1.78140259, -1.53140259, -1.28140259])
def test_scalar(self): section = Section(self.grib_id, None, ['Ni']) self.assertEqual(section['Ni'], 47)