Histogramming, grouping, and binning#

Overview#

Histogramming (see sc.hist), grouping (using sc.groupby), and binning (see Binned data) all serve similar but slightly different purposes. Picking the optimal one of the three for a particular application may yield more natural code and better performance. Let us start by an example. Consider a table of scattered measurements:

[1]:
import numpy as np
import scipp as sc
N = 5000
values = 10*np.random.rand(N)
table = sc.DataArray(
    data=sc.array(dims=['position'], unit=sc.units.counts, values=values, variances=values),
    coords={
        'x':sc.array(dims=['position'], unit='m', values=np.random.rand(N)),
        'y':sc.array(dims=['position'], unit='m', values=np.random.rand(N))
    })
table.values *= 1.0/np.exp(5.0*table.coords['x'].values)
sc.table(table['position', :5])
[1]:
CoordinatesData
x [m]y [m] [counts]
0.3350.5741.179±2.509
0.2630.2310.361±1.159
0.3500.5710.242±1.182
0.0390.2466.543±2.820
0.7370.9080.067±1.636

We may now be interested in the total intensity (counts) as a function of 'x'. There are three ways to do this:

[2]:
xbins = sc.linspace('x', 0, 1, num=40, unit='m')
ds = sc.Dataset()
ds['histogram'] = table.hist(x=xbins)
ds['groupby'] = table.groupby('x', bins=xbins).sum('position')
ds['bin'] = table.bin(x=xbins).bins.sum()
ds.plot()

In the above plot we can only see a single line, since the three solutions yield exactly the same result (neglecting floating-point rounding errors):

  • hist sorts data points into ‘x’ bins, summing immediately.

  • groupby groups by ‘x’ and then sums (on-the-fly) all data points falling in the same ‘x’ bin.

  • bin sorts data points into ‘x’ bins. Summing all rows in a bin yields the same result as grouping and summing directly.

So in this case we get equivalent results, but the application areas differ, as described in more detail in the following sections.

Histogramming#

scipp.hist directly sums the data and is efficient. Limitations are:

  • When histogramming in more than one dimension, the implementation uses sc.bin internally, which may be less efficient and uses more memory.

  • Can only apply “sum” or “nansum” to accumulate into a bin. scipp.nanhist is currently implemented differently and uses sc.bin interally. It therefore uses more memory and may be less efficient.

We can also histogram binned data (since binning preserves the 'y' coord), to create 2-D (or N-D) histograms:

[3]:
binned = table.bin(x=xbins)
hist = binned.hist(y=30)
hist.plot()
[4]:
hist
[4]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (18.84 KB)
    • x: 39
    • y: 30
    • x
      (x [bin-edge])
      float64
      m
      0.0, 0.026, ..., 0.974, 1.0
      Values:
      array([0. , 0.02564103, 0.05128205, 0.07692308, 0.1025641 , 0.12820513, 0.15384615, 0.17948718, 0.20512821, 0.23076923, 0.25641026, 0.28205128, 0.30769231, 0.33333333, 0.35897436, 0.38461538, 0.41025641, 0.43589744, 0.46153846, 0.48717949, 0.51282051, 0.53846154, 0.56410256, 0.58974359, 0.61538462, 0.64102564, 0.66666667, 0.69230769, 0.71794872, 0.74358974, 0.76923077, 0.79487179, 0.82051282, 0.84615385, 0.87179487, 0.8974359 , 0.92307692, 0.94871795, 0.97435897, 1. ])
    • y
      (y [bin-edge])
      float64
      m
      9.049e-05, 0.033, ..., 0.967, 1.000
      Values:
      array([9.04948404e-05, 3.34189377e-02, 6.67473806e-02, 1.00075823e-01, 1.33404266e-01, 1.66732709e-01, 2.00061152e-01, 2.33389595e-01, 2.66718038e-01, 3.00046481e-01, 3.33374924e-01, 3.66703367e-01, 4.00031809e-01, 4.33360252e-01, 4.66688695e-01, 5.00017138e-01, 5.33345581e-01, 5.66674024e-01, 6.00002467e-01, 6.33330910e-01, 6.66659353e-01, 6.99987795e-01, 7.33316238e-01, 7.66644681e-01, 7.99973124e-01, 8.33301567e-01, 8.66630010e-01, 8.99958453e-01, 9.33286896e-01, 9.66615338e-01, 9.99943781e-01])
    • (x, y)
      float64
      counts
      19.207, 23.096, ..., 0.209, 0.077
      σ = 4.555, 4.965, ..., 5.382, 3.207
      Values:
      array([[19.20744575, 23.09625687, 34.37323766, ..., 38.5391044 , 17.74729472, 29.5899929 ], [15.67503412, 18.86728267, 50.0971469 , ..., 35.64070069, 8.2550709 , 19.19848821], [ 9.68012746, 22.95811431, 9.76336876, ..., 3.9301816 , 35.71325108, 5.20505846], ..., [ 0.14677959, 0.15564463, 0.26073101, ..., 0.30569656, 0.05354549, 0.1718223 ], [ 0.11804396, 0.14990225, 0.25786319, ..., 0.18137207, 0.18112369, 0.1144902 ], [ 0.05286149, 0.06898509, 0.19702152, ..., 0.16144791, 0.20857092, 0.07651566]])

      Variances (σ²):
      array([[20.74758465, 24.65561085, 35.87639531, ..., 41.13358895, 18.85271394, 31.73726866], [19.08249594, 23.34290317, 60.96638053, ..., 43.27541952, 9.82507068, 23.7663553 ], [13.1751199 , 32.0697976 , 12.9564399 , ..., 5.29480775, 48.2743173 , 7.47938725], ..., [16.08475773, 16.98424379, 27.59987562, ..., 32.64858034, 5.95381789, 18.3631743 ], [14.35256632, 17.45129986, 30.87116914, ..., 23.13633284, 22.12669236, 13.88932982], [ 7.43085983, 9.96779582, 28.69948405, ..., 22.68414359, 28.96697084, 10.28256585]])

