def test_get_base_request_size_time_range(self): path = self.get_temporary_file_path('foo.nc') field = self.get_field(ntime=60) time_range = [field.time.get_value()[0], field.time.get_value()[1]] field.write(path) rd = RequestDataset(path) ops = OcgOperations(dataset=rd) size_no_tr = ops.get_base_request_size() time_size_no_tr = size_no_tr['field']['foo']['time']['kb'] ops = OcgOperations(dataset=rd, time_range=time_range) size_with_tr = ops.get_base_request_size() time_size_with_tr = size_with_tr['field']['foo']['time']['kb'] self.assertAlmostEqual(time_size_no_tr - time_size_with_tr, 0.453125)
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() actual = size['total'] desired = 1784714.6640625 self.assertAlmostEqual(actual, desired)
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.assertAlmostEqual(size['total'], 116890.046875) self.assertAsSetEqual(list(size['field']['tas'].keys()), list(rd.get().keys())) with self.assertRaises(DefinitionValidationError): OcgOperations(dataset=rd, regrid_destination=rd).get_base_request_size()
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') bdm = rd2.dimension_map bdm.set_variable(DMK.X, 'xc') bdm.set_variable(DMK.Y, 'yc') rd2 = self.test_data.get_rd('narccap_pr_wrfg_ncep', kwds={'dimension_map': bdm}) rds = [rd1, rd2] ops = OcgOperations(dataset=rds, geom='state_boundaries', select_ugid=[23]) size = ops.get_base_request_size() actual = size['total'] desired = 22243.46484375 self.assertAlmostEqual(actual, desired)
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['field']['tas']['time']['shape'][0], 3650)
def test_get_base_request_size_test_data(self): for key in list(self.test_data.keys()): rd = self.test_data.get_rd(key) ops = OcgOperations(dataset=rd) ret = ops.get_base_request_size() self.assertTrue(ret['total'] > 1)