Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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,))
Exemplo n.º 3
0
 def test_numberOfSection(self):
     n = 4
     section = _Section(self.grib_id, n, ['numberOfSection'])
     self.assertEqual(section['numberOfSection'], n)
Exemplo n.º 4
0
 def test_invalid(self):
     section = _Section(self.grib_id, None, ['Ni'])
     with self.assertRaisesRegexp(KeyError, 'Nii'):
         section['Nii']
Exemplo n.º 5
0
 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])
Exemplo n.º 6
0
 def test_typeOfFirstFixedSurface(self):
     section = _Section(self.grib_id, None, ['typeOfFirstFixedSurface'])
     self.assertEqual(section['typeOfFirstFixedSurface'], 100)
Exemplo n.º 7
0
 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, ))
Exemplo n.º 8
0
 def test_scalar(self):
     section = _Section(self.grib_id, None, ['Ni'])
     self.assertEqual(section['Ni'], 47)
Exemplo n.º 9
0
 def test_invalid(self):
     section = _Section(self.grib_id, None, ['Ni'])
     with self.assertRaisesRegexp(KeyError, 'Nii'):
         section['Nii']
Exemplo n.º 10
0
 def test_numberOfSection(self):
     n = 4
     section = _Section(self.grib_id, n, ['numberOfSection'])
     self.assertEqual(section['numberOfSection'], n)
Exemplo n.º 11
0
 def test_typeOfFirstFixedSurface(self):
     section = _Section(self.grib_id, None, ['typeOfFirstFixedSurface'])
     self.assertEqual(section['typeOfFirstFixedSurface'], 100)
Exemplo n.º 12
0
 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])
Exemplo n.º 13
0
 def test_scalar(self):
     section = _Section(self.grib_id, None, ['Ni'])
     self.assertEqual(section['Ni'], 47)