; 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

; ------ 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

;---Read in site info

sitefile  = "monthly.dat"
sitedata = asciiread(sitefile,-1,"string")
delim = ","
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"monthly")

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", "Land:North America:United States:Conterminous US:New York","Water"/)
res@mpSpecifiedFillColors       = (/"transparent","transparent",       "transparent"/)
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 = 4
res@mpUSStateLineThicknessF = 4
res@mpNationalLineThicknessF = 4
res@mpGridLonSpacingF = 2
res@mpDataBaseVersion = "MediumRes" ;-- better map resolution
res@gsnAddCyclic = False

res@cnGridBoundFillColor = "Transparent"


  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

res@lbLabelBarOn        = False  
res@gsnDraw             = False

size = dimsizes(sitelons)
res@mpOutlineSpecifiers =   (/ "Land:North America:United States:Conterminous US:New York"/)
res@mpGeophysicalLineThicknessF = 6
res@mpUSStateLineThicknessF = 6
res@mpNationalLineThicknessF = 6
res@mpOutlineDrawOrder   = "PreDraw"       ;      = "PostDraw" 
plot = gsn_csm_contour_map(wks,fillvarlevel,res)


labels = (/"-10","-8","-6","-4","-2","0","2","4","6","8","10","F"/)
lbres                    = True      ; Set up a resource list for the labelbar.
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/27,47,67,87,107,127,147,167,187,207,227,-1/)
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = True 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  markercolors(n) = round((siteanom(n)*10),3)+127
end do
markercolors=where((markercolors.lt.17),17,markercolors)
markercolors=where((markercolors.gt.255),237,markercolors)

stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
tres@txFontHeightF        = 0.014
    if any(siteanom.lt.-9.5)
      tres@txFontHeightF        = 0.011
    end if
stationtext  =     gsn_add_text(wks,plot,round(siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.03
dum = gsn_add_text(wks,plot,"30 Day Temperature Anomaly",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for a minimum of 28 days is required)",-77.5,41.0,tres)


;dum2=gsn_add_text(wks,plot,clicks(2),-80,45.0,tres)

gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)

draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)

; make weekly plot below
wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"weekly")

sitefile  = "weekly.dat"
sitedata  = asciiread(sitefile,-1,"string")
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

size = dimsizes(sitelons)

plot = gsn_csm_contour_map(wks,fillvarlevel,res)


labels = (/"-10","-8","-6","-4","-2","0","2","4","6","8","10","F"/)
lbres                    = True      ; Set up a resource list for the labelbar.
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/27,47,67,87,107,127,147,167,187,207,227,-1/)
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = True 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  markercolors(n) = round((siteanom(n)*10),3)+127
end do
markercolors=where((markercolors.lt.17),17,markercolors)
markercolors=where((markercolors.gt.255),237,markercolors)

stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
tres@txFontHeightF        = 0.014
    if any(siteanom.lt.-9.5)
      tres@txFontHeightF        = 0.011
    end if
stationtext  =     gsn_add_text(wks,plot,round(siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.03
dum = gsn_add_text(wks,plot,"7 Day Temperature Anomaly",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for all 7 days is required)",-77.5,41.0,tres)

gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)

draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)

; make daily plot below
wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"daily")
;gsn_define_colormap(wks,"BlueRed")
sitefile  = "daily.dat"
sitedata  = asciiread(sitefile,-1,"string")
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

size = dimsizes(sitelons)

plot = gsn_csm_contour_map(wks,fillvarlevel,res)


labels = (/"-10","-8","-6","-4","-2","0","2","4","6","8","10","F"/)
lbres                    = True      ; Set up a resource list for the labelbar.
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/27,47,67,87,107,127,147,167,187,207,227,-1/)
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = True 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  markercolors(n) = round((siteanom(n)*10),3)+127
end do
markercolors=where((markercolors.lt.17),17,markercolors)
markercolors=where((markercolors.gt.255),237,markercolors)

tres@txFontHeightF        = 0.014
stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
    if any(siteanom.lt.-9.5)
      tres@txFontHeightF        = 0.011
    end if
