Allow more NCEP cloud levels to be decoded for plotting purposes.
[WPS.git] / util / plotfmt_nc.ncl
blob4bb93f4ccd44edf5e12f9e84ec24860d59ba91c8
1 ;_______________________________________________________________________________________
2 ;To run the script type:
3 ;       ncl plotfmt_nc.ncl {input file}
5 ;       e.g.
6 ;               ncl plotfmt_nc.ncl 'inputFILE="FILE:2005-06-01_00.nc"'
7 ;_______________________________________________________________________________________
9 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
10 load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
11 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
13 begin
15 ; Make sure we have a datafile to work with
16   if (.not. isvar("inputFILE") ) then
17     print(" ")
18     print(" ### MUST SUPPLY a inputFILE ### ")
19     print(" ")
20     print("     Something like: ")
21     print("     ncl plotfmt_nc.ncl inputFILE=FILE:2005-06-01_00.nc")
22     print("          REMEMBER TO ADD QUOTES" )
23     print("          Refer to the information at the top of this file for more info and syntax" )
24     exit
25   end if
27   inFILE = addfile(inputFILE,"r")
29 ; We generate plots, but what kind do we prefer?
30   type = "x11"
31 ; type = "pdf"
32 ; type = "ps"
33 ; type = "ncgm"
35   outf = "plotfmt_nc"
36   wks = gsn_open_wks(type,"outf")
39   vNames = getfilevarnames (inFILE) 
40   nNames = dimsizes (vNames)   
42   res = True
43   res@cnFillOn = True
44   res@gsnSpreadColors  = True
45   res@lbLabelAutoStride= True
47   do n=0,nNames-1  
49      print("VAR = " + vNames(n) )
50      var = inFILE->$vNames(n)$
52      dims = dimsizes(var)
53      lat = new ( dims(0), float)
54      lon = new ( dims(1), float)
55      lon@units = "degrees_east"
56      lat@units = "degrees_north"
57      lat(0) = var@startlat
58      lon(0) = var@startlon
60      if (var@projection .eq. 0) then         ;Cylindrical Equidistant
61        do i=1,dims(0)-1
62          lat(i) = lat(i-1) + var@deltalat
63        end do
64        do i=1,dims(1)-1
65          lon(i) = lon(i-1) + var@deltalon
66        end do
67      end if
69      if (var@projection .eq. 1) then          ; Mercator
70        res1 = True
71        res1@MAP_PROJ  = 3
72        res1@TRUELAT1  = var@truelat1
73        res1@DX        = var@dx*1000.
74        res1@DY        = var@dy*1000.
75        res1@REF_LAT   = lat(0)
76        res1@REF_LON   = lon(0)
77        res1@POLE_LAT  = 90.0
78        res1@POLE_LON  =  0.0
79        res1@LATINC    = 0.0
80        res1@LONINC    = 0.0
81        res1@KNOWNI    = 1.0
82        res1@KNOWNJ    = 1.0
83        loc = wrf_ij_to_ll (var@nx,var@ny,res1)
84        
85        res@gsnAddCyclic = False
86        res@mpLimitMode = "Corners"
87        res@mpLeftCornerLatF = lat(0)
88        res@mpLeftCornerLonF = lon(0)
89        res@mpRightCornerLatF = loc(1)
90        res@mpRightCornerLonF = loc(0)
91        res@tfDoNDCOverlay = True
92        res@mpProjection = "mercator"
93      end if
95      if (var@projection .eq. 3) then          ; Lambert Conformal
96        res1 = True
97        res1@MAP_PROJ  = 1
98        res1@TRUELAT1  = var@truelat1
99        res1@TRUELAT2  = var@truelat2
100        res1@STAND_LON = var@xlonc
101        res1@DX        = var@dx*1000.
102        res1@DY        = var@dy*1000.
103        res1@REF_LAT   = lat(0)
104        res1@REF_LON   = lon(0)
105        res1@POLE_LAT  = 90.0
106        res1@POLE_LON  =  0.0
107        res1@LATINC    = 0.0
108        res1@LONINC    = 0.0
109        res1@KNOWNI    = 1.0
110        res1@KNOWNJ    = 1.0
111        loc = wrf_ij_to_ll (var@nx,var@ny,res1)
113        res@gsnAddCyclic = False
114        res@mpLimitMode = "Corners"
115        res@mpLeftCornerLatF = lat(0)
116        res@mpLeftCornerLonF = lon(0)
117        res@mpRightCornerLatF = loc(1)
118        res@mpRightCornerLonF = loc(0)
119        res@tfDoNDCOverlay = True
120        res@mpProjection = "LambertConformal"
121        res@mpLambertParallel1F = var@truelat1
122        res@mpLambertParallel2F = var@truelat2
123        res@mpLambertMeridianF = var@xlonc
124      end if
126      if (var@projection .eq. 4) then        ;Gaussian
127        delta = 2.*(var@startlat)/(2.*var@nlats-1)
128        if (var@startlat .ge. 80.) then
129          delta = -1.0*delta
130        end if
131        do i=1,dims(0)-1
132          lat(i) = lat(i-1) + delta
133        end do
134        do i=1,dims(1)-1
135          lon(i) = lon(i-1) + var@deltalon
136        end do
137      end if
139      var!1 = "lon"
140      var!0 = "lat"
141      var&lon = lon
142      var&lat = lat
144      var@description = var@level +"   "+ var@description
146      ;map = gsn_csm_contour_map_ce(wks,var,res)
147      map = gsn_csm_contour_map(wks,var,res)
148      delete(lat)
149      delete(lon)
150      delete(var)
152   end do
155