Esempio n. 1
0
 def test_yaxis_labels_with_axes(self):
     import matplotlib.pyplot as plt
     fig = plt.figure()
     ax = fig.add_subplot(111)
     ax.set_ylim(0, 3)
     iplt.points(self.cube, coords=('bar', 'str_coord'), axes=ax)
     plt.close(fig)
     self.assertPointsTickLabels('yaxis', ax)
Esempio n. 2
0
 def test_yaxis_labels_with_axes(self):
     import matplotlib.pyplot as plt
     fig = plt.figure()
     ax = fig.add_subplot(111)
     ax.set_ylim(0, 3)
     iplt.points(self.cube, coords=('bar', 'str_coord'), axes=ax)
     plt.close(fig)
     self.assertPointsTickLabels('yaxis', ax)
Esempio n. 3
0
    def test_xaxis_labels_with_axes(self):
        import matplotlib.pyplot as plt

        fig = plt.figure()
        ax = fig.add_subplot(111)
        ax.set_xlim(0, 3)
        iplt.points(self.cube, coords=("str_coord", "bar"), axes=ax)
        plt.close(fig)
        self.assertPointsTickLabels("xaxis", ax)
def main():
    fname = iris.sample_data_path('rotated_pole.nc')
    temperature = iris.load_strict(fname)
    
    # Calculate the lat lon range and buffer it by 10 degrees
    lat_range, lon_range = iris.analysis.cartography.lat_lon_range(temperature)
    lat_range = lat_range[0] - 10, lat_range[1] + 10
    lon_range = lon_range[0] - 10, lon_range[1] + 10

    
    # Plot #1: Point plot showing data values & a colorbar
    plt.figure()
    iplt.map_setup(temperature, lat_range=lat_range, lon_range=lon_range)
    points = qplt.points(temperature, c=temperature.data)
    cb = plt.colorbar(points, orientation='horizontal')
    cb.set_label(temperature.units)
    iplt.gcm().drawcoastlines()
    plt.show()
    
    
    # Plot #2: Contourf of the point based data
    plt.figure()
    iplt.map_setup(temperature, lat_range=lat_range, lon_range=lon_range)
    qplt.contourf(temperature, 15)
    iplt.gcm().drawcoastlines()
    plt.show()
    
    
    # Plot #3: Contourf overlayed by coloured point data
    plt.figure()
    iplt.map_setup(temperature, lat_range=lat_range, lon_range=lon_range)
    qplt.contourf(temperature)
    iplt.points(temperature, c=temperature.data)
    iplt.gcm().drawcoastlines()
    plt.show()
    
    
    
    # For the purposes of this example, add some bounds to the latitude and longitude
    temperature.coord('grid_latitude').guess_bounds()
    temperature.coord('grid_longitude').guess_bounds()
    
    
    # Plot #4: Block plot
    plt.figure()
    iplt.map_setup(temperature, lat_range=lat_range, lon_range=lon_range)
    iplt.pcolormesh(temperature)
    iplt.gcm().bluemarble()
    iplt.gcm().drawcoastlines()
    plt.show()
Esempio n. 5
0
    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()
Esempio n. 6
0
    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 main():
    fname = iris.sample_data_path('rotated_pole.nc')
    temperature = iris.load_strict(fname)

    # Calculate the lat lon range and buffer it by 10 degrees
    lat_range, lon_range = iris.analysis.cartography.lat_lon_range(temperature)
    lat_range = lat_range[0] - 10, lat_range[1] + 10
    lon_range = lon_range[0] - 10, lon_range[1] + 10

    # Plot #1: Point plot showing data values & a colorbar
    plt.figure()
    iplt.map_setup(temperature, lat_range=lat_range, lon_range=lon_range)
    points = qplt.points(temperature, c=temperature.data)
    cb = plt.colorbar(points, orientation='horizontal')
    cb.set_label(temperature.units)
    iplt.gcm().drawcoastlines()
    plt.show()

    # Plot #2: Contourf of the point based data
    plt.figure()
    iplt.map_setup(temperature, lat_range=lat_range, lon_range=lon_range)
    qplt.contourf(temperature, 15)
    iplt.gcm().drawcoastlines()
    plt.show()

    # Plot #3: Contourf overlayed by coloured point data
    plt.figure()
    iplt.map_setup(temperature, lat_range=lat_range, lon_range=lon_range)
    qplt.contourf(temperature)
    iplt.points(temperature, c=temperature.data)
    iplt.gcm().drawcoastlines()
    plt.show()

    # For the purposes of this example, add some bounds to the latitude and longitude
    temperature.coord('grid_latitude').guess_bounds()
    temperature.coord('grid_longitude').guess_bounds()

    # Plot #4: Block plot
    plt.figure()
    iplt.map_setup(temperature, lat_range=lat_range, lon_range=lon_range)
    iplt.pcolormesh(temperature)
    iplt.gcm().bluemarble()
    iplt.gcm().drawcoastlines()
    plt.show()
