Example #1
0
 def test_get_base_request_size_multifile_with_geom(self):
     rd1 = self.test_data.get_rd('cancm4_tas')
     rd2 = self.test_data.get_rd('narccap_pr_wrfg_ncep')
     rds = [rd1,rd2]
     ops = OcgOperations(dataset=rds,geom='state_boundaries',select_ugid=[23])
     size = ops.get_base_request_size()
     self.assertEqual(size,{'variables': {'pr': {'level': {'kb': 0.0, 'shape': None, 'dtype': None}, 'temporal': {'kb': 228.25, 'shape': (29216,), 'dtype': dtype('float64')}, 'value': {'kb': 21341.375, 'shape': (1, 29216, 1, 17, 11), 'dtype': dtype('float32')}, 'realization': {'kb': 0.0, 'shape': None, 'dtype': None}, 'col': {'kb': 0.0859375, 'shape': (11,), 'dtype': dtype('float64')}, 'row': {'kb': 0.1328125, 'shape': (17,), 'dtype': dtype('float64')}}, 'tas': {'level': {'kb': 0.0, 'shape': None, 'dtype': None}, 'temporal': {'kb': 28.515625, 'shape': (3650,), 'dtype': dtype('float64')}, 'value': {'kb': 171.09375, 'shape': (1, 3650, 1, 4, 3), 'dtype': dtype('float32')}, 'realization': {'kb': 0.0, 'shape': None, 'dtype': None}, 'col': {'kb': 0.0234375, 'shape': (3,), 'dtype': dtype('float64')}, 'row': {'kb': 0.03125, 'shape': (4,), 'dtype': dtype('float64')}}}, 'total': 21769.5078125})
Example #2
0
 def test_get_base_request_size_multifile(self):
     rd1 = self.test_data.get_rd('cancm4_tas')
     rd2 = self.test_data.get_rd('narccap_pr_wrfg_ncep')
     rds = [rd1,rd2]
     ops = OcgOperations(dataset=rds)
     size = ops.get_base_request_size()
     self.assertEqual({'variables': {'pr': {'level': {'kb': 0.0, 'shape': None, 'dtype': None}, 'temporal': {'kb': 228.25, 'shape': (29216,), 'dtype': dtype('float64')}, 'value': {'kb': 1666909.75, 'shape': (1, 29216, 1, 109, 134), 'dtype': dtype('float32')}, 'realization': {'kb': 0.0, 'shape': None, 'dtype': None}, 'col': {'kb': 1.046875, 'shape': (134,), 'dtype': dtype('float64')}, 'row': {'kb': 0.8515625, 'shape': (109,), 'dtype': dtype('float64')}}, 'tas': {'level': {'kb': 0.0, 'shape': None, 'dtype': None}, 'temporal': {'kb': 28.515625, 'shape': (3650,), 'dtype': dtype('float64')}, 'value': {'kb': 116800.0, 'shape': (1, 3650, 1, 64, 128), 'dtype': dtype('float32')}, 'realization': {'kb': 0.0, 'shape': None, 'dtype': None}, 'col': {'kb': 1.0, 'shape': (128,), 'dtype': dtype('float64')}, 'row': {'kb': 0.5, 'shape': (64,), 'dtype': dtype('float64')}}}, 'total': 1783969.9140625},size)
Example #3
0
 def test_get_base_request_size_test_data(self):
     for key in self.test_data.keys():
         rd = self.test_data.get_rd(key)
         try:
             ops = OcgOperations(dataset=rd)
         ## the project cmip data may raise an exception since projection is
         ## not associated with a variable
         except DimensionNotFound:
             rd = self.test_data.get_rd(key,kwds=dict(dimension_map={'R':'projection','T':'time','X':'longitude','Y':'latitude'}))
             ops = OcgOperations(dataset=rd)
         ret = ops.get_base_request_size()
         self.assertTrue(ret['total'] > 1)
Example #4
0
 def test_get_base_request_size_with_geom(self):
     rd = self.test_data.get_rd('cancm4_tas')
     ops = OcgOperations(dataset=rd, geom='state_boundaries', select_ugid=[23])
     size = ops.get_base_request_size()
     self.assertEqual(size, {'variables': {'tas': {'level': {'kb': 0.0, 'shape': None, 'dtype': None},
                                                   'temporal': {'kb': 28.515625, 'shape': (3650,),
                                                                'dtype': dtype('float64')},
                                                   'value': {'kb': 171.09375, 'shape': (1, 3650, 1, 4, 3),
                                                             'dtype': dtype('float32')},
                                                   'realization': {'kb': 0.0, 'shape': None, 'dtype': None},
                                                   'col': {'kb': 0.0234375, 'shape': (3,),
                                                           'dtype': dtype('float64')},
                                                   'row': {'kb': 0.03125, 'shape': (4,),
                                                           'dtype': dtype('float64')}}}, 'total': 199.6640625})
Example #5
0
    def test_get_base_request_size(self):
        rd = self.test_data.get_rd('cancm4_tas')
        ops = OcgOperations(dataset=rd)
        size = ops.get_base_request_size()
        self.assertEqual(size, {'variables': {'tas': {'level': {'kb': 0.0, 'shape': None, 'dtype': None},
                                                      'temporal': {'kb': 28.515625, 'shape': (3650,),
                                                                   'dtype': dtype('float64')},
                                                      'value': {'kb': 116800.0, 'shape': (1, 3650, 1, 64, 128),
                                                                'dtype': dtype('float32')},
                                                      'realization': {'kb': 0.0, 'shape': None, 'dtype': None},
                                                      'col': {'kb': 1.0, 'shape': (128,), 'dtype': dtype('float64')},
                                                      'row': {'kb': 0.5, 'shape': (64,), 'dtype': dtype('float64')}}},
                                'total': 116830.015625})

        with self.assertRaises(DefinitionValidationError):
            OcgOperations(dataset=rd, regrid_destination=rd).get_base_request_size()
Example #6
0
 def test_get_base_request_size_with_calculation(self):
     rd = self.test_data.get_rd('cancm4_tas')
     ops = OcgOperations(dataset=rd,calc=[{'func':'mean','name':'mean'}],
                         calc_grouping=['month'])
     size = ops.get_base_request_size()
     self.assertEqual(size['variables']['tas']['temporal']['shape'][0],3650)