[Thread Prev][Thread Next][Index]

Re: [ferret_users] Fill and



Dear Serena,

On Tue, Jun 21, 2022 at 8:52 PM Serena Illig <serena.illig.ird@xxxxxxxxx> wrote:
[ . . . ]
use coads_climatology.cdf
shade/x=50w:20e/y=30s:30n/levels=(14,29,1) SST[l=@ave]
  ---> 15 color levels, with levels 0(1), the colorscale is OK
shade/x=50w:20e/y=30s:30n/levels=(0.014,0.029,0.001) SST[l=@ave]/1000
 ---> 15 color levels, with levels 0(1/1000), the colorscale is missing the last level


That must be due to the binary (internal) representation of the fractional numbers like 0.001 .  Because the internal representation of 0.001 is slightly larger than the exact value, the last contour level is slightly larger than 0.029 and is excluded from the list.  See the demonstration in Fortran below.

As a workaround, make the terminal point slightly larger, perhaps by 1/10 of delta, than the target:

levels=(0.014,0.0291,0.001)

This is not just a problem of PyFerret.  It exists in any programming languages (which, by the way, makes me wonder how the Julia language generates the desired list of numbers from "0.014:0.001:0.029" . . . ).

Best regards,

Ryo
---------
program try
  implicit NONE
  real(4), parameter:: c0 = 0.014, c1 = 0.029, del = 0.001
  real(4):: c
  integer:: n, i

  write(*,*) "cummulative iteration"
  c = c0
  do while (c <= c1)
    write(*,*) c
    c = c + del
  end do

  write(*,*) "direct calculation"
  n = floor( (c1 - c0) / del )
  do i = 0, n
    c = c0 + i * del
    write(*,*) c
  end do
end program try
 



 

shade/x=50w:20e/y=30s:30n/levels=(0.014,0.028,0.001) SST[l=@ave]/1000
  ---> 14 colors levels with levels 0(1/1000), the colorscale is OK
fill/x=50w:20e/y=30s:30n/levels=(0.0014,0.0029,0.0001) SST[l=@ave]/10000
  ---> 15 colors levels with levels 0(1/10000), the colorscale is missing the last level

I could not find any rules for which it happens. I thought at first that it is linked to the number of levels, but I found counter-examples (see my last example above).

Maybe this issue has already been reported?

Have a nice day,

Serena Illig

.¸. , . .·´¯`·
 ><(((º>     `·.¸.·´¯`·...¸><(((º>¸.¸. , . .·´¯`· ><(((º> .
`·.¸.·´¯`·...¸><(((º>                                                    .
                                                                                  .
  Serena ILLIG-THEVENIN       LEGOS/IRD             .
                                                                                  .
  Editorial Board Member for Scientific Reports      .
                                                                              .
                         14 Av. E. Belin                           .
                         31400 Toulouse                        .
                         FRANCE                                   .
                                                                             .
         E-mail : serena.illig.ird@xxxxxxxxx             .
         Web-site : http://sillig.free.fr                       .
         Phone : +33 5 61 33 29 26                      .
                                                                       .
                                                     <º)))><..·


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

Privacy Policy | Disclaimer | Accessibility Statement