def test_lazy_data(self): cube = self.cube.copy() # "Rebase" the cube onto a lazy version of its data. cube.data = cube.lazy_data() # Check that lazy data is preserved in save-pairs generation. slices_and_fields = save_pairs_from_cube(cube) for aslice, _ in slices_and_fields: self.assertTrue(aslice.has_lazy_data())
def test_lazy_data(self): cube = self.cube.copy() # "Rebase" the cube onto a lazy version of its data. cube.data = cube.lazy_data() # Check that lazy data is preserved in save-pairs generation. slices_and_fields = save_pairs_from_cube(cube) for aslice, _ in slices_and_fields: self.assertTrue(aslice.has_lazy_data())
def test_field_coords(self): slices_and_fields = save_pairs_from_cube( self.cube, field_coords=['grid_longitude', 'grid_latitude']) for aslice, field in slices_and_fields: self.assertEqual(aslice.shape, (11, 9)) self.assertEqual(field.lbcode, 101)
def test_default_bmdi(self): slices_and_fields = save_pairs_from_cube(self.cube) _, field = next(slices_and_fields) self.assertEqual(field.bmdi, -1e30)
def test_field_coords(self): slices_and_fields = save_pairs_from_cube( self.cube, field_coords=["grid_longitude", "grid_latitude"]) for aslice, field in slices_and_fields: self.assertEqual(aslice.shape, (11, 9)) self.assertEqual(field.lbcode, 101)
def test_cube_only(self): slices_and_fields = save_pairs_from_cube(self.cube) for aslice, field in slices_and_fields: self.assertEqual(aslice.shape, (9, 11)) self.assertEqual(field.lbcode, 101)
'/home/williamsjh/cylc-run/u-ai955/share/data/History_Data/*pg*', stash) stash = iris.AttributeConstraint(STASH=stashcode[3]) var34150 = iris.load( '/home/williamsjh/cylc-run/u-ai955/share/data/History_Data/*pg*', stash) #Concatenate the variables cat = iris.cube.CubeList([var30201[0], var30204[0], var30205[0], var34150[0]]) #Save to an output file #iris.save(cat,'apg.nc') import iris.fileformats.pp as pp with open('apg.pp', 'wb') as fh: i = 0 for cube in cat: # print i for sub_cube, field in pp.save_pairs_from_cube(cube): if field.lbnpt == 0: field.bdx = 1 field.bzx = sub_cube.coord('longitude').points[0] - field.bdx field.lbnpt = 1 else: pass field.save(fh) i = i + 1
def test_default_bmdi(self): slices_and_fields = save_pairs_from_cube(self.cube) _, field = next(slices_and_fields) self.assertEqual(field.bmdi, -1e30)
def test_cube_only(self): slices_and_fields = save_pairs_from_cube(self.cube) for aslice, field in slices_and_fields: self.assertEqual(aslice.shape, (9, 11)) self.assertEqual(field.lbcode, 101)