Another capability of hist is to histogram a dimension that has previously been binned with a different or higher resolution, i.e. different bin edges. Compare to the plot of the initial example:

[5]:
binned = table.bin(x=xbins)
binned.hist(x=100).plot()

Grouping#

groupby is more flexible in terms of operations than can be applied and may be the go-to solution when a quick one-liner is required. Limitations are:

  • Can only group along a single dimension.

  • Works best for small to medium-sized data, or if data is already mostly sorted along the grouping dimension. Slow if millions of small input slices contribute to each group.

groupby can also operate on binned data, combining bin contents by concatenation:

[6]:
binned = table.bin(x=xbins)
binned.coords['param'] = sc.array(dims=['x'], values=(np.random.random(39)*4).astype(np.int32))
grouped = binned.groupby('param').bins.concat('x')
grouped
[6]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (156.33 KB)
    • param: 4
    • param
      (param)
      int32
      𝟙
      0, 1, 2, 3
      Values:
      array([0, 1, 2, 3], dtype=int32)
    • (param)
      DataArrayView
      binned data [len=1720, len=1646, len=631, len=1003]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[position:1720, ] Coordinates: x float64 [m] (position) [0.00428328, 0.0248711, ..., 0.974558, 0.977012] y float64 [m] (position) [0.131774, 0.991945, ..., 0.229553, 0.726188] Data: float64 [counts] (position) [2.38078, 6.22066, ..., 0.012861, 0.0572269] [2.43232, 7.04439, ..., 1.68074, 7.57102] , <scipp.DataArray> Dimensions: Sizes[position:1646, ] Coordinates: x float64 [m] (position) [0.0390149, 0.0483642, ..., 0.942876, 0.931634] y float64 [m] (position) [0.246145, 0.756705, ..., 0.655808, 0.60322] Data: float64 [counts] (position) [6.54329, 4.76978, ..., 0.0466242, 0.0495224] [7.95273, 6.07464, ..., 5.20044, 5.2218] , <scipp.DataArray> Dimensions: Sizes[position:631, ] Coordinates: x float64 [m] (position) [0.564945, 0.572006, ..., 0.885454, 0.882945] y float64 [m] (position) [0.704131, 0.599911, ..., 0.318584, 0.809937] Data: float64 [counts] (position) [0.0226163, 0.0452565, ..., 0.0252781, 0.0950171] [0.381226, 0.790271, ..., 2.11584, 7.85401] , <scipp.DataArray> Dimensions: Sizes[position:1003, ] Coordinates: x float64 [m] (position) [0.159652, 0.174484, ..., 0.861037, 0.850108] y float64 [m] (position) [0.771904, 0.471038, ..., 0.164548, 0.472695] Data: float64 [counts] (position) [0.843059, 1.14362, ..., 0.114429, 0.120612] [1.873, 2.73633, ..., 8.47726, 8.46012] ]

Each output bin is a combination of multiple input bins:

