<div dir="ltr"><div class="gmail_default" style="font-size:small">Melissa,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Could you be more specific than &quot;it&#39;s not working correctly?&quot;  It&#39;s hard for us to debug a problem when we don&#39;t know where to look. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">It&#39;s also helpful to include a sample image with an explanation of what&#39;s wrong with it, or an error message.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 31, 2015 at 10:28 AM, Melissa Lazenby <span dir="ltr">&lt;<a href="mailto:M.Lazenby@sussex.ac.uk" target="_blank">M.Lazenby@sussex.ac.uk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Hi NCL-Users<br>
<br>
I am struggling to get my loops to work in a plot I am trying to create for an animation.<br>
<br>
I have u and v wind data that has 7304 timesteps in it and I have a text file of shipping data that I want to use to plot ship tracks for the same wind fields i.e I would like to create 7304 png images to use to create an animation using fmpeg.<br>
<br>
The text file of the shipping data has 252391 timesteps so I only want to extract the data that matches the wind data. So I want to plot ship tracks only every 6 hours.<br>
<br>
The wind data is 4 times daily at 00,06,12,18<br>
The ship data is hourly 00,01,02,03,04 etc..<br>
<br>
I want to create plots to match up with the wind fields i.e. use the winds as the background plot and overlay them with ship tracks using polymarker function in NCL for every 6 hours.<br>
<br>
Below is my script but it is not working correctly.<br>
<br>
If anyone could please advice how to go about fixing it that would be much appreciated.<br>
<br>
Many thanks!<br>
<br>
Kindest Regards<br>
Melissa<br>
<br>
;----------------------------------------------------------------------<br>
; Krakatoa_1.ncl<br>
;----------------------------------------------------------------------<br>
load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;   <br>
load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;    <br>
load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot; <br>
load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl&quot;<br>
<br>
begin<br>
<br>
f=addfile(&quot;/mnt/geog/ml382/McGill_Project/ReanalysisV2/<a href="http://uwnd_krakatoa.nc" target="_blank">uwnd_krakatoa.nc</a>&quot;, &quot;r&quot;)  <br>
<br>
g=addfile(&quot;/mnt/geog/ml382/McGill_Project/ReanalysisV2/<a href="http://vwnd_krakatoa.nc" target="_blank">vwnd_krakatoa.nc</a>&quot;, &quot;r&quot;)               
<br>
 <br>
     <br>
  latS   =  -70.<br>
  latN   =  50. <br>
  lonL   =  0.<br>
  lonR   =  150.<br>
<br>
  u        = f-&gt;uwnd(:,0,:,:)<br>
  v        = g-&gt;vwnd(:,0,:,:)<br>
<br>
  lat   = f-&gt;lat<br>
  lon   = f-&gt;lon<br>
  time  = f-&gt;time<br>
<br>
speed= new(dimsizes(u),float)   <br>
<br>
do gg = 0,dimsizes(time)-1  <br>
<br>
speed(gg,:,:)  = sqrt(u(gg,:,:)^2+v(gg,:,:)^2)<br>
<br>
    speed!0 = &quot;time&quot;<br>
    speed!1 = &quot;lat&quot;<br>
    speed!2 = &quot;lon&quot;<br>
    speed&amp;time= time <br>
    speed&amp;lat = lat<br>
    speed&amp;lon = lon<br>
    speed@long_name = &quot;Wind Speed&quot;<br>
    speed@units     = &quot;m/s&quot;<br>
<br>
   <br>
wks  = gsn_open_wks(&quot;X11&quot;,&quot;Krakatoa_Animation_&quot;+time(gg)+&quot;&quot;)              ; specifies a plot<br>
plot = new (dimsizes(time),&quot;graphic&quot;)<br>
plot1= new (dimsizes(time),&quot;graphic&quot;)<br>
plot2= new (dimsizes(time),&quot;graphic&quot;)<br>
x= new (dimsizes(time),&quot;float&quot;)<br>
y= new (dimsizes(time),&quot;float&quot;)<br>
;---Create plot<br>
<br>
  res                      = True               ; plot mods desired<br>
<br>
  res@cnFillOn             = True               ; turn on color for contours<br>
  res@cnLinesOn            = False              ; turn off contour lines<br>
  res@cnLineLabelsOn       = False              ; turn off contour line labels<br>
  res@gsnScalarContour     = True               ; contours desired<br>
  res@gsnDraw             = False              ; do not draw the plot<br>
  res@gsnFrame            = False  <br>
 <br>
  <br>
  res@vcRefMagnitudeF           = 2.0             ; define vector ref mag<br>
  res@vcRefLengthF              = 0.008           ; define length of vec ref<br>
  res@vcRefAnnoOrthogonalPosF   = -1.0            ; move ref vector<br>
  res@vcRefAnnoArrowLineColor   = &quot;black&quot;         ; change ref vector color<br>
  res@vcRefAnnoArrowUseVecColor = False           ; don&#39;t use vec color for ref<br>
