Fitting a real point source¶
Weights used:
Spatial
Spectral
This jupyter notebook fits for the phase-averaged polarization of the point source GX 301-2, observed with observation ID 01002601. Please refer to the previous notebook for help downloading and processing this data set.
[1]:
import leakagelib
>>> PyXSPEC is not installed, you will no be able to use it.
Performing a polarization fit to these data is almost identical to the steps we performed for the simulated source. The only difference is the command to load the data. Here we need to specify that the data is stored in the “event_l2_weight” directory (which we created in the previous notebook.)
[2]:
datas = leakagelib.IXPEData.load_all_detectors_with_path("data", "01002601", event_dir="event_l2_weight")
>>> Reading (in memory) /opt/homebrew/anaconda3/lib/python3.12/site-packages/ixpeobssim/caldb/ixpe/xrt/bcf/vign/ixpe_d2_obssim20240101_vign_v013.fits...
WARNING: FITSFixedWarning: RADECSYS= 'ICRS ' / Celestial coordinate system
the RADECSYS keyword is deprecated, use RADESYSa. [astropy.wcs.wcs]
WARNING: FITSFixedWarning: 'datfix' made the change 'Set DATEREF to '2017-01-01T00:01:09.184' from MJDREF.
Set MJD-OBS to 59789.109204 from DATE-OBS.
Set MJD-END to 59794.248844 from DATE-END'. [astropy.wcs.wcs]
>>> Reading (in memory) /opt/homebrew/anaconda3/lib/python3.12/site-packages/ixpeobssim/caldb/ixpe/xrt/bcf/vign/ixpe_d1_obssim20240101_vign_v013.fits...
>>> Reading (in memory) /opt/homebrew/anaconda3/lib/python3.12/site-packages/ixpeobssim/caldb/ixpe/xrt/bcf/vign/ixpe_d3_obssim20240101_vign_v013.fits...
Next we center the data and cut to 2-8 keV.
[3]:
for data in datas:
data.iterative_centroid_center()
data.retain(data.evt_energies > 2)
data.retain(data.evt_energies < 8)
We create the same fit settings object as before, but this time skipping spectral weights for simplicity.
[4]:
settings = leakagelib.FitSettings(datas)
settings.apply_circular_roi(280)
settings.add_point_source() # Named "src" by default
settings.fix_flux("src", 1)
settings.set_initial_qu("src", (0.5,0))
settings.add_background() # Named "bkg" by default
settings.set_initial_qu("bkg", (0, 0)) # Assume an unpolarized background
settings.set_initial_flux("bkg", 0.1)
59535 events were cut for being outside the region of interest.
Finally, we perform the fit.
[5]:
fitter = leakagelib.Fitter(settings)
result = fitter.fit()
result
Your data set has background characters assigned, but you did not add a particle component. Particles will not be modeled. Was this intentional?
[5]:
FitResult:
q (src) = 0.0032 +/- 0.0057
u (src) = -0.0047 +/- 0.0057
q (bkg) = -0.0009 +/- 0.0197
u (bkg) = 0.0038 +/- 0.0197
f (bkg) = 0.1461 +/- 0.0008
Polarization:
PD (src): 0.0057 +/- 0.0057
PA (src): -27.8768 deg +/- 28.4854
PD (bkg): 0.0039 +/- 0.0197
PA (bkg): 51.5529 deg +/- 146.2607
Likelihood 1332618.773507991, dof 447936
Optimization terminated successfully.
As you see, this source has no detectable averaged polarization. The original analysis also found no net polarization, though phase-resolved polarization was detected. This could be probed with LeakageLib as well using the set_sweep function (defined later).
Note the warning “Your data set has background characters assigned, but you did not add a particle component. Particles will not be modeled. Was this intentional?”. We can fix that warning by adding a particle weight component, described in the next notebook.