[7]:
grouped.values[0]
[7]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (53.75 KB out of 156.25 KB)
    • position: 1720
    • x
      (position)
      float64
      m
      0.004, 0.025, ..., 0.975, 0.977
      Values:
      array([0.00428328, 0.02487105, 0.02043976, ..., 0.9824184 , 0.97455768, 0.9770116 ])
    • y
      (position)
      float64
      m
      0.132, 0.992, ..., 0.230, 0.726
      Values:
      array([0.13177381, 0.99194465, 0.59964942, ..., 0.20675492, 0.2295534 , 0.72618752])
    • (position)
      float64
      counts
      2.381, 6.221, ..., 0.013, 0.057
      σ = 1.560, 2.654, ..., 1.296, 2.752
      Values:
      array([2.38077835, 6.22066122, 4.98048428, ..., 0.01462048, 0.01286099, 0.05722694])

      Variances (σ²):
      array([2.4323159 , 7.04438941, 5.5164024 , ..., 1.98726687, 1.68073546, 7.57101765])

Binning#

scipp.bin actually reorders data and meta data such that all data contributing to a bin is in a contiguous block. Binning along multiple dimensions is supported. Of the three options it is the only solution that supports modifying data in the grouped/binned layout. A variety of operations on such binned data is available. Limitations are:

  • Requires copying and reordering the input data and can thus become expensive.

In the above example the 'y' information is dropped by hist and groupby, but bin preserves it:

