[ncl-talk] joint-histogram

Adam Phillips asphilli at ucar.edu
Thu Nov 16 10:55:47 MST 2017


Hi Marston,
When I change your y definition to this:
y :=
(/-2.0,0.0,0.5,1.0,1.5,2.0,2.5,3.0,4.0,5.0,7.0,9.0,11.0,13.0,15.0,17.0,19.0/)
all is well. NCL seems to have trouble when you set the first value to -99
and the last value to 99, and I'm not clear as to why. Setting them to
values closer to the other values in the array seemingly works. I have
attached the resulting plot. Note that the space between each of those
values on the Y-axis is the same in the misr_fq.png figure. If you
set gsnYAxisIrregular2Linear = True the space will be proportional to the
differences between the y values. See the attached misr_fq.2.png figure.
Hope that helps!
Adam

On Thu, Nov 16, 2017 at 10:30 AM, Marston Johnston <shejo284 at gmail.com>
wrote:

> Hi again Adam,
>
> Thanks to your help/advice/explanation, I got the isccp and modis plots
> exactly how I want them :-)
> But I still cannot get misr to function properly (see attached). For the
> misr y axis, I want the labels to
> be: (/"NR","0","0.5","1.0","1.5","2.0","2.5","3.0","4.0","5.0","
> 7.0","9.0","11.0","13.0","15.0","17.0"," “/), which is 1 greater than the
> y-coord in the misr array.
> Sadly, I still get the same error:
>
> "warning:_NhlCreateSplineCoordApprox: Attempt to create spline
> approximation for Y axis failed: consider adjusting trYTensionF value
> warning:IrTransInitialize: error creating spline approximation for
> trYCoordPoints; defaulting to linear"
>
> In this case, y is 1 greater than the I’m&hgt. What’s going on here that
> is different from the other 2 cases?
>
> /M
>
> Marston S. Ward
>
> On 16 Nov 2017, 17:40 +0100, Adam Phillips <asphilli at ucar.edu>, wrote:
>
> Hi Marston,
> I downloaded your dropbox file, but didn't see your script within the zip
> file or attached to your email. Can you send that?
>
> With regards to your questions about what sections of code are doing:
> res at sfXArray      = im&tau
> res at sfYArray      = im&pres
>
> Normally NCL uses coordinate variables attached to the array input into
> the graphical functions to determine where to plot the data in the
> graphical space. However, in the raster_plot.ncl script that Mary sent you
> the coordinate variables (x and y) are of size +1 greater than those
> dimensions of the im array. This necessitates the use of sfXArray/sfYArray
> to tell NCL how to plot the data. If the dimension sizes of your data
> matches those of the desired coordinate variables then you do not need to
> use sfXArray/sfYArray, assuming the coordinate variables are properly
> attached to the array.
>
> res at tmXBMode      = "Explicit"
> res at tmXBValues    = im&tau
> res at tmXBLabels    = ""+im&tau
>
> res at tmYLMode      = "Explicit"
> res at tmYLValues    = im&pres
> res at tmYLLabels    = im&pres+""
>
> Keep in mind that the above ONLY adjusts the tick marks and their labels.
> It has nothing to do with how the data is plotted in space. In the above,
> you are explicitly telling NCL where to put the major tickmarks
> (tmXBValues/tmYLValues) as well as how to label those major tickmarks.
> (tmXBLabels/tmYLLabels).
>
> With regards to your error message: I cannot tell what is going on without
> looking at the script. In my experience when I encounter a graphical error
> that doesn't look like it should be occurring, I will try to simplify the
> resource lists and/or the input data to see where the error is coming from,
> eliminating resources until the error message disappears, allowing me to
> see what is causing the issue.
> Hope that helps!
> Adam
>
>
> On Wed, Nov 15, 2017 at 5:32 PM, Marston Johnston <shejo284 at gmail.com>
> wrote:
>
>> Hi Mary,
>>
>> I appreciate your help with this and fixing that error. I got a bit
>> frustrated at the end and therefore a bit sloppy.
>>  I must say that I still do not fully understand the following features
>> of the code, especially the addition of a string to the labels.
>>
>> res at sfXArray      = im&tau
>> res at sfYArray      = im&pres
>>
>> res at tmXBMode      = "Explicit"
>> res at tmXBValues    = im&tau
>> res at tmXBLabels    = ""+im&tau
>> res at tiXAxisString = "Cloud Optical Depth"
>>
>> res at tmYLMode      = "Explicit"
>> res at tmYLValues    = im&pres
>> res at tmYLLabels    = im&pres+""
>>
>> In the attached code, I’m calculating the weighted-mean of modis, isccp,
>> and misr joint-histograms.
>> With your help, I’m able to get the isccp and modis figures to behave
>> better but they are still off.
>> With these two figures, the contour doesn’t want to line up with the
>> major tick marks.
>> The 3rd misr fig has a different set of y-axis values, and when I try to
>> plot these I get:
>>
>> "warning:_NhlCreateSplineCoordApprox: Attempt to create spline
>> approximation for Y axis failed: consider adjusting trYTensionF value
>> warning:IrTransInitialize: error creating spline approximation for
>> trYCoordPoints; defaulting to linear”
>>
>> From what I’ve read of this error, it should not occur in my case.
>>
>> I could really use your help in nailing this down properly. Why is the
>> contour off and my misr figure causing this error when I’m plotting the
>> y-axis explicitly?
>> I’ve attached the faulty figures and included a link to the data below.
>> There are a lot of small files but on my mac it goes quite fast (few
>> seconds).
>>
>> https://www.dropbox.com/s/ian474obfp3amu1/fq_data.zip?dl=0
>>
>> Appreciate the help,
>>
>> /M
>>
>> Marston S. Ward
>>
>> On 14 Nov 2017, 18:05 +0100, Mary Haley <haley at ucar.edu>, wrote:
>>
>> Hi Marston,
>>
>> The reason you are seeing what looks like log values is because the Y
>> coordinate array is irregularly spaced, and NCL by default will take your
>> irregular Y axis values and place them linearly on the Y axis.
>>
>> I don't know if this is intentional, but you have:
>>
>>   im!0 ="x"
>>   im!1 ="y"
>>
>> Dimension 0 is associated with the Y axis, and dimension 1 is the X
>> axis.  Just wanted to point that out, since you are calling dimension 0
>> "x", and dimension 1 "y".  I changed this to:
>>
>>   im!1 ="x"
>>   im!0 ="y"
>>
>> Which seems to make your plot match better with the one you attached.
>> You can't make x a coordinate array, because it has one more element than
>> the X dimension of your data.
>>
>> Instead, in order to associate the x and y values with your plot, use
>> these special resources, which are mentioned in the raster_5.ncl example on
>> the same page:
>>
>> res at sfXArray             = x
>> res at sfYArray             = y
>>
>> Finally, you are going to get weird labels on your axes, because NCL is
>> simply trying to put labels along the X axis where it thinks it makes
>> sense. If you want the same labels on your axes as your actual x values,
>> then set:
>>
>> res at tmXBMode             = "Explicit"
>> res at tmXBValues           = x
>> res at tmXBLabels           = ""+x    ; labels have to be strings
>>
>> See attached.
>>
>> --Mary
>>
>>
>>
>>
>>
>> On Mon, Nov 13, 2017 at 6:04 PM, Marston Johnston <shejo284 at gmail.com>
>> wrote:
>>
>>> Hi Mary,
>>>
>>> Thanks for the tips in the table. However, there is a better example:
>>>
>>> https://www.ncl.ucar.edu/Applications/raster.shtml
>>>
>>> However, I’m having some trouble with the finer details of the plot. It
>>> involves getting the tick labels just in the correct place.
>>>
>>> My code below is basically example 6, which looks very much like the
>>> same coordinate values of one of the iSCCP products:
>>>
>>> I’m trying to compare my model output with the above figure but there are some issue:
>>>
>>> 1.) In the ncl example 6, the figure dimension is 7x6 while mine is 7x7. When I plot it as below I get log x-axis despite my values not being log.
>>>
>>> 2.) None of the labels ended up on the major axis.
>>>
>>> I’m not sure how NCL axis works. Could I get some tips on how to force the axis to fall on the grid edges as in the figure above?
>>>
>>>   im =
>>>    (/(/0.60   0.81   1.86   3.83   3.09   0.78   0.01/), (/0.45   0.63   1.47   4.96   5.45   2.27   0.28/), \ (/0.60   0.66   0.88   2.03   2.45   1.56   0.50/),(/0.76   0.91   1.02   1.17   1.46   1.44   0.63/), \
>>>
>>>    (/0.85   1.41   1.32   0.88   0.91   1.07   0.72/),(/1.55   1.84   1.24   0.70   0.41   0.46   0.36/), (/7.19   1.73   0.60   0.28   0.14   0.08   0.05/)/)
>>>
>>> x = (/0.0,0.3,1.3,3.6,9.4,23.0,60.0,100.0/)
>>> y = (/1000.0,800.0,680.0,560.0,440.0,310.0,180.0/)
>>>
>>> im!0=“x"
>>> im!1 =“y”
>>> im&x = x
>>> im&y = y
>>>
>>> wks  = gsn_open_wks("png","raster")      ; send graphics to PNG file
>>> res                      = True          ; plot mods desired
>>> res at cnFillOn             = True          ; Turn on contour fill
>>> res at cnFillMode           = "RasterFill"  ; Turn on raster fill
>>> res at cnLinesOn            = False        ; Turn off contour lines
>>> res at cnLineLabelsOn       = False         ; turns off contour line labels
>>> res at cnFillPalette        = "BlAqGrYeOrReVi200";MPL_viridis"
>>> res at lbLabelBarOn         = True
>>> res at lbOrientation        = "vertical"     ; vertical label bar
>>>
>>> plot = gsn_csm_contour(wks,im,res)       ; contour the variable
>>>
>>> Best,
>>> /M
>>>
>>> *Marston S. Ward*
>>>
>>> On 16 Oct 2017, 21:31 +0200, Mary Haley <haley at ucar.edu>, wrote:
>>>
>>> Marston,
>>>
>>> Take a look at this page:
>>>
>>> http://www.ncl.ucar.edu/Applications/table.shtml
>>>
>>> These are examples showing how to draw filed cells (square or triangle)
>>> based on some criteria.  I think table_4.ncl colors the cells by ranges of
>>> values.
>>>
>>> --Mary
>>>
>>>
>>> On Mon, Oct 16, 2017 at 1:03 PM, Marston Johnston <shejo284 at gmail.com>
>>> wrote:
>>>
>>>> Hi Dennis,
>>>>
>>>>
>>>>
>>>> At first glance it would appear so, but example 6 calculates the
>>>> percentage. In the ucar example:
>>>>
>>>> https://climatedataguide.ucar.edu/climate-data/isccp-interna
>>>> tional-satellite-cloud-climatology-project
>>>>
>>>>
>>>>
>>>> The ISCCP cloud fraction is calculated for each bin instead of density
>>>> of the frequency of occurrence. So in example 6 there are 2 datasets that
>>>> are used as input data, but in the figure in question seems to use 3.
>>>>
>>>>
>>>>
>>>> /M
>>>>
>>>>
>>>>
>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>
>>>> Marston S. Ward, PhD
>>>>
>>>> Department of Earth Sciences
>>>>
>>>> University of Gothenburg, Sweden
>>>>
>>>> Email: marston.johnston at gu.se
>>>>
>>>> SkypeID: marston.johnston
>>>>
>>>> Phone: +46-31-7864901 <+46%2031%20786%2049%2001>
>>>>
>>>> Only the fruitful thing is true!
>>>>
>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *From:* ncl-talk <ncl-talk-bounces at ucar.edu> on behalf of Dennis Shea <
>>>> shea at ucar.edu>
>>>> *Date:* Monday, 16 October 2017 at 20:53
>>>> *To:* Marston Ward <marston.johnston at gu.se>
>>>> *Cc:* "ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
>>>> *Subject:* Re: [ncl-talk] joint-histogram
>>>>
>>>>
>>>>
>>>> I am not a graphics person.
>>>>
>>>> Looks like example 6
>>>> https://www.ncl.ucar.edu/Applications/pdf.shtml
>>>>
>>>> ===
>>>>
>>>> Really, a contour plot with raster mode.
>>>>
>>>>
>>>>
>>>> On Mon, Oct 16, 2017 at 12:46 PM, Marston Ward <marston.johnston at gu.se>
>>>> wrote:
>>>>
>>>> Hi guys!
>>>>
>>>>
>>>>
>>>> I’m trying to develop a NCL script to produce the attached figure,
>>>> which is a joint-histogram, but a bit different from what pdfxy produces.
>>>>
>>>> I have a good idea of how this image is produced; but why reinvent the
>>>> wheel? I don’t think that NCL has such a plot function, or am I mistaken?
>>>>
>>>> Does anyone have such a script – and would like to share?
>>>>
>>>> This is something I can definitely think of contributing to the NCL.
>>>>
>>>>
>>>>
>>>> Best,
>>>>
>>>> /M
>>>>
>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>
>>>> Marston S. Ward, PhD
>>>>
>>>> Department of Earth Sciences
>>>>
>>>> University of Gothenburg, Sweden
>>>>
>>>> Email: marston.johnston at gu.se
>>>>
>>>> SkypeID: marston.johnston
>>>>
>>>> Phone: +46-31-7864901 <+46%2031%20786%2049%2001>
>>>>
>>>> Only the fruitful thing is true!
>>>>
>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>> _______________________________________________
>>>> 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
>>
>>
>
>
> --
> Adam Phillips
> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/   303-497-1726 <(303)%20497-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/20171116/5d470350/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: misr_fq.png
Type: image/png
Size: 57594 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171116/5d470350/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: misr_fq.2.png
Type: image/png
Size: 56202 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171116/5d470350/attachment-0003.png>


More information about the ncl-talk mailing list