[ncl-talk] Problem with gsn_add_text

Rick Brownrigg brownrig at ucar.edu
Mon Apr 17 10:04:49 MDT 2017


Hi Stavros,

I don't know for certain, but I suspect you need to assign the _FillValue
to the string array "points" that you constructed from "t2" (I don't see
how the attributes from t2 would carry to points via the sprintf() ).

Hope that helps...
Rick

On Sun, Apr 16, 2017 at 12:56 PM, Stavros Dafis <sdafis at cc.uoi.gr> wrote:

> Hello everyone, I am facing a problem with the function gsn_add_text. In
> the
> description of the function, it is mentioned that no missing values will be
> plotted:
>
> &#8220;This function attaches a list of text strings to the given plot.
> The text
> strings will be drawn only when the plot is drawn. If a missing value is
> encountered in the text strings or x/y values, then no text string will be
> drawn at this pair.&#8221;
>
> My script reads a netCDF file with 3 variables t2(lat,lon), lat(lat),
> lon(lon),
> so in order to attach values on the plot using this function, I have to
> make
> new 2-D variables for lat/lon and define the string to be plotted on the
> map.
> Values are assigned just fine on the plot, over the land, but missing
> values
> are also printed over the sea. I tried to use landsea masking but my data
> have
> high horizontal resolution (5km). Any suggestions?
>
> I have the same problem with WRF data, with already 2-D lat/lon arrays.
>
>  This is the part of the code which prints the values:
> .
> .
> .
> contour = gsn_csm_contour_map(wks,t2,res)
>
> t2 at missing_value = -1
> t2 at _FillValue = -1
> (default missing values = -999)
>
> lat2 = new(dimsizes(t2),typeof(lat),-1)
> lon2 = new(dimsizes(t2),typeof(lon),-1)
>
> nb = dimsizes(t2)
>
> do nl=0,nb(0)-1,1
> do ml=0,nb(1)-1,1
>
> lat2(nl,ml) = lat(nl)
> lon2(nl,ml) = lon(ml)
>
> end do
> end do
>
> points = sprintf("%3.0f", t2)
> ;points = ""+t2(:,:)+""
>
> values = gsn_add_text(wks,contour,points,lon2(:,:),lat2(:,:),True)
>
>
>
> --
> Stavros NTAFIS (DAFIS)
> -----------------------------------------------
> Physicist - Meteorologist, M.Sc.
> Research Associate, National Observatory of Athens
> (+33)9 81 94 22 12, Mobile: +30 697 04 20 242
> ---------------
> Weather charts:
> http://www.meteo.gr
> http://www.meteo.gr/meteomaps/
>
>
>
> _______________________________________________
> 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/20170417/f2f64b8e/attachment.html 


More information about the ncl-talk mailing list