pl_normalization_spline = xInterpolatedUnivariateSpline(_phi, esum, k=3, **fmt) # Build the polarization angle as a function of the phase. _pol_angle = polarization_angle(0,_phi,0,0) fmt = dict(xname='Pulsar phase', yname='Polarization angle [rad]') pol_angle_spline = xInterpolatedUnivariateSpline(_phi, _pol_angle, k=1, **fmt) # Build the polarization degree as a function of the phase. _pol_degree = polarization_degree(0,_phi,0,0) fmt = dict(xname='Pulsar phase', yname='Polarization degree') pol_degree_spline = xInterpolatedUnivariateSpline(_phi, _pol_degree, k=1, **fmt) ROI_MODEL = xROIModel(254.457625, 35.3423888889) herx1_ephemeris = xEphemeris(0., 0.8064516129, 0, 0) herx1_pulsar = xPeriodicPointSource('Her X-1', ROI_MODEL.ra, ROI_MODEL.dec, energy_spectrum, polarization_degree, polarization_angle, herx1_ephemeris) ROI_MODEL.add_source(herx1_pulsar) if __name__ == '__main__': print(ROI_MODEL) from ximpol.utils.matplotlib_ import pyplot as plt plt.figure() pl_index_spline.plot(show=False) plt.figure() pl_normalization_spline.plot(show=False) plt.figure() pol_angle_spline.plot(show=False)
_phi=numpy.linspace(0,1,23) _pol_angle = polarization_angle(0,_phi,0,0) pol_angle_spline = xInterpolatedUnivariateSpline(_phi, _pol_angle, k=1, **fmt) _pol_degree = polarization_degree(0,_phi,0,0) fmt = dict(xname='Pulsar phase', yname='Polarization degree') pol_degree_spline = xInterpolatedUnivariateSpline(_phi, _pol_degree, k=1, **fmt) _pol_degree_noqed = polarization_degree_noqed(0,_phi,0,0) pol_degree_spline_noqed = xInterpolatedUnivariateSpline(_phi, _pol_degree_noqed, k=1, **fmt) ROI_MODEL = xROIModel(26.59342, 61.75078) fouru_ephemeris = xEphemeris(0., 0.115088121, -2.64E-14, 0) fouru_pulsar = xPeriodicPointSource('4U 0142+61', ROI_MODEL.ra, ROI_MODEL.dec, energy_spectrum, polarization_degree, polarization_angle, fouru_ephemeris) ROI_MODEL.add_source(fouru_pulsar) if __name__ == '__main__': print(ROI_MODEL) from ximpol.utils.matplotlib_ import pyplot as plt plt.figure() pl_index_spline.plot(show=False) plt.figure() pl_normalization_spline.plot(show=False) plt.figure() pol_angle_spline.plot(show=False)
return phasogram_spline(phase) / average_eflux * spectrum_spline(E) def polarization_degree(E, phase, ra, dec): """Return the polarization degree. """ return pol_degree_spline(phase) def polarization_angle(E, phase, ra, dec): """Return the polarization angle. """ return numpy.radians(pol_angle_spline(phase)) ephem = xEphemeris(0.0, 1.0 / GK_PER_PERIOD) """We have all the ingredients, can define the ROI. Note that, since the input XSPEC model is already including the interstellar abrosorption, we are setting the column density explicitely to 0 here. """ ROI_MODEL = xROIModel(GK_PER_RA, GK_PER_DEC) gk_per = xPeriodicPointSource( "GK Per", GK_PER_RA, GK_PER_DEC, energy_spectrum, polarization_degree, polarization_angle,
# Build the polarization degree as a function of the phase. _phi, _pol_degree = numpy.loadtxt(PDEG_FILE_PATH, unpack=True) _pol_degree /= 100. # Filter the data points to reduce the noise. _pol_degree = scipy.signal.wiener(_pol_degree, 5) fmt = dict(xname='Pulsar phase', yname='Polarization degree') pol_degree_spline = xInterpolatedUnivariateSpline(_phi, _pol_degree, k=1, **fmt) # And, again, this needs to be wrapped into a function. def polarization_angle(E, t, ra, dec): return pol_angle_spline(t) ROI_MODEL = xROIModel(83.633083, 22.014500) crab_ephemeris = xEphemeris(0., 29.8003951530036, -3.73414e-10, 1.18e-20) crab_pulsar = xPeriodicPointSource('Crab pulsar', ROI_MODEL.ra, ROI_MODEL.dec, energy_spectrum, polarization_degree, polarization_angle, crab_ephemeris) ROI_MODEL.add_source(crab_pulsar) if __name__ == '__main__': print(ROI_MODEL) from ximpol.utils.matplotlib_ import pyplot as plt plt.figure() pl_index_spline.plot(show=False) plt.figure() pl_normalization_spline.plot(show=False) plt.figure() pol_angle_spline.plot(show=False)
return energy_spectrum_spline.__call__(phase, E) def polarization_degree(E, phase, ra, dec): """ """ return polarization_degree_spline.__call__(phase, E) def polarization_angle(E, phase, ra, dec): """ """ return polarization_angle_spline.__call__(phase, E) ephem = xEphemeris(0., 1./PERIOD) """We have all the ingredients, can define the ROI. """ ROI_MODEL = xROIModel(RA, DEC) axp_1708 = xPeriodicPointSource('J1708', RA, DEC, energy_spectrum, polarization_degree, polarization_angle, ephem, column_density=COLUMN_DENSITY, redshift=0.) ROI_MODEL.add_source(axp_1708) if __name__ == '__main__': plt.figure()
# Filter the data points to reduce the noise. _pol_degree = scipy.signal.wiener(_pol_degree, 5) fmt = dict(xname='Pulsar phase', yname='Polarization degree') pol_degree_spline = xInterpolatedUnivariateSpline(_phi, _pol_degree, k=1, **fmt) # And, again, this needs to be wrapped into a function. def polarization_angle(E, t, ra, dec): return pol_angle_spline(t) ROI_MODEL = xROIModel(83.633083, 22.014500) crab_ephemeris = xEphemeris(0., 29.8003951530036, -3.73414e-10, 1.18e-20) crab_pulsar = xPeriodicPointSource('Crab pulsar', ROI_MODEL.ra, ROI_MODEL.dec, energy_spectrum, polarization_degree, polarization_angle, crab_ephemeris) ROI_MODEL.add_source(crab_pulsar) if __name__ == '__main__': print(ROI_MODEL) from ximpol.utils.matplotlib_ import pyplot as plt plt.figure() pl_index_spline.plot(show=False) plt.figure() pl_normalization_spline.plot(show=False) plt.figure() pol_angle_spline.plot(show=False) plt.figure()