예제 #1
0
파일: cn12p.py 프로젝트: akrherz/me
 ["algeria","angola","angola-exclave-called-cabinda","benin","botswana",     \
  "burundi","cameroon","central-african-republic","chad","congo","djibouti", \
  "egypt","equatorial-guinea","ethiopia","gabon","gambia","ghana","guinea",  \
  "guinea-bissau","ivory-coast","kenya","lesotho","liberia","libya",         \
  "madagascar","malawi","mali","mauritania","mauritius","morocco",           \
  "mozambique","namibia","niger","nigeria","rwanda","senegal","sierra-leone",\
  "somalia","south-africa","sudan","swaziland","tanzania","togo","tunisia",  \
  "uganda","upper-volta","western-sahara","zaire","zambia","zimbabwe"]

#
#  Open a workstation.
#
wks_type = "ps"
wks = Ngl.open_wks(wks_type,"cn12p")

dirc = Ngl.ncargpath("data")
z    = Ngl.asciiread(dirc+"/asc/cn12n.asc",len_dims,"float")
 
resources = Ngl.Resources()
resources.sfXCStartV  = -18.0
resources.sfXCEndV    =  52.0
resources.sfYCStartV  = -35.0
resources.sfYCEndV    =  38.0
resources.vpXF        =   0.1
resources.mpMaskAreaSpecifiers  =  mask_specs
resources.mpFillAreaSpecifiers  =  fill_specs
resources.pmLabelBarDisplayMode =  "always"
Ngl.contour_map(wks,z[:,:],resources)

del resources
Ngl.end()
예제 #2
0
파일: streamline.py 프로젝트: akrherz/me
#
#  Import all names from the NetCDF module.
#
from Scientific.IO.NetCDF import NetCDFFile

#
#  Import Ngl support functions.
#
import Ngl

#
#  Open the netCDF file.
#
file = NetCDFFile(Ngl.ncargpath("data") + "/cdf/pop.nc","r")

#
#  Open a workstation.
#
wks_type = "ps"

rlist            = Ngl.Resources()
rlist.wkColorMap = ["White","Black","Tan1","SkyBlue","Red"]
wks = Ngl.open_wks(wks_type,"streamline",rlist)

#
#  Get the u/v and lat/lon variables.
#
urot  = file.variables["urot"]
vrot  = file.variables["vrot"]
lat2d = file.variables["lat2d"][:,:]
lon2d = file.variables["lon2d"][:,:]
예제 #3
0
파일: ngl04p.py 프로젝트: akrherz/me
#
#  Import the NetCDF reader.
#
from Scientific.IO.NetCDF import NetCDFFile

#
#  Import Ngl support functions.
#
import Ngl

#
#  Open the netCDF file.  This file is a netCDF version of the file:
#
#     ncargpath("data") + "/grb/ced1.lf00.t00z.eta.grb"
#
file = NetCDFFile(Ngl.ncargpath("data") + "/cdf/ced1.lf00.t00z.eta.nc","r")

names = file.variables.keys()  #  Get the variable names
print "\nVariable names:"      #  and print them out.
print names                    


#
#  For variable in names[1], retrieve and print all attributes
#  and their values (exclude printing the built-in functions).
#
print "\nThe attributes and their values for variable " + names[1] + ":"
for attrib in dir(file.variables[names[1]]):
  t = getattr(file.variables[names[1]],attrib)
  if (type(t) != types.BuiltinFunctionType):
   print "Attribute " + "'" + attrib + "' has value:", t
예제 #4
0
파일: ngl05p.py 프로젝트: akrherz/me
#
import Numeric

#
#  Import the NetCDF reader.
#
from Scientific.IO.NetCDF import NetCDFFile

#
#  Import Ngl support functions.
#
import Ngl
#
#  Open three netCDF files and get variables.
#
data_dir  = Ngl.ncargpath("data")
cdf_file1 = NetCDFFile(data_dir + "/cdf/941110_P.cdf","r")
cdf_file2 = NetCDFFile(data_dir + "/cdf/sstdata_netcdf.nc","r")
cdf_file3 = NetCDFFile(data_dir + "/cdf/Pstorm.cdf","r")

psl = cdf_file1.variables["Psl"]   
sst = cdf_file2.variables["sst"]  
pf  = cdf_file3.variables["p"]  

psl_lon  =  cdf_file1.variables["lon"][:]
psl_lat  =  cdf_file1.variables["lat"][:]
psl_nlon =  len(psl_lon)
psl_nlat =  len(psl_lat)