stationtext  =     gsn_add_text(wks,plot,round(siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.026
dum = gsn_add_text(wks,plot,"Yesterday's Temperature Anomaly",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for at least 90% of the day is required)",-77.5,41.0,tres)

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)


draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)





;;;;;;;;;;  solar section below






; make solar weekly plot below
wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"solarweekly")

sitefile  = "solarweekly.dat"
sitedata  = asciiread(sitefile,-1,"string")
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

size = dimsizes(sitelons)

plot = gsn_csm_contour_map(wks,fillvarlevel,res)

labels = (/"3","6","9","12","15","18","21","24","27","30","33","MJ/m~S~2~N~"/)
lbres                    = True      ; Set up a resource list for the labelbar.
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/31,52,73,94,115,136,157,178,199,220,241,-1/)
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = False 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  markercolors(n) = round((siteanom(n)*7),3)+10
end do
markercolors=where((markercolors.gt.255),255,markercolors)

stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
tres@txFontHeightF        = 0.014
    if any(siteanom.lt.-9.5)
      tres@txFontHeightF        = 0.011
    end if
stationtext  =     gsn_add_text(wks,plot,round(siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.03
dum = gsn_add_text(wks,plot,"7 Day Mean Daily Insolation",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for all 7 days is required)",-77.5,41.0,tres)

gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)
draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)

; make solar monthly plot below
wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"solarmonthly")

sitefile  = "solarmonthly.dat"
sitedata  = asciiread(sitefile,-1,"string")
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

size = dimsizes(sitelons)

plot = gsn_csm_contour_map(wks,fillvarlevel,res)

labels = (/"3","6","9","12","15","18","21","24","27","30","33","MJ/m~S~2~N~"/)
lbres                    = True      ; Set up a resource list for the labelbar.
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/31,52,73,94,115,136,157,178,199,220,241,-1/)
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = False 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  markercolors(n) = round((siteanom(n)*7),3)+10
end do
;markercolors=where((markercolors.lt.17),17,markercolors)
markercolors=where((markercolors.gt.255),255,markercolors)

stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
tres@txFontHeightF        = 0.014
    if any(siteanom.lt.-9.5)
      tres@txFontHeightF        = 0.011
    end if
stationtext  =     gsn_add_text(wks,plot,round(siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.03
dum = gsn_add_text(wks,plot,"30 Day Mean Daily Insolation",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for a minimum of 28 days is required)",-77.5,41.0,tres)

gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)
draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)

; make solar daily plot below
wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"solardaily")

sitefile  = "solardaily.dat"
sitedata  = asciiread(sitefile,-1,"string")
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

size = dimsizes(sitelons)

plot = gsn_csm_contour_map(wks,fillvarlevel,res)

labels = (/"3","6","9","12","15","18","21","24","27","30","33","MJ/m~S~2~N~"/)
lbres                    = True      ; Set up a resource list for the labelbar.
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/31,52,73,94,115,136,157,178,199,220,241,-1/)
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = False 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  markercolors(n) = round((siteanom(n)*7),3)+10
end do
markercolors=where((markercolors.gt.255),255,markercolors)

stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
tres@txFontHeightF        = 0.014
    if any(siteanom.lt.-9.5)
      tres@txFontHeightF        = 0.011
    end if
stationtext  =     gsn_add_text(wks,plot,round(siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.03
dum = gsn_add_text(wks,plot,"Yesterday's Total Insolation",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for at least 90% of the day is required)",-77.5,41.0,tres)

gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)

draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)





;;;;;         precip section below






; make precip monthly anomaly plot below
wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"precipmonthly")
;gsn_define_colormap(wks,"OceanLakeLandSnow")
sitefile  = "precipmonthly.dat"
sitedata  = asciiread(sitefile,-1,"string")
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

size = dimsizes(sitelons)

plot = gsn_csm_contour_map(wks,fillvarlevel,res)

