;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) res_mark = True res_mark@gsMarkerIndex = 1 ; 17 predefined markers available res_mark@gsMarkerSizeF = 0.012 ; Breaking up rf array into small arrays depending on their value ; ; ind fn return INDEX (in this case the line NOs when the below is TRUE) ; rf0 = ind(rf.eq.0.0) rf_range0 = rf(rf0) nrf_range0 = dimsizes(rf_range0) ; print("rf0 output of ind(rf) while rf_range0 is actual value of rf"+ " "+rf0+" "+rf_range0) printVarSummary(rf_range0) rf1 = ind(rf.ge.0.1.and.rf.lt.2.5) rf_range1 = rf(rf1) nrf_range1 = dimsizes(rf_range1) ; print("rf1 output of ind(rf) while rf_range1 is actual value of rf"+ " "+rf1+" "+rf_range1) printVarSummary(rf_range1) rf2 = ind(rf.ge.2.5.and.rf.lt.7.5) rf_range2 = rf(rf2) nrf_range2 = dimsizes(rf_range2) printVarSummary(rf_range2) ; print("rf2 output of ind(rf) while rf_range2 is actual value of rf"+ " "+rf2+" "+rf_range2) rf3 = ind(rf.ge.7.5.and.rf.lt.35.5) rf_range3 = rf(rf3) nrf_range3 = dimsizes(rf_range3) ; print("rf3 output of ind(rf) while rf_range3 is actual value of rf"+ " "+rf3+" "+rf_range3) printVarSummary(rf_range3) rf4 = ind(rf.ge.35.5.and.rf.lt.64.5) rf_range4 = rf(rf4) nrf_range4 = dimsizes(rf_range4) ; print("rf4 output of ind(rf) while rf_range4 is actual value of rf"+ " "+rf4+" "+rf_range4) printVarSummary(rf_range4) do n = 0, nrf_range0-1 res_mark@gsMarkerColor = "Blue" str = unique_string("polymarker") plot@$str$ = gsn_add_polymarker(wks,plot,lon,lat,res_mark) end do do n = 0, nrf_range1-1 res_mark@gsMarkerColor = "red" str = unique_string("polymarker") plot@$str$ = gsn_add_polymarker(wks,plot,lon,lat,res_mark) end do ; overlay(plot,plot1) ;----------------- DO NOT SEE THE BOTTOM PAR--------------------------------- ;----------------------------------- NOt TO be seen--------------------- ; if ((rf(n).ge.0.1).and.(rf(n).lt.2.5)) then ; where(rf(n).eq.0.0, rf_range1, rf_range2) ; print(rf_range1) ; else ; rf_range1 = ff ; res_mark@gsMarkerColor = color(1) ; else if ((rf(n).ge.2.5).and.(rf(n).lt.7.5)) then ; res_mark@gsMarkerColor = color(2) ; else if ((rf(n).ge.7.5).and.(rf(n).lt.70.5)) then ; res_mark@gsMarkerColor = "yellow" ; end if ; print("rf_range1 "+rf_range1) ; end if ; end if ;print(rf+" "+res_mark@gsMarkerColor) ; end do ; str = unique_string("polymarker") ; print(str) ; plot@$str$ = gsn_add_polymarker(wks,plot,lon,lat,res_mark) ; print(plot@$str$) ;print(rf+" "+res_mark@gsMarkerColor) ; 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