Multi-dimensional datasets

This is the continuation of 1-D datasets and tables.

Creation, slicing, and visualization

[1]:
import numpy as np
import scipp as sc

To create variables with more than one dimension we specify a list of dimension labels and provide data with a corresponding shape. When inserted into a dataset it is important to note that while the dimensions extents have to match, individual variables may have transposed memory layout.

[2]:
d = sc.Dataset(
    data={
        'alice': sc.Variable(dims=['z', 'y', 'x'], values=np.random.rand(10, 10, 10),
                             variances=0.1*np.random.rand(10, 10, 10)),
        'bob': sc.Variable(dims=['x', 'z'], values=np.arange(0.0, 10.0, 0.1).reshape(10, 10),
                           variances=0.1*np.random.rand(10, 10))
    },
    coords={
        'x': sc.arange('x', 11.0, unit=sc.units.m),
        'y': sc.arange('y', 11.0, unit=sc.units.m),
        'z': sc.arange('z', 11.0, unit=sc.units.m)})

Note that in this example the coordinates are exceeding the shape of the data by 1. This means that the coordinates represent bin edges:

[3]:
sc.show(d)
d
bobbob(dims=['x', 'z'], shape=[10, 10], unit=dimensionless, variances=True)variances x zvalues x z alicealice(dims=['z', 'y', 'x'], shape=[10, 10, 10], unit=dimensionless, variances=True)variances z yxvalues z yx zz(dims=['z'], shape=[11], unit=m, variances=False)values z yy(dims=['y'], shape=[11], unit=m, variances=False)values y xx(dims=['x'], shape=[11], unit=m, variances=False)values x
[3]:
Show/Hide data repr Show/Hide attributes
scipp.Dataset (17.45 KB)
    • z: 10
    • y: 10
    • x: 10
    • x
      (x [bin-edge])
      float64
      m
      0.0, 1.0, ..., 9.0, 10.0
      Values:
      array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
    • y
      (y [bin-edge])
      float64
      m
      0.0, 1.0, ..., 9.0, 10.0
      Values:
      array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
    • z
      (z [bin-edge])
      float64
      m
      0.0, 1.0, ..., 9.0, 10.0
      Values:
      array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
    • alice
      (z, y, x)
      float64
      0.84, 0.98, ..., 0.4, 0.94
      σ = 0.1, 0.18, ..., 0.06, 0.08
      Values:
      array([[[8.43100312e-01, 9.79445654e-01, 7.42507908e-01, 8.46883411e-01, 9.30022780e-01, 3.93341079e-01, 7.44243068e-01, 7.81968719e-01, 5.27786418e-01, 2.76806729e-01], [4.84189477e-01, 2.23757133e-01, 2.68359208e-01, 2.16096121e-01, 5.70349270e-01, 9.67449779e-01, 6.04493461e-02, 1.90701377e-01, 5.48561746e-01, 8.22279532e-01], [9.78226805e-01, 3.18514436e-01, 1.26387420e-01, 6.24682741e-01, 4.04250634e-01, 1.40103269e-01, 4.61021231e-01, 8.04000063e-01, 2.73153474e-01, 2.87439312e-01], [3.78596486e-01, 2.33926099e-02, 6.20993815e-02, 7.46334948e-02, 5.71500538e-01, 5.57160677e-01, 2.92187046e-01, 1.28230010e-01, 1.96550703e-01, 6.86599303e-01], [1.23119380e-01, 9.34511196e-01, 8.17578180e-01, 4.94527264e-01, 7.32680338e-01, 7.41603343e-01, 8.35767888e-01, 7.13696027e-01, 3.15237930e-01, 6.56841852e-01], [1.51100142e-01, 9.37375052e-01, 8.11785906e-02, 6.80872505e-02, 7.06191919e-01, 5.12971398e-01, 9.55874975e-01, 8.56365995e-01, 2.80789759e-01, 5.46926150e-01], [4.49315859e-01, 1.17103476e-01, 8.59382940e-01, 5.93309323e-01, 3.77846156e-01, 5.99748496e-01, 5.39234542e-01, 2.39056518e-02, 1.23979947e-01, 9.50095661e-02], [8.31013555e-01, 2.69078746e-01, 4.68682590e-01, 5.13792162e-01, 2.39377081e-02, 1.26740761e-01, 4.15310760e-01, 9.62701963e-01, 6.99262666e-01, 4.27293008e-01], [1.54364133e-01, 5.50321258e-02, 4.67456341e-01, 1.69051556e-01, 6.83983583e-01, 8.29940790e-01, 3.68905083e-02, 1.94964795e-02, 8.45368337e-01, 4.26984056e-01], [5.17303585e-01, 9.03559988e-01, 2.98507223e-01, 2.43508808e-01, 3.88895675e-01, 8.17583318e-01, 7.39244160e-01, 5.23886619e-01, 9.22079548e-01, 1.73299277e-01]], [[3.25853242e-01, 9.05663761e-01, 9.62112699e-01, 4.06084183e-01, 4.87607208e-01, 4.55038306e-03, 7.65908080e-01, 2.88492785e-01, 2.96914121e-01, 4.85693318e-01], [9.11568827e-02, 3.68324656e-01, 2.92835647e-01, 7.60612743e-01, 6.32862587e-01, 6.62470160e-01, 9.74163109e-01, 8.29410890e-01, 3.97203620e-01, 9.48351947e-01], [1.95887330e-03, 1.20760452e-01, 6.34440601e-01, 6.46474513e-01, 8.25039678e-01, 6.14762012e-01, 6.75854891e-01, 3.79059383e-01, 6.80778343e-01, 6.34723284e-01], [9.43979130e-01, 8.31430984e-01, 5.71157085e-01, 7.75640192e-01, 2.78024852e-01, 2.09268647e-01, 2.04239862e-01, 1.63525834e-01, 1.18415981e-01, 5.58070406e-01], [5.94305092e-01, 6.41059817e-01, 1.95272222e-01, 5.51899031e-01, 7.97779125e-01, 9.92333893e-01, 9.52009396e-01, 7.66888246e-01, 9.64631735e-01, 3.33404826e-01], [4.19753861e-01, 1.62752197e-01, 9.67577708e-02, 3.31248517e-01, 5.16731878e-01, 1.24867077e-03, 3.95585230e-01, 8.08827492e-01, 1.20603917e-01, 2.01425160e-01], [8.62600255e-02, 6.89589885e-01, 5.70490603e-01, 4.81139373e-01, 6.55218421e-01, 4.85139265e-01, 2.71481645e-01, 6.08131252e-01, 7.70749081e-01, 2.11060513e-01], [3.86843881e-01, 9.04456946e-01, 3.39368429e-01, 4.34416578e-01, 4.93071040e-01, 8.41649267e-01, 1.92725798e-01, 2.23901108e-01, 7.96124749e-01, 7.24495230e-01], [4.24284539e-01, 3.16813411e-01, 4.87462048e-01, 1.22429687e-01, 2.04168370e-01, 7.11872318e-01, 4.97066875e-01, 2.64774259e-01, 4.99486708e-01, 9.48334600e-01], [9.91421684e-02, 9.66775209e-01, 8.52825694e-01, 7.10443109e-01, 5.79474291e-01, 3.33612530e-01, 6.50822119e-01, 1.99743144e-02, 1.65418083e-01, 3.20780457e-01]], [[4.74635787e-01, 3.08871284e-02, 7.71656991e-01, 2.52478958e-01, 9.02237650e-01, 7.57083795e-02, 1.72194484e-01, 9.70145813e-01, 8.40664882e-01, 3.73840894e-01], [3.48831242e-01, 9.63773704e-02, 9.53068000e-01, 7.69493403e-01, 7.76583217e-01, 3.60290929e-01, 4.02889383e-01, 9.12258154e-01, 3.63265383e-01, 1.13230816e-01], [3.91654361e-01, 2.38085752e-01, 2.34447396e-01, 3.90495441e-01, 9.48673458e-01, 2.19874522e-01, 3.54755646e-02, 1.25932560e-01, 3.60827811e-01, 8.51853986e-01], [3.04910943e-01, 5.02471148e-01, 2.11468466e-01, 6.68251599e-01, 6.65099466e-01, 3.30178838e-01, 3.62571432e-01, 9.94119193e-01, 9.62087152e-01, 2.42656429e-03], [9.61786535e-01, 1.43573953e-01, 2.95527327e-01, 1.59807876e-01, 3.57338327e-01, 9.95845359e-01, 1.89113010e-01, 2.85878456e-01, 5.32791023e-01, 2.58984586e-01], [4.78305355e-01, 1.13212180e-01, 1.90316159e-02, 3.06346532e-01, 6.93613364e-01, 3.28122599e-01, 5.88713666e-01, 4.95125637e-01, 9.16752202e-01, 9.54437653e-01], [2.16975368e-01, 5.16247656e-01, 3.64721888e-01, 6.52158510e-01, 3.35430218e-01, 3.14683003e-01, 2.47570224e-01, 5.07752236e-01, 7.42087940e-01, 2.62123613e-01], [7.33418052e-01, 5.50835366e-01, 2.03797798e-01, 3.06248431e-01, 1.40640178e-01, 2.93671418e-01, 9.37173650e-01, 8.58391689e-01, 3.15942978e-01, 7.89581973e-01], [8.69876422e-02, 1.03637453e-01, 9.53046539e-01, 2.17182906e-01, 6.57404756e-01, 8.65141579e-01, 1.46139353e-01, 3.19295962e-01, 6.97103889e-01, 5.65242105e-01], [8.31945833e-01, 2.10471421e-01, 8.86563760e-01, 6.37287461e-01, 6.57194296e-01, 7.78405185e-01, 1.51112253e-01, 3.48666556e-01, 7.18926629e-01, 1.46711620e-02]], [[7.76162717e-01, 4.77671717e-01, 4.16488128e-01, 4.88599015e-01, 3.08907188e-01, 2.69878316e-02, 2.03414675e-01, 6.94295103e-01, 6.52958021e-01, 4.55970692e-01], [2.47307213e-01, 3.99859505e-01, 2.10988691e-02, 3.18557493e-02, 7.15504081e-01, 5.63978431e-01, 3.94360802e-02, 3.10251650e-01, 4.37525220e-01, 4.78684599e-01], [7.08772962e-01, 3.87212158e-01, 3.35839311e-01, 8.38331588e-01, 7.67960245e-01, 1.36078767e-01, 5.18583243e-01, 2.59193246e-01, 1.24628477e-03, 2.49566306e-01], [9.83628307e-01, 8.99139391e-01, 8.67284209e-02, 6.67585655e-01, 3.17022616e-01, 1.92937283e-01, 2.27811953e-01, 8.35906276e-01, 3.75529721e-01, 3.31639392e-01], [1.47391771e-01, 1.34266305e-01, 4.42601070e-01, 4.92930516e-01, 5.45191410e-01, 1.58514793e-01, 9.01313186e-01, 3.12095642e-01, 5.74809784e-01, 7.31256753e-01], [1.54902079e-01, 4.56476699e-01, 4.06026901e-01, 8.56296655e-01, 9.75136784e-01, 1.43739784e-01, 8.37071082e-01, 6.85758884e-01, 8.99555800e-01, 1.56342440e-01], [9.94126998e-02, 8.93250227e-01, 3.90503646e-01, 2.72472644e-01, 8.52426545e-01, 6.65818818e-01, 1.44155737e-02, 7.48059361e-01, 8.54237083e-01, 7.52374504e-01], [7.96563668e-01, 4.62277547e-01, 6.95898834e-01, 4.70715547e-01, 8.44268818e-01, 9.81551439e-01, 4.28940684e-01, 7.61742083e-01, 3.30790362e-01, 7.93883722e-01], [9.62310805e-01, 5.87080606e-01, 8.00722575e-01, 4.08001760e-01, 3.09052382e-01, 8.67592131e-01, 2.40415311e-01, 5.79628685e-01, 5.90071829e-01, 9.23478966e-01], [7.12103183e-01, 4.97072965e-01, 1.69690251e-01, 7.60542405e-01, 3.19868869e-01, 4.85337816e-02, 6.97993748e-01, 1.67849678e-01, 5.40749776e-01, 2.13613455e-01]], [[7.23956913e-01, 3.53522180e-01, 4.23606776e-01, 3.23677279e-02, 4.72151074e-02, 9.80168647e-01, 9.51921896e-01, 1.10580571e-01, 7.59846641e-01, 4.47316230e-03], [6.14654904e-01, 7.14277878e-01, 4.08499515e-01, 8.00553108e-01, 5.50601115e-01, 5.67429072e-01, 2.06650968e-01, 3.79469727e-01, 3.29263017e-01, 6.46239506e-01], [4.13437637e-01, 3.30161146e-01, 5.74806499e-01, 5.71496384e-01, 3.64006642e-01, 4.25833872e-01, 6.36511891e-01, 1.66089094e-01, 6.37022318e-01, 9.86640271e-01], [8.67091623e-01, 4.65307822e-01, 5.40516463e-01, 3.58855302e-01, 5.02486216e-01, 6.99216641e-01, 7.90088173e-01, 5.05582679e-01, 6.43641213e-01, 8.63885345e-01], [6.02452014e-01, 5.99093585e-01, 4.37528523e-01, 3.89513876e-01, 6.40693351e-01, 5.58229155e-01, 5.40204426e-01, 9.15147821e-01, 4.09691748e-01, 2.61009422e-01], [8.99368744e-01, 4.88702505e-01, 4.45679254e-01, 9.77935987e-01, 9.89502109e-01, 9.58117488e-02, 3.89945230e-02, 8.92032022e-01, 5.34870797e-01, 2.16268859e-01], [9.92928110e-01, 8.10628296e-01, 7.24626067e-02, 2.02005748e-01, 1.12932837e-01, 3.98348727e-01, 1.07648751e-01, 4.94835197e-01, 5.44139743e-01, 7.10661041e-01], [3.64075806e-01, 5.20727769e-02, 6.20311679e-01, 9.59429432e-01, 9.29237785e-01, 2.87973976e-01, 5.15322586e-01, 8.55101084e-01, 8.29347925e-01, 8.19313414e-01], [5.02975496e-01, 9.35168184e-01, 6.78801085e-01, 9.12055848e-01, 7.72122698e-01, 8.91013027e-01, 7.93109527e-01, 8.17681048e-01, 5.64702309e-01, 9.25147468e-01], [4.18914551e-01, 5.52254318e-01, 1.55123422e-01, 3.78096209e-02, 1.59658754e-01, 8.12870496e-01, 5.12377896e-01, 5.46316586e-01, 4.02464168e-02, 6.95128918e-01]], [[8.97901416e-01, 4.18516663e-01, 5.61708175e-01, 2.13561288e-01, 8.22521965e-01, 3.39567636e-02, 3.22014220e-01, 1.45950112e-01, 9.45479836e-01, 7.28405153e-01], [3.43896058e-01, 7.29239545e-01, 8.80878192e-01, 9.89864959e-01, 9.14732059e-02, 8.35367425e-01, 4.05648291e-01, 7.04462570e-01, 6.52220421e-01, 3.02092327e-01], [2.66464266e-01, 6.74164808e-01, 5.10437466e-01, 5.13130536e-01, 1.81647075e-01, 7.71980458e-01, 6.48844025e-01, 9.25073213e-01, 7.38962215e-01, 3.77232302e-01], [2.35117060e-01, 3.07801860e-01, 6.56043403e-01, 7.35885471e-01, 1.21593992e-01, 9.52714700e-02, 8.16496339e-01, 2.20855294e-01, 8.95354742e-01, 7.43873671e-01], [7.43259887e-01, 8.79002117e-01, 4.88340138e-01, 9.80518476e-01, 6.87551730e-01, 1.62250710e-01, 9.00980384e-01, 6.99851110e-01, 5.55343728e-01, 2.44628994e-01], [2.84670583e-01, 4.00989457e-01, 5.26601908e-01, 5.15113243e-01, 4.28174693e-01, 3.12295304e-01, 1.12018112e-01, 7.15622113e-01, 6.22416493e-01, 9.47086323e-01], [4.12114857e-01, 5.67950805e-01, 8.04564841e-01, 6.92688609e-01, 8.05924606e-01, 9.58659224e-01, 6.77942354e-01, 5.90810395e-01, 1.24180699e-03, 2.66543735e-01], [1.33753848e-01, 7.40642516e-01, 4.74779869e-01, 2.17011482e-01, 9.85562227e-01, 7.78279884e-01, 1.93810077e-01, 7.91023500e-01, 1.40392969e-01, 7.85627537e-01], [7.40781916e-01, 9.70463253e-01, 7.38220749e-02, 1.41724448e-01, 1.72524204e-01, 1.76322759e-01, 8.92176005e-01, 5.03235697e-01, 3.63513094e-01, 6.48861539e-01], [5.10011678e-01, 4.25887021e-01, 9.59310016e-01, 9.89003812e-01, 5.50645791e-02, 1.50533158e-01, 2.53794229e-01, 3.59715952e-01, 6.21015411e-01, 4.34711145e-01]], [[1.12033145e-01, 3.27816676e-01, 2.69894204e-01, 6.93629869e-01, 2.02958005e-01, 4.66251660e-01, 4.56630582e-01, 8.82352794e-02, 2.94707208e-01, 9.03338941e-01], [8.48644136e-01, 3.90074424e-01, 2.72384256e-01, 1.27562231e-01, 1.21368274e-01, 7.93699738e-01, 7.49962308e-01, 1.43425599e-01, 1.83592693e-01, 8.60777235e-01], [6.35778773e-02, 1.26716369e-01, 8.74582247e-02, 8.91318307e-01, 5.80001523e-01, 7.97195003e-01, 3.97698526e-01, 3.44268122e-01, 7.42657060e-01, 5.72597293e-01], [2.09926756e-02, 2.48528371e-01, 7.37387276e-01, 7.50190590e-03, 6.13600203e-01, 3.30740029e-01, 2.92151190e-01, 9.85630897e-01, 3.16469393e-01, 5.41765530e-01], [6.73234993e-02, 1.79987918e-01, 2.63206926e-01, 4.44742143e-01, 3.17957815e-01, 2.18073819e-01, 4.50288304e-01, 7.99343644e-01, 7.11253748e-01, 2.27157106e-01], [4.46458589e-01, 7.00147805e-01, 8.41273471e-01, 1.14546008e-01, 3.23072141e-01, 5.98240367e-01, 9.29179465e-01, 6.69328249e-01, 1.96734997e-01, 1.98254045e-01], [7.91254716e-01, 3.42660149e-01, 1.04359934e-01, 6.87134909e-01, 2.45635584e-01, 8.14633444e-01, 9.79465544e-01, 3.76900566e-01, 9.02161069e-01, 7.46556799e-01], [6.82032166e-01, 6.84562508e-01, 4.45496184e-01, 5.33994509e-01, 9.96476756e-01, 5.73554583e-01, 6.38552324e-01, 8.37428888e-01, 3.65689468e-01, 1.19100377e-01], [2.24094623e-01, 9.02921835e-01, 1.88768234e-01, 2.11675386e-01, 4.09802578e-01, 4.65244478e-02, 3.74033596e-01, 1.73568939e-01, 2.64472406e-01, 1.28895127e-02], [3.62870155e-01, 9.33304833e-01, 3.47366419e-01, 2.96058784e-01, 5.30585358e-01, 5.55634610e-01, 3.67117544e-01, 5.68958813e-01, 7.43310240e-01, 6.79066207e-01]], [[5.28015761e-01, 4.39522368e-01, 8.93429593e-01, 7.23777248e-01, 7.92108348e-01, 2.49847572e-01, 8.18568559e-01, 1.47283127e-01, 9.17046234e-02, 3.18317224e-01], [3.54395366e-01, 7.94845608e-01, 6.84048585e-01, 6.88337490e-01, 1.39798864e-01, 2.94998246e-01, 9.76704076e-02, 6.73842482e-01, 7.32191004e-02, 9.14028386e-01], [4.17294943e-03, 2.31635001e-01, 9.39655425e-01, 6.58969245e-01, 6.59234768e-01, 3.11855908e-01, 3.18574520e-01, 8.14097921e-01, 2.38250189e-02, 2.98433088e-01], [1.96988895e-01, 7.54728884e-01, 4.17685730e-01, 7.85022351e-01, 7.13137020e-01, 1.22047654e-01, 4.79848035e-01, 4.04805412e-01, 8.68927647e-01, 8.34382857e-01], [2.95550861e-01, 3.59925749e-01, 3.39978090e-01, 7.97511416e-01, 2.00029041e-01, 7.08101186e-01, 3.24626283e-01, 5.14912443e-01, 9.66701986e-02, 2.59733140e-01], [5.64988267e-01, 3.71066258e-01, 7.96986309e-01, 4.00443866e-01, 6.99728547e-01, 3.33401279e-01, 6.86534548e-01, 5.77166725e-01, 3.78019402e-01, 6.76063456e-01], [8.46676530e-01, 2.49208687e-01, 1.71086507e-01, 2.67100729e-03, 9.22261180e-01, 8.23424634e-01, 6.83346943e-01, 1.63145769e-01, 6.74423180e-01, 4.92495522e-01], [4.05175565e-01, 3.61565082e-01, 9.17560074e-01, 2.72349908e-01, 1.27374438e-01, 9.44713747e-01, 5.46936953e-02, 2.33482932e-01, 4.14024953e-01, 6.85782041e-01], [1.89235822e-01, 1.07885907e-01, 3.89639782e-01, 7.13794817e-01, 1.07717412e-01, 6.38191451e-01, 2.32240780e-01, 9.02907426e-01, 4.86564716e-01, 4.64995536e-01], [6.19263971e-01, 4.16843808e-01, 2.63020717e-01, 8.99739566e-02, 3.69628607e-01, 5.85329869e-01, 7.37753749e-01, 9.41328300e-02, 1.37983784e-02, 7.43947684e-01]], [[4.23533333e-01, 8.87633517e-01, 6.41300063e-01, 5.73925993e-01, 5.14552057e-01, 7.06573318e-01, 6.00842448e-01, 7.44585870e-01, 9.53003353e-01, 8.45879231e-01], [6.59109419e-01, 1.80127455e-01, 6.22006516e-01, 9.46860904e-01, 8.94698342e-01, 4.59442378e-01, 4.26148760e-01, 8.39282113e-01, 8.74059770e-01, 2.94558221e-02], [6.30790723e-01, 1.44872477e-01, 8.99521175e-01, 9.60128476e-01, 3.50972597e-01, 4.59601565e-01, 9.15120709e-01, 9.97039800e-01, 3.69994026e-01, 9.62456656e-01], [8.44614708e-01, 4.25876349e-01, 4.77157662e-01, 2.71082112e-01, 3.46204190e-01, 2.38356881e-01, 5.96676978e-01, 5.75190047e-01, 3.33456852e-01, 1.82019822e-01], [8.78271593e-01, 6.71740247e-01, 2.89072637e-01, 1.51186176e-01, 8.74766758e-01, 9.63634226e-01, 3.51134178e-01, 2.64502718e-01, 6.74165877e-01, 5.37971204e-01], [4.07747138e-01, 6.35142420e-01, 6.31831882e-02, 7.43442591e-02, 5.54893029e-01, 4.92429697e-01, 7.05440836e-02, 9.38710891e-01, 3.08399869e-02, 5.43017044e-01], [8.89093593e-01, 7.36057676e-02, 2.96675007e-01, 9.75585573e-01, 8.43701990e-01, 7.88062979e-01, 9.52117740e-01, 6.88470102e-01, 1.56918724e-01, 6.70548560e-01], [3.11727115e-01, 9.36377961e-01, 5.72745675e-01, 8.29093383e-01, 6.48038183e-02, 1.28816038e-01, 5.59103326e-01, 3.12824752e-02, 9.90769887e-01, 7.14207775e-01], [8.31363217e-01, 7.90823149e-01, 2.01739875e-01, 1.66235338e-01, 1.91960558e-01, 7.73759425e-01, 9.52534159e-01, 6.91234762e-01, 1.04692150e-01, 5.02317094e-01], [8.47238528e-01, 8.89850765e-01, 3.57342615e-01, 9.41360633e-01, 2.55336290e-01, 2.37716240e-01, 3.62624066e-01, 4.59402942e-01, 3.62083694e-01, 9.56822999e-01]], [[5.99055096e-01, 2.57416657e-01, 4.88488643e-01, 6.35095585e-01, 6.05241573e-01, 1.05112180e-01, 8.16339789e-01, 7.80248924e-02, 1.89540213e-01, 8.46414270e-02], [6.24129999e-01, 1.71806977e-01, 6.07502647e-01, 3.01378303e-01, 4.10588059e-01, 2.29459621e-01, 3.39667318e-01, 5.73419275e-01, 4.70776413e-01, 5.79715327e-01], [9.41831926e-01, 4.86167966e-02, 1.69864477e-01, 2.94281471e-01, 7.24853307e-01, 8.92249407e-01, 1.31637786e-01, 5.52606587e-01, 6.62392957e-01, 1.59043641e-01], [3.13679014e-01, 2.75568420e-01, 8.28048182e-01, 8.43701157e-01, 7.66123247e-01, 4.83402445e-01, 5.69671016e-01, 1.54279834e-01, 6.85862165e-01, 8.76523267e-01], [9.30332337e-01, 3.53731695e-01, 2.53564504e-01, 6.48350692e-03, 7.73986117e-01, 5.79456295e-01, 4.87657470e-01, 4.95630884e-01, 1.98301447e-01, 1.00404625e-01], [4.38107826e-01, 7.73699641e-01, 3.43653113e-01, 1.62673986e-01, 7.73782490e-01, 1.37612190e-01, 9.43513322e-01, 6.84959277e-01, 7.55922787e-01, 8.03119078e-01], [4.90580617e-01, 1.82978745e-01, 7.71517934e-01, 6.73034385e-01, 9.34745639e-04, 8.20638522e-01, 1.00557272e-01, 3.10559596e-02, 8.40903584e-01, 2.68383208e-01], [1.14777523e-01, 3.21566035e-01, 2.28543300e-01, 8.79440267e-01, 3.53990316e-01, 9.61191101e-01, 3.44471527e-01, 9.43698380e-01, 6.70116757e-01, 7.86797816e-01], [2.36856184e-01, 5.96697473e-01, 6.78064538e-01, 6.33743083e-01, 8.04930322e-01, 1.95112648e-01, 1.48059080e-01, 2.06086000e-01, 6.57692296e-01, 3.14886207e-01], [2.79056285e-01, 7.64859753e-01, 4.89649695e-01, 3.18149818e-01, 4.64863637e-01, 6.16946787e-01, 7.72871513e-01, 6.28795230e-02, 3.97200891e-01, 9.35325567e-01]]])

      Variances (σ²):
      array([[[0.00977799, 0.03328999, 0.02099268, 0.08523986, 0.06458751, 0.02124188, 0.05493142, 0.01871309, 0.09537455, 0.0879436 ], [0.01140074, 0.04963518, 0.03973575, 0.07941139, 0.02281041, 0.08500559, 0.05380055, 0.09279386, 0.00123732, 0.08940703], [0.09175031, 0.05782927, 0.05029677, 0.05318792, 0.01683545, 0.01511576, 0.09590242, 0.06010987, 0.01509904, 0.01965961], [0.02978233, 0.04830146, 0.01057635, 0.08549325, 0.02533703, 0.00861812, 0.01293013, 0.09048576, 0.0513709 , 0.04742695], [0.02418095, 0.00422957, 0.06726612, 0.05161081, 0.02093218, 0.08158282, 0.07855525, 0.09500991, 0.0264233 , 0.00921093], [0.01217417, 0.02466452, 0.03778098, 0.05518372, 0.06085784, 0.06926233, 0.03287856, 0.0121447 , 0.00816244, 0.00682198], [0.0128632 , 0.01713204, 0.0753818 , 0.05340245, 0.01318338, 0.01920397, 0.01759237, 0.04429642, 0.06373353, 0.05249015], [0.00423505, 0.00223716, 0.03092383, 0.01014479, 0.02939116, 0.04170465, 0.00227179, 0.0368485 , 0.00829125, 0.01451941], [0.07142796, 0.08453321, 0.04375322, 0.05537941, 0.03114041, 0.02609563, 0.00718528, 0.03541881, 0.06638704, 0.0892635 ], [0.04284432, 0.01424868, 0.00159248, 0.07985458, 0.09756761, 0.01888564, 0.026536 , 0.03484373, 0.01514807, 0.07363959]], [[0.01288482, 0.00422093, 0.05878381, 0.03569885, 0.01654385, 0.09601286, 0.07666066, 0.03747281, 0.02437685, 0.01944487], [0.01384357, 0.00599442, 0.09925426, 0.01688281, 0.03477801, 0.07130389, 0.00120697, 0.07405414, 0.08252047, 0.03916866], [0.02058178, 0.0106156 , 0.05173597, 0.00077485, 0.00871173, 0.03176173, 0.04715389, 0.01678884, 0.07153497, 0.09688344], [0.06586034, 0.06916534, 0.08131979, 0.05736059, 0.03181066, 0.0248621 , 0.00962547, 0.00087275, 0.08853922, 0.03666589], [0.0738536 , 0.04790225, 0.00309132, 0.07364776, 0.03407934, 0.08653668, 0.01184532, 0.08213266, 0.08781116, 0.09069056], [0.06325929, 0.08784388, 0.0966742 , 0.01940678, 0.09843405, 0.06282394, 0.00203399, 0.02013315, 0.06392425, 0.02213621], [0.02938807, 0.05115032, 0.08719796, 0.07836407, 0.03971021, 0.05776076, 0.03437269, 0.07299288, 0.02903283, 0.0282347 ], [0.02959622, 0.07501334, 0.04915893, 0.00649456, 0.01152109, 0.0312465 , 0.00661091, 0.07886898, 0.04771252, 0.07059179], [0.00497946, 0.09815364, 0.02464619, 0.01105334, 0.03035363, 0.09463591, 0.05809044, 0.08046126, 0.04472202, 0.00441456], [0.01926966, 0.02072984, 0.08280807, 0.04772708, 0.00791052, 0.01350834, 0.00378927, 0.08069286, 0.03736064, 0.0070857 ]], [[0.04925188, 0.00042381, 0.07277828, 0.05993771, 0.06097169, 0.02151181, 0.07494206, 0.08065646, 0.07875661, 0.04995713], [0.05032563, 0.0793651 , 0.05704679, 0.07439469, 0.02189482, 0.05107393, 0.05545312, 0.04156078, 0.079701 , 0.09571065], [0.05784401, 0.07676822, 0.01202971, 0.09893836, 0.04593378, 0.04000489, 0.02507546, 0.06538457, 0.00378514, 0.08026022], [0.08695584, 0.07532949, 0.08266175, 0.02692012, 0.01388281, 0.0010322 , 0.07360733, 0.00480908, 0.08413769, 0.0617632 ], [0.0187997 , 0.01130481, 0.00099418, 0.01978638, 0.0200204 , 0.00205513, 0.05695917, 0.04481834, 0.00531608, 0.03767379], [0.03880308, 0.02016521, 0.08237202, 0.05918761, 0.06595986, 0.06168319, 0.00405422, 0.01165214, 0.03876585, 0.08940837], [0.01316936, 0.04952688, 0.0368415 , 0.09599092, 0.02620184, 0.04683714, 0.00137104, 0.03477487, 0.04466784, 0.08319222], [0.05794199, 0.02066415, 0.07550187, 0.06662206, 0.0910528 , 0.08466189, 0.02941754, 0.09388373, 0.01041295, 0.05525091], [0.07143727, 0.04271047, 0.04152685, 0.07657259, 0.08776813, 0.01097222, 0.02174661, 0.08172619, 0.02938275, 0.05565023], [0.018071 , 0.00448154, 0.04623011, 0.04601133, 0.07930101, 0.05663327, 0.06989977, 0.02863645, 0.01497594, 0.04940437]], [[0.07395509, 0.0499419 , 0.0337796 , 0.02778817, 0.02418124, 0.00124169, 0.04388503, 0.01421977, 0.06342226, 0.09221193], [0.03655249, 0.07825827, 0.05890133, 0.08946882, 0.0679045 , 0.00767648, 0.08210308, 0.00077661, 0.09975727, 0.09908642], [0.05857954, 0.01973145, 0.00448555, 0.05059671, 0.0530692 , 0.00302129, 0.06658093, 0.01020903, 0.04184322, 0.04816755], [0.03447044, 0.0909988 , 0.03449986, 0.07424534, 0.00421098, 0.08424205, 0.06336507, 0.0574734 , 0.00678751, 0.01945394], [0.08599412, 0.06912907, 0.03742623, 0.03908785, 0.03406622, 0.09814842, 0.09127071, 0.00506295, 0.07805987, 0.09045483], [0.03693041, 0.07642084, 0.08528617, 0.06705371, 0.0805468 , 0.08973265, 0.06574597, 0.00382441, 0.04797014, 0.08639936], [0.02722091, 0.05980196, 0.02213508, 0.08803043, 0.07732256, 0.03650339, 0.0119929 , 0.03772859, 0.06519828, 0.08440199], [0.03792559, 0.04215496, 0.01996612, 0.06815307, 0.00603382, 0.06741282, 0.09503425, 0.07134743, 0.08283377, 0.05334781], [0.07144106, 0.06428796, 0.0579339 , 0.0898428 , 0.06212784, 0.07817638, 0.0678857 , 0.00726095, 0.08546544, 0.03358584], [0.07819444, 0.05391877, 0.00783559, 0.03214008, 0.04468997, 0.02373803, 0.00173461, 0.01248562, 0.01252701, 0.08738613]], [[0.06517074, 0.01758618, 0.00957589, 0.07193424, 0.06410489, 0.09188623, 0.04381555, 0.04310429, 0.06038646, 0.01666348], [0.08940909, 0.08269775, 0.07059204, 0.00676937, 0.03516762, 0.07072981, 0.06651565, 0.00824761, 0.02619632, 0.08291858], [0.05893529, 0.04295609, 0.08017345, 0.09953083, 0.01511361, 0.08785642, 0.07864639, 0.02243938, 0.07725865, 0.04297022], [0.08712554, 0.08988796, 0.07009388, 0.02165903, 0.07315096, 0.04872208, 0.05187535, 0.04465255, 0.04309134, 0.04747049], [0.0471462 , 0.00917036, 0.05943721, 0.08692474, 0.01397871, 0.08291823, 0.08862161, 0.09666171, 0.05696657, 0.02769973], [0.013342 , 0.06296879, 0.07054723, 0.00691697, 0.05310704, 0.09379324, 0.03980376, 0.05733804, 0.02240736, 0.02320506], [0.02220523, 0.04310912, 0.04150522, 0.01244996, 0.01261481, 0.04005007, 0.00751742, 0.02754956, 0.03477304, 0.07731747], [0.00507072, 0.05759985, 0.07430028, 0.07337733, 0.05365853, 0.039077 , 0.09326913, 0.00290908, 0.05698492, 0.06681443], [0.04254165, 0.05260273, 0.02852985, 0.00374086, 0.06382601, 0.05223675, 0.00018995, 0.03167498, 0.0286631 , 0.06026024], [0.04523361, 0.04235843, 0.08963092, 0.09808462, 0.06353525, 0.08081424, 0.0483459 , 0.04361157, 0.05654158, 0.02956978]], [[0.0372075 , 0.09524427, 0.03231696, 0.05681683, 0.0551864 , 0.01451296, 0.06284138, 0.07398717, 0.0961595 , 0.0920177 ], [0.01685313, 0.08681326, 0.01290345, 0.01860274, 0.03666453, 0.01800033, 0.08735944, 0.03527105, 0.09235204, 0.08707592], [0.04572779, 0.03138577, 0.09040248, 0.04855923, 0.03396335, 0.07849309, 0.05068081, 0.08588404, 0.09954902, 0.04777135], [0.09542301, 0.02661209, 0.02716349, 0.00028801, 0.05165114, 0.09223805, 0.01518883, 0.02983552, 0.00610698, 0.08615763], [0.00579424, 0.00698001, 0.02283645, 0.02277614, 0.05978599, 0.07205352, 0.09584656, 0.06057529, 0.08987323, 0.04632137], [0.09129781, 0.04094303, 0.07372579, 0.08931952, 0.09826471, 0.02111407, 0.01931553, 0.01397969, 0.04077431, 0.06938979], [0.00658745, 0.01106357, 0.03264736, 0.06614144, 0.0074408 , 0.05718321, 0.07730031, 0.01206825, 0.01258736, 0.09704793], [0.02961791, 0.03549542, 0.01808493, 0.06127258, 0.01043828, 0.00209326, 0.04188399, 0.0406187 , 0.00188061, 0.06217382], [0.09314279, 0.00531176, 0.03173641, 0.0175611 , 0.04099342, 0.07713708, 0.09153494, 0.00119552, 0.08734986, 0.02252649], [0.09442195, 0.06652414, 0.01654008, 0.00551091, 0.04785578, 0.03778782, 0.0755369 , 0.0330364 , 0.09410666, 0.06714746]], [[0.00144532, 0.0434172 , 0.05467803, 0.03604385, 0.05335591, 0.0280554 , 0.08420432, 0.03180167, 0.00336118, 0.01021946], [0.04576205, 0.04465114, 0.02118612, 0.09283032, 0.07862288, 0.08626839, 0.09423442, 0.03145629, 0.07495804, 0.06038165], [0.09600424, 0.08046924, 0.08750425, 0.00292825, 0.05758744, 0.07216329, 0.03719673, 0.0083693 , 0.03306011, 0.0333803 ], [0.01594434, 0.03840306, 0.08904103, 0.08292455, 0.05653702, 0.06464172, 0.09297787, 0.0788191 , 0.0425853 , 0.08532655], [0.09669716, 0.00953764, 0.09345017, 0.02351383, 0.01603449, 0.07039776, 0.06470266, 0.01859996, 0.03392896, 0.06361332], [0.02849009, 0.01672408, 0.05863349, 0.01679542, 0.06763361, 0.03131725, 0.09073124, 0.06719343, 0.01247287, 0.01716719], [0.08131811, 0.03934267, 0.0509204 , 0.05224423, 0.04275597, 0.0492767 , 0.04790989, 0.06346982, 0.04263986, 0.09854421], [0.03761856, 0.04759999, 0.0421385 , 0.08077102, 0.02478799, 0.01940454, 0.08637266, 0.08671045, 0.0269264 , 0.00194462], [0.07690048, 0.07384371, 0.03435828, 0.09167121, 0.01404387, 0.09955984, 0.09553481, 0.09908142, 0.04272848, 0.03440782], [0.06787121, 0.01996001, 0.05565214, 0.08521106, 0.04211759, 0.03938764, 0.05393732, 0.01640129, 0.08583756, 0.06474651]], [[0.03055789, 0.04714417, 0.07995218, 0.0051105 , 0.04519202, 0.0965282 , 0.04184671, 0.01764392, 0.08665313, 0.07315845], [0.07226204, 0.01560809, 0.00864882, 0.04276494, 0.08243659, 0.02079891, 0.02753113, 0.07108393, 0.06267372, 0.08352569], [0.03857961, 0.05804702, 0.03108831, 0.04644377, 0.02151119, 0.02654806, 0.07109615, 0.07865594, 0.0267788 , 0.09724022], [0.06143871, 0.01548939, 0.03008074, 0.05398342, 0.07582332, 0.05353792, 0.04884929, 0.08088022, 0.08005183, 0.01885517], [0.00898209, 0.06354473, 0.03746197, 0.00645727, 0.07649394, 0.03226792, 0.06055435, 0.09001816, 0.07631356, 0.0530752 ], [0.00454059, 0.08941703, 0.07213788, 0.08700357, 0.09031402, 0.06230323, 0.01787431, 0.02720505, 0.06738667, 0.08113546], [0.04995303, 0.09223033, 0.09486539, 0.02959268, 0.09876353, 0.05460551, 0.09555469, 0.07668106, 0.09623521, 0.01382969], [0.07844002, 0.09871249, 0.08372469, 0.04754922, 0.06158306, 0.03877709, 0.00845677, 0.09500354, 0.03725965, 0.05641984], [0.07912055, 0.08361512, 0.05090518, 0.04078866, 0.04011156, 0.07487514, 0.04527789, 0.01905811, 0.04348349, 0.03072899], [0.01759133, 0.00466437, 0.05966712, 0.04730452, 0.02432746, 0.09533006, 0.06969545, 0.01092821, 0.06004154, 0.05527723]], [[0.09134656, 0.02597146, 0.08989281, 0.02322209, 0.04183218, 0.03273239, 0.0601147 , 0.05250387, 0.00367422, 0.06961974], [0.01775684, 0.06030436, 0.05385972, 0.07453375, 0.07941685, 0.04735928, 0.01794569, 0.01508165, 0.06864545, 0.04838022], [0.0911433 , 0.02862967, 0.04746237, 0.09216797, 0.03769085, 0.02833506, 0.05652082, 0.09681374, 0.09664636, 0.05601236], [0.08177927, 0.04058775, 0.06243309, 0.04362764, 0.01839898, 0.00325778, 0.04030215, 0.00312679, 0.06616138, 0.0184287 ], [0.04905544, 0.0830074 , 0.0059297 , 0.02453296, 0.05855199, 0.03116264, 0.02324493, 0.08047379, 0.02250177, 0.01131231], [0.0985751 , 0.08976117, 0.03456848, 0.01713518, 0.09080839, 0.0053995 , 0.04055303, 0.06152717, 0.08356044, 0.05651308], [0.06043823, 0.08473055, 0.06632782, 0.01466291, 0.02214227, 0.03633808, 0.028318 , 0.05633279, 0.06980608, 0.09070036], [0.04733247, 0.08762828, 0.01457013, 0.01360447, 0.01583127, 0.06926354, 0.02258253, 0.00854496, 0.00364646, 0.03366822], [0.03375679, 0.08095398, 0.02852507, 0.00270874, 0.04271656, 0.06241914, 0.06075017, 0.03996236, 0.07468712, 0.022325 ], [0.01114913, 0.09298408, 0.01375772, 0.08537083, 0.06693049, 0.07837931, 0.02318394, 0.05310762, 0.0994478 , 0.07622736]], [[0.03273712, 0.09028798, 0.01265405, 0.04604303, 0.08609032, 0.09893741, 0.04180761, 0.08316347, 0.0014511 , 0.04915792], [0.02718661, 0.07188292, 0.0463875 , 0.0922762 , 0.02461779, 0.08277081, 0.06292308, 0.01430301, 0.07503892, 0.09238514], [0.0940341 , 0.01928149, 0.00865203, 0.00290714, 0.00028943, 0.00230409, 0.02539431, 0.07668964, 0.04325261, 0.09178161], [0.05381857, 0.01727346, 0.08183655, 0.01573092, 0.05542287, 0.02541265, 0.05530472, 0.05932547, 0.07822977, 0.05510706], [0.09106139, 0.05474247, 0.0453854 , 0.03339756, 0.00192212, 0.00829243, 0.06841568, 0.07129117, 0.00746356, 0.06331542], [0.06169801, 0.00975805, 0.07779564, 0.08913143, 0.05337075, 0.03828191, 0.09373283, 0.03376539, 0.07575368, 0.0980258 ], [0.08830172, 0.00637684, 0.01204437, 0.06352079, 0.05409202, 0.00396539, 0.09018194, 0.01985524, 0.04442663, 0.04363791], [0.03820088, 0.08865254, 0.02570543, 0.02941845, 0.02015302, 0.06803951, 0.02928986, 0.0884325 , 0.00731237, 0.09604851], [0.03084611, 0.07846194, 0.06514005, 0.09337765, 0.07637683, 0.06785134, 0.08968551, 0.04268788, 0.02333428, 0.02359498], [0.08573779, 0.03487795, 0.07654185, 0.05851032, 0.06547816, 0.07421432, 0.03368307, 0.08410981, 0.0031227 , 0.00660528]]])
    • bob
      (x, z)
      float64
      0.0, 0.1, ..., 9.8, 9.9
      σ = 0.29, 0.04, ..., 0.17, 0.21
      Values:
      array([[0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], [1. , 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9], [2. , 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9], [3. , 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9], [4. , 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9], [5. , 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9], [6. , 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9], [7. , 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9], [8. , 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9], [9. , 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9]])

      Variances (σ²):
      array([[0.08416732, 0.00175708, 0.08868729, 0.05948284, 0.02830854, 0.08791572, 0.06943187, 0.0662291 , 0.03548022, 0.09896059], [0.03392556, 0.06411376, 0.01526064, 0.09106409, 0.04974322, 0.03460254, 0.02156921, 0.05617922, 0.05844132, 0.09030627], [0.06886208, 0.08755593, 0.04528562, 0.0571194 , 0.03284097, 0.088008 , 0.069877 , 0.02383418, 0.0310831 , 0.02353692], [0.07807252, 0.0818573 , 0.00046819, 0.03756468, 0.04377433, 0.09468626, 0.03767971, 0.01538852, 0.02032383, 0.08705854], [0.00991602, 0.08018377, 0.03848552, 0.00119523, 0.04999321, 0.02594306, 0.06336386, 0.06903054, 0.09090613, 0.06561196], [0.0160349 , 0.03963399, 0.06973565, 0.07034654, 0.01864558, 0.08147588, 0.09582292, 0.05928961, 0.06099661, 0.00786478], [0.06058146, 0.048059 , 0.04181376, 0.04525737, 0.02369891, 0.02918095, 0.09618988, 0.06822642, 0.01892642, 0.02474382], [0.01900317, 0.00759153, 0.08855607, 0.05303084, 0.01427409, 0.0675504 , 0.08864342, 0.08278652, 0.03017619, 0.07951055], [0.08743517, 0.06409611, 0.01527976, 0.00344253, 0.06329733, 0.05110938, 0.01741153, 0.06138777, 0.04754124, 0.01836018], [0.06190856, 0.03692911, 0.03993223, 0.03606326, 0.05212808, 0.0063708 , 0.07551425, 0.02186461, 0.03011745, 0.04588975]])

