[ncl-talk] Cannot Find error in gsn_add_text

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Sat Apr 4 23:08:49 MDT 2015


Sebastian,

This is tricky.  The use of gsn_add_text and other gsn_ annotations
requires that you delay plot output until after the annotations are added
to internal buffers.  See the example at the bottom of the gsn_add_text
function page, "conwomap_3.ncl", for how to control the output flow.

In particular, add these two commands BEFORE calling gsn_csm_vector_map:

    res at gsnDraw = False      ; do not draw
    res at gsnFrame = False    ; do not advance

Also, add these two commands AFTER calling gsn_add_text, and BEFORE delete
(wks):

    draw(plotB)
    frame(wks)

--Dave

On Sat, Apr 4, 2015 at 9:58 PM, Sebastian Otarola-Bustos <
Sebastian.F.Otarola-Bustos.1 at nd.edu> wrote:

> Hi All, I'm trying to write the names of some locations in a map throw the
> gsn_add_text command, but this isn't working and I can't find the error
> because is not throwing me any one. I only see the map after running my
> code without any text.  I attached you some parts of my code where I use
> this command, it would be great if someone can help me to find my mistake.
>
> Best Regards,
> Sebastián.
>
>   srcFileName = "/afs/
> crc.nd.edu/user/s/sotarola/WRF/Santiago/Sim/1/wrfout_d03_2011-06-01_00:00:00.nc
> "
> sfile       = addfile(srcFileName,"r")
>
>  lat        = wrf_user_getvar(sfile,"lat",-1)
>  lon        = wrf_user_getvar(sfile,"lon",-1)
>
>  opt = True
>  loc = wrf_user_ll_to_ij(sfile,-70.71263323,-33.479181,opt)
>  loc=loc-1
>
>  do n=0,ntimes-1
>       wks = gsn_open_wks("png","animate"+sprinti("%02i",n))    ;
> animate_00.png, animate_01.png, etc
>       gsn_define_colormap(wks,"gui_default")
>       print("Trabajando en el tiempo: " + times(n))
>       res at gsnRightString  = " Velocity(m/s):  "+ times(n)
>       res at gsnLeftString = " "
>       plotB =gsn_csm_vector_map(wks,u(n,:,:),v(n,:,:),res)
>       txres = False
>       text =
> gsn_add_text(wks,plotB,"Cerrillos",lon(1,loc(1),loc(0)),lat(1,loc(1),loc(0)),txres)
>       delete(wks)   ; Make sure PNG file is closed
>   end do
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150404/cabd22d7/attachment.html 


More information about the ncl-talk mailing list