[ncl-talk] Fwd: Could I add some FillPatterns effect suchasobliquelines to a raster fill plot ?
Adam Phillips
asphilli at ucar.edu
Tue Aug 25 13:25:47 MDT 2015
Hi Lin,
I have come to the same conclusion that you have: That there are not enough
grids for this method to effectively work. Previously this method has
worked well on much larger grids but at this scale it is obviously not
working. I have a test script that I passed on to a NCL developer for them
to look at, but I am not hopeful. It looks like the only method that would
work would be to make repeated targeted calls to gsn_add_polyline.
To answer your question, you are passing in 3 lons and 19 lats, and the
input sizes of those two arrays must be the same when using gsn_add_text.
Try this:
txres = True
text = new(dimsizes(sig),"string")
text = sig
lon = (/0.5,1.5,2.5/)
lat = ispan(0,18,1)
txres at txFontHeightF = 0.010
txres at txJust = "CenterCenter"
dummy = new(dimsizes(arr),graphic)
do gg = 0,2
do hh = 0,18
dummy(hh,gg) =
gsn_add_text(wks,plot(i),text(hh,gg),lon(gg),lat(hh),txres)
end do
end do
(The other option to the above coding would be to create 3 arrays (lat,lon,
and text) of size 57 containing the appropriate values. Then a single call
to gsn_add_text would suffice.)
I put the above coding into my test script and I got the attached plot.
Note that if you are paneling that you will not want to overwrite the dummy
array each time through.. If you have 3 panels dummy could be an array of
size (3,19,3) instead of above where it is just a (19,3).
Hope that all helps.
Adam
On Tue, Aug 25, 2015 at 4:00 AM, xianglin72 <xianglin72 at icloud.com> wrote:
> Hi, Adams
>
>
> Thank you for the reply. I've tried another some times, but failed
> to get something. I don't know how the NCL
>
> make the fill pattern exactly, and I guess that there is not enough grids
> (only 19*3 grids ) in my plot, so NCL can not
>
> deal with few grids correctly.
>
> Here below is the data used in the first subplot , and you can see
> that no fill pattern were done for the 3rd column
>
> values. In fact, I want all the grids with the values less than 0.05 to
> be filled with oblique lines.
>
>
> significance values for the trend
>
> 0.055 0.055 0.000
>
> 0.000 0.000 0.000
>
> 0.000 0.055 0.000
>
> 0.000 0.007 0.000
>
> 0.055 0.055 0.000
>
> 0.000 0.001 0.000
>
> 0.055 0.000 0.000
>
> 0.055 0.000 0.000
>
> 0.000 0.055 0.000
>
> 0.000 0.055 0.000
>
> 0.000 0.037 0.000
>
> 0.002 0.003 0.000
>
> 0.000 0.055 0.000
>
> 0.000 0.055 0.000
>
> 0.000 0.055 0.001
>
> 0.002 0.055 0.055
>
> 0.001 0.055 0.000
>
> 0.000 0.055 0.000
>
> 0.000 0.000 0.002
>
> Besides, I want to ask one more question:
>
> I add the follwoing scripts to post all the values to the corresponding
> cells (so that I can understand why NCL can not contour correctly) :
> res at cnFillOn = False
> plot(i) = gsn_csm_contour(wks, sig, res)
> text = new(dimsizes(sig),"string")
> text = sig
> lon = ispan(1,3,1)
> lat = ispan(1,19,1)
> txres = True
> txres at txFontHeightF = 0.015
> txres at txJust = "CenterLeft"
> dummy = gsn_add_text(wks,plot(i),text,lat,lon,txres)
> however, I got some error message as below:
> fatal:Dimension sizes of left hand side and right hand side of assignment
> do not match
> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 5659 in
> file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 118 in
> file dtr_sat_raster.ncl
>
>
>
> Lin
>
>
> 原始邮件
> *发件人:* Adam Phillips<asphilli at ucar.edu>
> *收件人:* xianglin72<xianglin72 at icloud.com>
> *抄送:* ncl-talk at ucar.edu<ncl-talk at ucar.edu>
> *发送时间:* 2015年8月25日(周二) 02:04
> *主题:* Fwd: [ncl-talk] Could I add some FillPatterns effect
> suchasobliquelines to a raster fill plot ?
>
> Hi Lin,
> (ncl-talk included)
> Method #2 is the way to go, and I still think you should be able to do it
> by modifying and using trial and error on the following lines:
> sig = where(sig.le.0.05,sig,0.06)
> res2 at cnLevels = 0.05
>
> For instance, I would try the following:
> sig = where(sig.le.0.05,sig,0.15)
> res2 at cnLevels = 0.045
>
> and if that doesn't work try this:
> sig = where(sig.le.0.05,sig,0.055)
> res2 at cnLevels = 0.045
>
> You should notice the range of the the pattern fill changing.
>
> You might have to try modifying the above two settings several times
> before you get it right, but it should be quite possible to match up the 2
> plots.
>
> I am also wondering whether this line is correct:
> plot(i) = gsn_csm_contour(wks, y, res)
> I think it should be:
> plot(i) = gsn_csm_contour(wks, sig, res)
>
> as you want to compare the exact same field raster and color filled to one
> pattern filled. The array y is based on this line:
> y = where(sig.le.0.05,dtr,-999.) ; significant trend
> and contains dtr data as opposed to sig data.
>
> If you cannot get the plot or do not wish to go through the trial and
> error process you can attempt to draw polylines through each significant
> grid box, but as I indicated previously this can get tedious.
>
> If you have any further questions please respond to ncl-talk.
> Adam
>
> On Sun, Aug 23, 2015 at 10:13 AM, xianglin72 <xianglin72 at icloud.com>
> wrote:
>
>> Hi, Adams,
>>
>>
>> I've tried for sometimes, but it seems that this problem is
>> unresolvable.
>>
>>
>> 1、
>>
>> res at cnFillMode = "RasterFill"
>>
>> plot(i) = gsn_csm_contour(wks, y, res)
>> opt = True
>> opt at gsnShadeFillType = "pattern" ; pattern fill
>> opt at gsnShadeMid = 3 ; use pattern #2
>> plot(i) = gsn_contour_shade(plot(i), -0.01, 0.05, opt)
>> ……..
>> no fillPattern will be done.
>>
>> 2、
>> y = where(sig.le.0.05,dtr,-999.) ; significant
>> trend
>> y at _FillValue = -999.
>> res at cnFillMode = "RasterFill" ; “CellFill“
>> plot(i) = gsn_csm_contour(wks, y, res)
>>
>> sig = where(sig.le.0.05,sig,0.06)
>> res2 at cnFillMode = "AreaFill" ;"AreaFill"
>> res2 at cnMonoFillPattern = True
>> res2 at cnFillPattern = 3
>> res2 at cnMonoFillColor = False
>> res2 at cnFillColors = (/"black","black","white","white"/)
>> res2 at cnLevelSelectionMode = "ExplicitLevels"
>> res2 at cnLevels = (/0.,0.05,0.1/)
>> iplot = gsn_csm_contour(wks, sig, res2)
>> overlay(plot(i),iplot)
>> …...
>> Then the cnFillPattern can not be shown as preferred. (see the attached
>> fig file, All the significant values have been raster filled in the
>> corresponding rectangular cell, all the shaded lines should also be added
>> within these cells as expected, )
>>
>>
>> Thanks
>>
>> LIn
>>
>>
>>
>>
>>
>>
>> 原始邮件
>> *发件人:* Adam Phillips<asphilli at ucar.edu>
>> *收件人:* xianglin72<xianglin72 at icloud.com>
>> *抄送:* ncl-talk at ucar.edu<ncl-talk at ucar.edu>
>> *发送时间:* 2015年8月23日(周日) 12:24
>> *主题:* Re: [ncl-talk] Could I add some FillPatterns effect such
>> asobliquelines to a raster fill plot ?
>>
>> Hi Lin,
>> You are correct, you cannot raster fill and pattern fill at the same
>> time. However, I remembered that I replied to someone with this issue in
>> April. See the response here:
>> http://mailman.ucar.edu/pipermail/ncl-talk/2015-April/002370.html
>> In short: you need to manipulate the values of the boxes that are not
>> hatched so that the pattern fill only covers the boxes that you want. Note
>> in the example coding that the user had _FillValue(s); you may or may not
>> have that set for the boxes you do not want pattern filled.
>>
>> The above referenced method requires trial and error, but it is possible
>> to do what you want.
>>
>> An alternative to the above would be to make many calls to
>> gsn_add_polyline, drawing a line across each grid box, but that method may
>> be intensive to implement as well.
>>
>> Good luck. If you have any other inquires please respond to ncl-talk.
>> Adam
>>
>> On Aug 21, 2015, at 10:05 PM, xianglin72 <xianglin72 at icloud.com> wrote:
>>
>> Hi, Adam
>>
>>
>> Thank you the reply. I've tried what you have told before sending
>> the first mail( see the attached script), however, I can not get what you
>> and I expect ( see the attached plot).
>>
>> I've checked the explaination on the resource of "raster fill", and
>> found the following :
>>
>>
>> The following resources can be used to control fill features when
>> *cnFillMode* is set to RasterFill:
>>
>> - *cnFillColors*
>> - *cnGridBoundFillColor*
>> - *cnMissingValFillColor*
>> - *cnOutOfRangeFillColor*
>> - *cnRasterSmoothingOn*
>> - *cnRasterMinCellSizeF*
>> - *cnRasterSampleFactorF*
>> - *cnRasterCellSizeF*
>>
>>
>> So you can find that the cnMonoFillColor and cnFillPattern can not
>> work for this mode, which I've said in the first mail.
>>
>>
>> Since the "AreaFill" mode can not get the same effect and the "cnFillPattern"
>> resource can not be used for "CellFill" and
>>
>> "rasterfill" mode, I still don't know how to add some shading effect for
>> the chosen raster grids.
>>
>>
>> Thanks
>>
>>
>> Lin
>>
>>
>>
>>
>> 原始邮件
>> *发件人:* Adam Phillips<asphilli at ucar.edu>
>> *收件人:* xianglin72<xianglin72 at icloud.com>
>> *抄送:* ncl-talk at ucar.edu<ncl-talk at ucar.edu>
>> *发送时间:* 2015年8月22日(周六) 02:19
>> *主题:* Re: [ncl-talk] Could I add some FillPatterns effect such as
>> obliquelines to a raster fill plot ?
>>
>> Hi Lin,
>> You can always do an overlay where you create two images:
>> 1) Create a RasterFill plot with colors. (You already have this plot.)
>> 2) Create a RasterFill plot with pattern fill (not color fill).
>>
>> Then you would overlay 2) on 1) using the overlay procedure.
>>
>> See example #10 here:
>> http://www.ncl.ucar.edu/Applications/overlay.shtml#ex10
>>
>> Note that for plot 2) (or plot_shade in example 10) you would want to
>> set the following resources:
>> res at cnFillPattern = 3
>> res at cnMonoFillColor = True
>> res at lbLabelBarOn = False ; no labelbar needed
>>
>> Available fill patterns:
>> http://www.ncl.ucar.edu/Document/Graphics/Images/fillpatterns.png
>>
>> Hope that helps. If not, please respond to ncl-talk.
>> Adam
>>
>>
>>
>>
>> On Fri, Aug 21, 2015 at 8:44 AM, xianglin72 <xianglin72 at icloud.com>
>> wrote:
>>
>>> Hi, all
>>>
>>>
>>> I've made a raster fill plot ( see the attachment), and I want to
>>> add some FillPattern effect for some chosen cells in the plot.
>>>
>>>
>>> However, I found that the resource of cnFillPattern can not work for the
>>> raster fill plot. How could I do to add some effect,
>>>
>>>
>>> for example, some oblique lines to the chosen rectanglar cells?
>>>
>>>
>>>
>>> Thanks
>>>
>>>
>>>
>>> Lin
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>>
>> --
>> Adam Phillips
>> Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
>> www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
>>
>> <http://www.cgd.ucar.edu/staff/asphilli>
>>
>> <test2.eps>
>>
>> <dtr_sat_raster.ncl>
>>
>>
>
>
> --
> Adam Phillips
> Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
>
> <http://www.cgd.ucar.edu/staff/asphilli>
>
--
Adam Phillips
Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150825/f3a1aeb9/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raster.overlay.png
Type: image/png
Size: 54504 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150825/f3a1aeb9/attachment.png
More information about the ncl-talk
mailing list