[8]:
binned = table.bin(x=xbins)
binned.values[0]
[8]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (4.22 KB out of 156.25 KB)
    • position: 135
    • x
      (position)
      float64
      m
      0.004, 0.025, ..., 0.020, 0.011
      Values:
      array([4.28327541e-03, 2.48710530e-02, 2.04397558e-02, 1.14240481e-02, 5.36814262e-03, 1.42232603e-02, 1.67404830e-02, 2.43401563e-02, 1.76706911e-02, 9.65890049e-03, 4.33106922e-03, 1.74734277e-02, 1.96895870e-02, 2.20288262e-02, 9.90842113e-03, 3.27422098e-03, 1.53555039e-02, 2.09553813e-02, 2.16084668e-02, 1.50061056e-02, 1.12154889e-02, 5.72774219e-03, 1.41254646e-02, 1.35803516e-02, 1.53378631e-02, 2.54382472e-02, 1.07140578e-02, 4.92623897e-03, 2.22036081e-02, 1.11312583e-02, 3.79602377e-03, 9.27880022e-03, 1.03672834e-02, 8.32156009e-03, 9.44114799e-03, 2.05699145e-02, 1.83471141e-02, 2.32099056e-02, 1.45624457e-02, 4.46622294e-03, 1.35223914e-03, 2.15781189e-04, 1.10415569e-03, 2.22350541e-02, 1.32673879e-02, 1.70381185e-02, 1.97296529e-02, 5.39453962e-03, 2.55388420e-02, 3.64381140e-03, 1.61514063e-02, 2.16279035e-02, 1.18415945e-02, 8.34046210e-03, 1.29114007e-02, 1.08196484e-02, 1.53858732e-02, 1.26036249e-02, 2.29882503e-02, 1.26170721e-02, 2.04791753e-02, 2.20101098e-02, 2.06128234e-02, 2.29903761e-02, 5.04002285e-03, 1.44694352e-02, 2.01676257e-02, 9.33751544e-03, 1.68018583e-02, 8.73824570e-03, 1.67200698e-02, 7.25575037e-03, 2.02843168e-03, 2.20486918e-02, 1.54745039e-02, 2.26502348e-03, 8.50375062e-03, 5.22926856e-03, 7.32009320e-03, 1.57995892e-02, 7.94533261e-03, 7.39477025e-03, 6.21244443e-03, 2.15016114e-02, 7.16490872e-03, 9.98858439e-03, 2.36172902e-02, 1.96599531e-03, 2.12466815e-03, 1.91882353e-02, 1.19489266e-02, 2.00537040e-02, 1.23458948e-02, 1.50383681e-02, 7.29991137e-03, 1.81597729e-02, 2.49863980e-02, 1.27605830e-02, 1.48177747e-02, 1.59744173e-02, 1.77593394e-02, 1.36001713e-02, 1.96992135e-02, 1.68182241e-02, 7.25521639e-04, 2.34480331e-02, 1.30831679e-02, 1.10549338e-02, 2.31453873e-02, 3.57412941e-03, 1.78012909e-02, 9.03609199e-03, 3.65671773e-03, 1.00754488e-02, 1.41582782e-02, 6.27233709e-06, 1.06289906e-02, 2.20275480e-02, 2.35114078e-02, 1.50395116e-02, 2.41356069e-02, 2.17456475e-02, 8.07146403e-03, 6.25856001e-03, 1.29834431e-02, 9.83340900e-03, 1.77797750e-02, 2.50143743e-02, 1.41364785e-02, 1.12437656e-02, 8.26629153e-04, 1.59537494e-02, 1.50240455e-02, 2.01495729e-02, 1.07788616e-02])
    • y
      (position)
      float64
      m
      0.132, 0.992, ..., 0.675, 0.608
      Values:
      array([0.13177381, 0.99194465, 0.59964942, 0.49363577, 0.2127482 , 0.12864632, 0.7613325 , 0.89115111, 0.44793689, 0.62677658, 0.23408822, 0.35595621, 0.85639807, 0.65924373, 0.93419942, 0.82012465, 0.84764683, 0.60283737, 0.06503763, 0.54202408, 0.59683863, 0.16495537, 0.01137156, 0.06480275, 0.40755808, 0.79538398, 0.274381 , 0.64968767, 0.80656593, 0.27286715, 0.09150349, 0.02771513, 0.07493086, 0.79237575, 0.28538631, 0.2537379 , 0.0845757 , 0.44000661, 0.14204128, 0.07544352, 0.85576192, 0.6555947 , 0.4183384 , 0.10369909, 0.96465327, 0.48172764, 0.93753863, 0.18225726, 0.71620807, 0.90333973, 0.51454395, 0.01120855, 0.10136972, 0.21680273, 0.96898975, 0.39313292, 0.59349115, 0.15410168, 0.4470427 , 0.91668624, 0.97986014, 0.39404689, 0.85233725, 0.69846411, 0.99293991, 0.29899925, 0.04476237, 0.07733534, 0.96768735, 0.34111181, 0.94251592, 0.70260275, 0.69017873, 0.21547919, 0.19628125, 0.1215121 , 0.55172481, 0.91790001, 0.50854154, 0.45248929, 0.70260465, 0.30853849, 0.00910139, 0.00806118, 0.99451325, 0.244598 , 0.29891159, 0.73266252, 0.90653575, 0.93137762, 0.94213573, 0.0607429 , 0.66969935, 0.60866278, 0.92057085, 0.23182518, 0.47998728, 0.77838557, 0.22578654, 0.30603042, 0.15381437, 0.19990978, 0.54529402, 0.06181529, 0.30392366, 0.03253114, 0.81584015, 0.55578812, 0.93309084, 0.27282163, 0.91445579, 0.35494852, 0.04582113, 0.36116871, 0.39491033, 0.40099799, 0.57908434, 0.74111918, 0.76770658, 0.77739838, 0.65793043, 0.6147767 , 0.93361024, 0.86345967, 0.32295279, 0.6902465 , 0.07552463, 0.84610424, 0.37432918, 0.14032292, 0.96699844, 0.36268406, 0.6971209 , 0.6747667 , 0.60780791])
    • (position)
      float64
      counts
      2.381, 6.221, ..., 6.723, 1.465
      σ = 1.560, 2.654, ..., 2.727, 1.243
      Values:
      array([2.38077835, 6.22066122, 4.98048428, 9.14909507, 4.7417855 , 6.58587068, 1.31314308, 6.63331687, 8.07954578, 1.46567749, 0.71183427, 3.28412763, 7.04714653, 2.69563803, 0.18234984, 5.73462534, 2.37567644, 2.50153667, 4.00051802, 0.90812177, 8.46402407, 9.04715078, 2.95251997, 0.11785512, 7.83179949, 4.30370497, 6.0684871 , 9.65091004, 6.1192404 , 8.51329951, 7.05461416, 6.21060318, 3.03011164, 2.6644871 , 0.9312826 , 5.02380396, 5.61294861, 3.7164721 , 5.83567561, 9.06024384, 4.13087566, 1.19197107, 6.82648745, 5.98238872, 5.62078622, 7.76900371, 0.78789947, 4.55307874, 8.37005328, 0.12101319, 0.44862741, 7.00389822, 4.22844103, 1.37703092, 3.31498711, 2.98189953, 5.44118724, 1.40584036, 2.35297947, 3.66080535, 6.88436368, 8.84373957, 2.2621352 , 7.23759583, 5.27485921, 4.42862835, 2.3260989 , 9.54130511, 1.34334742, 1.23221852, 0.93002583, 7.38689158, 0.39005911, 4.85757324, 8.62188761, 3.88129211, 4.88884969, 4.47175254, 3.41013135, 2.51215681, 4.33117576, 7.76023366, 1.48551991, 1.01032893, 2.4964648 , 0.5977492 , 1.90569326, 4.2823205 , 6.84146784, 7.04518728, 6.21710838, 2.2169715 , 8.37830094, 4.76889781, 4.94900191, 0.30686484, 1.21424279, 8.07697189, 7.24474796, 4.40837685, 1.45378359, 5.47757952, 4.89243525, 5.01867055, 3.0405405 , 0.54457554, 7.7071643 , 1.46471273, 6.86183924, 1.20951689, 4.58803707, 8.60772462, 9.41614279, 2.89328382, 0.54169796, 7.1460139 , 5.8847416 , 2.51644603, 1.3014231 , 2.04171942, 2.70348916, 4.95685522, 4.00912497, 2.94949801, 4.14449582, 5.92743029, 0.07401431, 4.11542143, 7.2291964 , 2.6594427 , 4.05530947, 8.60310882, 4.28040602, 6.7228615 , 1.46487689])

      Variances (σ²):
      array([2.4323159 , 7.04438941, 5.5164024 , 9.68690735, 4.87078184, 7.07128947, 1.42778741, 7.49177493, 8.82588703, 1.53819874, 0.7274174 , 3.5839595 , 7.77622282, 3.00951535, 0.19161136, 5.82928018, 2.56525974, 2.77786353, 4.45695676, 0.97887995, 8.95222552, 9.30999532, 3.16858893, 0.12613564, 8.45604542, 4.88743442, 6.40244291, 9.89157525, 6.83773141, 9.00055175, 7.18979034, 6.50552635, 3.19132401, 2.77768927, 0.97629864, 5.56800589, 6.15221237, 4.17378954, 6.27643581, 9.26484517, 4.15889995, 1.19325779, 6.8642792 , 6.68586242, 6.00629743, 8.45985916, 0.86958733, 4.67755879, 9.51010065, 0.12323814, 0.48636032, 7.80376571, 4.48635849, 1.43567049, 3.5360516 , 3.14765825, 5.87629608, 1.49728485, 2.63959009, 3.89918877, 7.62664916, 9.87257158, 2.50771822, 8.11927581, 5.40947531, 4.76090171, 2.57289236, 9.997328 , 1.46107704, 1.28724909, 1.01111879, 7.65979923, 0.39403528, 5.42372277, 9.31547095, 3.92549805, 5.10119993, 4.59021444, 3.53725597, 2.71866137, 4.50670238, 8.05252974, 1.5323876 , 1.12500109, 2.58752079, 0.62836059, 2.14455551, 4.32462319, 6.9145345 , 7.75459759, 6.59986729, 2.45079043, 8.91178552, 5.14130559, 5.13297533, 0.33603195, 1.37582377, 8.60910145, 7.80188726, 4.77492681, 1.58877969, 5.86301611, 5.39885154, 5.4589485 , 3.05159042, 0.61231498, 8.22819083, 1.5479536 , 7.70371325, 1.23132604, 5.01512694, 9.00554476, 9.58988717, 3.0427733 , 0.58143545, 7.14623802, 6.2059455 , 2.80944046, 1.46377014, 2.20117182, 3.05024299, 5.5261963 , 4.17423174, 3.04325537, 4.42246999, 6.22614788, 0.08089542, 4.6637186 , 7.75866493, 2.81323599, 4.07210534, 9.31748159, 4.61433654, 7.43546966, 1.5459916 ])