lbres                    = True      ; Set up a resource list for the labelbar.
labels = (/"-2.0","-1.6","-1.2","-0.8","-0.4","0","+0.4","+0.8","+1.2","+1.6","+2.0","in"/)
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/204,184,164,144,124,104,84,64,44,24,4,-1/); use with gsn_define_colormap(wks,"OceanLakeLandSnow")
lbres@lbFillColors       = (/200,192,184,176,168,140,132,124,116,108,100,-1/) 
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = True 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  if siteanom(n).ge.0
  markercolors(n) = ((round((siteanom(n)*20),3))*-1)+140
  else
  markercolors(n) = ((round((siteanom(n)*20),3))*-1)+160
  end if
end do
markercolors=where((markercolors.lt.70),70,markercolors)
markercolors=where((markercolors.gt.230),230,markercolors)

stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
tres@txFontHeightF        = 0.010
 ;   if any(siteanom.lt.-9.5)
 ;     tres@txFontHeightF        = 0.011
 ;   end if
stationtext  =     gsn_add_text(wks,plot,.1*round(10*siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.03
dum = gsn_add_text(wks,plot,"30 Day Precipitation Anomaly",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for a minimum of 28 days is required)",-77.5,41.0,tres)

gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)

draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)


; make precip weekly anomaly plot below
wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"precipweekly")
gsn_define_colormap(wks,"OceanLakeLandSnow")
sitefile  = "precipweekly.dat"
sitedata  = asciiread(sitefile,-1,"string")
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

size = dimsizes(sitelons)

plot = gsn_csm_contour_map(wks,fillvarlevel,res)

lbres                    = True      ; Set up a resource list for the labelbar.
labels = (/"-1.0","-0.8","-0.6","-0.4","-0.2","0","+0.2","+0.4","+0.6","+0.8","+1.0","in"/)
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/204,184,164,144,124,104,84,64,44,24,4,-1/) ; use with gsn_define_colormap(wks,"OceanLakeLandSnow")
lbres@lbFillColors       = (/180,176,172,168,164,140,136,132,128,124,120,-1/) 
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = True 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  if siteanom(n).ge.0
  markercolors(n) = ((round((siteanom(n)*20),3))*-1)+140
  else
  markercolors(n) = ((round((siteanom(n)*20),3))*-1)+160
  end if
end do
markercolors=where((markercolors.lt.70),70,markercolors)
markercolors=where((markercolors.gt.230),230,markercolors)

stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
tres@txFontHeightF        = 0.010
 ;   if any(siteanom.lt.-9.5)
 ;     tres@txFontHeightF        = 0.011
 ;   end if
stationtext  =     gsn_add_text(wks,plot,.1*round(10*siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.03
dum = gsn_add_text(wks,plot,"7 Day Precipitation Anomaly",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for all 7 days is required)",-77.5,41.0,tres)

gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)
draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)


; make precip monthly total plot below
wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"preciptotalmonthly")
;gsn_define_colormap(wks,"WhiteGreen")
sitefile  = "preciptotalmonthly.dat"
sitedata  = asciiread(sitefile,-1,"string")
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

size = dimsizes(sitelons)

plot = gsn_csm_contour_map(wks,fillvarlevel,res)

lbres                    = True      ; Set up a resource list for the labelbar.
labels = (/"0","0.1","0.2","0.4","0.7","1.0","1.5","2.0","2.5","3.0","4.0","in"/)
;lbres@lbFillColors       = (/10,15,20,30,45,60,85,110,135,160,200,-1/)           ; use these with gsn_define_colormap(wks,"WhiteGreen")
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/140,139,138,136,133,130,125,120,115,110,100,-1/)
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = True 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  markercolors(n) = ((round((siteanom(n)*10),3))*-1)+140
end do
markercolors=where((markercolors.lt.80),80,markercolors)

stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
tres@txFontHeightF        = 0.010
 ;   if any(siteanom.lt.-9.5)
 ;     tres@txFontHeightF        = 0.011
 ;   end if
stationtext  =     gsn_add_text(wks,plot,.1*round(10*siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.03
dum = gsn_add_text(wks,plot,"30 Day Precipitation Total",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for a minimum of 28 days is required)",-77.5,41.0,tres)

gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)

draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)

