Debian Codegraph @

hugo/content/ref/fit/ex/fit-with-masks.md

raw
1 +++
2 title = "Fitting with masks"
3 weight = 10
4 +++
5
6 ## Fitting with masks
7
8 In this example we demonstrate how to mask certain areas on the detector image to exclude their influence on the fitting procedure. This can be done by invoking the method `addMask` on a simulation object.
9
10 ```
11 simulation = ScatteringSimulation()
12 simulation.addMask(Rectangle(x1, y1, x2, y2), mask_value)
13 ```
14
15 where `Rectangle` is related to the shape of the mask in detector coordinates, `mask_value` can be either `True` (area is excluded from the simulation and fit) or `False` (area will stay in the simulation and will be taken into account in $\chi^2$ calculations during the fit). There can be an arbitrary number of masks of various shapes added to the simulation one after another. Each subsequent mask overrides the previously defined `mask_value` in the given area.
16
17 * In the given script we simulate a dilute random assembly of cylinders on a substrate.
18 The fitting procedure looks for the cylinder's height and radius.
19 * To demonstrate ways of setting complex masks,
20 the simulated image looks like a Pac-Man from the ancient arcade game.
21
22 {{< galleryscg >}}
23 {{< figscg src="/img/draw/fit_with_masks.png" width="600px" caption="Fit window">}}
24 {{< /galleryscg >}}
25
26 {{< show-ex file="fit/scatter2d/fit_with_masks.py" >}}