Examples¶
Below are some examples of tasks you may wish to perform. If you would like to see more examples, please submit an issue on github or e-mail me at michael-dot-lam-at-nanograv-dot-org.
Calculating scintillation parameters¶
Below is the very simplest way to get scintillation parameters.
ar = Archive(FILENAME) #loads archive, dedispersed and polarization averaged by default
ds = ar.getDynamicSpectrum() #without a template shape, this will average the data across the phase axis. One can set maketemplate=True to take the average pulse shape and make an underlying template
print(ds.scintillation_parameters()) #will return the scintillation timescale, scintillation bandwidth, and drift rate (rotation) using a 2D Gaussian fit
Make a Joy Division plot¶
ar = Archive(FILENAME) #loads archive, dedispersed and polarization averaged by default
ar.fscrunch() #frequency-average the data, if applicable.
ar.joyDivision() #makes the Joy-Division-style plot for pulses in time and phase
Make a template shape¶
If you are starting from a PSRFITS file, the easiest thing to do is probably the following:
ar = Archive(FILENAME) #loads archive, dedispersed and polarization averaged by default
ar.tscrunch() #time-average the data, if applicable.
template = ar.calculateTemplate() #By default, will use von Mises functions
If you already have the data array extracted, then you can go straight to the underlying functionality:
sp = SinglePulse(data,windowsize=len(data)//8) #windowsize will auto-calculate an off-pulse region
template = sp.smooth() # By default, will use von Mises functions
Comment out TOAs in a .tim file with a given condition¶
Let’s say we wish to comment out TOAs with a flag representing a specific backend: “-be legacy”