Esempio n. 8
0
def main():
    # Enable a future option, to ensure that the netcdf load works the same way
    # as in future Iris versions.
    iris.FUTURE.netcdf_promote = True

    # Load some test data.
    fname = iris.sample_data_path('rotated_pole.nc')
    air_pressure = iris.load_cube(fname)

    # Plot #1: Point plot showing data values & a colorbar
    plt.figure()
    points = qplt.points(air_pressure, c=air_pressure.data)
    cb = plt.colorbar(points, orientation='horizontal')
    cb.set_label(air_pressure.units)
    plt.gca().coastlines()
    iplt.show()

    # Plot #2: Contourf of the point based data
    plt.figure()
    qplt.contourf(air_pressure, 15)
    plt.gca().coastlines()
    iplt.show()

    # Plot #3: Contourf overlayed by coloured point data
    plt.figure()
    qplt.contourf(air_pressure)
    iplt.points(air_pressure, c=air_pressure.data)
    plt.gca().coastlines()
    iplt.show()

    # For the purposes of this example, add some bounds to the latitude
    # and longitude
    air_pressure.coord('grid_latitude').guess_bounds()
    air_pressure.coord('grid_longitude').guess_bounds()

    # Plot #4: Block plot
    plt.figure()
    plt.axes(projection=ccrs.PlateCarree())
    iplt.pcolormesh(air_pressure)
    plt.gca().stock_img()
    plt.gca().coastlines()
    iplt.show()
Esempio n. 9
0
def points(cube, *args, **kwargs):
    """
    Draws sample point positions on a labelled plot based on the given Cube.

    See :func:`iris.plot.points` for details of valid keyword arguments.

    """
    coords = kwargs.get('coords')
    result = iplt.points(cube, *args, **kwargs)
    _label_with_points(cube, coords=coords)
    return result
def main():
    fname = iris.sample_data_path('rotated_pole.nc')
    temperature = iris.load_cube(fname)
    
    # Plot #1: Point plot showing data values & a colorbar
    plt.figure()
    points = qplt.points(temperature, c=temperature.data)
    cb = plt.colorbar(points, orientation='horizontal')
    cb.set_label(temperature.units)
    plt.gca().coastlines()
    plt.show()
    
    
    # Plot #2: Contourf of the point based data
    plt.figure()
    qplt.contourf(temperature, 15)
    plt.gca().coastlines()
    plt.show()
    
    
    # Plot #3: Contourf overlayed by coloured point data
    plt.figure()
    qplt.contourf(temperature)
    iplt.points(temperature, c=temperature.data)
    plt.gca().coastlines()
    plt.show()
    
    
    
    # For the purposes of this example, add some bounds to the latitude and longitude
    temperature.coord('grid_latitude').guess_bounds()
    temperature.coord('grid_longitude').guess_bounds()
    
    
    # Plot #4: Block plot
    plt.figure()
    ax = plt.axes(projection=ccrs.PlateCarree())
    iplt.pcolormesh(temperature)
    plt.gca().stock_img()
    plt.gca().coastlines()
    plt.show()
Esempio n. 11
0
 def test_xaxis_labels(self):
     iplt.points(self.cube, coords=("str_coord", "bar"))
     self.assertBoundsTickLabels("xaxis")
    cmip5_pr_amoc_diff_digital_minus[k] = digital_minus(iris.analysis.interpolate.regrid(cmip5_pr_amoc_diff[k],destination_cube2)).copy()

in_cube = iris.analysis.maths.add(cmip5_pr_amoc_diff_digital_minus[0],cmip5_pr_amoc_diff_digital_minus[1])
for k in np.arange(2,models_unique.size):
    in_cube = iris.analysis.maths.add(in_cube,cmip5_pr_amoc_diff_digital_minus[k])

