Magpies method list¶
Here we briefly describe most functions implemented in the Magpies python library.
- magpies.xg(Rns, Mns)¶
Compute compactenss parameters of neutron star.
\(x_g = 2 G M / (R c^2)\)
- Parameters:
Rns – neutron star radius [km]
Mns – neutron star mass [Solar mass]
- Returns:
compactness parameter [uniteless]
- magpies.g14(Rns, Mns)¶
Calculate the free fall acceleration at the surface of neutron star.
\(g_{14} = G M / (R^2 \sqrt{1 - x_g}) / 10^{14}\)
- Parameters:
Rns – neutron star radius [km]
Mns – neutron star mass [Solar mass]
- Returns:
free fall acceleration at the surface of neutron star [g/1e14 cm/s/s]
- magpies.compute_L(Tmap, Rns)¶
Calculate the total thermal X-ray luminosity of neutron star.
\(L = \sigma_\mathrm{SB} R_\mathrm{NS}^2 \int_{4\pi} T_s^4 (\theta, \phi) \sin \theta d\theta d\phi\)
- Parameters:
Tmap – member of Tmap class containing surface temperature map.
Rns – radius of neutron star [km]
The thermal map can be one dimensional (in the case of axisymmetric temperature distribution) or two-dimensional.
- Returns:
total thermal luminosity [erg/s]
- magpies.compute_L_param(param, Teff, Rns, Mns)¶
Calculate the total thermal X-ray luminosity produced by single/two or more parameter blackbody.
- Parameters:
param – list of areas and relative temperatures
Teff – effective temperature
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
- Returns:
total thermal luminosity [erg/s]
- Example:
compute_L_param ([1, 1], 1e6, 12, 1.4) computes luminosity of neutron star with surface temperature 1 MK, radius 12 km and mass 1.4 solar mass
- magpies.compute_Teff(Tmap, Rns)¶
Calculate the effective temperature of neutron star.
- Parameters:
Tmap – member of Tmap class containing surface temperature map.
Rns – radius of neutron star [km]
The thermal map can be one dimensional (in the case of axisymmetric temperature distribution) or two-dimensional.
- Returns:
Effective temperature [K]
- magpies.D_factor(cospsi, Rns, Mns)¶
Calculate the lensing factor following the article Poutanen (2020) A&A 640, A24 (2020).
\(\mathcal D = 1 + \frac{3 u^2 y^2}{112} - \frac{e}{100} uy \left[ 2 \log \left( 1 - \frac{y}{2} \right) + y \frac{1-3y/4}{1-y/2}\right]\)
where \(u = \frac{Rg}{R_\mathrm{NS}}\) and \(y = 1 - \cos\psi\).
- Parameters:
cospsi – cosine of propagation angle \(\cos\psi\)
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
- Returns:
Dimensionless lensing factor \(\mathcal D\)
- magpies.single_BB_photons(Teff, Rns, Mns, eph, nphot, integ=True)¶
Calculate thermal spectra [number of photons per energy bin] emitted by neutron star with fixed surface temperature.
- Parameters:
Teff – effective temperature of neutron star [K]
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
eph – list of energies where spectra is to be calculated [keV]
nphot – total number of received photons
integ – if True it returns integer counts (0.3 means no counts in a bin), if False it returns fraction of counts as well.
- Returns:
redshifted spectra [number of photons per energy bin]
- magpies.two_BB_photons(param, Teff, Rns, Mns, eph, nphot, integ=True)¶
Calculate thermal spectra [number of photons per energy bin] composed of two blackbodies.
- Parameters:
param – array of four parameters [sc, sh, pc, ph]
Teff – effective temperature of neutron star
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
eph – list of energies where spectra is to be calculated [keV]
nphot – total number of received photons
integ – integ = True correspond to integer result and integ = False corresponds to float result
- Sc:
fraction of total surface area covered with first hot spot
- Sh:
fraction of total surface area covered with second hot spot
- Pc:
temperature of first hot spot as a fraction of Teff
- Ph:
temperature of second hot spot as a fraction of Teff
- Returns:
- sp:
redshifted spectra [number of photons per energy bin]
- magpies.examine_spectral_fit_1BB_photons(param, Teff, Rns, Mns, eph, nphot, L, integ=True)¶
Function to examine the quality of single blackbody fit [number of photons per energy bin] in comparison the neutron star spectra.
- Parameters:
param –
- sc:
relative area of hot region, :pc: relative temperature of hot region
Teff – effective temperature of neutron star [K]
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
eph – list of energies where spectra is to be calculated [keV]
nphot – total number of received photons
L – luminosity of neutron star
integ – if True it returns integer counts (0.3 means no counts in a bin), if False it returns fraction of counts as well.
- Returns:
redshifted spectra [number of photons per energy bin]
- magpies.examine_spectral_fit_2BB_photons(param, Teff, Rns, Mns, eph, nphot, L, integ=True)¶
Function to examine the quality of two blackbody fit [number of photons per energy bin] in comparison the neutron star spectra.
- Parameters:
param –
- sc:
relative area of hot region, :pc: relative temperature of hot region
Teff – effective temperature of neutron star [K]
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
eph – list of energies where spectra is to be calculated [keV]
nphot – total number of received photons
L – luminosity of neutron star
integ – if True it returns integer counts (0.3 means no counts in a bin), if False it returns fraction of counts as well.
- Returns:
redshifted spectra [number of photons per energy bin]
- magpies.Cstat_1BB(param, Teff, Rns, Mns, spec, eph, nphot, L)¶
Calculate C-statistics for synthetic spectra [counts per energy bin] composed of single blackbody.
- Parameters:
sc – fraction of total surface area covered with hot spot
Teff – effective temperature of hot spot
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
eph – list of energies where spectra is to be calculated [keV]
nphot – total number of received photons
L – luminosity of neutron star which we try to model
- Returns:
C-stat
- magpies.Cstat_2BB(param, Teff, Rns, Mns, spec, eph, nphot, L)¶
Calculate C-statistics for synthetic spectra [number of photons per energy bin] composed of two blackbody.
- Parameters:
param – array of two parameters [sc, sh, pc, ph]
Teff – effective temperature of neutron star
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
eph – list of energies where spectra is to be calculated [keV]
nphot – total number of received photons
L – luminosity of neutron star which we try to fit
- Sc:
fraction of total surface area covered with first hot spot
- Pc:
temperature of first hot spot as a fraction of Teff
- Returns:
C-stat
- magpies.fit_spectral_model_Cstat(Teff, Rns, Mns, spec, eph, nphot, L, significance=2.7)¶
Fit spectra [spec] with two models: (1) single blackbody model and (2) sum of two blackbody model and choose the best model using C-statistics
- Parameters:
Teff – effective temperature of neutron star
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
spec – spectra which we try to fit
eph – list of energies where spectra was calculated [keV]
nphot – total number of received photons
L – luminosity of neutron star which we try to fit
significance – Critical value of \(\Delta C\) to make a choice between single and two-blackbody model
- Returns:
list [s1, s2, p1, p2, Cstat BB1, Cstat BB2]
- magpies.spectra_pole(Tmap, Rns, Mns, eph)¶
Calculate redshifted thermal spectra [erg s^-1 cm^-2 keV^-1] emitted by neutron star observed from its magnetic pole (top row of thermal map).
\(H_E^\infty = \frac{15 \sigma_{SB}}{\pi^5 k_B^4} \int_\mathrm{viz} \frac{E^3 \cos \alpha \; \mathcal{D} \sin \theta d\theta d\phi}{\exp(E/(k_B T_s^\infty)) - 1}\)
- Parameters:
Tmap – member of Tmap class containing surface temperature map.
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
eph – list containing energy mesh \(E\) [keV]
- Returns:
- sp:
redshifted spectra [erg s^-1 cm^-2 keV^-1]
- visible_map:
two-dimensional array which contains only the temperature distribution on visible hemisphere
- magpies.spectra_any(Tmap, Rns, Mns, phase, chi, inc, eph)¶
Calculate redshifted thermal spectra [erg s^-1 cm^-2 keV^-1] emitted by neutron star observed from arbitrary orientation.
\(H_E^\infty = \frac{15 \sigma_{SB}}{\pi^5 k_B^4} \int_\mathrm{viz} \frac{E^3 \cos \alpha \; \mathcal{D} \sin \theta d\theta d\phi}{\exp(E/(k_B T_s^\infty)) - 1}\)
- Parameters:
Tmap – member of Tmap class containing surface temperature map.
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
phase – rotational phase [radian]
chi – magnetic obliquity angle (angle between orientation of original dipolar magnetic field - top of the surface thermal map)
inc – inclination of the observer with respect to the rotational axis.
eph – list containing energy mesh \(E\) [keV]
- Returns:
- sp:
redshifted spectra [erg s^-1 cm^-2 keV^-1]
- visible_map:
two-dimensional array which contains only the temperature distribution on visible hemisphere
- magpies.lightcurve(Tmap, Rns, Mns, phases, chi, inc)¶
Calculate soft X-ray lightcurve
- Parameters:
Tmap – member of Tmap class containing surface temperature map.
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
phases – list of phases [radian]
chi – magnetic obliquity angle (angle between orientation of original dipolar magnetic field - top of the surface thermal map)
inc – inclination of the observer with respect to the rotational axis.
- Returns:
Soft X-ray lightcurve in units of intensity for each rotational phase [erg/s]
- magpies.phase_resolved_spectroscopy(Tmap, Rns, Mns, phases, chi, inc, eph)¶
Calculate phase-resolved spectroscopy for neutron star.
- Parameters:
Tmap – member of Tmap class containing surface temperature map.
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
phases – rotational phases [radian]
chi – magnetic obliquity angle (angle between orientation of original dipolar magnetic field - top of the surface thermal map)
inc – inclination of the observer with respect to the rotational axis.
eph – list energies where spectra should be computed [keV]
- Returns:
- sp:
number of photons per energy bin
- magpies.precompute_Dcos_alpha(Rns, Mns, chi, inc, phase, phi1, theta1)¶
Calculate \(\mathcal D \cos\alpha\) factor for all points of the mesh at the neutron star surface.
- Parameters:
Rns – radius of neutron star [km]
Mns – mass of neutron star [Solar mass]
chi – magnetic obliquity angle (angle between orientation of original dipolar magnetic field - top of the surface thermal map)
inc – inclination of the observer with respect to the rotational axis.
phase – rotational phase [radian]
phi1 – list of magnetic longuitudets [radians] where Tmap is provided
theta1 – list magnetic latitude [radians] where Tmap is provided
- Returns:
array of \(\mathcal D \cos\alpha\) factors
- magpies.flux_to_photons(flx, eph, nph)¶
Convert fluxes into number of photons
\(N_\mathrm{phot} = \frac{F}{E}\)
- Parameters:
flx – spectral fluxes […]
eph – mesh of energies [keV]
nph – total number of photons received by X-ray telescope.
- Returns:
number of photons per energy bin