; load libraries, twice for good measure 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/wrf/WRFUserARW.ncl" ;load "/home/torn/ncl/wrf_map_info.ncl" ;load "/home/torn/ncl/array_stat.ncl" ;load "/home/torn/ncl/image_conv.ncl" 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/wrf/WRFUserARW.ncl" ;load "/home/torn/ncl/wrf_map_info.ncl" ;load "/home/torn/ncl/array_stat.ncl" ;load "/home/torn/ncl/image_conv.ncl" ;load "wrf_dart_util.ncl" begin dasc = "./" ; input directory for ascii files fasc = "*txt" ; a unique identifier for file DASC = "./" ; output dir FASC = "BIG.txt" ; output file name system ("/bin/rm -f "+DASC+FASC) ; rm any pre-existing file ncol = stringtoint(systemfunc("ls -1 *txt | wc -l")) ; Use UNIX "cat" to concatenate the files into one file. system ("cd "+ dasc+" ; cat "+fasc+" > "+DASC+FASC) ; You can now read the file via "asciiread". data = asciiread(DASC+FASC,(/ncol,3/),"float") system ("/bin/rm -f "+DASC+FASC) ; rm any pre-existing file fils = systemfunc ("ls *txt") ;data@_FillValue = -999 ; ------ Load Data rows = numAsciiRow("usp01.dat") columns = numAsciiCol("usp01.dat") data01=asciiread("usp01.dat",(/rows,columns/),"float") templat = data01(:,2) templon = data01(:,3) tempdata= data01(:,4) p = onedtond(tempdata,(/7,9/)) lat = onedtond(templat,(/7,9/)) lon = onedtond(templon,(/7,9/)) p(0,0)=p(0,0)+.01 ; ------ Assign Coordinates uniquelat = lat(:,1) uniquelon = lon(1,:) uniquelat@units="degrees_north" uniquelon@units="degrees_east" latmin=min(lat) latmax=max(lat) lonmin=min(lon) lonmax=max(lon) fillvarlevel = p fillvarlevel!0="lat" fillvarlevel!1="lon" fillvarlevel&lon = uniquelon fillvarlevel&lat = uniquelat ; ------ Figure out ranges and associated colors/colorbar ctablesize = 254 ; set size of the color table minvalue = 0 ; set minimum desired data range maxvalue = 100 ; set maximum desired data range valueinterval = 5 ; set desired data interval cinterval = floattointeger(ctablesize/((maxvalue-minvalue)/valueinterval)) ; based on the above, set an optimum color interval colors = ispan(-1,ctablesize,abs(cinterval)) ; define optimum colors, based on data interval, starting with transparent ;---Read in site info sitefile = "Nick_Sites.csv" sitedata = asciiread(sitefile,-1,"string") delim = "," sitelats = tofloat(str_get_field(sitedata,4,delim)) sitelons = tofloat(str_get_field(sitedata,5,delim)) wks_type = "png" wks_type@wkWidth = 2000 wks_type@wkHeight = 1600 wks = gsn_open_wks(wks_type,"plot") res = True res@gsnFrame = False res@mpProjection = "CylindricalEquidistant" ;res@mpOutlineBoundarySets = "GeophysicalAndUSStates" res@gsnMaximize = True res@lbBoxMinorExtentF = 0.25 res@cnFillOn = False ; this controls whether or not a label bar exists res@cnLinesOn = False ;no contours on top of fill res@cnFillMode = "RasterFill" res@cnRasterSmoothingOn = True res@mpMinLonF = lonmin ;-- min longitude res@mpMaxLonF = lonmax ;-- max longitude res@mpMinLatF = latmin ;-- min latitude res@mpMaxLatF = latmax ;-- max latitude res@tfDoNDCOverlay = True ;this is a resource for overlaying multiple plots res@cnInfoLabelOn = False ; turn off contour label ;res@mpDataBaseVersion = "Ncarg4_1" ;res@mpDataSetName = "Earth..4" ; For counties ;res@mpFillAreaSpecifiers = (/"Land", "United States:States","Water"/) ; for states only ;res@mpFillAreaSpecifiers = (/"Land", "New York:Counties","Water"/) ; for counties ;res@mpSpecifiedFillColors = (/"white","transparent", "white"/) ;res@mpInlandWaterFillColor = 238 ;res@mpLandFillColor = -1 ; transparent ;res@mpOutlineOn = True ;res@mpOutlineSpecifiers = (/"Land","New York"/) ; for counties ;res@mpMaskOutlineSpecifiers = (/"water"/) ; new below with all of LI, but bad background res@mpDataBaseVersion = "Ncarg4_1" res@mpDataSetName = "Earth..4" ; For counties res@mpFillAreaSpecifiers = (/"Land", "United States:States","Water"/) ; for states only res@mpFillAreaSpecifiers = (/"Land", "Land:North America:United States:Conterminous US:New York","Water"/) res@mpSpecifiedFillColors = (/"white","transparent", "white"/) res@mpInlandWaterFillColor = 238 res@mpLandFillColor = -1 ; transparent res@mpOutlineOn = True res@mpMaskOutlineSpecifiers = (/"Land"/) res@mpOutlineSpecifiers = (/ "Land:North America:United States:Conterminous US:New York"/) res@mpGeophysicalLineThicknessF = 8 res@mpUSStateLineThicknessF = 8 res@mpNationalLineThicknessF = 8 res@mpCountyLineThicknessF = 5 res@mpGridLonSpacingF = 2 res@mpDataBaseVersion = "MediumRes" ;-- better map resolution res@gsnAddCyclic = False ;res@cnLevelSelectionMode = "ManualLevels" ;-- set contour levels manually ;res@cnMinLevelValF = minvalue ;-- minimum contour level ;res@cnMaxLevelValF = maxvalue ;-- maximum contour level ;res@cnLevelSpacingF = valueinterval ;-- contour level spacing ;res@lbLabelStride = 5 res@cnGridBoundFillColor = "Transparent" res@cnFillColors = colors ;res@cnFillDrawOrder = "PreDraw" ; Make sure map fill happens last res@tmXBBorderOn = False res@tmXBMinorPerMajor = 1 res@tmXBOn = False res@tmXTBorderOn = False res@tmXTOn = False res@tmYLBorderOn = False res@tmYLMinorPerMajor = 1 res@tmYLOn = False res@tmYRBorderOn = False res@tmYROn = False plot = gsn_csm_contour_map(wks, fillvarlevel, res) size = dimsizes(sitelons) markercolors = new(size(0),"string") do n=0,size(0)-1,1 markercolors(n) = "black" end do mres = True ; marker resources for best track mres@gsMarkerIndex = 16 ; marker style (filled circle) mres@gsMarkerSizeF = 5.0 ; marker size markers = new(size(0),graphic) do n=0,size(0)-1,1 mres@gsMarkerColor = markercolors(n) ; marker color markers(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres) end do tres = True dum = new(ncol,graphic) textcolors = (/"blue","red","orange","green"/) tres@txFont = "helvetica-bold" tres@txFontHeightF = 0.02 do i=0,ncol-1,1 tres@txFontColor = round(4*(data(i,2))-25,3) ; this part gives a color based on the value - edit for different ranges dum(i) = gsn_add_text(wks,plot,round(data(i,2),3),data(i,1)-.11,data(i,0)+.11,tres) end do words = (/"Maximum Wind Gusts On March 14~S~th","Temperature","Dewpoint","Sea Level","Pressure","Wind","Hourly Rain Rate"/) tres@txFontHeightF = 0.02 tres@txFontColor = 1 ; "black" dum2=new(1,graphic) dum2=gsn_add_text(wks,plot,words(0),-77.5,41.3,tres) ;tres@txFontColor = textcolors(1) ;dum2=gsn_add_text(wks,plot,words(1),-77.8,41,tres) ;tres@txFontColor = textcolors(3) ;dum2=gsn_add_text(wks,plot,words(2),-77.8,40.5,tres) ;tres@txFontColor = textcolors(2) ;dum2=gsn_add_text(wks,plot,words(3),-76.2,41.08,tres) ;tres@txFontColor = textcolors(2) ;dum2=gsn_add_text(wks,plot,words(4),-76.2,40.92,tres) ;tres@txFontColor = textcolors(0) ;dum2=gsn_add_text(wks,plot,words(5),-76.2,40.5,tres) ;tres@txFontHeightF = 0.012 ;tres@txFontColor = textcolors(3) ;dum2=gsn_add_text(wks,plot,words(6),-78.6,40.75,tres) ; Here's the part about the statewide extremes ;tres@txFontHeightF = 0.014 ;tres@txFontColor = textcolors(1) ;dum2=gsn_add_text(wks,plot,"Highest Temperature: "+.1*round(10*max(data(:,6)),3)+" F at "+systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,6)))),-78,45.2,tres) ;tres@txFontColor = "blue" ;dum2=gsn_add_text(wks,plot,"Lowest Temperature: "+.1*round(10*min(data(:,6)),3)+" F at "+systemfunc("head -n 1 ../meta/"+fils(minind(data(:,6)))),-78,45,tres) ;tres@txFontColor = textcolors(3) ;dum2=gsn_add_text(wks,plot,"Heaviest Precipitation Rate: "+.01*round(1200*max(data(:,10)),3)+" in./h at "+systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,10)))),-78,44.8,tres) ;tres@txFontColor = "black" ;dum2=gsn_add_text(wks,plot,"Strongest Wind: "+.1*round(10*max(data(:,8)),3)+" mph at "+systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,8)))),-78,44.6,tres) draw(plot) frame(wks) ;delete(plot) ;delete(wks) ;delete(words) ;delete(textcolors) ;wks_type = "png" ;wks_type@wkWidth = 2000 ;wks_type@wkHeight = 1600 ;wks = gsn_open_wks(wks_type,"ground") ;plot = gsn_csm_contour_map(wks, fillvarlevel, res) ;size = dimsizes(sitelons) ;markercolors = new(size(0),"string") ;do n=0,size(0)-1,1 ; markercolors(n) = "black" ;end do ;mres = True ; marker resources for best track ;mres@gsMarkerIndex = 16 ; marker style (filled circle) ;mres@gsMarkerSizeF = 5.0 ; marker size ;markers = new(size(0),graphic) ;do n=0,size(0)-1,1 ;mres@gsMarkerColor = markercolors(n) ; marker color ;markers(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres) ;end do ;tres = True ; text mods desired ;tres@txFontHeightF = 0.01 ; make smaller ;dum = new(ncol,graphic) ;textcolors = (/"red","green","yellow"/) ;tres@txFont = "helvetica-bold" ;do i=0,ncol-1,1 ; tres@txFontHeightF = 0.007 ; if (.not.isnan_ieee(data(i,13))) ; tres@txFontColor = 230 ; dum(i) = gsn_add_text(wks,plot,round(data(i,13),3),data(i,1)-.07,data(i,0)+.07,tres) ; tres@txFontColor = 200 ; dum(i) = gsn_add_text(wks,plot,round(data(i,14),3),data(i,1)-.07,data(i,0)+.00,tres) ; tres@txFontColor = 170 ; if (any(isnan_ieee(data(i,15)))) then ; dum(i) = gsn_add_text(wks,plot,"M",data(i,1)-.07,data(i,0)-.07,tres) ; else ; dum(i) = gsn_add_text(wks,plot,round(data(i,15),3),data(i,1)-.07,data(i,0)-.07,tres) ; end if ; tres@txFontColor = textcolors(1) ; tres@txFontColor = 100 ; dum(i) = gsn_add_text(wks,plot,.01*round(100*data(i,16),3),data(i,1)+.099,data(i,0)+.07,tres) ; tres@txFontColor = 110 ; dum(i) = gsn_add_text(wks,plot,.01*round(100*data(i,17),3),data(i,1)+.099,data(i,0)+.00,tres) ; tres@txFontColor = 120 ; if (any(isnan_ieee(data(i,18)))) then ; dum(i) = gsn_add_text(wks,plot,"M",data(i,1)+.099,data(i,0)-.07,tres) ; else ; dum(i) = gsn_add_text(wks,plot,.01*round(100*data(i,18),3),data(i,1)+.099,data(i,0)-.07,tres) ; end if ; end if ;end do ;words = (/"Current Soil Conditions:","Temperature","Moisture","Sea Level","Pressure","Wind","Hourly Rain Rate"/) ;tres@txFontHeightF = 0.015 ;tres@txFontColor = "black" ;dum2=new(1,graphic) ;dum2=gsn_add_text(wks,plot,words(0),-77,41.3,tres) ;dum2=gsn_add_text(wks,plot,words(1),-77.6,41,tres) ;tres@txFontColor = 230 ;dum2=gsn_add_text(wks,plot,"5 cm",-77.6,40.8,tres) ;tres@txFontColor = 200 ;dum2=gsn_add_text(wks,plot,"25 cm",-77.6,40.6,tres) ;tres@txFontColor = 170 ;dum2=gsn_add_text(wks,plot,"50 cm",-77.6,40.4,tres) ;tres@txFontColor = "black" ;dum2=gsn_add_text(wks,plot,words(2),-76.4,41,tres) ;tres@txFontColor = 100 ;dum2=gsn_add_text(wks,plot,"5 cm",-76.4,40.8,tres) ;tres@txFontColor = 110 ;dum2=gsn_add_text(wks,plot,"25 cm",-76.4,40.6,tres) ;tres@txFontColor = 120 ;dum2=gsn_add_text(wks,plot,"50 cm",-76.4,40.4,tres) ; Here's the part about the statewide extremes ;tres@txFontHeightF = 0.014 ;tres@txFontColor = "red" ;dum2=gsn_add_text(wks,plot,"Warmest 5 cm: "+.1*round(10*max(data(:,13)),3)+" F at "+systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,13)))),-78,45.2,tres) ;tres@txFontColor = "blue" ;dum2=gsn_add_text(wks,plot,"Coolest 5 cm: "+.1*round(10*min(data(:,13)),3)+" F at "+systemfunc("head -n 1 ../meta/"+fils(minind(data(:,13)))),-78,45,tres) ;tres@txFontColor = "green" ;dum2=gsn_add_text(wks,plot,"Wettest 5 cm: "+.01*round(100*max(data(:,16)),3)+" m~S~3~N~/m~S~3~N~ at "+systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,16)))),-78,44.8,tres) ;tres@txFontColor = "orange" ;dum2=gsn_add_text(wks,plot,"Driest 5 cm: "+.01*round(100*min(data(:,16)),3)+" m~S~3~N~/m~S~3~N~ at "+systemfunc("head -n 1 ../meta/"+fils(minind(data(:,16)))),-78,44.6,tres) ;draw(plot) ;frame(wks) ;delete(plot) ;delete(wks) ;delete(words) ;delete(textcolors) ;wks_type = "png" ;wks_type@wkWidth = 2000 ;wks_type@wkHeight = 1600 ;wks = gsn_open_wks(wks_type,"groundchange") ;plot = gsn_csm_contour_map(wks, fillvarlevel, res) ;size = dimsizes(sitelons) ;markercolors = new(size(0),"string") ;do n=0,size(0)-1,1 ; markercolors(n) = "black" ;end do ;mres = True ; marker resources for best track ;mres@gsMarkerIndex = 16 ; marker style (filled circle) ;mres@gsMarkerSizeF = 5.0 ; marker size ;markers = new(size(0),graphic) ;do n=0,size(0)-1,1 ;mres@gsMarkerColor = markercolors(n) ; marker color ;markers(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres) ;end do ;tres = True ; text mods desired ;tres@txFontHeightF = 0.01 ; make smaller ;do i=0,ncol-1,1 ; temp = (data(i,11)-32)*5/9 ; elev = 0.0065*(0.5+data(i,12)) ; data(i,9)=data(i,9)*((1-(elev/(temp+elev+273.15)))^-5.257) ;end do ;dum = new(ncol,graphic) ;textcolors = (/"red","green","yellow"/) ;tres@txFont = "helvetica-bold" ;do i=0,ncol-1,1 ; tres@txFontHeightF = 0.007 ; if (.not.isnan_ieee(data(i,13))) ; tres@txFontColor = 230 ; dum(i) = gsn_add_text(wks,plot,.1*round(10*(data(i,13)-data(i,19)),3),data(i,1)-.08,data(i,0)+.07,tres) ; tres@txFontColor = 200 ; dum(i) = gsn_add_text(wks,plot,.1*round(10*(data(i,14)-data(i,20)),3),data(i,1)-.08,data(i,0)+.00,tres) ; tres@txFontColor = 170 ; if (any(isnan_ieee(data(i,18)))) then ; dum(i) = gsn_add_text(wks,plot,"M",data(i,1)-.08,data(i,0)-.07,tres) ; else ; dum(i) = gsn_add_text(wks,plot,.1*round(10*(data(i,15)-data(i,21)),3),data(i,1)-.08,data(i,0)-.07,tres) ; end if ; ; tres@txFontColor = textcolors(1) ; tres@txFontColor = 100 ; dum(i) = gsn_add_text(wks,plot,.01*round(100*(data(i,16)-data(i,22)),3),data(i,1)+.099,data(i,0)+.07,tres) ; tres@txFontColor = 110 ; dum(i) = gsn_add_text(wks,plot,.01*round(100*(data(i,17)-data(i,23)),3),data(i,1)+.099,data(i,0)+.00,tres) ; tres@txFontColor = 120 ; if (any(isnan_ieee(data(i,18)))) then ; dum(i) = gsn_add_text(wks,plot,"M",data(i,1)+.099,data(i,0)-.07,tres) ; else ; dum(i) = gsn_add_text(wks,plot,.01*round(100*(data(i,18)-data(i,24)),3),data(i,1)+.099,data(i,0)-.07,tres) ; end if ; end if ;end do ;words = (/"24 Hour Change In Soil Conditions:","Temperature","Moisture","Sea Level","Pressure","Wind","Hourly Rain Rate"/) ;tres@txFontHeightF = 0.015 ;tres@txFontColor = "black" ;dum2=new(1,graphic) ;dum2=gsn_add_text(wks,plot,words(0),-77,41.3,tres) ;dum2=gsn_add_text(wks,plot,words(1),-77.6,41,tres) ;tres@txFontColor = 230 ;dum2=gsn_add_text(wks,plot,"5 cm",-77.6,40.8,tres) ;tres@txFontColor = 200 ;dum2=gsn_add_text(wks,plot,"25 cm",-77.6,40.6,tres) ;tres@txFontColor = 170 ;dum2=gsn_add_text(wks,plot,"50 cm",-77.6,40.4,tres) ;tres@txFontColor = "black" ;dum2=gsn_add_text(wks,plot,words(2),-76.4,41,tres) ;tres@txFontColor = 100 ;dum2=gsn_add_text(wks,plot,"5 cm",-76.4,40.8,tres) ;tres@txFontColor = 110 ;dum2=gsn_add_text(wks,plot,"25 cm",-76.4,40.6,tres) ;tres@txFontColor = 120 ;dum2=gsn_add_text(wks,plot,"50 cm",-76.4,40.4,tres) ; Here's the part about the statewide extremes ;tres@txFontHeightF = 0.015 ;tres@txFontColor = "black" ;dum2=gsn_add_text(wks,plot,"All Values Represent Today's",-78,45,tres) ;dum2=gsn_add_text(wks,plot,"Values Minus Yesterday's Values",-78,44.8,tres) ;tres@txFontColor = "red" ;dum2=gsn_add_text(wks,plot,"Most 5 cm Warming: "+.1*round(10*max(data(i,13)-data(i,19)),3)+" F at "+systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,13)))),-78,45.2,tres) ;tres@txFontColor = "blue" ;dum2=gsn_add_text(wks,plot,"Most 5 cm Cooling: "+.1*round(10*min(data(i,13)-data(i,19)),3)+" F at "+systemfunc("head -n 1 ../meta/"+fils(minind(data(:,13)))),-78,45,tres) ;tres@txFontColor = "green" ;dum2=gsn_add_text(wks,plot,"Most 5 cm Moistening: "+.01*round(100*max(data(i,16)-data(i,22)),3)+" m~S~3~N~/m~S~3~N~ at "+systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,16)))),-78,44.8,tres) ;tres@txFontColor = "orange" ;dum2=gsn_add_text(wks,plot,"Most 5 cm Drying: "+.01*round(100*min(data(i,16)-data(i,22)),3)+" m~S~3~N~/m~S~3~N~ at "+systemfunc("head -n 1 ../meta/"+fils(minind(data(:,16)))),-78,44.6,tres) ;draw(plot) ;frame(wks) end ;systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,2)))) ; max temp ;systemfunc("head -n 1 ../meta/"+fils(minind(data(:,3)))) ; min temp ;systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,4)))) ; max wind ;systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,5)))) ; max 24 precip ;systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,6)))) ; current temp ;systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,7)))) ; current dewpoint ;systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,8)))) ; current wind ;systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,9)))) ; current pressure ;systemfunc("head -n 1 ../meta/"+fils(maxind(data(:,10)))) ; current rain rate