def PlotFirstField(filename, variable = "Marine Air Temperature", vmin = None,vmax = None, field = 0): ''' Plot the first field of the data in the netcdf file - i.e. a map of the humidities in the first month uses iris :param cube cube: the input cube :returns: None ''' import matplotlib.pyplot as plt import iris.quickplot as qplt import cartopy.crs as ccrs import iris cube = iris.load_cube(filename, variable) plt.clf() ax = plt.axes(projection=ccrs.Robinson()) ax.gridlines() #draw_labels=True) ax.coastlines() qplt.pcolor(cube[field], cmap=plt.cm.PiYG,vmin=vmin,vmax=vmax) plt.show() return # PlotFirstField
def test_orography(self): qplt.contourf(self.cube) iplt.orography_at_points(self.cube) iplt.points(self.cube) self.check_graphic() coords = ['altitude', 'grid_longitude'] qplt.contourf(self.cube, coords=coords) iplt.orography_at_points(self.cube, coords=coords) iplt.points(self.cube, coords=coords) self.check_graphic() # TODO: Test bounds once they are supported. with self.assertRaises(NotImplementedError): qplt.pcolor(self.cube) iplt.orography_at_bounds(self.cube) iplt.outline(self.cube) self.check_graphic()
def test_osgb_to_latlon(self): path = tests.get_data_path( ('NIMROD', 'uk2km', 'WO0000000003452', '201007020900_u1096_ng_ey00_visibility0180_screen_2km')) src = iris.load_cube(path)[0] src.data = src.data.astype(np.float32) grid = Cube(np.empty((73, 96))) cs = GeogCS(6370000) lat = DimCoord(np.linspace(46, 65, 73), 'latitude', units='degrees', coord_system=cs) lon = DimCoord(np.linspace(-14, 8, 96), 'longitude', units='degrees', coord_system=cs) grid.add_dim_coord(lat, 0) grid.add_dim_coord(lon, 1) result = regrid(src, grid) qplt.pcolor(result, antialiased=False) qplt.plt.gca().coastlines() self.check_graphic()
def main(): # Parameters to compare between forecasts path = datadir + 'deterministic/' filename = 'rp_physics.nc' name = 'Temperature [K]' pressure = 500 lead_time = 7*24 cs = iris.Constraint( name=name, pressure=pressure, forecast_period=lead_time) # Load full precision reference forecast cube = iris.load_cube(path + filename, cs) # Calculate the errors with each different precision used as the `truth` diffs = CubeList() for pseudo_truth in cube.slices_over('precision'): # Add the precision of the `truth` cube as another coordinate p = pseudo_truth.coord('precision').points[0] p = AuxCoord(p, long_name='reference_precision') # Calculate the errors diff = rms_diff(cube, pseudo_truth) diff.add_aux_coord(p) # Store the errors in the cubelist diffs.append(diff) # Combine all the errors into a single cube with dimensions of # precision vs reference_precision diffs = diffs.merge_cube() # Plot the errors qplt.pcolor(diffs, vmin=0, cmap='cubehelix_r') precisions = cube.coord('precision').points plt.xticks(precisions) plt.yticks(precisions) plt.show() return
def test_pcolor(self): qplt.pcolor(self._small()) self.check_graphic()
def _check(self, cube): qplt.contourf(cube) self.check_graphic() qplt.pcolor(cube) self.check_graphic()
def test_bounds(self): cube = simple_cube() qplt.pcolor(cube) self.check_graphic()
def test_xaxis_labels(self): qplt.pcolor(self.cube, coords=("str_coord", "bar")) self.assertBoundsTickLabels("xaxis")
def test_xaxis_labels(self): qplt.pcolor(self.cube, coords=('str_coord', 'bar')) self.assertBoundsTickLabels('xaxis')
def _regrid(self, method): regridder = Regridder(self.src, self.grid, method, 'mask') result = regridder(self.src) qplt.pcolor(result, antialiased=False) qplt.plt.gca().coastlines()