[ncl-talk] Problem with gsn_add_text
Stavros Dafis
sdafis at cc.uoi.gr
Sun Apr 16 12:56:45 MDT 2017
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:
“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.”
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/
More information about the ncl-talk
mailing list