for row in range(3):
  for col in range(3):
    data2d[0,row, col] += row * 2
    data2d[0,row, col] += col * 2

mask2d = flex.int(flex.grid(1, 3, 3),3)
mask2d[0, 1, 1] = 5

background2d = flex.double(flex.grid(1, 3, 3),0)
from dials.model.data import Reflection, ReflectionList
from scitbx.array_family import flex
r = Reflection()
r.shoebox = data2d
r.shoebox_mask = mask2d
r.shoebox_background = background2d

rlist = ReflectionList()
rlist.append(r)

#from dials.algorithms.background.flat_background_subtractor \
# import layering_and_background_avg
#layering_and_background_avg(rlist)

#from dials.algorithms.background.curved_background_subtractor \
# import layering_and_background_modl
#layering_and_background_modl(rlist)

from dials.algorithms.background.inclined_background_subtractor \
 import layering_and_background_plane
layering_and_background_plane(rlist)
for row in range(3):
    for col in range(3):
        data2d[0, row, col] += row * 2
        data2d[0, row, col] += col * 2

mask2d = flex.int(flex.grid(1, 3, 3), 3)
mask2d[0, 1, 1] = 5

background2d = flex.double(flex.grid(1, 3, 3), 0)
from dials.model.data import Reflection, ReflectionList
from scitbx.array_family import flex

r = Reflection()
r.shoebox = data2d
r.shoebox_mask = mask2d
r.shoebox_background = background2d

rlist = ReflectionList()
rlist.append(r)

# from dials.algorithms.background.flat_background_subtractor \
# import layering_and_background_avg
# layering_and_background_avg(rlist)

# from dials.algorithms.background.curved_background_subtractor \
# import layering_and_background_modl
# layering_and_background_modl(rlist)

from dials.algorithms.background.inclined_background_subtractor import (
    layering_and_background_plane, )