; make precip weekly total plot below
wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"preciptotalweekly")
gsn_define_colormap(wks,"WhiteGreen")
sitefile  = "preciptotalweekly.dat"
sitedata  = asciiread(sitefile,-1,"string")
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

size = dimsizes(sitelons)

plot = gsn_csm_contour_map(wks,fillvarlevel,res)

lbres                    = True      ; Set up a resource list for the labelbar.
labels = (/"0","0.1","0.2","0.4","0.7","1.0","1.5","2.0","2.5","3.0","4.0","in"/)
;lbres@lbFillColors       = (/10,15,20,30,45,60,85,110,135,160,200,-1/)           ; use these with gsn_define_colormap(wks,"WhiteGreen")
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/140,139,138,136,133,130,125,120,115,110,100,-1/)
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = True 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  markercolors(n) = ((round((siteanom(n)*10),3))*-1)+140
end do
markercolors=where((markercolors.lt.80),80,markercolors)

stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
tres@txFontHeightF        = 0.010
 ;   if any(siteanom.lt.-9.5)
 ;     tres@txFontHeightF        = 0.011
 ;   end if
stationtext  =     gsn_add_text(wks,plot,.1*round(10*siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.03
dum = gsn_add_text(wks,plot,"7 Day Precipitation Total",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for all 7 days is required)",-77.5,41.0,tres)

gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)

draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)

; make precip daily total plot below
wks_type = "png"
wks_type@wkWidth = 2000
wks_type@wkHeight = 1600 
wks = gsn_open_wks(wks_type,"preciptotaldaily")
gsn_define_colormap(wks,"WhiteGreen")
sitefile  = "preciptotaldaily.dat"
sitedata  = asciiread(sitefile,-1,"string")
sitelats  = tofloat(str_get_field(sitedata,1,delim))
sitelons  = tofloat(str_get_field(sitedata,2,delim))
siteanom  = tofloat(str_get_field(sitedata,3,delim))

size = dimsizes(sitelons)

plot = gsn_csm_contour_map(wks,fillvarlevel,res)

lbres                    = True      ; Set up a resource list for the labelbar.
labels = (/"0","0.1","0.2","0.4","0.7","1.0","1.5","2.0","2.5","3.0","4.0","in"/)
;lbres@lbFillColors       = (/10,15,20,30,45,60,85,110,135,160,200,-1/)           ; use these with gsn_define_colormap(wks,"WhiteGreen")
lbres@vpWidthF           = 0.1
lbres@vpHeightF          = 0.25
lbres@lbBoxLinesOn       = False
lbres@lbFillColors       = (/140,139,138,136,133,130,125,120,115,110,100,-1/)
lbres@lbMonoFillPattern  = True
lbres@lbOrientation      = "Vertical"
lbres@lbPerimOn          = False
lbres@lbLabelFontHeightF = .013
lbres@lbLabelAutoStride  = True 
lbid = gsn_create_labelbar_ndc(wks,12,labels,.7,.5,lbres)
amres = True
amres@amZone           = 0
amres@amParallelPosF   = 0.4  
amres@amOrthogonalPosF = 0    
annoid = gsn_add_annotation(plot,lbid,amres)


;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
  markercolors(n) = ((round((siteanom(n)*10),3))*-1)+140
end do
markercolors=where((markercolors.lt.80),80,markercolors)

stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres                = True         ; marker resources for best track
mres@gsMarkerIndex  = 16           ; marker style (filled circle)
mres@gsMarkerSizeF  = 23.0          ; marker size
mres@gsMarkerColor  = markercolors(n)      ; marker color
mres@tfPolyDrawOrder= "PostDraw"

stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)

tres                      = True                ; text mods desired
tres@tfPolyDrawOrder  = "PostDraw"
tres@txFont = "helvetica-bold"
tres@txFontHeightF        = 0.010
 ;   if any(siteanom.lt.-9.5)
 ;     tres@txFontHeightF        = 0.011
 ;   end if
