Re: Problem with gsn_add_polyline

From: Will Hobbs <Will.Hobbs_at_nyahnyahspammersnyahnyah>
Date: Tue Aug 20 2013 - 17:35:06 MDT

James

Try setting 'mpres@gsnFrame = False'

Will

From: James Madden <jmmadden@alaska.edu<mailto:jmmadden@alaska.edu>>
Date: Wednesday, 21 August 2013 9:31 AM
To: "ncl-talk@ucar.edu<mailto:ncl-talk@ucar.edu>" <ncl-talk@ucar.edu<mailto:ncl-talk@ucar.edu>>
Subject: Problem with gsn_add_polyline

Hello,

I am experiencing trouble with gsn_add_polyline. I have attempted to fix this specific problem through the posts on this forum, as well as through the gsn_add_polyline tutorial, however I am not sure what the problem is.

What I want to do is plot the CALIPSO scan track over my WRF plot. My issue is that the scan track appears only after I advance the frame - the polyline does not appear on the plot.

I have rearranged the order a couple of times, and I have modified the resources, but I haven't been successful.

What am I missing here?

Any help is appreciated. Thank you much. The code is below.

The issue should be near the end, unless it happens to be within the 'res' resources in the middle of the code.

Code:

;************************************************
; Program to plot CALIPSO scan track onto WRF daily average plot.
;************************************************

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/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin
wks = gsn_open_wks("x11","CALIPSO SCAN TRACK")

diri = "/import/archive/u1/uaf/jmmadden/WILDFIRE2009/CALIPSOdata/NC/"
fili = systemfunc("cd "+diri+" ;ls CAL* ")
nfil = dimsizes(fili)

do nf = 0, nfil-1 ; LOOPING
print(nf + " " + fili(nf))

b = addfile(diri+fili(nf),"r")

;GEOLOCATION ARRAYS

lat1d = b->Latitude(fakeDim94|:,fakeDim95|0)
lon1d = b->Longitude(fakeDim96|:,fakeDim97|0)

;-----------------------------------------------------------------------
; open file and read in data
;-----------------------------------------------------------------------

  all_filesref = systemfunc ("ls /import/archive/u1/uaf/jmmadden/WILDFIRE2009/WRFouts/wrfout_d01_2009*") ; all files in folder

  print(all_filesref) ; output gives the list of files in folder

  a = addfiles(all_filesref+".nc","r") ; Note the +".nc"

  ListSetType (a, "cat")

  idim=dimsizes(all_filesref) ; get dimensions

nx = 159
ny = 199

ref1= new((/24,nx,ny/),float)
uu = new((/24,nx,ny/),float)
vv = new((/24,nx,ny/),float)

;----------------------------------------------------------------------

; Plotting Resources
;----------------------------------------------------------------------

  gsn_define_colormap(wks,"BlAqGrYeOrReVi200") ;
  res = True ; plot mods desired
  res@gsnMaximize = True ; uncomment to maximize size
  res@gsnSpreadColors = True ; use full range of colormap
  res@cnFillOn = True ; color plot desired
  res@cnLinesOn = False ; turn off contour lines
  res@cnLineLabelsOn = False ; turn off contour labels
  res@cnLevelSelectionMode = "ExplicitLevels"
  res@cnFillMode = "Fill"
  res@lbLabelAutoStride = True
  res@NoHeaderFooter = True
  res@cnLevels = (/0.1,0.2,0.3,0.4,0.5,0.7,0.9,1.3,1.7,2.,2.5,3./)
  res@tfDoNDCOverlay = True; set True for native projection (faster)

;************************************************
; Use WRF_contributed procedure to set map resources
;************************************************
   mpres = True
   mpres@gsnDraw = False

   pltres = True
   pltres@NoTitles = True

   mpres@mpGeophysicalLineColor = 1
   mpres@mpGridLineColor = 1

    ; Plotting options for Wind Vectors
      opts = res
      opts@FieldTitle = "Wind" ; overwrite Field Title
      opts@NumVectors = 47 ; density of wind barbs

;--------------------------------------------------------------------
; Loop starts for all days
;--------------------------------------------------------------------

 do ifile=0,idim-1 ; loop over all days

 times=wrf_user_list_times(a[ifile]) ; get times in the file

 istart=1 ; to ensure to leave out initial hour (=0)
 iend=24 ; to ensure 24h chunks are read for daily averages
 iday=0 ; set to zero to be able to count days with violation

;----------------------------------------------------------------------
; breathing level 0, level 3 64-113m, 4 113-219m, 5 219-343m
;----------------------------------------------------------------------

 ref1(:,:,:) = a[ifile]->PM2_5_DRY(istart:iend,0,:,:) ; PM 2.5 concentration

 uu(:,:,:) = a[ifile]->U(istart:iend,0,:,1:ny)
 vv(:,:,:) = a[ifile]->V(istart:iend,0,1:nx,:)

ref1!0 = "time"
ref1!1 = "lat"
ref1!2 = "lon"

uu!0 = "time"
uu!1 = "lat"
uu!2 = "lon"
vv!0 = "time"
vv!1 = "lat"
vv!2 = "lon"

;----------------------------------------------------------------------
; take daily average of hourly wind, concentrations
;----------------------------------------------------------------------

uavg = dim_avg(uu(lat|:,lon|:,time|:))
vavg = dim_avg(vv(lat|:,lon|:,time|:))
      uavg = uavg*1.94386 ; Turn wind into knots
      vavg = vavg*1.94386
      uavg@units = "kts"
      vavg@units = "kts"

refavg1= dim_avg(ref1(lat|:,lon|:,time|:))
refavg1@description="PM~B~2.5~N~ Average Concentration "+times(0)+" to "+times(24)
refavg1@units="~F33~m~F21~g/m~S~3~N~" ; for PM2.5

print(min(refavg1)+" "+max(refavg1))

 mpres@mpCenterLatF = a[ifile]@CEN_LAT
 mpres@mpCenterLonF = a[ifile]@CEN_LON

 vector = wrf_vector(a[ifile],wks,uavg,vavg,opts)
 contour = wrf_contour(a[ifile],wks,refavg1(:,:),res)

 gres = True
 gres@gsLineThicknessF = 4.0
 gres@gsLineColor ="red"

 plot = wrf_map_overlays(a[ifile],wks,(/contour,vector/),pltres,mpres)

 line = gsn_add_polyline(wks,plot,lon1d,lat1d,gres)

 draw(plot)
 frame(wks)

 delete(line)
 delete(plot)
 delete(vector)

 end do ; loop over all days
end do
end

Once again, thank you for the help.

-mike

--
Mike Madden
Graduate Research Assistant
Department of Atmospheric Sciences
University of Alaska Fairbanks
IARC 338N
Office:  (907) 474-7618
Cell: (417) 439-2830
---------------------------------------------------------------------
"Buy the ticket, take the ride."  Hunter S. Thompson

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Aug 20 17:35:22 2013

This archive was generated by hypermail 2.1.8 : Wed Aug 21 2013 - 13:54:15 MDT