out_cube_minus = in_cube

cmip5_pr_amoc_diff_digital2 = out_cube_minus.copy()
cmip5_pr_amoc_diff_digital2.data = cmip5_pr_amoc_diff_digital2.data*0.0+np.nan
cmip5_pr_amoc_diff_digital2.data[np.where(out_cube_plus.data >= 4)] = 1.0
cmip5_pr_amoc_diff_digital2.data[np.where(out_cube_minus.data >= 4)] = 1.0

plt.figure()
qplt.contourf(cmip5_pr_amoc_diff_regrid_mean,np.linspace(-5e-7,5e-7,50))
points = iplt.points(cmip5_pr_amoc_diff_digital2, c =cmip5_pr_amoc_diff_digital2.data, s= 2.0)
plt.gca().coastlines()
plt.title('AMOC mean precipitation change and agreement (4 out of 6)')
plt.show()



# for k,model in enumerate(models_unique):
#     print k
#     tmp = cmip5_sst_amoc_diff[k].copy()
#     latitude = DimCoord(np.arange(-90,90, 1), standard_name='latitude',units='degrees')
#     longitude = DimCoord(np.arange(0, 360, 1), standard_name='longitude',
#                          units='degrees')
#     cube2 = iris.cube.Cube(np.zeros((180, 360), np.float32),standard_name='precipitation_flux', long_name='precipitation_flux', var_name='pr', units='kg m-2 s-1',dim_coords_and_dims=[(latitude, 0), (longitude, 1)])
#     cube_tmp = regridding_unstructured(tmp)
#     x = np.ma.array(cube_tmp[2])
Esempio n. 13
0
 def test_points_with_c_kwarg_specified_mappable(self):
     mappable_initial = points(self.cube, c=self.cube.data, cmap="cool")
     mappable = points(self.cube, c=self.cube.data)
     cbar = plt.colorbar(mappable_initial)
     self.assertIs(cbar.mappable, mappable_initial)
Esempio n. 14
0
 def test_points_with_c_kwarg(self):
     mappable = points(self.cube, c=self.cube.data)
     cbar = plt.colorbar()
     self.assertIs(cbar.mappable, mappable)
Esempio n. 15
0
 def test_scatter(self):    
     iplt.points(self.cube) 
     map = iplt.gcm()
     map.drawcoastlines()
     self.check_graphic()
 def test_points_with_c_kwarg_specified_mappable(self):
     mappable_initial = points(self.cube, c=self.cube.data, cmap='cool')
     mappable = points(self.cube, c=self.cube.data)
     cbar = plt.colorbar(mappable_initial)
     self.assertIs(cbar.mappable, mappable_initial)
Esempio n. 17
0
 def test_xaxis_labels(self):
     iplt.points(self.cube, coords=('str_coord', 'bar'))
     self.assertBoundsTickLabels('xaxis')
	south = -20
	east = 40
	west = -130

	tmp1 = high_low_mean_cube.intersection(longitude=(west, east))
	tmp1 = tmp1.intersection(latitude=(south, north))

	tmp2 = digital_cube_final.intersection(longitude=(west, east))
	tmp2 = tmp2.intersection(latitude=(south, north))

	plt.close('all')
	plt.figure()
	min_val = -1.0*z_range_maxs[k]
	max_val = z_range_maxs[k]
	tmp = tmp1.copy()
	tmp.data[np.where(tmp.data < min_val)] = min_val
	tmp.data[np.where(tmp.data > max_val)] = max_val
	qplt.contourf(tmp,np.linspace(min_val,max_val,51))
	points = iplt.points(tmp2, c = tmp2.data , s= 2.0)
	plt.gca().coastlines()
	plt.title(variable_names[k]+' aero 1960-1980 minus 1935-1955 '+np.str(no_agree)+'of3')
	#plt.savefig('/home/ph290/Documents/figures/'+variable_names[k]+'_aero.pdf')
	plt.show()







MIROC5_pr_regrid  = iris.analysis.interpolate.regrid(MIROC5_pr, destination_cube)

tas_mean = iris.analysis.maths.add(HadGEM2_tas_regrid,MIROC5_tas_regrid)
tas_mean2 = iris.analysis.maths.divide(tas_mean,2)

