def gen_dummy_data(): minlat = 24 maxlat = 50 minlon = -125 maxlon = -67 #---Size of dummy data. Use smaller values (16x32) for faster code speed nlat = 64 nlon = 128 data = Ngl.generate_2d_array([nlat,nlon], 10, 19, 0., 100.) lat = Ngl.fspan(minlat,maxlat,nlat) lon = Ngl.fspan(minlon,maxlon,nlon) return data,lat,lon
wks = Ngl.open_wks(wks_type, "viewport1") # Add some named colors. This is no longer needed in PyNGL 1.5.0 #forest_green = numpy.array([ 34, 139, 34])/255. #navy_blue = numpy.array([ 0, 0, 128])/255. #brown = numpy.array([165, 42, 42])/255. #ig = Ngl.new_color(wks,forest_green[0],forest_green[1],forest_green[2]) #ib = Ngl.new_color(wks,navy_blue[0], navy_blue[1], navy_blue[2]) #ir = Ngl.new_color(wks,brown[0], brown[1], brown[2]) # Generate some dummy data. cmin = -19.23 cmax = 16.81 data = Ngl.generate_2d_array([100, 100], 10, 10, cmin, cmax) nice_min, nice_max, nice_spc = Ngl.nice_cntr_levels(cmin, cmax, cint=3) # Read in color map so we can subset it cmap = Ngl.read_colormap_file("nrl_sirkes") # Set up resources for a contour plot. cnres = Ngl.Resources() cnres.nglMaximize = True # Maximize plot in frame cnres.nglDraw = False # Don't draw plot cnres.nglFrame = False # Don't advance the frame cnres.cnFillOn = True # Turn on contour fill cnres.cnFillPalette = cmap[:-3, :]
[0.75,0.50,1.00],[0.50,0.00,1.00],[0.00,0.00,1.00], \ [0.00,0.50,1.00],[0.00,1.00,1.00],[0.00,1.00,0.60], \ [0.00,1.00,0.00],[0.70,1.00,0.00],[1.00,1.00,0.00], \ [1.00,0.75,0.00],[1.00,0.38,0.38],[1.00,0.00,0.38], \ [1.00,0.00,0.00]]) # # Open a workstation. # wres = Ngl.Resources() wres.wkColorMap = cmap wks_type = "png" wks = Ngl.open_wks(wks_type, "cn12p", wres) # Generate some dummy data dirc = Ngl.pynglpath("data") z = Ngl.generate_2d_array([40, 40], 15, 15, -10., 110.) # Create contour and map resource lists. cnres = Ngl.Resources() mpres = Ngl.Resources() cnres.nglDraw = False cnres.nglFrame = False mpres.nglDraw = False mpres.nglFrame = False # # Map fill resources. # # To fill map areas, you can first specify a general set # of areas (mpFillBoundarySets) and then a specific set of # areas. This allows you to indicate what general areas you always
dmax = dmaxs[n // 3] dspa = dspas[n // 3] mstart = numpy.random.uniform(10, 25, 1).astype(int) mend = numpy.random.uniform(10, 25, 1).astype(int) xstart = numpy.random.uniform(dmin, dmin + 2, 1) xend = numpy.random.uniform(dmax - 2, dmax, 1) #---This is a new resource added in PyNGL 1.5.0 res.cnFillPalette = colormaps[n // 3] res.cnMinLevelValF = dmin res.cnMaxLevelValF = dmax res.cnLevelSpacingF = dspa data = Ngl.generate_2d_array([nlat, nlon], mstart[0], mend[0], xstart[0], xend[0]) plots.append(Ngl.contour_map(wks, data, res)) # Resources for panelling pres = Ngl.Resources() pres.nglFrame = False pres.nglPanelLabelBar = True # Calculate start Y position for first row of plots height = 0.15 # we know this will be height of small plots extra = 1.0 - (3 * height) top = 1.0 - (extra / 2.) # Draw a title before we draw plots title = "Multiple panels on one page, 3 different colormaps"
dmax = dmaxs[n / 3] dspa = dspas[n / 3] mstart = numpy.random.uniform(10, 25, 1).astype(int) mend = numpy.random.uniform(10, 25, 1).astype(int) xstart = numpy.random.uniform(dmin, dmin + 2, 1) xend = numpy.random.uniform(dmax - 2, dmax, 1) #---This is a new resource added in PyNGL 1.5.0 res.cnFillPalette = colormaps[n / 3] res.cnMinLevelValF = dmin res.cnMaxLevelValF = dmax res.cnLevelSpacingF = dspa data = Ngl.generate_2d_array([nlat, nlon], mstart, mend, xstart, xend) plots.append(Ngl.contour_map(wks, data, res)) # Resources for panelling pres = Ngl.Resources() pres.nglFrame = False pres.nglPanelLabelBar = True # Calculate start Y position for first row of plots height = 0.15 # we know this will be height of small plots extra = 1.0 - (3 * height) top = 1.0 - (extra / 2.) # Draw a title before we draw plots title = "Multiple panels on one page, 3 different colormaps"
[0.75,0.50,1.00],[0.50,0.00,1.00],[0.00,0.00,1.00], \ [0.00,0.50,1.00],[0.00,1.00,1.00],[0.00,1.00,0.60], \ [0.00,1.00,0.00],[0.70,1.00,0.00],[1.00,1.00,0.00], \ [1.00,0.75,0.00],[1.00,0.38,0.38],[1.00,0.00,0.38], \ [1.00,0.00,0.00]]) # # Open a workstation. # wres = Ngl.Resources() wres.wkColorMap = cmap wks_type = "ps" wks = Ngl.open_wks(wks_type,"cn12p",wres) # Generate some dummy data dirc = Ngl.pynglpath("data") z = Ngl.generate_2d_array ([40,40],15,15,-10.,110.) # Create contour and map resource lists. cnres = Ngl.Resources() mpres = Ngl.Resources() cnres.nglDraw = False cnres.nglFrame = False mpres.nglDraw = False mpres.nglFrame = False # # Map fill resources. # # To fill map areas, you can first specify a general set # of areas (mpFillBoundarySets) and then a specific set of # areas. This allows you to indicate what general areas you always