[ncl-talk] Adding text data in a contour plot

Stefano Guerra guerras90 at gmail.com
Wed Dec 2 04:37:20 MST 2015


Hi Kyle, thank you for your answer.

I tried this code, it works fine for my purpose, but there is a problem
with time of execution. The first 7/8 "textlat" loops are sufficiently
fast, but the following loops become very slow, than process fault.

contour_tc = wrf_contour(a,wks,tf2,opts)
      plot = wrf_map_overlays(a,wks,(/contour_tc/),platres,mpres)
;overlay per info confini
      poly = gsn_add_shapefile_polylines(wks,plot,"reg2011_g.shp",pres)
;aggiungo shapefile confini regionali
      latout = fspan(36,47,23)
      lonout = fspan(7,18,23)
      do textlat = 0,23,1
print (textlat)
         do textlon = 0,23,1
         loc  = wrf_user_latlon_to_ij(a, latout(textlat), lonout(textlon))
        text = gsn_add_text(wks,plot,sprintf("%0.0f",
tc2(loc(0),loc(1))),lonout(textlon),latout(textlat),txres)
        end do
          end do

draw(plot)
frame(wks)

Thank you again,
Stefano.

2015-12-01 14:51 GMT+01:00 Kyle Griffin <ksgriffin2 at wisc.edu>:

> Stefano,
>
> It'll take some additional lines of code, but gsn_add_text has the
> functionality you are most likely looking for.
>
> https://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_text.shtml
>
> The biggest concern is that your x and y need to be individual pairs
> corresponding to each and every grid point that you want the text at. In
> essence, you would need a two-dimensional latitude array and
> two-dimensional longitude array of only the points where you want text to
> be plotted, as well as the values/strings you want plotted at those points.
>
> I would recommend trying this function with a small number of grid points
> first to make sure it works and does what you want before trying to make
> the function apply to an entire grid. This may prove to be a bit trickier
> with a WRF grid, I have not worked with them myself so I'm not sure. Let
> the list know if you have any problems/questions...
>
>
> Kyle
>
> ----------------------------------------
> Kyle S. Griffin
> Department of Atmospheric and Oceanic Sciences
> University of Wisconsin - Madison
> Room 1407
> 1225 W Dayton St, Madison, WI 53706
> Email: ksgriffin2 at wisc.edu
>
> On Tue, Dec 1, 2015 at 5:31 AM, Stefano Guerra <guerras90 at gmail.com>
> wrote:
>
>> Hi,
>>
>> I tried to search this function, but I couldn't find how can I add text
>> data (from a WRF output) on a contour plot.
>>
>> Maybe I can explain better with an example, I want realize something like this:
>>
>>
>> http://modeles2.meteociel.fr/modeles_gfs/runs/2015120106/3-580.GIF?01-6
>>
>>
>> Thank you for your help,
>> Stefano.
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151202/7c8ddc97/attachment.html 


More information about the ncl-talk mailing list