source: palm/trunk/SCRIPTS/NCL/Archive/plotts.ncl @ 1676

Last change on this file since 1676 was 154, checked in by letzel, 17 years ago
  • new NCL scripts added to trunk/SCRIPTS/NCL
  • previous NCL scripts moved to trunk/SCRIPTS/NCL/Archive
File size: 3.1 KB
RevLine 
[154]1load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"
2load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
3load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
4load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
5
6; time series
7; last change: $Id: plotts.ncl 127 2007-10-23 11:05:25Z letzel $
8
9begin
10;
11; set default value(s) for shell script variables assigned on command line
12  if ( .not. isvar("cm") ) then     ; colormap
13    cm = "ncview_default"
14  end if
15  if ( .not. isvar("di") ) then     ; input directory (with final /)
16    di = ""
17  end if
18  if ( .not. isvar("d") ) then      ; output directory (with final /)
19    d = di
20  end if
21  if ( .not. isvar("fi") ) then     ; base name of input file (without suffix)
22    fi = "example_xy"
23  end if
24  if ( .not. isvar("fo") ) then     ; base name of output files (without suffix)
25    fo = ""
26  end if
27  if ( .not. isvar("ts") ) then      ; output time step
28    ts = 0
29  end if
30  if ( .not. isvar("te") ) then     ; output x-coordinate range start (in m)
31    te = 0
32  end if
33;
34; open input file
35  f  = addfile( di + fi  + ".nc", "r" )
36;
37; open workstation(s) and set colormap
38  wks_x11 = gsn_open_wks("x11","cross-section") ; X11 workstation
39  gsn_define_colormap(wks_x11,cm)
40  if ( isvar("fo") ) then
41    wks_pdf = gsn_open_wks("pdf",d+fo)  ; optional workstations
42    gsn_define_colormap(wks_pdf,cm)
43    wks_eps = gsn_open_wks("eps",d+fo)  ; for output on file
44    gsn_define_colormap(wks_eps,cm)
45    wks_ps  = gsn_open_wks("ps",d+fo)
46    gsn_define_colormap(wks_ps,cm)
47  end if
48;
49; read input data using 'coordinate subscripting'
50; NCL uses the closest corresponding values (in case of two equally distant
51; values NCL chooses the smaller one)
52
53  if ( .not. isvar("var1") .and. .not. isvar("var2") .and. .not. isvar("var3")  .and. .not. isvar("var4") .and. .not. isvar("var5") .and. .not. isvar("var6")) then
54    vNam = getfilevarnames(f)
55    n2 = dimsizes(vNam)-1
56
57    print(vNam)
58
59  else
60
61    vNam = new((/6/), string)
62
63    vNam(0) = var1
64    vNam(1) = var2
65    vNam(2) = var3
66    vNam(3) = var4
67    vNam(4) = var5
68    vNam(5) = var6
69    n2 = 6
70  end if
71
72  t= f ->time({ts:te})
73
74  res=True
75  res@gsnDraw=False
76  res@gsnFrame=False
77
78  resP = True
79  resP@txString="time series"
80
81  res@vpWidthF=4
82
83  plot=new(40,graphic)                 ; create a plot array
84  plot_pdf=new(40,graphic)             ; create a plot array
85  plot_ps=new(40,graphic)              ; create a plot array
86  plot_eps=new(40,graphic)             ; create a plot array
87
88  n = 0
89
90  do while ( n .lt. n2)
91    data = f ->$vNam(n)$({ts:te})
92    plot(n) = gsn_csm_xy(wks_x11,t,data,res)
93    plot_pdf(n) = gsn_csm_xy(wks_pdf,t,data,res)
94    plot_eps(n) = gsn_csm_xy(wks_eps,t,data,res)
95    plot_ps(n) = gsn_csm_xy(wks_ps,t,data,res)
96    n = n + 1
97  end do
98
99  pa = 0
100  pb = 5
101
102  do while ( pa .lt. dimsizes(plot) )
103    gsn_panel(wks_pdf,plot_pdf(pa:pb),(/6,1/),resP) ; Panel the plots, first using rows x columns, then using number of plots per row
104    gsn_panel(wks_eps,plot_eps(pa:pb),(/6,1/),resP)
105    gsn_panel(wks_ps,plot_ps(pa:pb),(/6,1/),resP)
106    gsn_panel(wks_x11,plot(pa:pb),(/6,1/),resP)
107    pa = pa + 6
108    pb = pb + 6
109  end do
110
111end
Note: See TracBrowser for help on using the repository browser.