sst_lon  =  cdf_file2.variables["lon"][:]
sst_lat  =  cdf_file2.variables["lat"][:]
예제 #5
0
파일: meteogram.py 프로젝트: akrherz/me
  output[:,0]    = x[:,0]
  output[:,nj-1] = x[:,nj-1]

#
#  Return smoothed array.
#
  return output

#
#  Main program.
#

#
#  Read in the data variables from the NetCDF file.
#
cdf_file   = NetCDFFile(Ngl.ncargpath("data") + "/cdf/meteo_data.nc","r")
tempisobar = cdf_file.variables["tempisobar"][:,:]  # temperature
levels     = cdf_file.variables["levels"][:]        # levels
taus       = cdf_file.variables["taus"][:]          # taus
rh         = cdf_file.variables["rh"][:,:]          # realtive humidity
ugrid      = cdf_file.variables["ugrid"][:,:]       # horizontal winds 
vgrid      = cdf_file.variables["vgrid"][:,:]       # vertical winds
rain03     = cdf_file.variables["rain03"][:]        # rainfall
tempht     = cdf_file.variables["tempht"][:]        # surface temperatures

#
#  Smooth temperature and humidity.
#  
smothtemp = smth9(tempisobar, 0.50, -0.25)
smothrh   = smth9(        rh, 0.50, -0.25)
예제 #6
0
파일: skewt3.py 프로젝트: akrherz/me
#            PO 3007, Boulder, Colorado
#
#   Date:    Tue Mar  1 14:58:28 MST 2005
# 
#   Description:
#            Produces two plots using real data:
#              1. Shows the full radiosonde.
#              2. This "thins" the number of wind barbs plotted and 
#                 uses a Centigrade scale.  Setting Wthin to 3 causes
#                 the plotting of every third wind barb.
#    
import Ngl
  
nlvl = 65
ncol = 7
TestData =  Ngl.asciiread(Ngl.ncargpath("data") + "/asc/sounding_ATS.asc", \
                          [nlvl,ncol], "float")

#
# Order: Surface is 'bottom'  eg: 1000,950,935,897,...  
#
p    = TestData[:,0]    # pressure     [mb / hPa] 
tc   = TestData[:,1]    # temperature  [C]    
tdc  = TestData[:,2]    # dew pt temp  [C]   
z    = TestData[:,4]    # geopotential [gpm] 
wspd = TestData[:,5]    # wind speed   [knots or m/s]    
wdir = TestData[:,6]    # meteorological wind dir   

wks_type = "ps"
wks = Ngl.open_wks(wks_type, "skewt3")
예제 #7
0
파일: ngl02p.py 프로젝트: akrherz/me
import Numeric,sys,os

#
#  Import the NetCDF reader.
#
from Scientific.IO.NetCDF import NetCDFFile

#
#  Import Ngl support functions.
#
import Ngl

#  
#  Open the netCDF file.
#  
cdf_file = NetCDFFile(Ngl.ncargpath("data") + "/cdf/contour.cdf","r")

#
#  Associate Python variables with NetCDF variables.
#  These variables have associated attributes.
#
temp = cdf_file.variables["T"]    # temperature
Z    = cdf_file.variables["Z"]    # geopotential height
pres = cdf_file.variables["Psl"]  # pressure at mean sea level
lat  = cdf_file.variables["lat"]  # latitude
lon  = cdf_file.variables["lon"]  # longitude

#
#  Open a workstation.
#
wks_type = "ps"
예제 #8
0
파일: ngl01p.py 프로젝트: akrherz/me
resources.tiYAxisString   = "Y Axis"    # Label for the Y axis
resources.tiMainFont      = "Helvetica" # Font for title
resources.tiXAxisFont     = "Helvetica" # Font for X axis label
resources.tiYAxisFont     = "Helvetica" # Font for Y axis label
  
resources.xyMarkLineModes = ["Lines","Markers","MarkLines"]
resources.xyMarkers       = [0,1,3]     # (none, dot, asterisk)
resources.xyMarkerColor   = 3           # Marker color
resources.xyMarkerSizeF   = 0.03        # Marker size (default
                                          # is 0.01)
  
plot = Ngl.xy(wks,x,y2,resources)       # Draw an XY plot.
  
#---------- Begin fifth plot ------------------------------------------
  
filename = Ngl.ncargpath("data") + "/asc/xy.asc"
data     = Ngl.asciiread(filename,(129,4),"float")
  
#
#  Define a two-dimensional array of data values based on
#  columns two and three of the input data.
#
uv = Numeric.zeros((2,129),Numeric.Float0)
uv[0,:] = data[:,1]
uv[1,:] = data[:,2]
  
#
#  Use the first column of the input data file (which is simply the
#  row number) for longitude values.  The fourth column of data is
#  not used in this example.
#