[ncl-talk] how to add values on the grid cells when drawing raster contours?
Dennis Shea
shea at ucar.edu
Sat Oct 18 10:47:48 MDT 2014
Also ...
http://www.ncl.ucar.edu/Applications/text.shtml
Example 4
On Sat, Oct 18, 2014 at 10:41 AM, Mary Haley <haley at ucar.edu> wrote:
> First, there are a couple of things wrong with your script:
>
> 1) You have 0.0 as a _FillValue, which will not work when contouring with
> NCL.
>
> You can fix this with:
>
> var at _FillValue = default_fillvalue(typeof(var))
>
> 2) You shouldn't set the "lat2d" and "lon2d" attributes, because your data
> is rectilinear, and already has coordinate arrays via "lat" and "lon".
>
> 3) To add text strings, you want to use gsn_add_text. Since you have
> missing values in "var", it might be easier to convert "var" to 1D using
> ndtooned, and then conform the lat and lon coordinate arrays to be the same
> size as "var", using a combination of conform and ndtooned. You can then
> use "ind" to get the index locations in "var1d" where the values are not
> missing, and use the lat1d and lon1d as the locations of these strings:
>
> ;
> ; Create 1D arrays of lat,lon,var values so we can
> ; put a text string at each value that is not missing.
> ;
> lat1d = ndtooned(conform(var,var&lat,0))
> lon1d = ndtooned(conform(var,var&lon,1))
> var1d = ndtooned(var)
> ii = ind(.not.ismissing(var1d))
> ntext = dimsizes(ii)
>
> txres = True
> txres at txFontHeightF = 0.008
> txres at txJust = "CenterCenter"
>
> txid = gsn_add_text(wks,plot,""+var1d(ii),lon1d(ii),lat1d(ii),txres)
>
> draw(plot)
> frame(wks)
>
> I'll attach the full script so you can run it.
>
> --Mary
>
> On Sat, Oct 18, 2014 at 8:39 AM, LI Qi <liqi123sh at qq.com> wrote:
>
>> Dear NCL,
>>
>> I'd like to ask how to add values on the grid cells like the right figure
>> shown below?
>>
>>
>>
>>
>>
>> Attached are the script and data.
>>
>> Any advice will be greatly appreciated!
>>
>> Qi Li
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> 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/20141018/823153f8/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BE5E7705 at 89A38E5D.B27B4254.jpg
Type: image/jpeg
Size: 58770 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141018/823153f8/attachment.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: B3691800 at 89A38E5D.B27B4254.jpg
Type: image/jpeg
Size: 16833 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141018/823153f8/attachment-0001.jpg
More information about the ncl-talk
mailing list