GaLab Examples

From OpenGrads Wiki

Jump to: navigation, search

Contents

[edit] THIS PAGE IS UNDER CONSTRUCTION

from pylab import * 
from PIL   import Image
from matplotlib.toolkits.basemap import cm as bacm
from grads    import *
from examples import *


[edit] Blue Marble Examples (Map Projections)

class BlueMarbleExamples(GaLabExamples):

   """
   Examples based on the Blue Marble image.
   """
   def startup(self):
       self.file = self.DataDir + '/model.ctl'
   def ex_proj_cyl(self):
       ga.basemap('cyl')
       ga.blue_marble(Show=True)
       title("Blue Marble Background (MODIS)")
   def ex_proj_geos(self):
       ga.basemap('geos',opts=-75.) # GOES East
       bm = ga.blue_marble()
       ga.map.imshow(bm,)
       title("Geostationary Projection (GOES East)")
   def ex_proj_stereo(self):
       subplot(211)
       ga.basemap('nps') 
       ga.blue_marble(Show=True)
       title("Northern Stereographic Projection")
       subplot(212)
       ga.basemap('sps') 
       ga.blue_marble(Show=True)
       title("Southern Stereographic Projection")
   def ex_proj_orthographic(self):
       ga.basemap('ortho',opts=(20.,0.)) 
       ga.blue_marble(Show=True)
       title("Orthographic Projection (Equator)")
   def ex_proj_polar_orthographic(self):
       subplot(211)
       ga.basemap('npo') 
       ga.blue_marble(Show=True)
       title("Orthographic Projection (North Pole)")
       subplot(212)
       ga.basemap('spo') 
       ga.blue_marble(Show=True)
       title("Orthographic Projection (South Pole)")

[edit] Examples based on the model.ctl file

class ModelFileExamples(GaLabExamples):

   """
   A set of examples plotting data from the classic "model.ctl" file.
   """
   def startup(self):
       self.file = self.DataDir + '/model.ctl'
   def ex_imshow(self):
       ga.imshow('ts-273')
       title('Surface Temperature (Celsius)')
   def ex_colormaps(self):
       ga.imshow('ts-273', cmap=cm.hot, sub=211)
       title('Surface Temperature (Celsius)')
       ga.imshow('ts-273', cmap=cm.gray, sub=212)
   def ex_pcolor(self):
       ga.pcolor('ps/100')
       title('Surface Pressure (hPa)')
   def ex_implain(self):
       ga.implain('ps')
   def ex_contour(self):
       ga.cmd('set lev 300')
       ga.contourf('zg',clines=True,sub=211)
       title('300 hPa Heights')
       ga.contour('zg',N=10,sub=212)

[edit] Examples based on the aero.nc file

class AeroFileExamples(GaLabExamples):

   """
   A set of examples plotting data from the "aero.nc" file.
   """
   def startup(self):
       self.file = self.DataDir + '/aero.nc'
   def ex_marble_dust(self):
       ga.blue_marble('on')    # use Blue Marble background
       ga.basemap('latlon')
       ga.imshow('duexttau',cmap=gacm.hot_l)
       title("Mineral Dust Optical Thickness") 
       ga.blue_marble('off')  
   def ex_marble_h500(self):
       ga.blue_marble('on')    # use Blue Marble background
       ga.basemap('npo')
       ga.contour('h500',N=12)
       title("500 hPa Heights") 
       ga.blue_marble('off')  
   def ex_goes_fulldisk(self):
       sat = Image.open("goes_fulldisk.jpg")
       ga.basemap('geos', opts=-75.) # GOES East
       ga.imshow('duexttau',cmap=gacm.hot_l,bgim=sat,
                  mpcol='cyan',dlon=20,dlat=15)
       title("Mineral Dust Optical Thickness") 
   def ex_goes_conus(self):
       sat = Image.open("goes_conus.jpg")
       opts=(-109.65,14.23,-44.65,62.23,-75.) # image info
       ga.basemap('geos', opts=opts, resolution='l') 
       ga.contour('h500',bgim=sat,N=12,Map=False)
       title("500 hPa Heights")
Personal tools