[ncl-talk] Contour fill transparency not working with RasterFill mode
David Brown
dbrown at ucar.edu
Tue Oct 3 17:47:36 MDT 2017
I reviewed some old tickets and I think the explanation for the need
to set all elements of the color to 0 is because of a bug related to
cairo compositing (whether the bug is NCL's fault is not yet clear to
us). This behavior has not been documented because it is a bug --
although we should have mentioned it in the release notes.
Anyway, the problem, as I stated to Alan Brammer a couple of years ago is this:
I have been looking at this issue and there is clearly something
wrong. The only color that seems to be completely transparent when set
for a raster fill plot is transparent black (0,0,0,0). That does mean
there is a work-around fix for your specific test case: just change
line 63 from
reds(:30,3) = 0.
to
reds(:30,:) = 0.
-------
I later described this to Rick Brownrigg as follows:
I don't know if you saw this or not, but there is definitely some
weird behavior here. As far as I can tell the correct values are being
delivered to the cdriver routine cro_Cellarray, but from there the
transparency definitely gets mutated somehow. I suspect some kind of
compositing issue, but I don't know cairo very well.
My findings so far are that (1,1,1,0) is always completely opaque. If
alpha is 0 and you set one or more of the rgb components to 0 you get
partial transparency, but as stated in the message to Alan, complete
transparency only occurs with (0,0,0,0).
-------
Anyway the fact is that transparency cannot be fully supported for
RasterFill until we get to the bottom of our issue with cairo. If
anyone has some familiarity with cairo compositing for images and has
a suggestion we would be interested in your input.
-dave
On Tue, Oct 3, 2017 at 12:55 PM, Mary Haley <haley at ucar.edu> wrote:
> Hi Guido,
>
> Thanks for providing your script and data offline.
>
> The first thing to note is that cnMissingValFillColor will not be effective
> in this case, because your data doesn't have any missing values.
>
> The reason why you are not getting any transparency with raster fill is due
> to a quirk with raster fill that I never knew about until Dave Brown helped
> me look over your script today.
>
> The simple fix is to replace this line:
>
> cmap_r(0,3)=0.0
>
> with this line, which is setting the first color to black, but then making
> it transparent:
>
> cmap_r(0,:)=0.0
>
> Also, you can remove or comment this line, as it has no effect:
>
> ResC at cnMissingValFillColor=0
>
> Dave said he would look into why this quirk is necessary for raster fill and
> maybe he'll post back here with an explanation.
>
> Meanwhile, I'm going to update some of our examples to mention this so
> hopefully the next user won't run into this.
>
> Your ICON example is very nice by the way! Would you be willing to let me
> include it on our ICON examples page? If so, I may clean it up a little to
> add some comments and to remove the "do" loop since this is only one file.
> I won't redistribute the data file. You can email me offline about this if
> desired.
>
> --Mary
>
>
>
>
>
>
>
> On Mon, Oct 2, 2017 at 9:44 AM, Mary Haley <haley at ucar.edu> wrote:
>>
>> I admit, I don't know what "the larger value" means in this case. Dave
>> would know, but I think he's out of the office for a few days. Did setting
>> cnGridBoundFillColor fix anything?
>>
>> If not, is it possible for you to provide the script/data? You can do this
>> offline if necessary. I don't think we have any unstructured examples like
>> this that have missing data.
>>
>> Thanks,
>>
>> --Mary
>>
>>
>>
>>
>> On Fri, Sep 29, 2017 at 9:47 AM, Karin Meier-Fleischer
>> <meier-fleischer at dkrz.de> wrote:
>>>
>>> cnMissingValFillColor:
>>>
>>> ...
>>> Also note that the triangular mesh contouring algorithm does not
>>> distinguish between missing value areas and areas outside the grid boundary.
>>> Therefore if ContourPlot is given non-rectangular data or trGridType is
>>> explicitly set to TriangularMesh, the color index used will be the larger
>>> value of those assigned to the resources cnMissingValFillColor and
>>> cnGridBoundFillColor.
>>>
>>> Maybe Mary, Dave or Rick can say somthing more about it.
>>>
>>> -Karin
>>>
>>> Am 29.09.17 um 17:23 schrieb Guido Cioni:
>>>
>>> Yep, and I still get the same behaviour :(
>>>
>>> I also thought that was the case but then I read that "Transparent" is
>>> the default option for cnMissingValFillColor.
>>>
>>> Maybe it has something to do with the unstructured grid that I'm using?
>>>
>>> On 29. Sep 2017, at 17:14, Karin Meier-Fleischer
>>> <meier-fleischer at dkrz.de> wrote:
>>>
>>> Hi Guido, :-)
>>>
>>> have you tried the cnMissingValFillColor resource to set the color for
>>> missing value?
>>>
>>> ResC at cnFillPalette = cmap_r
>>> ResC at cnMissingValFillColor = 0
>>>
>>> Bye,
>>> Karin
>>>
>>> Am 29.09.17 um 16:55 schrieb Guido Cioni:
>>>
>>> Hi,
>>> I'm trying to plot filled contour of wind speed overlaid on a map. In
>>> order to mask small values of winds I've both masked the original data and
>>> set the first color of the color palette as transparent, i.e.
>>>
>>> cmap_r=read_colormap_file("wind_17lev")
>>> cmap_r(0,3)=0.0
>>> ResC at cnFillPalette= cmap_r
>>>
>>> However, when drawing with ResC at cnFillMode = "RasterFill", this causes
>>> the Missing Values to be coloured with white instead that being transparent,
>>> as you can see in the attached picture.
>>>
>>>
>>>
>>> Going back to old discussion this seems to be an old problem that was
>>> fixed in 6.2.0. Am I wrong?
>>>
>>> I'm attaching the script that I'm using, although it is not 100% clean.
>>> Cheers
>>>
>>>
>>>
>>> Guido Cioni
>>> http://guidocioni.altervista.org
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>>
>>> Guido Cioni
>>> http://guidocioni.altervista.org
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
More information about the ncl-talk
mailing list