# Common settings on BornAgain

file:///usr/share/doc/bornagain/html/ref/sim/setup/index.html Recent content in Common settings on BornAgain Hugo en-us

# Background

file:///usr/share/doc/bornagain/html/ref/sim/setup/bg.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/setup/bg.html <h3 id="poisson-background">Poisson background</h3> <p>To add a Poisson background to a <code>Simulation</code> instance, use</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">bg</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">PoissonBackground</span><span class="p">()</span> </span></span><span class="line"><span class="cl"><span class="n">simulation</span><span class="o">.</span><span class="n">setBackground</span><span class="p">(</span><span class="n">bg</span><span class="p">)</span> </span></span></code></pre></div><p>In this case, the output intensity is randomly distributed around the exact value with discrete Poisson statistics.</p> <p>The lower the intensity of the probing beam, the lower the signal-to-noise ratio.</p> <h3 id="constant-background">Constant background</h3> <p>To add a constant background to a <code>Simulation</code> instance, use</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">bg</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">ConstantBackground</span><span class="p">(</span><span class="mf">1e3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">simulation</span><span class="o">.</span><span class="n">setBackground</span><span class="p">(</span><span class="n">bg</span><span class="p">)</span> </span></span></code></pre></div><p>Background is applied before the <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/specular">specular simulation</a> is normalized, so the threshold value will also be divided by the probe beam intensity.</p>

# Progress monitor

file:///usr/share/doc/bornagain/html/ref/sim/setup/progress.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/setup/progress.html <h3 id="terminal-progress-monitor">Terminal progress monitor</h3> <p>To monitor progress of a time-consuming simulation, use</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">simulation</span><span class="o">.</span><span class="n">setTerminalProgressMonitor</span><span class="p">()</span> </span></span><span class="line"><span class="cl"><span class="n">simulation</span><span class="o">.</span><span class="n">simulate</span><span class="p">()</span> </span></span></code></pre></div><p>While the simulation is running, progress will be printed in the form</p> <pre tabindex="0"><code>... 17% </code></pre><p>To prevent problems if the script is run in batch mode, use the conditional</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="k">if</span> <span class="ow">not</span> <span class="s2">&#34;__no_terminal__&#34;</span> <span class="ow">in</span> <span class="nb">globals</span><span class="p">():</span> </span></span><span class="line"><span class="cl"> <span class="n">simulation</span><span class="o">.</span><span class="n">setTerminalProgressMonitor</span><span class="p">()</span> </span></span></code></pre></div><p>This is used for example in</p> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/FindPeaks.py"/>auto/Examples/scatter2d/FindPeaks.py</a>