[Thread Prev][Thread Next][Index]

Re: [ferret_users] apparent bug in frequency_histogram.jnl



Hi Keith,
Thank you for the report and the solution. I agree with you about what was going on. This is sure an old script! I've updated our copy and we'll include the fix with the next Ferret release. Writing floating-point numbers in a fixed format is always a bit perilous.

Ansley

On 6/15/2011 2:38 PM, Keith Lindsay wrote:
Hi,

I think I have found a bug in frequency_histogram.jnl. In particular instances, the bars are shifted by two bins horizontally.

The attached CDL file leads to a demonstration of the problem.

The commands

sp ncgen -b hist_test.cdl
set data hist_test.nc
go frequency_histogram.jnl var .5 4.5 .1 weight

produce the attached figure. The bins should be centered over 1, 2, and 3, but they are shifted to the right by two bins.

It seems to be problem with missing values in the expression and weight leading to lines in the generated frequency_h.raw file with no space between the value pairs, and then the frequency.awk script generates extra lines of output which ends up shifting the bars.

If I replace the following lines of frequency_histogram.jnl

list/nohead/form=(F10.0,1PG14.7)/file=frequency_h.raw index, wt_index
list/nohead/form=(F10.0,1PG14.7)/file=frequency_h.raw/append vn+1,0 ! MAX index + 1

with

list/nohead/form=(F10.0,x,1PG14.7)/file=frequency_h.raw index, wt_index
list/nohead/form=(F10.0,x,1PG14.7)/file=frequency_h.raw/append vn+1,0 ! MAX index + 1

I get the expected results.

This does not appear to be a problem with frequency_histogram2.jnl

Keith

******************************************************************
Keith Lindsay                http://www.cgd.ucar.edu/oce/klindsay/
email: klindsay@xxxxxxxx   phone: 303-497-1722   fax: 303-497-1700


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

Privacy Policy | Disclaimer | Accessibility Statement