If we omit the call to bins.sum in the original example, we can subsequently apply another histogramming or binning operation to the data:

[9]:
binned = binned.bin(y=100)
binned
[9]:
Show/Hide data repr Show/Hide attributes
scipp.DataArray (218.29 KB)
    • x: 39
    • y: 100
    • x
      (x [bin-edge])
      float64
      m
      0.0, 0.026, ..., 0.974, 1.0
      Values:
      array([0. , 0.02564103, 0.05128205, 0.07692308, 0.1025641 , 0.12820513, 0.15384615, 0.17948718, 0.20512821, 0.23076923, 0.25641026, 0.28205128, 0.30769231, 0.33333333, 0.35897436, 0.38461538, 0.41025641, 0.43589744, 0.46153846, 0.48717949, 0.51282051, 0.53846154, 0.56410256, 0.58974359, 0.61538462, 0.64102564, 0.66666667, 0.69230769, 0.71794872, 0.74358974, 0.76923077, 0.79487179, 0.82051282, 0.84615385, 0.87179487, 0.8974359 , 0.92307692, 0.94871795, 0.97435897, 1. ])
    • y
      (y [bin-edge])
      float64
      m
      9.049e-05, 0.010, ..., 0.990, 1.000
      Values:
      array([9.04948404e-05, 1.00890277e-02, 2.00875606e-02, 3.00860934e-02, 4.00846263e-02, 5.00831592e-02, 6.00816920e-02, 7.00802249e-02, 8.00787578e-02, 9.00772906e-02, 1.00075823e-01, 1.10074356e-01, 1.20072889e-01, 1.30071422e-01, 1.40069955e-01, 1.50068488e-01, 1.60067021e-01, 1.70065554e-01, 1.80064086e-01, 1.90062619e-01, 2.00061152e-01, 2.10059685e-01, 2.20058218e-01, 2.30056751e-01, 2.40055284e-01, 2.50053816e-01, 2.60052349e-01, 2.70050882e-01, 2.80049415e-01, 2.90047948e-01, 3.00046481e-01, 3.10045014e-01, 3.20043547e-01, 3.30042079e-01, 3.40040612e-01, 3.50039145e-01, 3.60037678e-01, 3.70036211e-01, 3.80034744e-01, 3.90033277e-01, 4.00031809e-01, 4.10030342e-01, 4.20028875e-01, 4.30027408e-01, 4.40025941e-01, 4.50024474e-01, 4.60023007e-01, 4.70021540e-01, 4.80020072e-01, 4.90018605e-01, 5.00017138e-01, 5.10015671e-01, 5.20014204e-01, 5.30012737e-01, 5.40011270e-01, 5.50009802e-01, 5.60008335e-01, 5.70006868e-01, 5.80005401e-01, 5.90003934e-01, 6.00002467e-01, 6.10001000e-01, 6.19999532e-01, 6.29998065e-01, 6.39996598e-01, 6.49995131e-01, 6.59993664e-01, 6.69992197e-01, 6.79990730e-01, 6.89989263e-01, 6.99987795e-01, 7.09986328e-01, 7.19984861e-01, 7.29983394e-01, 7.39981927e-01, 7.49980460e-01, 7.59978993e-01, 7.69977525e-01, 7.79976058e-01, 7.89974591e-01, 7.99973124e-01, 8.09971657e-01, 8.19970190e-01, 8.29968723e-01, 8.39967256e-01, 8.49965788e-01, 8.59964321e-01, 8.69962854e-01, 8.79961387e-01, 8.89959920e-01, 8.99958453e-01, 9.09956986e-01, 9.19955518e-01, 9.29954051e-01, 9.39952584e-01, 9.49951117e-01, 9.59949650e-01, 9.69948183e-01, 9.79946716e-01, 9.89945248e-01, 9.99943781e-01])
    • (x, y)
      DataArrayView
      binned data [len=2, len=2, ..., len=3, len=0]
      Values:
      [<scipp.DataArray> Dimensions: Sizes[position:2, ] Coordinates: x float64 [m] (position) [0.00621244, 0.0215016] y float64 [m] (position) [0.00910139, 0.00806118] Data: float64 [counts] (position) [1.48552, 1.01033] [1.53239, 1.125] , <scipp.DataArray> Dimensions: Sizes[position:2, ] Coordinates: x float64 [m] (position) [0.0141255, 0.0216279] y float64 [m] (position) [0.0113716, 0.0112086] Data: float64 [counts] (position) [2.95252, 7.0039] [3.16859, 7.80377] , ..., <scipp.DataArray> Dimensions: Sizes[position:3, ] Coordinates: x float64 [m] (position) [0.979065, 0.989522, 0.975151] y float64 [m] (position) [0.987675, 0.982084, 0.984571] Data: float64 [counts] (position) [0.0024342, 0.0253075, 0.0487739] [0.325364, 3.56427, 6.39293] , <scipp.DataArray> Dimensions: Sizes[position:0, ] Coordinates: x float64 [m] (position) [] y float64 [m] (position) [] Data: float64 [counts] (position) [] [] ]

As in the 1-D example above, summing the bins is equivalent to histogramming binned data:

[10]:
binned.bins.sum().plot()