[ncl-talk] Issues with bin_sum

Dennis Shea shea at ucar.edu
Wed Mar 4 15:13:57 MST 2015


Mary

Attached is a fortran-77 subroutine and a variation of your/Carl's test ncl
script to which I added a 4th test: gcnt_so.

%> WRAPIT bindata_ncl.f

For the following script you will have to add a new path for the shared
object:

external TEST "/Users/shea/fcode/bindata_ncl.so"    ; <=== change to your
local path

%> ncl bindata_tst.ncl

OK?

D



On Tue, Mar 3, 2015 at 2:08 PM, Mary Haley <haley at ucar.edu> wrote:

> The one thing to note about the min/max values and the binning algorithm
> is that the lat/lon values that are given for the binning represent the
> *centers* of the binning ranges, and not the edges.
>
> So, if you specify latitudes (/ -85,-80,-75,...,80,85/), and longitudes
> (/-175,-170,...,170,175/):
>
>    - The first bin range will be lat: [-87.5 to -82.5 ] and lon: [-177.5
>    to -172.5].
>    - The second range will be [-82.5 to -77.5] and [-172.5 to -167.5]
>    - ...
>    - The last range will be [82.5 to 87.5] and [172.5 to 177.5]
>
>
> We will hopefully get this fixed by V6.3.0.  We actually have the fix, but
> are trying to determine if it's the best fix.
>
> --Mary
>
> On Fri, Feb 27, 2015 at 5:36 PM, Carl Schreck <cjschrec at ncsu.edu> wrote:
>
>> Thanks Mary. It makes sense to me that it was something to do with the
>> out of range values. I'm still don't really understand why the ml/nl values
>> come out wrong, but the important thing is that it works.
>>
>> I'm sure it was originally assumed that bin_sum would be used to bin to a
>> global grid so this wouldn't be an issue. But it'll be good for it to have
>> better exception handling. Thanks again!
>>
>>     Carl
>>
>> On Thu, Feb 26, 2015 at 4:14 PM, Mary Haley <haley at ucar.edu> wrote:
>>
>>> 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
>>>>
>>>
>>>
>>
>>
>> --
>>
>> <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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150304/d3c6178e/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bindata_tst.ncl
Type: application/octet-stream
Size: 11246 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150304/d3c6178e/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bindata_ncl.f
Type: application/octet-stream
Size: 1692 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150304/d3c6178e/attachment-0001.obj 


More information about the ncl-talk mailing list