Background is applied before the specular simulation is normalized, so the threshold value will also be divided by the probe beam intensity.
The script below shows how to add a constant background in the context of a GISAXS simulation of an air-substrate bilayer with cylindrical particles embedded.
#!/usr/bin/env python3"""
Cylinder form factor in DWBA with constant background
"""importbornagainasbafrombornagainimportba_plotasbp,deg,nmimportmatplotlib.pyplotaspltdefget_sample():frombornagainimportstd_samplesreturnstd_samples.cylinders()defget_simulation(sample):beam=ba.Beam(1e6,0.1*nm,0.2*deg)n=100detector=ba.SphericalDetector(n,0.,2*deg,n,0.,2*deg)simulation=ba.ScatteringSimulation(beam,sample,detector)background=ba.ConstantBackground(1e3)simulation.setBackground(background)returnsimulationif__name__=='__main__':sample=get_sample()simulation=get_simulation(sample)result=simulation.simulate()bp.plot_simulation_result(result)plt.show()