load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" ;************************************************ ;************************************************ ; get list of files ;************************************************ diri = "pacific-12-2012/pacific/2012/12/" ; input directory diri = "./" fili = systemfunc("cd "+diri+" ; ls nodc_R5900666_*.nc") print(fili) nfili = dimsizes(fili) ;************************************************ ; set resources common to both t and s curves ;************************************************ res = True ; plot mods desired ;res@gsnMaximize = True res@trYReverse = True ; reverse Y-axis res@xyLineThicknessF = 2 ; choose dash patterns res@gsnDraw = False res@gsnFrame = False ;************************************************ ; set resource list specific each curve ;************************************************ res_t = res res_s = res res_t@xyLineColor = "blue" res_s@xyLineColor = "red" ;************************************************ ; The res_s resource list is the one you want to ; modify to get extra titles. ;************************************************ res_s@gsnStringFontHeightF = 0.01 res_s@gsnLeftStringFontColor = res_s@xyLineColor res_t@gsnLeftStringFontColor = res_t@xyLineColor ;************************************************ ; read in data: there is only 1 time, 1 lat, 1 lon ;************************************************ wks = gsn_open_wks ("png","nodc") plot_t = new(nfili,graphic) plot_s = new(nfili,graphic) do nf=0,nfili-1 f = addfile (diri+fili(nf),"r") t = f->temperature(0,:,0,0) s = f->salinity(0,:,0,0) delete(f) res_t@gsnLeftString = t@long_name + " (" + t@units + ")" ; left title for s variable plot_t(nf) = gsn_csm_xy(wks,t&pressure,t,res_t) if (nf.ne.0) then overlay(plot_t(0),plot_t(nf)) end if res_s@tiMainString = fili(nf) ; main title res_s@gsnLeftString = s@long_name + " (" + s@units + ")" ; right title for s variable plot_s(nf) = gsn_csm_xy(wks,s&pressure,s,res_s) if (nf.ne.0) then overlay(plot_s(0),plot_s(nf)) end if delete([/t,s/]) ; may change size next file end do draw(plot_t(0)) frame(wks) draw(plot_s(0)) frame(wks) delete(wks) delete([/plot_s,plot_t/])