HadGEM2_tas_regrid_digital = digital(iris.analysis.interpolate.regrid(HadGEM2_tas_regrid,cube)).copy()
MIROC5_tas_regrid_digital = digital(iris.analysis.interpolate.regrid(MIROC5_tas_regrid,cube)).copy()
tas_regrid_digital = iris.analysis.maths.add(HadGEM2_tas_regrid_digital,MIROC5_tas_regrid_digital)
tas_regrid_digital2 = tas_regrid_digital.copy()
tas_regrid_digital2.data = tas_regrid_digital2.data*0.0+np.nan
tas_regrid_digital2.data[np.where(tas_regrid_digital.data == 2)] = 1.0
tas_regrid_digital2.data[np.where(tas_regrid_digital.data == -2)] = 1.0

plt.figure()
qplt.contourf(tas_mean2,50)
points = iplt.points(tas_regrid_digital2, c = tas_regrid_digital2.data, s= 2.0)
plt.gca().coastlines()
plt.title('Aerosol mean surface temperature change and agreement (K)')
plt.show()

NorESM1_pr_regrid = NorESM1_pr.copy()
pr_mean = iris.analysis.maths.add(HadGEM2_pr_regrid,MIROC5_pr_regrid)
#pr_mean = iris.analysis.maths.add(pr_mean,NorESM1_pr_regrid)
pr_mean2 = iris.analysis.maths.divide(pr_mean,2)

HadGEM2_pr_regrid_digital = digital(iris.analysis.interpolate.regrid(HadGEM2_pr_regrid,cube)).copy()
MIROC5_pr_regrid_digital = digital(iris.analysis.interpolate.regrid(MIROC5_pr_regrid,cube)).copy()
#NorESM1_pr_regrid_digital = digital(iris.analysis.interpolate.regrid(NorESM1_pr_regrid,cube))
pr_regrid_digital = iris.analysis.maths.add(HadGEM2_pr_regrid_digital,MIROC5_pr_regrid_digital)
#pr_regrid_digital = iris.analysis.maths.add(pr_regrid_digital,NorESM1_pr_regrid_digital)
pr_regrid_digital2 = pr_regrid_digital.copy()
#vals = np.array([0.05,2.5e-7,0.5,4.8,0.05,2.5e-7,0.05,2.5e-7,1.0])

vals = np.array([0.3,2.5e-6,5.0,0.05,2.5e-7,2.5,0.25,1.0e-6,1.0])


plt.close('all')
cmap = mpl_cm.get_cmap('coolwarm')
index = np.array([4,5,3,0,1,2,6,7,8])

fig = plt.subplots(3,3)
    
for i,dummy in enumerate(plots):
	ax1 = plt.subplot(3,3,i+1)
	min_val = -1.0*vals[i]
	max_val = vals[i]
	tmp = plots[index[i]].copy()
	tmp.data[np.where(tmp.data < min_val)] = min_val*0.999999
	tmp.data[np.where(tmp.data > max_val)] = max_val*0.999999
	CS = iplt.contourf(tmp,np.linspace(min_val,max_val,21),cmap=cmap)
	#plt.title(np.str(i))
	tmp2 = dots[index[i]].copy()
	points = iplt.points(tmp2, c = tmp2.data , s= 0.1)
	plt.gca().coastlines()
	CB = plt.colorbar(CS, shrink=0.8, extend='both',orientation="horizontal")
	plt.subplots_adjust(hspace = .05)
	plt.subplots_adjust(wspace = .025)

# fig.tight_layout()
plt.show()
#plt.savefig('/home/ph290/Documents/figures/palaeo_amo_prop_fig4_v3.pdf')
Esempio n. 21
0
 def test_scatter(self):
     iplt.points(self.cube)
     plt.gca().coastlines()
     self.check_graphic()
 def test_points_with_c_kwarg(self):
     mappable = points(self.cube, c=self.cube.data)
     cbar = plt.colorbar()
     self.assertIs(cbar.mappable, mappable)
Esempio n. 23
0
 def test_xaxis_labels(self):
     iplt.points(self.cube, coords=("str_coord", "bar"))
     self.assertBoundsTickLabels("xaxis")
Esempio n. 24
0
 def test_scatter(self):
     iplt.points(self.cube)
     plt.gca().coastlines()
     self.check_graphic()
Esempio n. 25
0
 def test_xaxis_labels(self):
     iplt.points(self.cube, coords=('str_coord', 'bar'))
     self.assertBoundsTickLabels('xaxis')