<br>
  res@vcGlyphStyle            = &quot;CurlyVector&quot;     ; turn on curley vectors<br>
  res@vcLineArrowColor        = &quot;black&quot;           ; change vector color<br>
  res@vcLineArrowThicknessF   = 2.0               ; change vector thickness<br>
  res@vcVectorDrawOrder       = &quot;PostDraw&quot;        ; draw vectors last<br>
  res@vcMinDistanceF = 0.02<br>
 <br>
   res@gsnLeftString   = &quot;&quot;<br>
   res@gsnMainString   = &quot;&quot; <br>
   res@gsnRightString  = &quot;&quot;<br>
<br>
  res@mpMinLonF            =  lonL               ; select a subregion<br>
  res@mpMaxLonF            =  lonR<br>
  res@mpMinLatF            =  latS<br>
  res@mpMaxLatF            =  latN<br>
<br>
<br>
  pres                      = True<br>
  pres@mpFillOn = False<br>
  pres@cnFillOn             = True               ; color on<br>
  pres@cnLinesOn            = False              ; turn off contour lines<br>
  pres@gsnScalarContour     = True               ; vectors over contours<br>
  pres@gsnSpreadColors      = True               ; use full colormap<br>
  pres@gsnAddCyclic        = False<br>
  pres@gsnDraw             = False              ; do not draw the plot<br>
  pres@gsnFrame            = False  <br>
  pres@lbLabelBarOn        = False<br>
  pres@gsnMaximize         = True<br>
<br>
  pres@mpMinLonF            =  lonL               ; select a subregion<br>
  pres@mpMaxLonF            =  lonR<br>
  pres@mpMinLatF            =  latS<br>
  pres@mpMaxLatF            =  latN<br>
<br>
<br>
   pres@gsnLeftString   = &quot;&quot;<br>
   pres@gsnMainString   = &quot;&quot; <br>
   pres@gsnRightString  = &quot;&quot;<br>
 <br>
 <br>
  pres@cnLevelSelectionMode= &quot;ManualLevels&quot;  ; manual levels<br>
  pres@cnMinLevelValF      =  -100           ; min level<br>
  pres@cnMaxLevelValF      =  120            ; max level<br>
  pres@cnLevelSpacingF     =  10             ; contour spacing<br>
<br>
<br>
  mres               = True   <br>
  mres@gsMarkerIndex = 3                        ; polymarker style<br>
  mres@gsMarkerSizeF = 20.                      ; polymarker size<br>
  mres@gsMarkerColor = &quot;red&quot;    <br>
<br>
 mpres                   = True                     ; plot mods desired<br>
 mpres@xyMarkLineModes   = &quot;Markers&quot;                ; choose which have markers<br>
 mpres@xyMarkers         =  16                      ; choose type of marker  <br>
 mpres@xyMarkerColor     = &quot;red&quot;                    ; Marker color<br>
 mpres@xyMarkerSizeF     = 0.01                     ; Marker size (default 0.01)<br>
<br>
<br>
;Ship track data<br>
<br>
  ship  = &quot;/mnt/geog/ml382/McGill_Project/ReanalysisV2/Krakatoa_ID.txt&quot;<br>
  data   = asciiread(ship,-1,&quot;string&quot;)<br>
  year   = stringtointeger(str_get_cols(data,1,5))<br>
  month  = stringtointeger(str_get_cols(data,8,9))<br>
  day    = stringtointeger(str_get_cols(data,11,13))<br>
  hour   = stringtointeger(str_get_cols(data,15,20))<br>
  slat    = stringtointeger(str_get_cols(data,22,28))<br>
  slon    = stringtointeger(str_get_cols(data,31,37))<br>
<br>
<br>
k=0<br>
<br>
 <br>
do j=0, 4<br>
jj=j+1881<br>
 do i=0, 11<br>
  do m=0, 30<br>
n = 0<br>
   do nn=0, 7304<br>
   <br>
 data_index = ind((year(k) .eq. jj) .and. (month(k) .eq. i) .and. (day(k) .eq. m) .and. (hour(k) .eq. n))<br>
 <br>
<br>
  if(.not. any(ismissing(data_index))) then<br>
  x(k)=slon(data_index)<br>
  y(k)=slat(data_index)<br>
<br>
print(x)<br>
print(y)<br>
    <br>
end if<br>
<br>
  polyres               = True          ; poly marker mods desired <br>
  polyres@gsMarkerIndex = 16            ; choose circle as polymarker<br>
  polyres@gsMarkerSizeF = 7.0           ; select size to avoid streaking<br>
  polyres@gsMarkerColor = &quot;red&quot;   ; choose color<br>
  <br>
    <br>
     pres@gsnLeftString  = &quot;Krakatoa: Winds and Shipping Tracks&quot;<br>
     plot(gg) = gsn_csm_contour_map(wks,speed(gg,:,:),pres)<br>
     plot1(gg)= gsn_csm_vector(wks,u(gg,:,:),v(gg,:,:),res)<br>
  <br>
<br>
overlay(plot(gg),plot1(gg))<br>
  <br>
plot2(gg) = gsn_add_polymarker(wks,plot(gg),x(k),y(k),polyres)  ; draw polymarkers<br>
<br>
<br>
draw(plot(gg))<br>
frame(wks)<br>
 <br>
k=k+1<br>
n=nn+6 <br>
<br>
    end do<br>
   end do<br>
  end do<br>
 end do<br>
end do<br>
<br>
end<br>
<br>
</div>
</div>

<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>