;Reading HDF4-SDS files ;*********** Load Libraries ************************************ 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" ;************************************************************** begin ;*************************************************************** ; User Input ;*************************************************************** ; INPUT diri = "./" ; input directory fili = "rf-actual-23052013-mod.txt" ; file ; OUTPUT ;*************************************************************** ; Read ascii data ;*************************************************************** tStr = asciiread(diri+fili, -1,"string") ; will read input file as one dimensional string. print(tStr) ; convert string into float ; delim = " " ;lat = str_get_field(tStr,1,delim) ;lat = tofloat(str_get_field(tStr,1,delim)) ;lon = tofloat(str_get_field(tStr,2,delim)) ;hgt = tofloat(str_get_field(tStr,3,delim)) ;rf = tofloat(str_get_field(tStr,4,delim)) ; lat = stringtofloat(str_get_field(tStr,4,delim)) lon = stringtofloat(str_get_field(tStr,5,delim)) rf = stringtofloat(str_get_field(tStr,10,delim)) print(lat) print(lon) print(rf) wks = gsn_open_wks("ps","stn-v6") res = True res@gsnDraw = False res@gsnFrame = False res@mpMinLatF = 08.0 res@mpMaxLatF = 18.0 res@mpMinLonF = 72.0 res@mpMaxLonF = 82.0 res@mpFillOn = False ; ------ Tick Mark res----------- res@tmXBLabelFontColor = "Red" res@tmXBLabelFontHeightF = 0.01 res@tmXBMode = "Explicit" res@tmXBValues = (/"72","74","76","78","80","82"/) res@tmXBLabels = (/"72~S~o~N~E","74~S~o~N~E","76~S~o~N~E","78~S~o~N~E","80~S~o~N~E","82~S~o~N~E"/) res@tmXBMajorLengthF = 0.0 res@tmXBMinorLengthF = 0.01 res@tmYLLabelFontColor = "Red" res@tmYLLabelFontHeightF = 0.01 res@tmYLMode = "Explicit" res@tmYLValues = (/"8","10","12","14","16","18"/) res@tmYLLabels = (/"8~S~o~N~E","10~S~o~N~E","12~S~o~N~E","14~S~o~N~E","16~S~o~N~E","18~S~o~N~E"/) res@tmYLMajorLengthF = 0.0 res@tmYLMinorLengthF = 0.01 ; ;----------Title res res@tiMainString = fili plot = gsn_csm_map(wks,res) ; ; ;---------Adding Markers according to rainfall value nrf = dimsizes(rf) markers = new(dimsizes(rf),string) dont_mark = "red" res_mark = True res_mark@gsMarkerIndex = 1 ; 17 predefined markers available res_mark@gsMarkerSizeF = 0.012 ; res_mark@gsMarkerColor = "black" do n = 0, nrf-1 if (rf(n).eq.0.0) then res_mark@gsMarkerColor = "Black" ; dum =gsn_add_polymarker(wks,plot,lon,lat,res_mark) else if ((rf(n).ge.0.1).and.(rf(n).lt.2.4)) then res_mark@gsMarkerColor = "Blue" else if ((rf(n).ge.2.5).and.(rf(n).lt.7.5)) then res_mark@gsMarkerColor = "Red" end if end if end if ; end do dum =gsn_add_polymarker(wks,plot,lon,lat,res_mark) end do print(rf+res_mark@gsMarkerColor) ; ----------Now adding text-------------------- txres = True txres@txFontHeightF = 0.012 txres@txFont = "helvetica-bold" txres@txFontQuality = "High" ; nrf = dimsizes(rf) ; text = new(nrf,graphic) ; colors = new(dimsizes(rf),string) ; colors = "" ; 1. print(nrf) ;colors = where((rf.eq.0.0),"White",colors) ; This is a string variable ; colors = where((rf.eq.0.0),colors,colors) ; This is a string variable ; colors = where(((rf.ge.0.1).and.(rf.lt.2.4)),"White",colors) ; This is a string variable ; colors = where(((rf.ge.2.5).and.(rf.lt.7.5)),"Blue",colors) ; colors = where(((rf.ge.7.6).and.(rf.lt.35.5)),"Red",colors) ; colors = where(((rf.ge.35.6).and.(rf.lt.64.4)),"Orange",colors) ; colorss= stringtoint(colors) ; colors = where((rf.ge.2.5).and.(rf.lt.7.5),"Red ","Blue") ; do n = 0, nrf-1 ; if ((rf(n).ge.0.1).and.(rf(n).lt.2.5)) then ; txres@txFontColor = 2 ; RHS should be an integer ; ; else if ((rf(n).ge.2.5).and.(rf(n).lt.7.5)) then ; txres@txFontColor = 9 ; RHS should be an integer ; else if ((rf(n).ge.7.5).and.(rf(n).lt.15.5)) then ; txres@txFontColor = 13 ; RHS should be an integer ; end if ; end if ; end if ;colors = ispan(1,67,10) ; print(colors) ;text = new(nrf,graphic) ; do n = 0, nrf-1 ; txres@txFontColor = colors(n) ; RHS should be an integer ; text(n) = gsn_add_text(wks,plot," "+sprintf("%9.4g",rf(n)),lon(n),lat(n),txres) ; end do ; text = gsn_add_text(wks,plot," "+sprintf("%9.4g",rf),lon,lat,txres) ; text = gsn_add_text(wks,plot,sprintf("%12.4g",val),lon,lat,txres) draw(plot) frame(wks) end