To slice in multiple dimensions, we can simply chain the slicing notation used previously for 1D data. This gives us a number of different options for visualizing our data:

[4]:
sc.table(d['x', 5]['z', 2])

We can plot and item of a Dataset using:

[5]:
sc.plot(d['bob'])

Plotting a 3-dimensional data cube will show a 2D image with a slider to navigate through the third dimension (note that interactive sliders will only appear in a Jupyter notebook and not in the documentation pages):

[6]:
sc.plot(d['alice'])

Finally, by extracting a 1D variable, we obtain a 1D plot:

[7]:
sc.plot(d['x', 8]['y', 2])

Note that this is now plotted as a histogram since the coordinate in the dataset represents bin edges, in contrast to the 1D data plotted in 1-D datasets and tables.

Operations automatically broadcast based on dimension labels. That is, if one of the operands lacks one (or multiple) dimensions that the other operands have, the operand is considered constant along those dimensions. Its values are implicitly “duplicated” so the shape matches. In contrast to numpy or MATLAB there is no need to keep track of dimension order:

[8]:
d['alice'] -= d['bob']
d['alice'] -= d['alice']['y', 5]
sc.plot(d['alice']['x', 4])

Exercise 1

Remove the X and Z surface layer of the volume, i.e., remove the first and last slice in each of the dimensions 'x' and 'z'.

