;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 = "input_new.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,1,delim)) lon = stringtofloat(str_get_field(tStr,2,delim)) hgt = stringtofloat(str_get_field(tStr,3,delim)) rf = stringtofloat(str_get_field(tStr,4,delim)) print(lat) print(lon) print(hgt) print(rf) wks = gsn_open_wks("ps","stn-v3") 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 ; res_mark = True res_mark@gsMarkerIndex = 1 ; 17 predefined markers available res_mark@gsMarkerSizeF = 0.018 res_mark@gsMarkerColor = "red" dum =gsn_add_polymarker(wks,plot,lon,lat,res_mark) ; ----------Now adding text-------------------- txres = True txres@txFontHeightF = 0.012 txres@txFont = "helvetica-bold" txres@txFontQuality = "High" nrf = dimsizes(rf) text = new(nrf,graphic) ; 1. print(nrf) ; colors = where(((rf.ge.0.1).and.(rf.lt.2.5)),"Blue"," ") ; This is a string variable ; colors = where(((rf.ge.2.5).and.(rf.lt.7.5)),"Red"," ") ; colors = where(((rf.ge.7.5).and.(rf.lt.15.5)),"Yellow"," ") ; 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