Data Classes

The Base classes defined for Profile, and so on.

Profile class

The Class of Profile

class tatpulsar.data.profile.Profile(counts, cycles=1, error=None)[source]

Profile class

Parameters

counts : array-like

the counts in each phase bin of Profile

cycles : int

the period cycles of input Profile (default is 1). If cycles=2, the phase of profile would be np.linspace(0, 2, size_of_Profile+1)[:-1]

error : array-like

the error of each phase bin, if not given the error will be the poisson error of counts (sqruare root of counts)

Attributes

counts : array-like

The counts in each phase bin of Profile

phase : array-like

The midpoints of phase bins

phase_off : list

The list of phase off interval, the two value are the left and right phase bin of off pulse phases. left_edge = phase_off[0] right_edge = phase_ff[1]

ref_time : float, default None

The reference time (in second) used to fold the profile

property chisq[source]

chisquare statistic value of profile

property dof[source]

degree of freedom is \((n-1)\) where \(n\) is the number of bins.

norm(method=0, bkg_range=None, return_profile=False)[source]

normalize the profile, and return a normalized Profile object

bkg_range is the background phase range selected to calculated the mean level of background, used in method=0.

Parameters

method: int, optional

The normalization method utilized, optional methods are {0, 1} method = 0 : \(N = (P - P_{min})/(P_{max} - P_{min})\) if background range are selected (bkg_range is not None) \(N = (P - \bar{B})/(P_{max} - \bar{B})\) where \(\bar{B}\) is the mean level in bkg_range method = 1 : \(N = (P-P_{min})/\bar{P}\)

bkg_range: list, optional

The background phase range for background estimation

return_profile: bool, optional

whether to return the profile, if False modify the attributes

property pulsefrac[source]

Calculate the pulse fraction of given profile. The algorithm of calculating pulse fraction is:

\[PF = (p_{\mathrm{max}} - p_{\mathrm{min}})/(p_{\mathrm{max}} + p_{\mathrm{min}})\]

where \(p\) is the counts of profile.

Note

please note the pulse fraction has valid physical meaning only if the input profile is folded by the net lightcurve or the background level can be well estimated and subtracted from the observed pulse profile.

Returns

pf: float

The pulse fraction of profile

pf_err: float

The error of pulse fraction

rebin(nbins=None, factor=None, return_profile=False)[source]

Rebin the profile into the given bin size or use the factor to split the intervals.

Parameters

nbins: int

the number of the bins of new profile, if ‘nbins’ is used, then the ‘factor’ parameter would not work

factor: int

rebin profile to a new shape, new shape must be a factor of the original shape

return_profile: bool, optional

whether to return the profile, if False modify the attributes

Returns

profile: Profile object

return a new profile in one cycle

resample(sample_num=1, kind='poisson')[source]

resampling the profile

Parameters

sample_num : int, optional

number of the resamplings for the profile, the default number is 1

kind : str, optional

The distribution of the profile, default is poisson. (‘poisson’, ‘gaussian’) are refering to the poisson and gauss distribution

Returns

resampled_profile : array or ndarray

if sample_num == 1, return a one dimensional array if sample_num >1 , return a multi-dimensional array

property rms[source]

calculate the Root-Mean-Square (RMS) of a given pulse profile (reference: Tsygankov, Sergey S., et al. MNRAS, 457.1 (2016): 258-266.)

\[\mathrm{RMS}=\frac{(\frac{1}{N}\sum_{i=1}^{N}(P_i - \overline{P}))^{1/2}}{\overline{P}}\]

where \(P_i\) is the background-corrected count rate in a given bin of the pulse profile, \(\overline{P}\) is the count rate averaged over the pulse period, and \(N\) is the total number of phase bins in the profile.

Note

This definition gives significantly lower absolute value of the pulsed fraction, however all features described above have the same form.

Returns

rms: float

The RMS value

sampling_event(nphot, tstart, tstop, f0, f1=0, f2=0, f3=0, pepoch=0)[source]

sampling the photon arrival time

Parameters

nphot: int

The output amount of sampled photons

tstart: array-like

The start time to generate arrival time (MJD)

tstop: array-like

The stop time to generate arrival time (MJD)

f0: float

The frequency of the pulsar

f1: float, optional

The frequency derivative of the pulsar

f2: float, optional

The second derivative of the frequency

f3: float, optional

The third derivative of the frequency

f4: float, optional

The fourth derivative of the frequency

pepoch: float

The reference time of the timing parameters (MJD)

Returns

event_list: array-like

The sampled arrival times of photons

sampling_phase(nphot)[source]

use rejection sampling method to draw the phase list

Parameters

nphot: int

The output amount of sampled photons

Returns

phase: array-like

The phase sample that satisfy the rejection rule

property significance[source]

Return the significance in unit of sigma of given profile.

property size[source]

return the real bin size of the profile. If the profile is presented in 2 cycles, the size is still the size of the bin size of the profile in 1 cycle.

tatpulsar.data.profile.draw_random_pulse(nbins=100, baseline=1000, pulsefrac=0.2)[source]

Generate a random pulse profile that consists of multiple Gaussian-like pulse

Parameters

nbins: int

The number of the new profile bins

baseline: int

The baseline (background) level of the profile in unit of counts

pulsefrac: float

pulse frac

Returns
profile: Profile object
tatpulsar.data.profile.phihist(phi, nbins, **kwargs)[source]

Ensure that the input and output of the histogram are appropriate. The input variables are the pulse phi of events, and the nbins. The counts of each bin are calculated by dividing [0, 1] into number of nbins.

Parameters

phi : array

a set of phase value of events.

nbins : int

the number of bins of profile

Returns

Profile : object

return the object of Profile