stationtext  =     gsn_add_text(wks,plot,.1*round(10*siteanom(n),3),sitelons(n),sitelats(n),tres)
end do


tres@txFontHeightF        = 0.028
dum = gsn_add_text(wks,plot,"Yesterday's Precipitation Total",-77.5,41.4,tres)
tres@txFontHeightF        = 0.015 
dum = gsn_add_text(wks,plot,"(data for at least 90% of the day is required)",-77.5,41.0,tres)

gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")

gres                 = True

;  add temperature stuff
gres@gsFillColor     = 190
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-79.8, -79.8,  -79.3,   -79.3, -79.8/)
dum1 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 190      ; marker color
markera = gsn_add_polymarker(wks,plot,-79.8,45.15,mres)
markerb = gsn_add_polymarker(wks,plot,-79.3,45.15,mres)

tres@txFontHeightF        = 0.0105
dum = gsn_add_text(wks,plot,"Temperature",-79.55,45.19,tres)
dum = gsn_add_text(wks,plot,"Anomaly",-79.55,45.06,tres)
dum = gsn_add_text(wks,plot,"________",-79.55,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 200      ; marker color
marker1 = gsn_add_polymarker(wks,plot,-79.55,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-79.55,44.71,tres)

mres@gsMarkerColor  = 210      ; marker color
marker2 = gsn_add_polymarker(wks,plot,-79.55,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-79.55,44.26,tres)

mres@gsMarkerColor  = 220      ; marker color
marker3 = gsn_add_polymarker(wks,plot,-79.55,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-79.55,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-79.55,43.81,tres)


;;;; Precipitation Section
gres@gsFillColor     = 130
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-78.9, -78.9,  -78.1,   -78.1, -78.9/)
dum2 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 130      ; marker color
markerc = gsn_add_polymarker(wks,plot,-78.9,45.15,mres)
markerd = gsn_add_polymarker(wks,plot,-78.1,45.15,mres)

dum = gsn_add_text(wks,plot,"Precipitation",-78.5,45.19,tres)
dum = gsn_add_text(wks,plot," Total  Anomaly",-78.49,45.06,tres)
dum = gsn_add_text(wks,plot,"____",-78.76,45.05,tres)
dum = gsn_add_text(wks,plot,"________",-78.3,45.05,tres)


mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 120      ; marker color
marker4 = gsn_add_polymarker(wks,plot,-78.75,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-78.75,44.71,tres)

mres@gsMarkerColor  = 110      ; marker color
marker5 = gsn_add_polymarker(wks,plot,-78.75,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.75,44.26,tres)

mres@gsMarkerColor  = 100      ; marker color
marker6 = gsn_add_polymarker(wks,plot,-78.75,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.75,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.75,43.81,tres)

mres@gsMarkerColor  = 50      ; marker color
marker7 = gsn_add_polymarker(wks,plot,-78.25,44.75,mres)
dum = gsn_add_text(wks,plot,"N/A",-78.25,44.75,tres)

mres@gsMarkerColor  = 60      ; marker color
marker8 = gsn_add_polymarker(wks,plot,-78.25,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-78.25,44.26,tres)

mres@gsMarkerColor  = 70      ; marker color
marker9 = gsn_add_polymarker(wks,plot,-78.25,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-78.25,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-78.25,43.81,tres)

; add solar section
gres@gsFillColor     = 150
plat = (/45,  45.3, 45.3, 45, 45/)
plon = (/-77.7, -77.7,  -77.2,   -77.2, -77.7/)
dum3 = gsn_add_polygon(wks,plot,plon,plat,gres)
mres@gsMarkerSizeF  = 36.5          ; marker size
mres@gsMarkerColor  = 150      ; marker color
markere = gsn_add_polymarker(wks,plot,-77.7,45.15,mres)
markerf = gsn_add_polymarker(wks,plot,-77.2,45.15,mres)

dum = gsn_add_text(wks,plot,"Insolation",-77.45,45.19,tres)
dum = gsn_add_text(wks,plot,"Total",-77.45,45.068,tres)
dum = gsn_add_text(wks,plot,"_____",-77.45,45.05,tres)

