;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 = stringtofloat(str_get_field(tStr,4,delim)) lon = stringtofloat(str_get_field(tStr,5,delim)) miss = stringtofloat(str_get_field(tStr,6,delim)) rf_surf = stringtofloat(str_get_field(tStr,7,delim)) rf_code = stringtofloat(str_get_field(tStr,8,delim)) missing = stringtofloat(str_get_field(tStr,9,delim)) rf = stringtofloat(str_get_field(tStr,10,delim)) ;print(lat) ;print(lon) ;print(rf) wks = gsn_open_wks("ps","stn-v5") 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 & Coloring them according to the RF value nrf = dimsizes(rf) ; print(nrf) color_of_marker = new(nrf,string) dont_mark = " " dont_mark@_FillValue = "missing" color_of_marker = where((rf.eq.0.0),dont_mark,dont_mark) color_of_marker = where(((rf.ge.0.1).and.(rf.lt.2.4)),"Green",dont_mark) color_of_marker = where(((rf.ge.2.5).and.(rf.lt.7.5)),"Blue",dont_mark) color_of_marker = where(((rf.ge.7.6).and.(rf.lt.35.5)),"Yellow",dont_mark) printVarSummary(dont_mark) print(color_of_marker) ; Array of 295 strings is printed corresponding to RF value ; res_mark = True res_mark@gsMarkerIndex = 1 ; 17 predefined markers available res_mark@gsMarkerSizeF = 0.012 do n = 0, nrf-1 ; if ((rf(n).ge.0.1).and.(rf(n).lt.2.5)) then res_mark@gsMarkerColor = color_of_marker(n) str = unique_string("poly") plot@$str$ = gsn_add_polymarker(wks,plot,lon,lat,res_mark) end do ; ----------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