[ncl-talk] joint-histogram

Marston Johnston shejo284 at gmail.com
Wed Nov 15 17:32:08 MST 2017


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-international-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
> > > > > > 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
> > > > > > > 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
> > > > > >
> > > >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171116/ca24c896/attachment.html>


More information about the ncl-talk mailing list