[ncl-talk] Problem with gsn_add_text

Rick Brownrigg brownrig at ucar.edu
Mon Apr 17 14:32:43 MDT 2017


Hi,

You used -1 as _FillValue for variable "t2". Note it is an integer value --
what type is the array t2 -- float or int?  In any case, you created the
formatted string array "points" from t2 as "%3.0f", so that any data values
in t2 that were -1 are now " -1", and thus it seems your _FillValue should
be " -1". Did you do this, and do the types between data and _FillValue
agree everywhere?

If that's not the issue, I think we may need to see script and dataset to
figure out what the issue is.

HTH...
Rick

On Mon, Apr 17, 2017 at 12:48 PM, Stavros Dafis <sdafis at cc.uoi.gr> wrote:

> Dear Rick, thank you for your suggestion, I have tried to assign both the
> FillValue and the missing value (@missing_value) but nothing seems to work.
>
> I forgot to mention that I am using NCL 6.2.0, 6.3.0 and 6.4.0, on
> different
> machines.
>
>
> --
> 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/
>
>
> Quoting Rick Brownrigg <brownrig at ucar.edu>:
>
> > 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/01bd2242/attachment.html 


More information about the ncl-talk mailing list