[Thread Prev][Thread Next][Index]

Re: [ferret_users] Problems with the contour plot range



Hi Andreas,
Yes, you're right.  Ferret uses double-precision for computation, but the graphics side, Plot-Plus, is single precision, which has a range of about 7 decimal places.  When Ferret reads double-precision data, it reads the full precision, so LIST/prec=8 will show you the numbers. When it's passed to Plot-Plus, it's put into single-precision variables.

I wonder if we could think of a way to do the contouring in two steps:
fill/levels=(0)(1e-09),(1e-08),(1e-07),(1e-06),(1e-05),(0.0001),(0.001) if icn2 LT 1e-03 then icnc2

fill/levels=(0.001),(0.01),(0.1),(0.4),(0.8),(1.2),(1.6),(2.0),(2.4),(2.8)(inf)  if icn2 gt 1e-03 then icnc2

Each of the two expressions has  a dynamic range that can be expressed accurately by a single precision variable.  The trick then would be to plot these together using sets of color levels that harmonize and two color keys plotted to fit together.  Here's a sketch of that:

! define two identical viewports

define view/x=0:1/y=0:1 full1
define view/x=0:1/y=0:1 full2
cancel  view

define symbol low_lev = (0)(1e-09),(1e-08),(1e-07),(1e-06),(1e-05),(0.0001),(0.001)
define symbol high_lev = (0.001),(0.01),(0.1),(0.4),(0.8),(1.2),(1.6),(2.0),(2.4),(2.8)(inf)

! plot the smaller values in one viewport with the lower set of levels. Make a half-height color key.

set view full1
fill/levels=($low_lev)/pal=blue_green_yellow/SET if icnc2 lt 1e-03 then icnc2
  ppl shakey,1,1,,2,,,,,($ppl$yorg),`($ppl$yorg)+($ppl$ylen)/2`
  ppl fill

! Now plot the larger values in another viewport, with a color key starting at half height
! The second viewport is drawn in on top of the first.

set view full2
fill/levels=($high_lev)/pal=yellow_orange_brown/SET if icnc2 ge 1e-03 then icnc2
  ppl shakey,1,1,,2,,,,,`($ppl$yorg)+($ppl$ylen)/2`,`($ppl$yorg)+($ppl$ylen)`
  ppl fill

You might want to adjust things so the length of the two color keys are proportional to the number of colors, so each box on the color key is the same size - and maybe make yourself a couple of custom color palettes to use for this variable.  Also note that sometimes doing a "SHADE" first and overlaying a "FILL" will get you better results than just a "FILL", as a shade plot draws color out to the edge of the grid boxes, and FILL only to the center of the grid boxes.



On 3/19/2015 4:40 AM, Bier, Andreas wrote:
Hello,

I would like to create a two-dimensional contour plot (depending on time and height) for an ice crystal number concentration (icnc).
My commands are:

let icnc1 = if icnc gt 0 then icnc
let icnc2 = icnc1[i=@ave,j=@ave]
--> averaging over longitude and latitude

contour/fill/levels=(0)(1e-09),(1e-08),(1e-07),(1e-06),(1e-05),(0.0001),(0.001),(0.01),(0.1),(0.4),(0.8),(1.2),(1.6),(2.0),(2.4),(2.8)(inf) icnc2

Doing so, the plotted data range of the contours goes only from 2.8 till 1e-05 and not till 1e-09. If I decrease my maximum value to 0.1 instead of 2.8, my smallest contour value decreases to 1e-06 and so on. Consequently, it seems to be a precision problem.
There is a possible adjustment for higher precision within the list command, e.g. list/p=8 icnc2.
But this adjustment doesn't work for the plot or contour commands and I didn't really found another solution for this problem in the User's Guide. I hope you can help me.

Best regards,
Andreas


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement