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