[ncl-talk] Issues with bin_sum

Mary Haley haley at ucar.edu
Thu Feb 26 14:14:13 MST 2015


Hi Carl,

Unless I am misunderstanding how bin_sum is supposed to work, I agree that
there appears to be a bug.

I recreated the "bin_sum" function entirely in NCL so it was easier to
debug. It also makes it easier to try out a fix.

Please see the attached code, which is based on your original code.

I'm calculating the binned sums using three methods:

   - The original "bin_sum" function (see function "*bin_sum_builtin*")

   - An NCL script version of "bin_sum" (see "*bin_sum_ncl*")

   - A third method of binning that uses a slightly different algorithm ("
   *bin_sum_other*")

I loop across the various bin ranges and show plots of the three results in
a panel plot.

   - The leftmost plot is from using *bin_sum_builtin*. This will always be
   wrong, except for the first time in the loop.

   - The middle plot is from *bin_sum_ncl*. This will be wrong if
   APPLY_THE_FIX is False, and correct otherwise.

   - The right plot is from *bin_sum_other*. This should always be correct


If you agree with the fix, then you can use "*bin_sum_ncl*" (with
APPLY_THE_FIX set to True) or "*bin_sum_other*" as a work-around. You can
remove all the print statements.

--Mary


On Wed, Feb 25, 2015 at 10:16 AM, Carl Schreck <cjschrec at ncsu.edu> wrote:

> No problem. Here's a slight update that also calculates it manually.
> Surprisingly, the manual one looks completely different than all the others.
>
> On Wed, Feb 25, 2015 at 10:56 AM, Mary Haley <haley at ucar.edu> wrote:
>
>> Hi Carl,
>>
>> I started to look at this yesterday and got pulled away on something else.
>>
>> I'll try to take a look today. Thanks for providing a sample code!
>>
>> --Mary
>>
>>
>> On Tue, Feb 24, 2015 at 8:15 AM, Carl Schreck <cjschrec at ncsu.edu> wrote:
>>
>>> I'm getting some strange results with bin_sum (see attached script and
>>> figures). This simple script is using bin_sum to make a 2-d histogram of
>>> some random data. The shading in each box tells how many points fall within
>>> that box.
>>>
>>> The data are the same in all plots, and so are the bin widths. The only
>>> thing I change is the range of bins. If I change the high end of the range
>>> (page 1-2), the figure stays the same as expected. But if I change the low
>>> end of the range (page 2-3), the whole plot changes in a seemingly random
>>> way.
>>>
>>> Any thoughts on what might be causing this? I'm using 6.2.1. Thanks!
>>>
>>>     Carl
>>>
>>> --
>>>
>>> <http://www.cicsnc.org/>
>>> <http://www.researcherid.com/rid/B-8711-2011>
>>> * Cyclone <http://www.cyclonecenter.org/>*Center.org
>>> <http://www.cyclonecenter.org/>  *Carl J. Schreck III, PhD*
>>> *Research Associate*
>>> Cooperative Institute for Climate and Satellites NC
>>> <http://www.cicsnc.org/>
>>> North Carolina State University <http://ncsu.edu/>
>>> NOAA's National Climatic Data Center <http://ncdc.noaa.gov/>
>>> 151 Patton Ave, Asheville, NC 28801
>>> e: cjschrec at ncsu.edu
>>> o: +1 828 257 3140
>>> Publications
>>> <http://scholar.google.com/citations?hl=en&user=th8ONEcAAAAJ&view_op=list_works&sortby=pubdate>
>>> monitor.cicsnc.org/mjo
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
>
> --
>
> <http://www.cicsnc.org/>
> <http://www.researcherid.com/rid/B-8711-2011>
> * Cyclone <http://www.cyclonecenter.org/>*Center.org
> <http://www.cyclonecenter.org/>  *Carl J. Schreck III, PhD*
> *Research Associate*
> Cooperative Institute for Climate and Satellites NC
> <http://www.cicsnc.org/>
> North Carolina State University <http://ncsu.edu/>
> NOAA's National Climatic Data Center <http://ncdc.noaa.gov/>
> 151 Patton Ave, Asheville, NC 28801
> e: cjschrec at ncsu.edu
> o: +1 828 257 3140
> Publications
> <http://scholar.google.com/citations?hl=en&user=th8ONEcAAAAJ&view_op=list_works&sortby=pubdate>
> monitor.cicsnc.org/mjo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150226/3803df9c/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_bin_carl2.ncl
Type: application/octet-stream
Size: 10501 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150226/3803df9c/attachment.obj 


More information about the ncl-talk mailing list