Make Background File¶
The make_background_file()
function allows one to create an event file of a background for a particular instrument configuration. This event file can then be added as background to any source event file one creates using instrument_simulator()
. make_background_file()
also allows one to specify a particular set of point sources to make the point-source contribution to the background, or to create the point-source properties on the fly. In this example, we will show how to do the
former using a point source table created by make_point_source_list()
.
First, import our modules:
[1]:
import matplotlib
matplotlib.rc("font", size=18)
import soxs
Second, define our parameters:
[2]:
exp_time = (100.0, "ks") # in seconds
fov = 50.0 # in arcmin, used only for the point source generation
sky_center = [22.0, -27.0] # in degrees
Now, use make_point_source_list()
to create an ASCII table of point source properties that can be used when creating the background. We’ll set a random seed using the prng
parameter to use a unique set of random numbers.
[3]:
soxs.make_point_source_list("point_source_table.dat", fov, sky_center, prng=24)
We can use this table of point source properties as an input to make_point_sources_file()
or to make_background_file()
to control precisely the properties of the generated sources. Because in this example we want to create a background, we’ll use make_background_file()
. We have to pass the name of the table we created to the input_sources
parameter if we want to use it:
[4]:
soxs.make_background_file(
"bkgnd_evt.fits",
exp_time,
"chandra_aciss_cy0",
sky_center,
input_pt_sources="point_source_table.dat",
overwrite=True,
prng=24,
)
soxs : [INFO ] 2025-02-18 14:00:01,844 Adding in point-source background.
soxs : [INFO ] 2025-02-18 14:00:01,845 Reading in point-source properties from point_source_table.dat.
soxs : [INFO ] 2025-02-18 14:00:12,239 Simulating events from 1 sources using instrument chandra_aciss_cy0 for 100 ks.
soxs : [INFO ] 2025-02-18 14:00:12,437 Scattering energies with RMF aciss_aimpt_cy0.rmf.
soxs : [INFO ] 2025-02-18 14:00:12,552 Detected 40273 events in total.
soxs : [INFO ] 2025-02-18 14:00:12,553 Generated 40273 photons from the point-source background.
soxs : [INFO ] 2025-02-18 14:00:12,553 Adding in astrophysical foreground.
soxs : [INFO ] 2025-02-18 14:00:13,045 Adding in instrumental background.
soxs : [INFO ] 2025-02-18 14:00:13,088 Making 39848 events from the galactic foreground.
soxs : [INFO ] 2025-02-18 14:00:13,088 Making 480726 events from the instrumental background.
soxs : [INFO ] 2025-02-18 14:00:13,133 Writing background events to file bkgnd_evt.fits.
We can use the write_image()
function in SOXS to bin the events into an image and write them to a file:
[5]:
soxs.write_image("bkgnd_evt.fits", "bkgnd_img.fits", overwrite=True)
We can now show the resulting image:
[6]:
fig, ax = soxs.plot_image(
"bkgnd_img.fits",
stretch="sqrt",
cmap="plasma",
width=0.5,
vmin=0.0,
vmax=1.0,
center=[22.0, -27.0],
)