mres@gsMarkerSizeF  = 50.0          ; marker size
mres@gsMarkerColor  = 160      ; marker color
marker10 = gsn_add_polymarker(wks,plot,-77.45,44.75,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.85,tres)
dum = gsn_add_text(wks,plot,"Day",-77.45,44.71,tres)

mres@gsMarkerColor  = 170      ; marker color
marker11 = gsn_add_polymarker(wks,plot,-77.45,44.3,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,44.40,tres)
dum = gsn_add_text(wks,plot,"Week",-77.45,44.26,tres)

mres@gsMarkerColor  = 180      ; marker color
marker12 = gsn_add_polymarker(wks,plot,-77.45,43.85,mres)
dum = gsn_add_text(wks,plot,"1",-77.45,43.95,tres)
dum = gsn_add_text(wks,plot,"Month",-77.45,43.81,tres)

draw(plot)
frame(wks)

delete(sitefile)
delete(sitelats)
delete(sitelons)
delete(sitedata)
delete(siteanom)
delete(markercolors)
delete(stationmarker)

































;dum = new(4,graphic)
;do i=0,3,1
;textcolors     = (/"steel blue","red","yellow","green"/)
;tres@txFontColor = textcolors(i)
;    dum(i) = gsn_add_text(wks,plot,words(i),-77.5,41.7-(.3*i),tres)
;end do

; Make Sample Markers with text

;samplemarkers = new(2,graphic)
;sampleres = True
;sampleres@gsMarkerSizeF  = 18.0 
;sampleres@gsMarkerIndex  = 2 
;sampleres@gsMarkerColor  = "black"      ; marker color
;sampleres@gsMarkerThicknessF     =  10

;do n=0,1,1
;sampleres@gsMarkerSizeF  = 18.0 +n
;sampleres@gsMarkerIndex  = 2 + (n*2)
;samplemarkers(n) = gsn_add_polymarker(wks,plot,-79.9,40.5,sampleres)
;end do

;newsampleres = True
;newsamplemarkers = new(2,graphic)

;do n=0,1,1
;newsampleres@gsMarkerSizeF  = 20 - (n*10)
;newsampleres@gsMarkerIndex  = 4
;newsampleres@gsMarkerThicknessF     =  10
;newsamplemarkers(n) = gsn_add_polymarker(wks,plot,-77.5,40.5,newsampleres)
;end do

;bothsampleres = True
;bothsamplemarkers = new(3,graphic)

;MarkerThicknessF     =  (/10,10,10/)
;MarkerSizeF  = (/20,10,18/)
;MarkerIndex  = (/4,4,2/)

;do n=0,2,1
;bothsampleres@gsMarkerSizeF  = MarkerSizeF(n)
;bothsampleres@gsMarkerIndex  = MarkerIndex(n)
;bothsampleres@gsMarkerThicknessF     = MarkerThicknessF(n)
;bothsamplemarkers(n) = gsn_add_polymarker(wks,plot,-75.5,40.5,bothsampleres)
;end do


;samplewords = (/" = Expected Enhanced Site       = Expected Snow Site       = Both"/)
;sample = new(1,graphic)
;do i=0,0,1
;textcolors     = (/"black"/)
;tres@txFontHeightF        = 0.015 
;tres@txFontColor = textcolors(i)
;    sample(i) = gsn_add_text(wks,plot,samplewords(i),-77.3,40.5,tres)
;end do

;clicks = (/"~F21~Click ~F22~Here ~F21~For 24 Hour Extremes","~F21~Click ~F22~Here ~F21~For Current Conditions",\
;          "~F21~Click ~F22~Here ~F21~For Soil Conditions"/)

;tres@txFontHeightF        = 0.02
;tres@txFontColor = "black"
;dum2=new(1,graphic)
;dum2=gsn_add_text(wks,plot,clicks(0),-78.2,45,tres)
;dum2=gsn_add_text(wks,plot,clicks(1),-78.2,44.5,tres)
;dum2=gsn_add_text(wks,plot,clicks(2),-78.2,44,tres)


end