Solution 1

[9]:
d = d['x', 1:-1]['z', 1:-1].copy()
d
[9]:
Show/Hide data repr Show/Hide attributes
scipp.Dataset (11.23 KB)
    • z: 8
    • y: 10
    • x: 8
    • x
      (x [bin-edge])
      float64
      m
      1.0, 2.0, ..., 8.0, 9.0
      Values:
      array([1., 2., 3., 4., 5., 6., 7., 8., 9.])
    • y
      (y [bin-edge])
      float64
      m
      0.0, 1.0, ..., 9.0, 10.0
      Values:
      array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
    • z
      (z [bin-edge])
      float64
      m
      1.0, 2.0, ..., 8.0, 9.0
      Values:
      array([1., 2., 3., 4., 5., 6., 7., 8., 9.])
    • alice
      (z, y, x)
      float64
      0.74, 0.87, ..., -0.48, 0.33
      σ = 0.47, 0.57, ..., 0.42, 0.53
      Values:
      array([[[ 7.42911563e-01, 8.65354929e-01, 7.48356662e-02, -2.91246703e-02, 3.30171229e-03, 3.70322850e-01, -5.20334707e-01, 1.76310204e-01], [ 2.05572458e-01, 1.96077876e-01, 4.29364227e-01, 1.16130709e-01, 6.61221489e-01, 5.78577879e-01, 2.05833979e-02, 2.76599703e-01], [-4.19917455e-02, 5.37682831e-01, 3.15225996e-01, 3.08307799e-01, 6.13513342e-01, 2.80269661e-01, -4.29768110e-01, 5.60174426e-01], [ 6.68678786e-01, 4.74399314e-01, 4.44391675e-01, -2.38707026e-01, 2.08019976e-01, -1.91345369e-01, -6.45301658e-01, -2.18793612e-03], [ 4.78307619e-01, 9.85144512e-02, 2.20650514e-01, 2.81047247e-01, 9.91085222e-01, 5.56424166e-01, -4.19392457e-02, 8.44027818e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 5.26837687e-01, 4.73732832e-01, 1.49890856e-01, 1.38486543e-01, 4.83890594e-01, -1.24103586e-01, -2.00696240e-01, 6.50145164e-01], [ 7.41704749e-01, 2.42610659e-01, 1.03168061e-01, -2.36608384e-02, 8.40400597e-01, -2.02859432e-01, -5.84926384e-01, 6.75520832e-01], [ 1.54061213e-01, 3.90704277e-01, -2.08818830e-01, -3.12563508e-01, 7.10623647e-01, 1.01481645e-01, -5.44053233e-01, 3.78882791e-01], [ 8.04023011e-01, 7.56067924e-01, 3.79194593e-01, 6.27424125e-02, 3.32363860e-01, 2.55236889e-01, -7.88853178e-01, 4.48141661e-02]], [[-8.23250513e-02, 7.52625375e-01, -5.38675745e-02, 2.08624286e-01, -2.52414219e-01, -4.16519182e-01, 4.75020175e-01, -7.60873207e-02], [-1.68348093e-02, 9.34036384e-01, 4.63146871e-01, 8.29698528e-02, 3.21683306e-02, -1.85824283e-01, 4.17132517e-01, -5.53486819e-01], [ 1.24873573e-01, 2.15415780e-01, 8.41489082e-02, 2.55060094e-01, -1.08248077e-01, -5.53238102e-01, -3.69193078e-01, -5.55924392e-01], [ 3.89258969e-01, 1.92436850e-01, 3.61905067e-01, -2.85138982e-02, 2.05623930e-03, -2.26142235e-01, 4.98993555e-01, 4.53349493e-02], [ 3.03617734e-02, 2.76495711e-01, -1.46538657e-01, -3.36275037e-01, 6.67722761e-01, -3.99600656e-01, -2.09247182e-01, -3.83961179e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 4.03035477e-01, 3.45690272e-01, 3.45811977e-01, -3.58183147e-01, -1.34395952e-02, -3.41143442e-01, 1.26265992e-02, -1.74664263e-01], [ 4.37623186e-01, 1.84766182e-01, -9.81010626e-05, -5.52973186e-01, -3.44511807e-02, 3.48459984e-01, 3.63266052e-01, -6.00809224e-01], [-9.57472621e-03, 9.34014924e-01, -8.91636262e-02, -3.62086083e-02, 5.37018980e-01, -4.42574314e-01, -1.75829676e-01, -2.19648313e-01], [ 9.72592416e-02, 8.67532145e-01, 3.30940929e-01, -3.64190680e-02, 4.50282586e-01, -4.37601414e-01, -1.46459081e-01, -1.97825573e-01]], [[ 2.11950184e-02, 1.04612264e-02, -3.67697641e-01, -6.66229595e-01, -1.16751952e-01, -6.33656407e-01, 8.53621894e-03, -2.46597779e-01], [-5.66171938e-02, -3.84928032e-01, -8.24440906e-01, -2.59632703e-01, 4.20238648e-01, -7.97635002e-01, -3.75507233e-01, -4.62030580e-01], [-6.92645403e-02, -7.01875901e-02, -1.79650668e-02, -2.07176539e-01, -7.66101702e-03, -3.18487840e-01, -4.26565638e-01, -8.98309516e-01], [ 4.42662692e-01, -3.19298481e-01, -1.88711000e-01, -6.58114167e-01, 4.91974992e-02, -6.09259130e-01, 1.50147393e-01, -5.24026080e-01], [-3.22210394e-01, 3.65741683e-02, -3.63366139e-01, -4.29945373e-01, 1.47750095e-02, 6.42421036e-02, -3.73663242e-01, -3.24746016e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 4.36773528e-01, -1.55232550e-02, -5.83824012e-01, -1.22710238e-01, 5.22079034e-01, -8.22655509e-01, 6.23004769e-02, -4.53187176e-02], [ 5.80084795e-03, 2.89871933e-01, -3.85581108e-01, -1.30867966e-01, 8.37811655e-01, -4.08130398e-01, 7.59831992e-02, -5.68765438e-01], [ 1.30603907e-01, 3.94695673e-01, -4.48294896e-01, -6.66084402e-01, 7.23852347e-01, -5.96655771e-01, -1.06130199e-01, -3.09483972e-01], [ 4.05962668e-02, -2.36336650e-01, -9.57542507e-02, -6.55267914e-01, -9.52060020e-02, -1.39077335e-01, -5.17909205e-01, -3.58806025e-01]], [[-1.35180325e-01, -2.20724774e-02, -9.45568259e-01, -9.42287001e-01, 8.84356898e-01, 9.12927373e-01, -7.81451451e-01, 2.24975844e-01], [ 2.25575373e-01, -3.71797390e-02, -1.77382879e-01, -4.38900994e-01, 4.71617323e-01, 1.67656445e-01, -5.12562295e-01, -2.05607780e-01], [-1.58541359e-01, 1.29127245e-01, -4.06439603e-01, -6.25495467e-01, 3.30022123e-01, 5.97517368e-01, -7.25942928e-01, 1.02151521e-01], [-2.33946832e-02, 9.48372097e-02, -6.19080685e-01, -4.87015892e-01, 6.03404892e-01, 7.51093650e-01, -3.86449343e-01, 1.08770416e-01], [ 1.10391080e-01, -8.15073087e-03, -5.88422111e-01, -3.48808757e-01, 4.62417406e-01, 5.01209903e-01, 2.31157986e-02, -1.25179049e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 3.21925791e-01, -3.73216647e-01, -7.75930239e-01, -8.76569271e-01, 3.02536978e-01, 6.86542277e-02, -3.97196825e-01, 9.26894642e-03], [-4.36629728e-01, 1.74632425e-01, -1.85065550e-02, -6.02643238e-02, 1.92162227e-01, 4.76328063e-01, -3.69309383e-02, 2.94477128e-01], [ 4.46465679e-01, 2.33121832e-01, -6.58801386e-02, -2.17379410e-01, 7.95201278e-01, 7.54115004e-01, -7.43509744e-02, 2.98315121e-02], [ 6.35518128e-02, -2.90555832e-01, -9.40126366e-01, -8.29843355e-01, 7.17058747e-01, 4.73383373e-01, -3.45715436e-01, -4.94624380e-01]], [[ 1.75272065e-02, 3.51062664e-02, -3.01551955e-01, 3.94347272e-01, -2.78338540e-01, 2.09996109e-01, -5.69672001e-01, 3.23063343e-01], [ 3.28250088e-01, 3.54276284e-01, 4.74751717e-01, -3.36701487e-01, 5.23072121e-01, 2.93630179e-01, -1.11595427e-02, 2.98039275e-02], [ 2.73175351e-01, -1.61644421e-02, -1.98270642e-03, -2.46527618e-01, 4.59685154e-01, 5.36825914e-01, 2.09451101e-01, 1.16545721e-01], [-9.31875970e-02, 1.29441494e-01, 2.20772228e-01, -3.06580701e-01, -2.17023834e-01, 7.04478228e-01, -4.94766819e-01, 2.72938249e-01], [ 4.78012660e-01, -3.82617705e-02, 4.65405233e-01, 2.59377037e-01, -1.50044594e-01, 7.88962273e-01, -1.57710030e-02, -6.70727654e-02], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 1.66961348e-01, 2.77962933e-01, 1.77575366e-01, 3.77749913e-01, 6.46363921e-01, 5.65924243e-01, -1.24811718e-01, -6.21174686e-01], [ 3.39653059e-01, -5.18220398e-02, -2.98101761e-01, 5.57387533e-01, 4.65984580e-01, 8.17919655e-02, 7.54013867e-02, -4.82023524e-01], [ 5.69473796e-01, -4.52779834e-01, -3.73388795e-01, -2.55650490e-01, -1.35972545e-01, 7.80157893e-01, -2.12386416e-01, -2.58903399e-01], [ 2.48975644e-02, 4.32708108e-01, 4.73890569e-01, -3.73110114e-01, -1.61762146e-01, 1.41776118e-01, -3.55906160e-01, -1.40108268e-03]], [[-3.72331129e-01, -5.71379267e-01, 5.79083860e-01, -1.20114136e-01, -1.31988707e-01, -4.72548883e-01, -5.81092970e-01, 9.79722115e-02], [-3.10073382e-01, -5.68889215e-01, 1.30162225e-02, -2.01703867e-01, 1.95459370e-01, -1.79217157e-01, -5.25902650e-01, -1.31423039e-02], [-5.73431436e-01, -7.53815246e-01, 7.76772299e-01, 2.56929383e-01, 1.98954635e-01, -5.31480939e-01, -3.25060127e-01, 5.45922063e-01], [-4.51619434e-01, -1.03886195e-01, -1.07044102e-01, 2.90528062e-01, -2.67500338e-01, -6.37028275e-01, 3.16302648e-01, 1.19734396e-01], [-5.20159887e-01, -5.78066545e-01, 3.30196135e-01, -5.11432508e-03, -3.80166549e-01, -4.78891161e-01, 1.30015395e-01, 5.14518751e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [-3.57487657e-01, -7.36913536e-01, 5.72588901e-01, -7.74365562e-02, 2.16393076e-01, 5.02860797e-02, -2.92427683e-01, 7.05426072e-01], [-1.55852972e-02, -3.95777286e-01, 4.19448501e-01, 6.73404615e-01, -2.46857843e-02, -2.90627141e-01, 1.68100639e-01, 1.68954472e-01], [ 2.02774029e-01, -6.52505236e-01, 9.71293777e-02, 8.67304370e-02, -5.51715920e-01, -5.55145869e-01, -4.95759310e-01, 6.77374089e-02], [ 2.33157027e-01, -4.93907052e-01, 1.81512776e-01, 2.07513217e-01, -4.26057578e-02, -5.62061921e-01, -1.00369436e-01, 5.46575244e-01]], [[ 6.84561100e-02, 9.64432843e-02, 3.23333382e-01, 9.23798011e-02, -8.35537069e-02, 1.32034011e-01, -4.29883598e-01, -2.86314779e-01], [ 4.23779349e-01, -1.12937723e-01, 2.87893623e-01, -5.59929683e-01, -3.84030333e-02, -5.88864141e-01, 9.66757572e-02, -3.04800302e-01], [-1.39431257e-01, 1.42669117e-01, 2.58525379e-01, -4.04937788e-02, -2.15453710e-02, -3.67960028e-01, 2.36931196e-01, -3.54194384e-01], [ 3.83662626e-01, -3.79300579e-01, 3.84578484e-01, 1.34084732e-02, -2.11353625e-01, -2.06686514e-01, -1.72361313e-01, 4.90908244e-01], [-1.11405093e-02, -4.57008219e-01, 3.97067550e-01, -4.99699506e-01, 3.74699907e-01, -3.61908265e-01, -6.22542817e-02, -2.81349204e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [-1.21857572e-01, -6.25899802e-01, -3.97772859e-01, 2.22532633e-01, 4.90023355e-01, -3.18760524e-03, -4.14020956e-01, 2.96403777e-01], [-9.50117604e-03, 1.20573766e-01, -1.28093959e-01, -5.72354109e-01, 6.11312468e-01, -6.31840853e-01, -3.43683793e-01, 3.60055502e-02], [-2.63180351e-01, -4.07346526e-01, 3.13350951e-01, -5.92011134e-01, 3.04790172e-01, -4.54293768e-01, 3.25740701e-01, 1.08545313e-01], [ 4.57775497e-02, -5.33965591e-01, -3.10469910e-01, -3.30099940e-01, 2.51928590e-01, 5.12192001e-02, -4.83033895e-01, -3.64221024e-01]], [[ 2.52491097e-01, 5.78116875e-01, 4.99581734e-01, -4.03409719e-02, 2.14143621e-01, 5.30298364e-01, -1.94125021e-01, 9.22163366e-01], [-4.55014964e-01, 5.58823328e-01, 8.72516645e-01, 3.39805314e-01, -3.29873192e-02, 3.55604677e-01, -9.94287784e-02, 8.43219783e-01], [-4.90269943e-01, 8.36337987e-01, 8.85784216e-01, -2.03920432e-01, -3.28281319e-02, 8.44576626e-01, 5.83289082e-02, 3.39154039e-01], [-2.09266071e-01, 4.13974473e-01, 1.96737853e-01, -2.08688839e-01, -2.54072816e-01, 5.26132894e-01, -3.63520845e-01, 3.02616865e-01], [ 3.65978273e-02, 2.25889448e-01, 7.68419172e-02, 3.19873730e-01, 4.71204529e-01, 2.80590094e-01, -6.74208173e-01, 6.43325890e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [-5.61536652e-01, 2.33491819e-01, 9.01241314e-01, 2.88808962e-01, 2.95633282e-01, 8.81573656e-01, -2.50240789e-01, 1.26078737e-01], [ 3.01235541e-01, 5.09562486e-01, 7.54749124e-01, -4.90089210e-01, -3.63613658e-01, 4.88559242e-01, -9.07428416e-01, 9.59929900e-01], [ 1.55680729e-01, 1.38556686e-01, 9.18910784e-02, -3.62932471e-01, 2.81329728e-01, 8.81990076e-01, -2.47476130e-01, 7.38521634e-02], [ 2.54708345e-01, 2.94159426e-01, 8.67016374e-01, -2.99556739e-01, -2.54713457e-01, 2.92079983e-01, -4.79307949e-01, 3.31243707e-01]]])

      Variances (σ²):
      array([[[0.22029233, 0.33056987, 0.21882023, 0.27534545, 0.23810478, 0.17481264, 0.07278902, 0.21649333], [0.22206581, 0.37104032, 0.20000419, 0.29357961, 0.21339582, 0.09935896, 0.10937035, 0.27463695], [0.226687 , 0.32352203, 0.18389623, 0.26751332, 0.17385365, 0.14530587, 0.05210505, 0.26365145], [0.28523674, 0.35310584, 0.24048197, 0.29061225, 0.16695403, 0.10777746, 0.03618896, 0.2806557 ], [0.26397365, 0.27487738, 0.25676913, 0.29288093, 0.22862861, 0.10999731, 0.11744887, 0.27992764], [0.30391528, 0.36846026, 0.20252816, 0.35723565, 0.20491587, 0.10018598, 0.05544936, 0.25604073], [0.26722172, 0.35898402, 0.26148545, 0.2985118 , 0.19985269, 0.13252468, 0.10830909, 0.22114931], [0.29108474, 0.32094498, 0.18961594, 0.27032268, 0.17333843, 0.1047629 , 0.11418519, 0.239829 ], [0.31422503, 0.29643224, 0.19417472, 0.28915523, 0.23672783, 0.15624242, 0.11577747, 0.2368385 ], [0.23680123, 0.35459413, 0.23084846, 0.26671211, 0.15560027, 0.10194126, 0.11600907, 0.22947712]], [[0.0511103 , 0.24572155, 0.12006171, 0.20390261, 0.2226663 , 0.1626238 , 0.26942076, 0.14808197], [0.13005158, 0.22999006, 0.13451869, 0.16482574, 0.25222843, 0.14313486, 0.23032507, 0.14902637], [0.12745471, 0.18497298, 0.15906235, 0.1888647 , 0.24115939, 0.11275719, 0.25414886, 0.0731105 ], [0.12601598, 0.25560502, 0.08704412, 0.15681372, 0.2021867 , 0.16128907, 0.19357337, 0.15346306], [0.0619913 , 0.17393745, 0.07991038, 0.16295132, 0.20320963, 0.14464091, 0.23358263, 0.07464144], [0.0708517 , 0.25531529, 0.1193116 , 0.20889078, 0.26283769, 0.09173596, 0.20041644, 0.10809121], [0.10021336, 0.20978477, 0.15611492, 0.16913276, 0.24799163, 0.08905278, 0.22353916, 0.11399321], [0.07135063, 0.24844514, 0.12674606, 0.23398371, 0.28581639, 0.11709928, 0.28264802, 0.07973832], [0.09339695, 0.21447012, 0.13669658, 0.23069904, 0.21212671, 0.10942835, 0.27049048, 0.09870812], [0.05516802, 0.21917338, 0.10613532, 0.22223192, 0.25778777, 0.15758151, 0.21740074, 0.0843013 ]], [[0.30849091, 0.23330458, 0.16997125, 0.1071185 , 0.23166742, 0.20014574, 0.12410585, 0.11827746], [0.33680729, 0.25842631, 0.23165191, 0.15084176, 0.23810221, 0.2383638 , 0.11066269, 0.15461247], [0.27828047, 0.20401053, 0.19277979, 0.13600647, 0.23344703, 0.22284164, 0.12009511, 0.09669843], [0.34954781, 0.23402483, 0.21642843, 0.08714824, 0.31466779, 0.21962578, 0.16735949, 0.06164271], [0.32767808, 0.23695121, 0.18127093, 0.11700349, 0.32857415, 0.24753143, 0.11494903, 0.13291507], [0.33496986, 0.28481115, 0.2092368 , 0.16348406, 0.32015838, 0.22200668, 0.11371049, 0.10282534], [0.31835098, 0.22166006, 0.23021351, 0.16025982, 0.26692913, 0.16825361, 0.14761467, 0.12005348], [0.30070397, 0.2194911 , 0.21033615, 0.08897109, 0.29783855, 0.25129496, 0.18123352, 0.13768897], [0.32283698, 0.25745887, 0.23202588, 0.1450651 , 0.30860211, 0.22414642, 0.11714703, 0.14032064], [0.31246778, 0.20736057, 0.17432316, 0.12762723, 0.25416376, 0.15799532, 0.1223717 , 0.06738222]], [[0.18004142, 0.14580506, 0.16639987, 0.21719836, 0.22297063, 0.13101712, 0.1289905 , 0.20938848], [0.24515299, 0.20682121, 0.10123501, 0.18826108, 0.20181422, 0.15371723, 0.09413382, 0.17519834], [0.20541133, 0.21640262, 0.19399647, 0.16820708, 0.21894082, 0.16584797, 0.10832558, 0.22626067], [0.2523432 , 0.20632305, 0.11612467, 0.22624443, 0.17980648, 0.13907693, 0.13053876, 0.19209337], [0.1716256 , 0.19566638, 0.18139037, 0.16707218, 0.21400263, 0.17582318, 0.18254792, 0.20596859], [0.22542403, 0.2067764 , 0.10138261, 0.2062005 , 0.22487764, 0.12700533, 0.14322424, 0.17140938], [0.20556436, 0.17773439, 0.10691559, 0.16570827, 0.17113448, 0.09471899, 0.11343576, 0.18377506], [0.22005509, 0.21052945, 0.16784296, 0.20675199, 0.17016141, 0.18047071, 0.08879528, 0.20598694], [0.21505797, 0.16475902, 0.0982065 , 0.21691947, 0.18332115, 0.08739152, 0.11756119, 0.17766512], [0.20481367, 0.22586009, 0.19255025, 0.21662872, 0.21189864, 0.13554748, 0.12949777, 0.2055436 ]], [[0.20539239, 0.28205874, 0.33550888, 0.20533722, 0.19857878, 0.14051881, 0.22306766, 0.23915256], [0.19696137, 0.26264523, 0.29729479, 0.18681535, 0.20206615, 0.16503687, 0.18435153, 0.23534511], [0.14153388, 0.34014426, 0.32725128, 0.18411417, 0.26255892, 0.12835823, 0.23496452, 0.24254209], [0.13676021, 0.27690527, 0.27898006, 0.20180196, 0.27630387, 0.09286626, 0.17891601, 0.14910004], [0.11712813, 0.27257823, 0.30146819, 0.20993681, 0.25611934, 0.17352399, 0.20965578, 0.23286629], [0.15109114, 0.32346757, 0.36801157, 0.24841553, 0.20517989, 0.09699296, 0.16306018, 0.18376737], [0.12121168, 0.28238914, 0.34483349, 0.15759161, 0.24124903, 0.15497774, 0.16114874, 0.15558042], [0.14564353, 0.26782671, 0.33996463, 0.1605891 , 0.18615909, 0.11956141, 0.18969918, 0.14487368], [0.11545988, 0.28147819, 0.29625315, 0.19114424, 0.26120291, 0.16921236, 0.15027601, 0.23034293], [0.17667226, 0.26628186, 0.28420296, 0.1980066 , 0.22185364, 0.15321432, 0.18211689, 0.23709972]], [[0.10327971, 0.25306553, 0.12819868, 0.24771724, 0.25101848, 0.36731532, 0.27628195, 0.0506571 ], [0.10451365, 0.21957362, 0.18498514, 0.27298421, 0.30923148, 0.37734542, 0.27593657, 0.12225396], [0.14033174, 0.28589175, 0.09508308, 0.25194877, 0.29512637, 0.32030772, 0.25284958, 0.08035604], [0.09826556, 0.28742853, 0.17507938, 0.25089835, 0.2876048 , 0.37608886, 0.32329938, 0.08988122], [0.06940014, 0.29183767, 0.11566866, 0.21039581, 0.29336084, 0.34781366, 0.26308024, 0.08122488], [0.07658658, 0.25702099, 0.10895024, 0.26199494, 0.25428033, 0.37384224, 0.31167371, 0.05976879], [0.09920518, 0.2493079 , 0.14439906, 0.2371173 , 0.27223978, 0.33102089, 0.3079501 , 0.08993579], [0.1074625 , 0.240526 , 0.17292584, 0.21914932, 0.24236762, 0.36948366, 0.33119073, 0.07422232], [0.13370622, 0.23274578, 0.18382604, 0.2084052 , 0.32252292, 0.37864581, 0.3435617 , 0.0900244 ], [0.07982251, 0.25403963, 0.17736588, 0.23647892, 0.26235072, 0.33704832, 0.26088157, 0.13313348]], [[0.24891963, 0.19975842, 0.12289112, 0.27356712, 0.27741065, 0.19617387, 0.21042201, 0.27681534], [0.21738355, 0.12845506, 0.16054556, 0.31081169, 0.20168136, 0.18185829, 0.26386202, 0.25283593], [0.25982249, 0.15089454, 0.16422439, 0.2498863 , 0.20743051, 0.22542331, 0.27143403, 0.21694101], [0.21726485, 0.14988698, 0.17176404, 0.30419842, 0.23442037, 0.20317645, 0.27365831, 0.27021404], [0.26532019, 0.15726821, 0.12423788, 0.30486904, 0.21315037, 0.21488151, 0.28279625, 0.26647577], [0.2911925 , 0.19194412, 0.20478419, 0.31868912, 0.24318568, 0.17220147, 0.21998314, 0.25754889], [0.29400579, 0.21467163, 0.1473733 , 0.32713863, 0.23548796, 0.24988185, 0.26945916, 0.28639743], [0.30048796, 0.20353093, 0.16532984, 0.28995816, 0.21965954, 0.16278392, 0.28778164, 0.22742186], [0.28539058, 0.17071142, 0.15856928, 0.26848666, 0.25575759, 0.19960504, 0.2118362 , 0.23364571], [0.20643984, 0.17947336, 0.16508513, 0.25270257, 0.27621252, 0.2240226 , 0.2037063 , 0.25020375]], [[0.23261527, 0.18662748, 0.08100493, 0.31445283, 0.16012511, 0.13852058, 0.17438343, 0.18231714], [0.26694817, 0.15059439, 0.13231659, 0.3520375 , 0.174752 , 0.09635156, 0.13696121, 0.24728837], [0.23527348, 0.14419704, 0.14995081, 0.3103115 , 0.15572779, 0.13492669, 0.21869329, 0.27528928], [0.24723156, 0.15916776, 0.10141048, 0.29101964, 0.13065051, 0.11870802, 0.12500634, 0.2448043 ], [0.28965121, 0.10266437, 0.0823158 , 0.33117265, 0.15855536, 0.1016508 , 0.20235334, 0.20114469], [0.29640498, 0.13130316, 0.07491802, 0.36342904, 0.13279223, 0.11895891, 0.18340673, 0.26220336], [0.29137435, 0.16306249, 0.07244575, 0.29476293, 0.1637308 , 0.10672388, 0.17821235, 0.248449 ], [0.29427209, 0.1113048 , 0.07138731, 0.28845192, 0.19665626, 0.10098841, 0.13042452, 0.18228938], [0.28759778, 0.12525974, 0.06049158, 0.31533722, 0.18981187, 0.13915605, 0.16184192, 0.25333004], [0.29962789, 0.11049239, 0.14315367, 0.33955115, 0.20577204, 0.10158982, 0.17498718, 0.27809072]]])
    • bob
      (x, z)
      float64
      1.1, 1.2, ..., 8.7, 8.8
      σ = 0.25, 0.12, ..., 0.25, 0.22
      Values:
      array([[1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8], [2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8], [3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8], [4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8], [5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8], [6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8], [7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8], [8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8]])

      Variances (σ²):
      array([[0.06411376, 0.01526064, 0.09106409, 0.04974322, 0.03460254, 0.02156921, 0.05617922, 0.05844132], [0.08755593, 0.04528562, 0.0571194 , 0.03284097, 0.088008 , 0.069877 , 0.02383418, 0.0310831 ], [0.0818573 , 0.00046819, 0.03756468, 0.04377433, 0.09468626, 0.03767971, 0.01538852, 0.02032383], [0.08018377, 0.03848552, 0.00119523, 0.04999321, 0.02594306, 0.06336386, 0.06903054, 0.09090613], [0.03963399, 0.06973565, 0.07034654, 0.01864558, 0.08147588, 0.09582292, 0.05928961, 0.06099661], [0.048059 , 0.04181376, 0.04525737, 0.02369891, 0.02918095, 0.09618988, 0.06822642, 0.01892642], [0.00759153, 0.08855607, 0.05303084, 0.01427409, 0.0675504 , 0.08864342, 0.08278652, 0.03017619], [0.06409611, 0.01527976, 0.00344253, 0.06329733, 0.05110938, 0.01741153, 0.06138777, 0.04754124]])

Note the important call to copy(). If we omit it, d will just be a multi-dimensional slice of the larger volume (which is kept alive), wasting memory and preventing further modification, such as insertion of other variables.

Note also that if we had also sliced 'y' the result would not contain the data for 'bob' since this item does not depend on Y.

More advanced operations with multi-dimensional datasets

Operations like concatenate and merge work just like with one-dimensional datasets.

Exercise 2

  • Try to concatenate the dataset with itself along the X dimensions. Why does this fail?

  • Make a copy of the dataset, add an offset to the X coordinate to fix the issue, and try to concatenate again.

Solution 2

[10]:
try:
    d = sc.concatenate(d, d, 'x')
except RuntimeError:
    print("Failed as expected!")
Failed as expected!

With a data extent of, e.g. 8 in this case, bin edges have extent 9. Naive concatenation would thus lead a new data extent of 16 and a coordinate extent of 18, which is meaningless and thus prevented. In this concatenate merges the last edge of the first input with the first edge of the second input, if compatible.

[11]:
offset = d.copy()
offset.coords['x'] += sc.scalar(8.0, unit=sc.units.m)
combined = sc.concatenate(d, offset, 'x')
sc.plot(combined['alice'])

Another available operation is rebin. This is only for count-data or count-density-data, so we have to set an appropriate unit first:

[12]:
d['alice'].unit = sc.units.counts
d['bob'].unit = sc.units.counts

Before rebin we have the following:

[13]:
sc.to_html(d)
sc.plot(d['z', 0])
Show/Hide data repr Show/Hide attributes
scipp.Dataset (11.23 KB)
    • z: 8
    • y: 10
    • x: 8
    • x
      (x [bin-edge])
      float64
      m
      1.0, 2.0, ..., 8.0, 9.0
      Values:
      array([1., 2., 3., 4., 5., 6., 7., 8., 9.])
    • y
      (y [bin-edge])
      float64
      m
      0.0, 1.0, ..., 9.0, 10.0
      Values:
      array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
    • z
      (z [bin-edge])
      float64
      m
      1.0, 2.0, ..., 8.0, 9.0
      Values:
      array([1., 2., 3., 4., 5., 6., 7., 8., 9.])
    • alice
      (z, y, x)
      float64
      counts
      0.74, 0.87, ..., -0.48, 0.33
      σ = 0.47, 0.57, ..., 0.42, 0.53
      Values:
      array([[[ 7.42911563e-01, 8.65354929e-01, 7.48356662e-02, -2.91246703e-02, 3.30171229e-03, 3.70322850e-01, -5.20334707e-01, 1.76310204e-01], [ 2.05572458e-01, 1.96077876e-01, 4.29364227e-01, 1.16130709e-01, 6.61221489e-01, 5.78577879e-01, 2.05833979e-02, 2.76599703e-01], [-4.19917455e-02, 5.37682831e-01, 3.15225996e-01, 3.08307799e-01, 6.13513342e-01, 2.80269661e-01, -4.29768110e-01, 5.60174426e-01], [ 6.68678786e-01, 4.74399314e-01, 4.44391675e-01, -2.38707026e-01, 2.08019976e-01, -1.91345369e-01, -6.45301658e-01, -2.18793612e-03], [ 4.78307619e-01, 9.85144512e-02, 2.20650514e-01, 2.81047247e-01, 9.91085222e-01, 5.56424166e-01, -4.19392457e-02, 8.44027818e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 5.26837687e-01, 4.73732832e-01, 1.49890856e-01, 1.38486543e-01, 4.83890594e-01, -1.24103586e-01, -2.00696240e-01, 6.50145164e-01], [ 7.41704749e-01, 2.42610659e-01, 1.03168061e-01, -2.36608384e-02, 8.40400597e-01, -2.02859432e-01, -5.84926384e-01, 6.75520832e-01], [ 1.54061213e-01, 3.90704277e-01, -2.08818830e-01, -3.12563508e-01, 7.10623647e-01, 1.01481645e-01, -5.44053233e-01, 3.78882791e-01], [ 8.04023011e-01, 7.56067924e-01, 3.79194593e-01, 6.27424125e-02, 3.32363860e-01, 2.55236889e-01, -7.88853178e-01, 4.48141661e-02]], [[-8.23250513e-02, 7.52625375e-01, -5.38675745e-02, 2.08624286e-01, -2.52414219e-01, -4.16519182e-01, 4.75020175e-01, -7.60873207e-02], [-1.68348093e-02, 9.34036384e-01, 4.63146871e-01, 8.29698528e-02, 3.21683306e-02, -1.85824283e-01, 4.17132517e-01, -5.53486819e-01], [ 1.24873573e-01, 2.15415780e-01, 8.41489082e-02, 2.55060094e-01, -1.08248077e-01, -5.53238102e-01, -3.69193078e-01, -5.55924392e-01], [ 3.89258969e-01, 1.92436850e-01, 3.61905067e-01, -2.85138982e-02, 2.05623930e-03, -2.26142235e-01, 4.98993555e-01, 4.53349493e-02], [ 3.03617734e-02, 2.76495711e-01, -1.46538657e-01, -3.36275037e-01, 6.67722761e-01, -3.99600656e-01, -2.09247182e-01, -3.83961179e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 4.03035477e-01, 3.45690272e-01, 3.45811977e-01, -3.58183147e-01, -1.34395952e-02, -3.41143442e-01, 1.26265992e-02, -1.74664263e-01], [ 4.37623186e-01, 1.84766182e-01, -9.81010626e-05, -5.52973186e-01, -3.44511807e-02, 3.48459984e-01, 3.63266052e-01, -6.00809224e-01], [-9.57472621e-03, 9.34014924e-01, -8.91636262e-02, -3.62086083e-02, 5.37018980e-01, -4.42574314e-01, -1.75829676e-01, -2.19648313e-01], [ 9.72592416e-02, 8.67532145e-01, 3.30940929e-01, -3.64190680e-02, 4.50282586e-01, -4.37601414e-01, -1.46459081e-01, -1.97825573e-01]], [[ 2.11950184e-02, 1.04612264e-02, -3.67697641e-01, -6.66229595e-01, -1.16751952e-01, -6.33656407e-01, 8.53621894e-03, -2.46597779e-01], [-5.66171938e-02, -3.84928032e-01, -8.24440906e-01, -2.59632703e-01, 4.20238648e-01, -7.97635002e-01, -3.75507233e-01, -4.62030580e-01], [-6.92645403e-02, -7.01875901e-02, -1.79650668e-02, -2.07176539e-01, -7.66101702e-03, -3.18487840e-01, -4.26565638e-01, -8.98309516e-01], [ 4.42662692e-01, -3.19298481e-01, -1.88711000e-01, -6.58114167e-01, 4.91974992e-02, -6.09259130e-01, 1.50147393e-01, -5.24026080e-01], [-3.22210394e-01, 3.65741683e-02, -3.63366139e-01, -4.29945373e-01, 1.47750095e-02, 6.42421036e-02, -3.73663242e-01, -3.24746016e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 4.36773528e-01, -1.55232550e-02, -5.83824012e-01, -1.22710238e-01, 5.22079034e-01, -8.22655509e-01, 6.23004769e-02, -4.53187176e-02], [ 5.80084795e-03, 2.89871933e-01, -3.85581108e-01, -1.30867966e-01, 8.37811655e-01, -4.08130398e-01, 7.59831992e-02, -5.68765438e-01], [ 1.30603907e-01, 3.94695673e-01, -4.48294896e-01, -6.66084402e-01, 7.23852347e-01, -5.96655771e-01, -1.06130199e-01, -3.09483972e-01], [ 4.05962668e-02, -2.36336650e-01, -9.57542507e-02, -6.55267914e-01, -9.52060020e-02, -1.39077335e-01, -5.17909205e-01, -3.58806025e-01]], [[-1.35180325e-01, -2.20724774e-02, -9.45568259e-01, -9.42287001e-01, 8.84356898e-01, 9.12927373e-01, -7.81451451e-01, 2.24975844e-01], [ 2.25575373e-01, -3.71797390e-02, -1.77382879e-01, -4.38900994e-01, 4.71617323e-01, 1.67656445e-01, -5.12562295e-01, -2.05607780e-01], [-1.58541359e-01, 1.29127245e-01, -4.06439603e-01, -6.25495467e-01, 3.30022123e-01, 5.97517368e-01, -7.25942928e-01, 1.02151521e-01], [-2.33946832e-02, 9.48372097e-02, -6.19080685e-01, -4.87015892e-01, 6.03404892e-01, 7.51093650e-01, -3.86449343e-01, 1.08770416e-01], [ 1.10391080e-01, -8.15073087e-03, -5.88422111e-01, -3.48808757e-01, 4.62417406e-01, 5.01209903e-01, 2.31157986e-02, -1.25179049e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 3.21925791e-01, -3.73216647e-01, -7.75930239e-01, -8.76569271e-01, 3.02536978e-01, 6.86542277e-02, -3.97196825e-01, 9.26894642e-03], [-4.36629728e-01, 1.74632425e-01, -1.85065550e-02, -6.02643238e-02, 1.92162227e-01, 4.76328063e-01, -3.69309383e-02, 2.94477128e-01], [ 4.46465679e-01, 2.33121832e-01, -6.58801386e-02, -2.17379410e-01, 7.95201278e-01, 7.54115004e-01, -7.43509744e-02, 2.98315121e-02], [ 6.35518128e-02, -2.90555832e-01, -9.40126366e-01, -8.29843355e-01, 7.17058747e-01, 4.73383373e-01, -3.45715436e-01, -4.94624380e-01]], [[ 1.75272065e-02, 3.51062664e-02, -3.01551955e-01, 3.94347272e-01, -2.78338540e-01, 2.09996109e-01, -5.69672001e-01, 3.23063343e-01], [ 3.28250088e-01, 3.54276284e-01, 4.74751717e-01, -3.36701487e-01, 5.23072121e-01, 2.93630179e-01, -1.11595427e-02, 2.98039275e-02], [ 2.73175351e-01, -1.61644421e-02, -1.98270642e-03, -2.46527618e-01, 4.59685154e-01, 5.36825914e-01, 2.09451101e-01, 1.16545721e-01], [-9.31875970e-02, 1.29441494e-01, 2.20772228e-01, -3.06580701e-01, -2.17023834e-01, 7.04478228e-01, -4.94766819e-01, 2.72938249e-01], [ 4.78012660e-01, -3.82617705e-02, 4.65405233e-01, 2.59377037e-01, -1.50044594e-01, 7.88962273e-01, -1.57710030e-02, -6.70727654e-02], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [ 1.66961348e-01, 2.77962933e-01, 1.77575366e-01, 3.77749913e-01, 6.46363921e-01, 5.65924243e-01, -1.24811718e-01, -6.21174686e-01], [ 3.39653059e-01, -5.18220398e-02, -2.98101761e-01, 5.57387533e-01, 4.65984580e-01, 8.17919655e-02, 7.54013867e-02, -4.82023524e-01], [ 5.69473796e-01, -4.52779834e-01, -3.73388795e-01, -2.55650490e-01, -1.35972545e-01, 7.80157893e-01, -2.12386416e-01, -2.58903399e-01], [ 2.48975644e-02, 4.32708108e-01, 4.73890569e-01, -3.73110114e-01, -1.61762146e-01, 1.41776118e-01, -3.55906160e-01, -1.40108268e-03]], [[-3.72331129e-01, -5.71379267e-01, 5.79083860e-01, -1.20114136e-01, -1.31988707e-01, -4.72548883e-01, -5.81092970e-01, 9.79722115e-02], [-3.10073382e-01, -5.68889215e-01, 1.30162225e-02, -2.01703867e-01, 1.95459370e-01, -1.79217157e-01, -5.25902650e-01, -1.31423039e-02], [-5.73431436e-01, -7.53815246e-01, 7.76772299e-01, 2.56929383e-01, 1.98954635e-01, -5.31480939e-01, -3.25060127e-01, 5.45922063e-01], [-4.51619434e-01, -1.03886195e-01, -1.07044102e-01, 2.90528062e-01, -2.67500338e-01, -6.37028275e-01, 3.16302648e-01, 1.19734396e-01], [-5.20159887e-01, -5.78066545e-01, 3.30196135e-01, -5.11432508e-03, -3.80166549e-01, -4.78891161e-01, 1.30015395e-01, 5.14518751e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [-3.57487657e-01, -7.36913536e-01, 5.72588901e-01, -7.74365562e-02, 2.16393076e-01, 5.02860797e-02, -2.92427683e-01, 7.05426072e-01], [-1.55852972e-02, -3.95777286e-01, 4.19448501e-01, 6.73404615e-01, -2.46857843e-02, -2.90627141e-01, 1.68100639e-01, 1.68954472e-01], [ 2.02774029e-01, -6.52505236e-01, 9.71293777e-02, 8.67304370e-02, -5.51715920e-01, -5.55145869e-01, -4.95759310e-01, 6.77374089e-02], [ 2.33157027e-01, -4.93907052e-01, 1.81512776e-01, 2.07513217e-01, -4.26057578e-02, -5.62061921e-01, -1.00369436e-01, 5.46575244e-01]], [[ 6.84561100e-02, 9.64432843e-02, 3.23333382e-01, 9.23798011e-02, -8.35537069e-02, 1.32034011e-01, -4.29883598e-01, -2.86314779e-01], [ 4.23779349e-01, -1.12937723e-01, 2.87893623e-01, -5.59929683e-01, -3.84030333e-02, -5.88864141e-01, 9.66757572e-02, -3.04800302e-01], [-1.39431257e-01, 1.42669117e-01, 2.58525379e-01, -4.04937788e-02, -2.15453710e-02, -3.67960028e-01, 2.36931196e-01, -3.54194384e-01], [ 3.83662626e-01, -3.79300579e-01, 3.84578484e-01, 1.34084732e-02, -2.11353625e-01, -2.06686514e-01, -1.72361313e-01, 4.90908244e-01], [-1.11405093e-02, -4.57008219e-01, 3.97067550e-01, -4.99699506e-01, 3.74699907e-01, -3.61908265e-01, -6.22542817e-02, -2.81349204e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [-1.21857572e-01, -6.25899802e-01, -3.97772859e-01, 2.22532633e-01, 4.90023355e-01, -3.18760524e-03, -4.14020956e-01, 2.96403777e-01], [-9.50117604e-03, 1.20573766e-01, -1.28093959e-01, -5.72354109e-01, 6.11312468e-01, -6.31840853e-01, -3.43683793e-01, 3.60055502e-02], [-2.63180351e-01, -4.07346526e-01, 3.13350951e-01, -5.92011134e-01, 3.04790172e-01, -4.54293768e-01, 3.25740701e-01, 1.08545313e-01], [ 4.57775497e-02, -5.33965591e-01, -3.10469910e-01, -3.30099940e-01, 2.51928590e-01, 5.12192001e-02, -4.83033895e-01, -3.64221024e-01]], [[ 2.52491097e-01, 5.78116875e-01, 4.99581734e-01, -4.03409719e-02, 2.14143621e-01, 5.30298364e-01, -1.94125021e-01, 9.22163366e-01], [-4.55014964e-01, 5.58823328e-01, 8.72516645e-01, 3.39805314e-01, -3.29873192e-02, 3.55604677e-01, -9.94287784e-02, 8.43219783e-01], [-4.90269943e-01, 8.36337987e-01, 8.85784216e-01, -2.03920432e-01, -3.28281319e-02, 8.44576626e-01, 5.83289082e-02, 3.39154039e-01], [-2.09266071e-01, 4.13974473e-01, 1.96737853e-01, -2.08688839e-01, -2.54072816e-01, 5.26132894e-01, -3.63520845e-01, 3.02616865e-01], [ 3.65978273e-02, 2.25889448e-01, 7.68419172e-02, 3.19873730e-01, 4.71204529e-01, 2.80590094e-01, -6.74208173e-01, 6.43325890e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [-5.61536652e-01, 2.33491819e-01, 9.01241314e-01, 2.88808962e-01, 2.95633282e-01, 8.81573656e-01, -2.50240789e-01, 1.26078737e-01], [ 3.01235541e-01, 5.09562486e-01, 7.54749124e-01, -4.90089210e-01, -3.63613658e-01, 4.88559242e-01, -9.07428416e-01, 9.59929900e-01], [ 1.55680729e-01, 1.38556686e-01, 9.18910784e-02, -3.62932471e-01, 2.81329728e-01, 8.81990076e-01, -2.47476130e-01, 7.38521634e-02], [ 2.54708345e-01, 2.94159426e-01, 8.67016374e-01, -2.99556739e-01, -2.54713457e-01, 2.92079983e-01, -4.79307949e-01, 3.31243707e-01]]])

      Variances (σ²):
      array([[[0.22029233, 0.33056987, 0.21882023, 0.27534545, 0.23810478, 0.17481264, 0.07278902, 0.21649333], [0.22206581, 0.37104032, 0.20000419, 0.29357961, 0.21339582, 0.09935896, 0.10937035, 0.27463695], [0.226687 , 0.32352203, 0.18389623, 0.26751332, 0.17385365, 0.14530587, 0.05210505, 0.26365145], [0.28523674, 0.35310584, 0.24048197, 0.29061225, 0.16695403, 0.10777746, 0.03618896, 0.2806557 ], [0.26397365, 0.27487738, 0.25676913, 0.29288093, 0.22862861, 0.10999731, 0.11744887, 0.27992764], [0.30391528, 0.36846026, 0.20252816, 0.35723565, 0.20491587, 0.10018598, 0.05544936, 0.25604073], [0.26722172, 0.35898402, 0.26148545, 0.2985118 , 0.19985269, 0.13252468, 0.10830909, 0.22114931], [0.29108474, 0.32094498, 0.18961594, 0.27032268, 0.17333843, 0.1047629 , 0.11418519, 0.239829 ], [0.31422503, 0.29643224, 0.19417472, 0.28915523, 0.23672783, 0.15624242, 0.11577747, 0.2368385 ], [0.23680123, 0.35459413, 0.23084846, 0.26671211, 0.15560027, 0.10194126, 0.11600907, 0.22947712]], [[0.0511103 , 0.24572155, 0.12006171, 0.20390261, 0.2226663 , 0.1626238 , 0.26942076, 0.14808197], [0.13005158, 0.22999006, 0.13451869, 0.16482574, 0.25222843, 0.14313486, 0.23032507, 0.14902637], [0.12745471, 0.18497298, 0.15906235, 0.1888647 , 0.24115939, 0.11275719, 0.25414886, 0.0731105 ], [0.12601598, 0.25560502, 0.08704412, 0.15681372, 0.2021867 , 0.16128907, 0.19357337, 0.15346306], [0.0619913 , 0.17393745, 0.07991038, 0.16295132, 0.20320963, 0.14464091, 0.23358263, 0.07464144], [0.0708517 , 0.25531529, 0.1193116 , 0.20889078, 0.26283769, 0.09173596, 0.20041644, 0.10809121], [0.10021336, 0.20978477, 0.15611492, 0.16913276, 0.24799163, 0.08905278, 0.22353916, 0.11399321], [0.07135063, 0.24844514, 0.12674606, 0.23398371, 0.28581639, 0.11709928, 0.28264802, 0.07973832], [0.09339695, 0.21447012, 0.13669658, 0.23069904, 0.21212671, 0.10942835, 0.27049048, 0.09870812], [0.05516802, 0.21917338, 0.10613532, 0.22223192, 0.25778777, 0.15758151, 0.21740074, 0.0843013 ]], [[0.30849091, 0.23330458, 0.16997125, 0.1071185 , 0.23166742, 0.20014574, 0.12410585, 0.11827746], [0.33680729, 0.25842631, 0.23165191, 0.15084176, 0.23810221, 0.2383638 , 0.11066269, 0.15461247], [0.27828047, 0.20401053, 0.19277979, 0.13600647, 0.23344703, 0.22284164, 0.12009511, 0.09669843], [0.34954781, 0.23402483, 0.21642843, 0.08714824, 0.31466779, 0.21962578, 0.16735949, 0.06164271], [0.32767808, 0.23695121, 0.18127093, 0.11700349, 0.32857415, 0.24753143, 0.11494903, 0.13291507], [0.33496986, 0.28481115, 0.2092368 , 0.16348406, 0.32015838, 0.22200668, 0.11371049, 0.10282534], [0.31835098, 0.22166006, 0.23021351, 0.16025982, 0.26692913, 0.16825361, 0.14761467, 0.12005348], [0.30070397, 0.2194911 , 0.21033615, 0.08897109, 0.29783855, 0.25129496, 0.18123352, 0.13768897], [0.32283698, 0.25745887, 0.23202588, 0.1450651 , 0.30860211, 0.22414642, 0.11714703, 0.14032064], [0.31246778, 0.20736057, 0.17432316, 0.12762723, 0.25416376, 0.15799532, 0.1223717 , 0.06738222]], [[0.18004142, 0.14580506, 0.16639987, 0.21719836, 0.22297063, 0.13101712, 0.1289905 , 0.20938848], [0.24515299, 0.20682121, 0.10123501, 0.18826108, 0.20181422, 0.15371723, 0.09413382, 0.17519834], [0.20541133, 0.21640262, 0.19399647, 0.16820708, 0.21894082, 0.16584797, 0.10832558, 0.22626067], [0.2523432 , 0.20632305, 0.11612467, 0.22624443, 0.17980648, 0.13907693, 0.13053876, 0.19209337], [0.1716256 , 0.19566638, 0.18139037, 0.16707218, 0.21400263, 0.17582318, 0.18254792, 0.20596859], [0.22542403, 0.2067764 , 0.10138261, 0.2062005 , 0.22487764, 0.12700533, 0.14322424, 0.17140938], [0.20556436, 0.17773439, 0.10691559, 0.16570827, 0.17113448, 0.09471899, 0.11343576, 0.18377506], [0.22005509, 0.21052945, 0.16784296, 0.20675199, 0.17016141, 0.18047071, 0.08879528, 0.20598694], [0.21505797, 0.16475902, 0.0982065 , 0.21691947, 0.18332115, 0.08739152, 0.11756119, 0.17766512], [0.20481367, 0.22586009, 0.19255025, 0.21662872, 0.21189864, 0.13554748, 0.12949777, 0.2055436 ]], [[0.20539239, 0.28205874, 0.33550888, 0.20533722, 0.19857878, 0.14051881, 0.22306766, 0.23915256], [0.19696137, 0.26264523, 0.29729479, 0.18681535, 0.20206615, 0.16503687, 0.18435153, 0.23534511], [0.14153388, 0.34014426, 0.32725128, 0.18411417, 0.26255892, 0.12835823, 0.23496452, 0.24254209], [0.13676021, 0.27690527, 0.27898006, 0.20180196, 0.27630387, 0.09286626, 0.17891601, 0.14910004], [0.11712813, 0.27257823, 0.30146819, 0.20993681, 0.25611934, 0.17352399, 0.20965578, 0.23286629], [0.15109114, 0.32346757, 0.36801157, 0.24841553, 0.20517989, 0.09699296, 0.16306018, 0.18376737], [0.12121168, 0.28238914, 0.34483349, 0.15759161, 0.24124903, 0.15497774, 0.16114874, 0.15558042], [0.14564353, 0.26782671, 0.33996463, 0.1605891 , 0.18615909, 0.11956141, 0.18969918, 0.14487368], [0.11545988, 0.28147819, 0.29625315, 0.19114424, 0.26120291, 0.16921236, 0.15027601, 0.23034293], [0.17667226, 0.26628186, 0.28420296, 0.1980066 , 0.22185364, 0.15321432, 0.18211689, 0.23709972]], [[0.10327971, 0.25306553, 0.12819868, 0.24771724, 0.25101848, 0.36731532, 0.27628195, 0.0506571 ], [0.10451365, 0.21957362, 0.18498514, 0.27298421, 0.30923148, 0.37734542, 0.27593657, 0.12225396], [0.14033174, 0.28589175, 0.09508308, 0.25194877, 0.29512637, 0.32030772, 0.25284958, 0.08035604], [0.09826556, 0.28742853, 0.17507938, 0.25089835, 0.2876048 , 0.37608886, 0.32329938, 0.08988122], [0.06940014, 0.29183767, 0.11566866, 0.21039581, 0.29336084, 0.34781366, 0.26308024, 0.08122488], [0.07658658, 0.25702099, 0.10895024, 0.26199494, 0.25428033, 0.37384224, 0.31167371, 0.05976879], [0.09920518, 0.2493079 , 0.14439906, 0.2371173 , 0.27223978, 0.33102089, 0.3079501 , 0.08993579], [0.1074625 , 0.240526 , 0.17292584, 0.21914932, 0.24236762, 0.36948366, 0.33119073, 0.07422232], [0.13370622, 0.23274578, 0.18382604, 0.2084052 , 0.32252292, 0.37864581, 0.3435617 , 0.0900244 ], [0.07982251, 0.25403963, 0.17736588, 0.23647892, 0.26235072, 0.33704832, 0.26088157, 0.13313348]], [[0.24891963, 0.19975842, 0.12289112, 0.27356712, 0.27741065, 0.19617387, 0.21042201, 0.27681534], [0.21738355, 0.12845506, 0.16054556, 0.31081169, 0.20168136, 0.18185829, 0.26386202, 0.25283593], [0.25982249, 0.15089454, 0.16422439, 0.2498863 , 0.20743051, 0.22542331, 0.27143403, 0.21694101], [0.21726485, 0.14988698, 0.17176404, 0.30419842, 0.23442037, 0.20317645, 0.27365831, 0.27021404], [0.26532019, 0.15726821, 0.12423788, 0.30486904, 0.21315037, 0.21488151, 0.28279625, 0.26647577], [0.2911925 , 0.19194412, 0.20478419, 0.31868912, 0.24318568, 0.17220147, 0.21998314, 0.25754889], [0.29400579, 0.21467163, 0.1473733 , 0.32713863, 0.23548796, 0.24988185, 0.26945916, 0.28639743], [0.30048796, 0.20353093, 0.16532984, 0.28995816, 0.21965954, 0.16278392, 0.28778164, 0.22742186], [0.28539058, 0.17071142, 0.15856928, 0.26848666, 0.25575759, 0.19960504, 0.2118362 , 0.23364571], [0.20643984, 0.17947336, 0.16508513, 0.25270257, 0.27621252, 0.2240226 , 0.2037063 , 0.25020375]], [[0.23261527, 0.18662748, 0.08100493, 0.31445283, 0.16012511, 0.13852058, 0.17438343, 0.18231714], [0.26694817, 0.15059439, 0.13231659, 0.3520375 , 0.174752 , 0.09635156, 0.13696121, 0.24728837], [0.23527348, 0.14419704, 0.14995081, 0.3103115 , 0.15572779, 0.13492669, 0.21869329, 0.27528928], [0.24723156, 0.15916776, 0.10141048, 0.29101964, 0.13065051, 0.11870802, 0.12500634, 0.2448043 ], [0.28965121, 0.10266437, 0.0823158 , 0.33117265, 0.15855536, 0.1016508 , 0.20235334, 0.20114469], [0.29640498, 0.13130316, 0.07491802, 0.36342904, 0.13279223, 0.11895891, 0.18340673, 0.26220336], [0.29137435, 0.16306249, 0.07244575, 0.29476293, 0.1637308 , 0.10672388, 0.17821235, 0.248449 ], [0.29427209, 0.1113048 , 0.07138731, 0.28845192, 0.19665626, 0.10098841, 0.13042452, 0.18228938], [0.28759778, 0.12525974, 0.06049158, 0.31533722, 0.18981187, 0.13915605, 0.16184192, 0.25333004], [0.29962789, 0.11049239, 0.14315367, 0.33955115, 0.20577204, 0.10158982, 0.17498718, 0.27809072]]])
    • bob
      (x, z)
      float64
      counts
      1.1, 1.2, ..., 8.7, 8.8
      σ = 0.25, 0.12, ..., 0.25, 0.22
      Values:
      array([[1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8], [2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8], [3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8], [4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8], [5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8], [6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8], [7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8], [8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8]])

      Variances (σ²):
      array([[0.06411376, 0.01526064, 0.09106409, 0.04974322, 0.03460254, 0.02156921, 0.05617922, 0.05844132], [0.08755593, 0.04528562, 0.0571194 , 0.03284097, 0.088008 , 0.069877 , 0.02383418, 0.0310831 ], [0.0818573 , 0.00046819, 0.03756468, 0.04377433, 0.09468626, 0.03767971, 0.01538852, 0.02032383], [0.08018377, 0.03848552, 0.00119523, 0.04999321, 0.02594306, 0.06336386, 0.06903054, 0.09090613], [0.03963399, 0.06973565, 0.07034654, 0.01864558, 0.08147588, 0.09582292, 0.05928961, 0.06099661], [0.048059 , 0.04181376, 0.04525737, 0.02369891, 0.02918095, 0.09618988, 0.06822642, 0.01892642], [0.00759153, 0.08855607, 0.05303084, 0.01427409, 0.0675504 , 0.08864342, 0.08278652, 0.03017619], [0.06409611, 0.01527976, 0.00344253, 0.06329733, 0.05110938, 0.01741153, 0.06138777, 0.04754124]])

We rebin onto a coarser grid, in this case combining two neightboring bins:

[14]:
new_x = sc.array(dims=['x'], unit=sc.units.m, values=d.coords['x'].values[::2])
d = sc.rebin(d, 'x', new_x)

The result looks as follows:

[15]:
sc.to_html(d)
sc.plot(d['z', 0])
Show/Hide data repr Show/Hide attributes
scipp.Dataset (5.70 KB)
    • z: 8
    • y: 10
    • x: 4
    • x
      (x [bin-edge])
      float64
      m
      1.0, 3.0, 5.0, 7.0, 9.0
      Values:
      array([1., 3., 5., 7., 9.])
    • y
      (y [bin-edge])
      float64
      m
      0.0, 1.0, ..., 9.0, 10.0
      Values:
      array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
    • z
      (z [bin-edge])
      float64
      m
      1.0, 2.0, ..., 8.0, 9.0
      Values:
      array([1., 2., 3., 4., 5., 6., 7., 8., 9.])
    • alice
      (z, y, x)
      float64
      counts
      1.61, 0.05, ..., 0.04, -0.15
      σ = 0.74, 0.7, ..., 0.55, 0.67
      Values:
      array([[[ 1.60826649, 0.045711 , 0.37362456, -0.3440245 ], [ 0.40165033, 0.54549494, 1.23979937, 0.2971831 ], [ 0.49569109, 0.6235338 , 0.893783 , 0.13040632], [ 1.1430781 , 0.20568465, 0.01667461, -0.64748959], [ 0.57682207, 0.50169776, 1.54750939, 0.80208857], [ 0. , 0. , 0. , 0. ], [ 1.00057052, 0.2883774 , 0.35978701, 0.44944892], [ 0.98431541, 0.07950722, 0.63754116, 0.09059445], [ 0.54476549, -0.52138234, 0.81210529, -0.16517044], [ 1.56009093, 0.44193701, 0.58760075, -0.74403901]], [[ 0.67030032, 0.15475671, -0.6689334 , 0.39893285], [ 0.91720158, 0.54611672, -0.15365595, -0.1363543 ], [ 0.34028935, 0.339209 , -0.66148618, -0.92511747], [ 0.58169582, 0.33339117, -0.224086 , 0.5443285 ], [ 0.30685748, -0.48281369, 0.2681221 , -0.59320836], [ 0. , 0. , 0. , 0. ], [ 0.74872575, -0.01237117, -0.35458304, -0.16203766], [ 0.62238937, -0.55307129, 0.3140088 , -0.23754317], [ 0.9244402 , -0.12537223, 0.09444467, -0.39547799], [ 0.96479139, 0.29452186, 0.01268117, -0.34428465]], [[ 0.03165624, -1.03392724, -0.75040836, -0.23806156], [-0.44154523, -1.08407361, -0.37739635, -0.83753781], [-0.13945213, -0.22514161, -0.32614886, -1.32487515], [ 0.12336421, -0.84682517, -0.56006163, -0.37387869], [-0.28563623, -0.79331151, 0.07901711, -0.69840926], [ 0. , 0. , 0. , 0. ], [ 0.42125027, -0.70653425, -0.30057647, 0.01698176], [ 0.29567278, -0.51644907, 0.42968126, -0.49278224], [ 0.52529958, -1.1143793 , 0.12719658, -0.41561417], [-0.19574038, -0.75102216, -0.23428334, -0.87671523]], [[-0.1572528 , -1.88785526, 1.79728427, -0.55647561], [ 0.18839563, -0.61628387, 0.63927377, -0.71817008], [-0.02941411, -1.03193507, 0.92753949, -0.62379141], [ 0.07144253, -1.10609658, 1.35449854, -0.27767893], [ 0.10224035, -0.93723087, 0.96362731, -0.10206325], [ 0. , 0. , 0. , 0. ], [-0.05129086, -1.65249951, 0.37119121, -0.38792788], [-0.2619973 , -0.07877088, 0.66849029, 0.25754619], [ 0.67958751, -0.28325955, 1.54931628, -0.04451946], [-0.22700402, -1.76996972, 1.19044212, -0.84033982]], [[ 0.05263347, 0.09279532, -0.06834243, -0.24660866], [ 0.68252637, 0.13805023, 0.8167023 , 0.01864438], [ 0.25701091, -0.24851032, 0.99651107, 0.32599682], [ 0.0362539 , -0.08580847, 0.48745439, -0.22182857], [ 0.43975089, 0.72478227, 0.63891768, -0.08284377], [ 0. , 0. , 0. , 0. ], [ 0.44492428, 0.55532528, 1.21228816, -0.7459864 ], [ 0.28783102, 0.25928577, 0.54777655, -0.40662214], [ 0.11669396, -0.62903928, 0.64418535, -0.47128982], [ 0.45760567, 0.10078046, -0.01998603, -0.35730724]], [[-0.9437104 , 0.45896972, -0.60453759, -0.48312076], [-0.8789626 , -0.18868764, 0.01624221, -0.53904495], [-1.32724668, 1.03370168, -0.3325263 , 0.22086194], [-0.55550563, 0.18348396, -0.90452861, 0.43603704], [-1.09822643, 0.32508181, -0.85905771, 0.64453415], [ 0. , 0. , 0. , 0. ], [-1.09440119, 0.49515234, 0.26667916, 0.41299839], [-0.41136258, 1.09285312, -0.31531293, 0.33705511], [-0.44973121, 0.18385981, -1.10686179, -0.4280219 ], [-0.26075002, 0.38902599, -0.60466768, 0.44620581]], [[ 0.16489939, 0.41571318, 0.0484803 , -0.71619838], [ 0.31084163, -0.27203606, -0.62726717, -0.20812454], [ 0.00323786, 0.2180316 , -0.3895054 , -0.11726319], [ 0.00436205, 0.39798696, -0.41804014, 0.31854693], [-0.46814873, -0.10263196, 0.01279164, -0.34360349], [ 0. , 0. , 0. , 0. ], [-0.74775737, -0.17524023, 0.48683575, -0.11761718], [ 0.11107259, -0.70044807, -0.02052839, -0.30767824], [-0.67052688, -0.27866018, -0.1495036 , 0.43428601], [-0.48818804, -0.64056985, 0.30314779, -0.84725492]], [[ 0.83060797, 0.45924076, 0.74444199, 0.72803834], [ 0.10380836, 1.21232196, 0.32261736, 0.743791 ], [ 0.34606804, 0.68186378, 0.81174849, 0.39748295], [ 0.2047084 , -0.01195099, 0.27206008, -0.06090398], [ 0.26248728, 0.39671565, 0.75179462, -0.03088228], [ 0. , 0. , 0. , 0. ], [-0.32804483, 1.19005028, 1.17720694, -0.12416205], [ 0.81079803, 0.26465991, 0.12494558, 0.05250148], [ 0.29423742, -0.27104139, 1.1633198 , -0.17362397], [ 0.54886777, 0.56745963, 0.03736653, -0.14806424]]])

      Variances (σ²):
      array([[[0.5508622 , 0.49416567, 0.41291743, 0.28928235], [0.59310613, 0.49358379, 0.31275477, 0.38400731], [0.55020903, 0.45140955, 0.31915952, 0.3157565 ], [0.63834258, 0.53109422, 0.27473148, 0.31684466], [0.53885103, 0.54965007, 0.33862592, 0.39737651], [0.67237553, 0.55976381, 0.30510184, 0.31149009], [0.62620573, 0.55999725, 0.33237737, 0.32945839], [0.61202972, 0.45993863, 0.27810133, 0.35401419], [0.61065728, 0.48332995, 0.39297026, 0.35261598], [0.59139536, 0.49756057, 0.25754152, 0.34548619]], [[0.29683185, 0.32396431, 0.3852901 , 0.41750273], [0.36004164, 0.29934442, 0.39536329, 0.37935144], [0.31242768, 0.34792705, 0.35391658, 0.32725936], [0.381621 , 0.24385784, 0.36347577, 0.34703643], [0.23592875, 0.24286169, 0.34785054, 0.30822407], [0.32616699, 0.32820238, 0.35457364, 0.30850765], [0.30999813, 0.32524768, 0.33704442, 0.33753237], [0.31979578, 0.36072977, 0.40291567, 0.36238634], [0.30786707, 0.36739563, 0.32155507, 0.3691986 ], [0.2743414 , 0.32836725, 0.41536928, 0.30170204]], [[0.54179549, 0.27708975, 0.43181316, 0.24238331], [0.59523359, 0.38249367, 0.47646601, 0.26527516], [0.48229099, 0.32878626, 0.45628867, 0.21679354], [0.58357265, 0.30357667, 0.53429357, 0.22900219], [0.56462929, 0.29827442, 0.57610557, 0.2478641 ], [0.61978101, 0.37272086, 0.54216507, 0.21653583], [0.54001104, 0.39047333, 0.43518274, 0.26766816], [0.52019507, 0.29930724, 0.54913351, 0.31892249], [0.58029585, 0.37709099, 0.53274852, 0.25746767], [0.51982835, 0.3019504 , 0.41215909, 0.18975392]], [[0.32584648, 0.38359823, 0.35398775, 0.33837898], [0.45197421, 0.28949609, 0.35553144, 0.26933216], [0.42181395, 0.36220355, 0.38478879, 0.33458625], [0.45866625, 0.34236909, 0.3188834 , 0.32263212], [0.36729198, 0.34846255, 0.38982581, 0.38851651], [0.43220043, 0.30758311, 0.35188298, 0.31463363], [0.38329874, 0.27262387, 0.26585347, 0.29721083], [0.43058454, 0.37459495, 0.35063211, 0.29478222], [0.37981699, 0.31512597, 0.27071267, 0.29522631], [0.43067376, 0.40917897, 0.34744612, 0.33504138]], [[0.48745112, 0.5408461 , 0.33909759, 0.46222022], [0.4596066 , 0.48411014, 0.36710302, 0.41969664], [0.48167815, 0.51136545, 0.39091715, 0.47750661], [0.41366547, 0.48078202, 0.36917013, 0.32801605], [0.38970635, 0.511405 , 0.42964333, 0.44252207], [0.47455871, 0.6164271 , 0.30217285, 0.34682755], [0.40360082, 0.5024251 , 0.39622677, 0.31672916], [0.41347024, 0.50055373, 0.3057205 , 0.33457286], [0.39693807, 0.48739739, 0.43041527, 0.38061893], [0.44295411, 0.48220957, 0.37506796, 0.41921661]], [[0.35634524, 0.37591591, 0.6183338 , 0.32693905], [0.32408727, 0.45796935, 0.6865769 , 0.39819052], [0.42622349, 0.34703184, 0.6154341 , 0.33320562], [0.38569409, 0.42597773, 0.66369366, 0.4131806 ], [0.36123781, 0.32606447, 0.6411745 , 0.34430512], [0.33360757, 0.37094518, 0.62812257, 0.3714425 ], [0.34851307, 0.38151636, 0.60326067, 0.39788588], [0.3479885 , 0.39207516, 0.61185128, 0.40541305], [0.366452 , 0.39223124, 0.70116873, 0.4335861 ], [0.33386215, 0.41384481, 0.59939904, 0.39401505]], [[0.44867806, 0.39645824, 0.47358452, 0.48723735], [0.34583861, 0.47135725, 0.38353965, 0.51669795], [0.41071703, 0.41411068, 0.43285382, 0.48837504], [0.36715184, 0.47596246, 0.43759682, 0.54387235], [0.4225884 , 0.42910693, 0.42803188, 0.54927203], [0.48313661, 0.52347331, 0.41538715, 0.47753203], [0.50867741, 0.47451192, 0.48536981, 0.55585658], [0.50401888, 0.455288 , 0.38244346, 0.5152035 ], [0.456102 , 0.42705594, 0.45536263, 0.44548191], [0.3859132 , 0.4177877 , 0.50023511, 0.45391006]], [[0.41924275, 0.39545776, 0.29864569, 0.35670057], [0.41754256, 0.48435409, 0.27110356, 0.38424957], [0.37947053, 0.46026232, 0.29065448, 0.49398258], [0.40639932, 0.39243012, 0.24935853, 0.36981064], [0.39231558, 0.41348844, 0.26020617, 0.40349803], [0.42770813, 0.43834706, 0.25175113, 0.44561009], [0.45443684, 0.36720868, 0.27045468, 0.42666135], [0.40557689, 0.35983923, 0.29764467, 0.3127139 ], [0.41285753, 0.3758288 , 0.32896791, 0.41517196], [0.41012028, 0.48270482, 0.30736186, 0.4530779 ]]])
    • bob
      (x, z)
      float64
      counts
      3.2, 3.4, ..., 16.4, 16.6
      σ = 0.39, 0.25, ..., 0.38, 0.28
      Values:
      array([[ 3.2, 3.4, 3.6, 3.8, 4. , 4.2, 4.4, 4.6], [ 7.2, 7.4, 7.6, 7.8, 8. , 8.2, 8.4, 8.6], [11.2, 11.4, 11.6, 11.8, 12. , 12.2, 12.4, 12.6], [15.2, 15.4, 15.6, 15.8, 16. , 16.2, 16.4, 16.6]])

      Variances (σ²):
      array([[0.15166969, 0.06054626, 0.14818349, 0.08258419, 0.12261054, 0.09144621, 0.0800134 , 0.08952442], [0.16204107, 0.03895372, 0.03875992, 0.09376755, 0.12062932, 0.10104357, 0.08441906, 0.11122997], [0.08769299, 0.11154942, 0.11560391, 0.04234449, 0.11065682, 0.19201279, 0.12751603, 0.07992303], [0.07168764, 0.10383583, 0.05647337, 0.07757141, 0.11865977, 0.10605495, 0.14417429, 0.07771743]])

Interaction with numpy

Variable in a dataset are exposed in a numpy-compatible buffer format, so we can directly hand them to numpy functions:

[16]:
d['alice'].values = np.sin(d['alice'].values)

In contrast to the 1-D case considered earlier, the values are now a multi-dimensional array:

[17]:
d['alice'].values
[17]:
array([[[ 0.99929808,  0.04569508,  0.36499233, -0.3372785 ],
        [ 0.39093787,  0.51884126,  0.94571882,  0.29282795],
        [ 0.47563967,  0.58390761,  0.77944725,  0.13003702],
        [ 0.90991459,  0.20423743,  0.01667384, -0.60318601],
        [ 0.54536295,  0.48091477,  0.99972887,  0.71880965],
        [ 0.        ,  0.        ,  0.        ,  0.        ],
        [ 0.8417791 ,  0.284397  ,  0.35207489,  0.43446925],
        [ 0.83289341,  0.07942348,  0.59522142,  0.09047058],
        [ 0.51821754, -0.49807928,  0.72573716, -0.16442046],
        [ 0.9999427 ,  0.42769117,  0.55436579, -0.67726509]],

       [[ 0.62122136,  0.15413972, -0.62014961,  0.38843521],
        [ 0.79390316,  0.51937271, -0.15305203, -0.13593217],
        [ 0.33375987,  0.33274127, -0.61429024, -0.79869145],
        [ 0.54944164,  0.32724935, -0.2222153 ,  0.51784376],
        [ 0.30206441, -0.46427308,  0.26492111, -0.55902411],
        [ 0.        ,  0.        ,  0.        ,  0.        ],
        [ 0.68070585, -0.01237085, -0.34719937, -0.16132951],
        [ 0.58297816, -0.52530311,  0.30887389, -0.2353155 ],
        [ 0.79828373, -0.12504405,  0.09430432, -0.38524933],
        [ 0.82193011,  0.29028233,  0.01268083, -0.3375234 ]],

       [[ 0.03165096, -0.85931419, -0.6819375 , -0.2358193 ],
        [-0.427337  , -0.88387049, -0.3685013 , -0.74299745],
        [-0.13900058, -0.2232444 , -0.32039729, -0.96991348],
        [ 0.12305154, -0.74918129, -0.53123841, -0.36522891],
        [-0.28176796, -0.71268017,  0.07893491, -0.64300021],
        [ 0.        ,  0.        ,  0.        ,  0.        ],
        [ 0.40890174, -0.64920157, -0.29607088,  0.01698094],
        [ 0.2913835 , -0.49379545,  0.41658105, -0.47307892],
        [ 0.50147222, -0.8976374 ,  0.12685387, -0.40375189],
        [-0.19449283, -0.68238631, -0.23214596, -0.76864183]],

       [[-0.1566055 , -0.95015647,  0.97446106, -0.52819684],
        [ 0.18728316, -0.57800668,  0.59661278, -0.65800782],
        [-0.02940987, -0.85829359,  0.80014654, -0.58411672],
        [ 0.07138177, -0.89395616,  0.97669869, -0.27412423],
        [ 0.10206232, -0.80592181,  0.82126651, -0.10188615],
        [ 0.        ,  0.        ,  0.        ,  0.        ],
        [-0.05126837, -0.99666415,  0.36272577, -0.37827108],
        [-0.25901021, -0.07868944,  0.61980194,  0.25470844],
        [ 0.62847223, -0.27948678,  0.99976931, -0.04450476],
        [-0.22505942, -0.98023046,  0.92853319, -0.74486989]],

       [[ 0.05260917,  0.0926622 , -0.06828924, -0.24411663],
        [ 0.63075545,  0.13761216,  0.7288921 ,  0.0186433 ],
        [ 0.25419078, -0.24596032,  0.83958079,  0.32025327],
        [ 0.03624596, -0.08570321,  0.46837829, -0.22001375],
        [ 0.42571407,  0.66297246,  0.59632697, -0.08274904],
        [ 0.        ,  0.        ,  0.        ,  0.        ],
        [ 0.43038953,  0.52721973,  0.93642132, -0.67869657],
        [ 0.28387314,  0.25639026,  0.52079039, -0.39550915],
        [ 0.1164293 , -0.5883682 ,  0.60054725, -0.45403587],
        [ 0.44180139,  0.10060994, -0.0199847 , -0.34975282]],

       [[-0.80974088,  0.44302469, -0.56838168, -0.46454502],
        [-0.77007748, -0.18756999,  0.0162415 , -0.51331661],
        [-0.9704881 ,  0.85919881, -0.32643198,  0.2190707 ],
        [-0.52737297,  0.18245615, -0.7861339 ,  0.42235064],
        [-0.89040148,  0.31938631, -0.75722744,  0.60082611],
        [ 0.        ,  0.        ,  0.        ,  0.        ],
        [-0.88865381,  0.4751657 ,  0.26352944,  0.40135742],
        [-0.39985861,  0.88794283, -0.31011398,  0.33070934],
        [-0.43472348,  0.18282568, -0.89429884, -0.41507196],
        [-0.2578053 ,  0.37928737, -0.56848871,  0.43154594]],

       [[ 0.16415309,  0.40384247,  0.04846132, -0.65652183],
        [ 0.30586004, -0.26869318, -0.58693436, -0.20662528],
        [ 0.00323785,  0.21630824, -0.37973091, -0.11699463],
        [ 0.00436203,  0.38756342, -0.40597014,  0.31318693],
        [-0.45123497, -0.10245188,  0.01279129, -0.33688212],
        [ 0.        ,  0.        ,  0.        ,  0.        ],
        [-0.67999614, -0.17434469,  0.46783161, -0.11734618],
        [ 0.11084434, -0.64456032, -0.02052694, -0.30284673],
        [-0.62139888, -0.27506776, -0.14894728,  0.4207628 ],
        [-0.46902637, -0.59765242,  0.29852594, -0.74946587]],

       [[ 0.73834154,  0.44326766,  0.67756152,  0.66540658],
        [ 0.10362202,  0.93643318,  0.31704997,  0.6770826 ],
        [ 0.33920159,  0.63024116,  0.72549165,  0.38709875],
        [ 0.20328166, -0.0119507 ,  0.26871631, -0.06086633],
        [ 0.25948343,  0.38639116,  0.68295077, -0.03087737],
        [ 0.        ,  0.        ,  0.        ,  0.        ],
        [-0.32219274,  0.92838765,  0.92353846, -0.12384328],
        [ 0.72483718,  0.26158104,  0.12462074,  0.05247737],
        [ 0.29001012, -0.26773496,  0.91812378, -0.17275296],
        [ 0.52172164,  0.53749157,  0.03735783, -0.14752383]]])

Exercise 3

  1. Use sc.mean to compute the mean of the data for Alice along the Z dimension.

  2. Do the same with numpy, what are the complications you encounter, that are not present when using the dataset?

Solution 3

[18]:
help(sc.mean)
Help on function mean in module scipp.core.reduction:

mean(x: 'VariableLike', dim: 'Optional[str]' = None, *, out: 'Optional[VariableLike]' = None) -> 'VariableLike'
    Element-wise mean over the specified dimension.

    If the input has variances, the variances stored in the output are based on
    the "standard deviation of the mean", i.e.,
    :math:`\sigma_{mean} = \sigma / \sqrt{N}`.
    :math:`N` is the length of the input dimension.
    :math:`\sigma` is estimated as the average of the standard deviations of
    the input elements along that dimension.

    See :py:func:`scipp.sum` on how rounding errors for float32 inputs are handled.

    :param x: Input data.
    :param dim: Dimension along which to calculate the mean. If not
                given, the mean over all dimensions is calculated.
    :param out: Optional output buffer.
    :raises: If the dimension does not exist, or the dtype cannot be summed,
             e.g., if it is a string.
    :return: The mean of the input values.
    :seealso: :py:func:`scipp.nanmean`.

[19]:
mean = sc.mean(d['alice'], 'z')

When using numpy to compute the mean: - We must remember (or lookup) which dimension corresponds to the Z dimensions. - We need a separate call for values and variances. - We need to manually scale the variance with the inverse of the number of data points to get the variance of the mean (standard deviation of the mean scales with 1/sqrt(N)).

[20]:
np_values = np.mean(d['alice'].values, axis=0)
np_variances = np.mean(d['alice'].variances, axis=0)
np_variances /= d['alice'].shape[0]
[21]:
print(mean.values)
print(mean.variances)
print(np_values)
print(np_variances)
[[ 0.20511598 -0.02835485  0.01583977 -0.17657954]
 [ 0.1518684   0.02426487  0.18700343 -0.15854068]
 [ 0.0333914   0.16186235  0.18797698 -0.17665707]
 [ 0.17128828 -0.07991063 -0.02688633 -0.03375474]
 [ 0.00141035 -0.02945778  0.33746162 -0.05434791]
 [ 0.          0.          0.          0.        ]
 [ 0.05245815  0.0478236   0.3328564  -0.07583488]
 [ 0.27099261 -0.03212634  0.28190606 -0.08479807]
 [ 0.22459535 -0.34357409  0.3027612  -0.20237805]
 [ 0.20487649 -0.06561335  0.12635553 -0.4179371 ]]
[[0.05354771 0.04980462 0.05177609 0.04563507]
 [0.0554286  0.05254233 0.05075685 0.04713751]
 [0.05413798 0.05036089 0.0506877  0.04667915]
 [0.05679864 0.04993828 0.05017505 0.04484992]
 [0.05113358 0.04873927 0.05330412 0.04814966]
 [0.05889898 0.05496036 0.04923683 0.04363405]
 [0.05585534 0.05115632 0.04884015 0.04576567]
 [0.05552593 0.05003635 0.04966316 0.04528138]
 [0.05485917 0.05039775 0.0536547  0.04608387]
 [0.05295451 0.05208756 0.05022781 0.04519067]]
[[ 0.20511598 -0.02835485  0.01583977 -0.17657954]
 [ 0.1518684   0.02426487  0.18700343 -0.15854068]
 [ 0.0333914   0.16186235  0.18797698 -0.17665707]
 [ 0.17128828 -0.07991063 -0.02688633 -0.03375474]
 [ 0.00141035 -0.02945778  0.33746162 -0.05434791]
 [ 0.          0.          0.          0.        ]
 [ 0.05245815  0.0478236   0.3328564  -0.07583488]
 [ 0.27099261 -0.03212634  0.28190606 -0.08479807]
 [ 0.22459535 -0.34357409  0.3027612  -0.20237805]
 [ 0.20487649 -0.06561335  0.12635553 -0.4179371 ]]
[[0.05354771 0.04980462 0.05177609 0.04563507]
 [0.0554286  0.05254233 0.05075685 0.04713751]
 [0.05413798 0.05036089 0.0506877  0.04667915]
 [0.05679864 0.04993828 0.05017505 0.04484992]
 [0.05113358 0.04873927 0.05330412 0.04814966]
 [0.05889898 0.05496036 0.04923683 0.04363405]
 [0.05585534 0.05115632 0.04884015 0.04576567]
 [0.05552593 0.05003635 0.04966316 0.04528138]
 [0.05485917 0.05039775 0.0536547  0.04608387]
 [0.05295451 0.05208756 0.05022781 0.04519067]]
[ ]: