Detailed User Interface Information

Signal

Various signal classes in PsrSigSim contain the actual data which is passed to various other classes to make realistic pulsar signals.

class psrsigsim.signal.FilterBankSignal(fcent, bandwidth, Nsubband=512, sample_rate=None, sublen=None, dtype=<class 'numpy.float32'>, fold=True)[source]

A filter bank signal, breaking the time domain signal into RF bins.

Unlike purely time domain signals, FilterBankSignal ‘s are 2-D arrays. Filter banks record the intensity of the signal and can be much more sparsely sampled. The time binning must accurately capture the pulse profile, not the RF oscillations. In practice a filter bank is generated from the observed time domain signal by the telescope backend. We allow for direct filter bank signals to save memory.

Required Args:

fcent [float]: central radio frequency (MHz)

bandwidth [float]: radio bandwidth of signal (MHz)

Optional Args:
Nsubband [int]: number of sub-bands, default 512
XUPPI backends use 2048 frequency channels divided between the four Stokes parameters, so 512 per Stokes parameter.
sample_rate [float]: sample rate of data (MHz), default: None
If no sample_rate is given the observation will default to the 20.48 us per sample (about 50 kHz). This is the sample rate for coherently dedispersed filter banks using XUPPI backends.

# subint is now depricated for ‘FOLD’ #subint [bool]: is this a folded subintegration, default False

sublen [float]: desired length of data subintegration (sec) if subint
is True, default: tobs. If left as none but subint is True, then when pulses are made, the sublen will default to the input observation length, tobs
dtype [type]: data type of array, default: np.float32
supported types are: np.float32 and np.int8
fold [bool]: If True, the initialized signal will be folded to some
number of subintegrations based on sublen (else will just make a single subintegration). If False, the data produced will be single pulse filterbank data. Default is True. NOTE - using False will generate a large amount of data.
init_data(Nsamp)

Initialize a data array to store the signal.

Required Args:
Nsamp (int): number of data samples
to_Baseband()[source]

convert signal to BasebandSignal

to_FilterBank(Nsubband=512)[source]

convert signal to FilterBankSignal

to_RF()[source]

convert signal to RFSignal

psrsigsim.signal.Signal()[source]

helper function to instantiate signals

class psrsigsim.signal.BasebandSignal(fcent, bandwidth, sample_rate=None, dtype=<class 'numpy.float32'>, Nchan=2)[source]

A time domain base-banded signal.

A BasebandSignal covers frequencies from 0 Hz to its bandwidth, e.g. ~1 GHz for L-band GUPPI. In reality the telescope backend basebands the RF signal, but we allow pre-basebanded signals to save memory.

Required Args:

fcent [float]: central radio frequency (MHz)

bandwidth [float]: radio bandwidth of signal (MHz)

Optional Args:
sample_rate [float]: sample rate of data (MHz), default: None
If no sample_rate is given the observation will default to the Nyquist frequency. Sub-Nyquist sampling is allowed, but a warning will be generated.
dtype [type]: data type of array, default: np.float32
any numpy compatible floating point type will work

Nchan [int]: number of frequency channels to simulate, default is 2.

init_data(Nsamp)

Initialize a data array to store the signal.

Required Args:
Nsamp (int): number of data samples
to_Baseband()[source]

convert signal to BasebandSignal

to_FilterBank(Nsubband=512)[source]

convert signal to FilterBankSignal

to_RF()[source]

convert signal to RFSignal

class psrsigsim.signal.RFSignal(fcent, bandwidth, sample_rate=None, dtype=<class 'numpy.float32'>)[source]

a time domain signal at true radio frequency sampling

RFSignals must be sampled at twice the maximum resolved frequency, i.e. a few GHz. As such, RFSignals take up a TON of memory. Consider using BasebandSignal if this is a concern.

Required Args:

fcent [float]: central radio frequency (MHz)

bandwidth [float]: radio bandwidth of signal (MHz)

Optional Args:
sample_rate [float]: sample rate of data (MHz), default: None
If no sample_rate is given the observation will default to the Nyquist frequency. Sub-Nyquist sampling is allowed, but a warning will be generated.
dtype [type]: data type of array, default: np.float32
any numpy compatible floating point type will work
init_data(Nsamp)

Initialize a data array to store the signal.

Required Args:
Nsamp (int): number of data samples
to_Baseband()[source]

Convert signal to BasebandSignal

to_FilterBank(Nsubband=512)[source]

Convert signal to FilterBankSignal

Parameters:
Nsubband : int

Number of frequency subbands.

to_RF()[source]

Convert signal to RFSignal

Returns:
psrsigsim.signal.RFSignal

Pulsar

class psrsigsim.pulsar.Pulsar(period, Smean, profiles=None, name=None)[source]

class for pulsars

The minimal data to instantiate a pulsar is the period, Smean, and pulse profile. The Profile is supplied via a PulseProfile-like object.

Parameters:
period : float

Pulse period (sec)

Smean : float

Mean pulse flux density (Jy)

profile : PulseProfile

Pulse profile or 2-D pulse portrait

name : str

Name of pulsar

make_pulses(signal, tobs)[source]

generate pulses from Profiles, PulsePortrait object

Required Args:
signal (Signal-like): signal object to store pulses tobs (float): observation time (sec)
null(signal, null_frac, length=None, frequency=None)[source]

Function to simulate pulsar pulse nulling. Given some nulling fraction, will replace simulated pulses with noise until nulling fraction is met. This function should only be run after running any ism or other delays have been added, e.g. disperison, FD, profile evolution, etc., but should be run before adding the radiometer noise (‘telescope.observe()`), if nulling is desired.

Parameters:
signal [class] : signal class containing the simulated pulses
null_frac [float] : desired pulsar nulling fraction, given as a

decimal; range of 0.0 to 1.0.

length [float] : desired length of each null in seconds. If not given,

will randomly null pulses. Default is None.

frequency [float] : frequency of pulse nulling, e.g. how often the pulsar

nulls per hour. E.g. if frequency is 2, then the pulsar will null twice per hour for some length of time. If not given, will randomly null pulses. Default is None.

class psrsigsim.pulsar.PulsePortrait[source]

Base class for pulse profiles.

A pulse portrait is a set of profiles across the frequency range. They are INTENSITY series, even when using amplitude style signals (like BasebandSignal ).

calc_profiles(phases, Nchan=None)[source]

Calculate the profiles at specified phase(s)

Args:
phases (array-like): phases to calc profile
Note:
The normalization can be wrong, if you have not run init_profiles AND you are generating less than one rotation.

This is implemented by the subclasses!

init_profiles(Nphase, Nchan=None)[source]

Generate the profile, evenly sampled.

Parameters:
Nphase (int): number of phase bins
class psrsigsim.pulsar.GaussPortrait(peak=0.5, width=0.05, amp=1)[source]

Sum of gaussian components.

The shape of the inputs determine the number of gaussian components in the pulse. single float : Single pulse profile made of a single gaussian

1-d array : Single pulse profile made up of multiple gaussians where n is the number of Gaussian components in the profile.

Parameters:
peak : float)

Center of gaussian in pulse phase.

width : float

Stdev of pulse in pulse phase, default: 0.1

amp : float

Amplitude of pulse relative to other pulses, default: ``1`

Profile is renormalized so that maximum is 1.
See draw_voltage_pulse, draw_intensity_pulse and make_pulses() methods for
more details.
calc_profiles(phases, Nchan=None)[source]

Calculate the profiles at specified phase(s).

Args:
phases (array-like): phases to calc profile
Note:
The normalization can be wrong, if you have not run init_profile AND you are generating less than one rotation.
init_profiles(Nphase, Nchan=None)[source]

Generate the profile.

Args:
Nphase (int): number of phase bins
class psrsigsim.pulsar.UserPortrait[source]

User specified 2-D pulse portrait.

calc_profiles(phases, Nchan=None)

Calculate the profiles at specified phase(s)

Args:
phases (array-like): phases to calc profile
Note:
The normalization can be wrong, if you have not run init_profiles AND you are generating less than one rotation.

This is implemented by the subclasses!

init_profiles(Nphase, Nchan=None)

Generate the profile, evenly sampled.

Parameters:
Nphase (int): number of phase bins
class psrsigsim.pulsar.DataPortrait(profiles, phases=None)[source]

A pulse portrait generated from data.

The data are samples of the profiles at specified phases. If you have a functional form for the _profiles use UserProfile instead.

Parameters:
profiles : array, list of lists

Profile data in 2-d array.

phases : array, list of lists (optional)

List of sampled phases. If phases are omitted profile is assumed to be evenly sampled and cover one whole rotation period.

Profile is renormalized so that maximum is 1.
See draw_voltage_pulse, draw_intensity_pulse and make_pulses() methods for
more details.
calc_profiles(phases, Nchan=None)[source]

Calculate the profile at specified phase(s).

Args:
phases (array-like): phases to calc profile
Note:
The normalization can be wrong, if you have not run init_profile AND you are generating less than one rotation.
init_profiles(Nphase, Nchan=None)

Generate the profile, evenly sampled.

Parameters:
Nphase (int): number of phase bins
class psrsigsim.pulsar.PulseProfile[source]

Base class for pulse profiles

Pulse profiles are INTENSITY series, even when using amplitude style signals (like BasebandSignal ).

calc_profile(phases)[source]

Calculate the profile at specified phase(s). This is implemented by the subclasses!

Args:
phases (array-like): phases to calc profile
Note:
The normalization can be wrong, if you have not run init_profile AND you are generating less than one rotation.
calc_profiles(phases, Nchan=None)

Calculate the profiles at specified phase(s)

Args:
phases (array-like): phases to calc profile
Note:
The normalization can be wrong, if you have not run init_profiles AND you are generating less than one rotation.

This is implemented by the subclasses!

init_profile(Nphase)[source]

Generate the profile, evenly sampled.

Args:
Nphase (int): number of phase bins
init_profiles(Nphase, Nchan=None)

Generate the profile, evenly sampled.

Parameters:
Nphase (int): number of phase bins
class psrsigsim.pulsar.GaussProfile(peak=0.5, width=0.05, amp=1)[source]

Sum of guassian components.

The shape of the inputs determine the number of gaussian components in the pulse.

single float : Single pulse profile made of a single gaussian

1-d array : Single pulse profile made up of multiple gaussians

where n is the number of Gaussian components in the profile.

Required Args:
N/A
Optional Args:
peak (float): center of gaussian in pulse phase, default: 0.5 width (float): stdev of pulse in pulse phase, default: 0.1 amp (float): amplitude of pulse relative to other pulses, default: 1

Pulses are normalized so that maximum is 1. See draw_voltage_pulse, draw_intensity_pulse and make_pulses() methods for more details.

calc_profiles(phases, Nchan=None)

Calculate the profiles at specified phase(s).

Args:
phases (array-like): phases to calc profile
Note:
The normalization can be wrong, if you have not run init_profile AND you are generating less than one rotation.
init_profiles(Nphase, Nchan=None)

Generate the profile.

Args:
Nphase (int): number of phase bins
set_Nchan(Nchan)[source]

Method to reintialize the portraits with the correct number of frequency channels. Once must run init_profiles or calc_profiles to remake the profiles property.

Note - No phases attribute, function must be updated.

Parameters:
Nchan : int

Number of frequency channels.

class psrsigsim.pulsar.UserProfile(profile_func)[source]

User specified pulse profile

UserProfile’s are specified by a function used to compute the profile at arbitrary pulse phase. If you want to generate a profile from empirical data, i.e. a Numpy array, use DataProfile.

Required Args:

profile_func (callable): a callable function to generate the profile
as a function of pulse phase. This function takes a single, array-like input, a phase or list of phases.

Profile is renormalized so that maximum is 1. See draw_voltage_pulse, draw_intensity_pulse and make_pulses() methods for more details.

calc_profile(phases)[source]

Calculate the profile at specified phase(s)

Args:
phases (array-like): phases to calc profile
Note:
The normalization can be wrong, if you have not run init_profile AND you are generating less than one rotation.
calc_profiles(phases, Nchan=None)

Calculate the profiles at specified phase(s)

Args:
phases (array-like): phases to calc profile
Note:
The normalization can be wrong, if you have not run init_profiles AND you are generating less than one rotation.

This is implemented by the subclasses!

init_profile(Nphase)

Generate the profile, evenly sampled.

Args:
Nphase (int): number of phase bins
init_profiles(Nphase, Nchan=None)

Generate the profile, evenly sampled.

Parameters:
Nphase (int): number of phase bins
class psrsigsim.pulsar.DataProfile(profiles, phases=None, Nchan=None)[source]

A set of pulse profiles generated from data.

The data are samples of the profile at specified phases. If you have a functional form for the profile use UserProfile instead.

Required Args:
profile (array-like): profile data
Optional Args:
phases (array-like): list of sampled phases. If phases are omitted
profile is assumed to be evenly sampled and cover one whole rotation period.

Profile is renormalized so that maximum is 1. See draw_voltage_pulse, draw_intensity_pulse and make_pulses() methods for more details.

calc_profiles(phases, Nchan=None)

Calculate the profile at specified phase(s).

Args:
phases (array-like): phases to calc profile
Note:
The normalization can be wrong, if you have not run init_profile AND you are generating less than one rotation.
init_profiles(Nphase, Nchan=None)

Generate the profile, evenly sampled.

Parameters:
Nphase (int): number of phase bins
set_Nchan(Nchan)[source]

Method to reintialize the portraits with the correct number of frequency channels. Once must run init_profiles or calc_profiles to remake the profiles property.

Note - Has same issue as set_Nchan before.

Parameters:
Nchan : int

Number of frequency channels.

Telescope

class psrsigsim.telescope.Telescope(aperture, area=None, Tsys=None, name=None)[source]

contains: observe(), noise(), rfi() methods

add_system(name=None, receiver=None, backend=None)[source]

append new system to dict systems

init_signal(system)[source]

instantiate a signal object with same Nt, Nf, bandwidth, etc as the system to be used for observation

observe(signal, pulsar, system=None, noise=False, ret_resampsig=False)[source]
Parameters:
signal – Signal() instance
pulsar – Pulsar() object, necessary for radiometer noise scaling
system – dict key for system to use
noise : bool

If True will add radiometer noise to the signal data.

ret_resampsig : bool

If True will return the resampled signal as a numpy array. Otherwise will not return anything.

class psrsigsim.telescope.Receiver(response=None, fcent=None, bandwidth=None, Trec=35, name=None)[source]

Telescope receiver. A Receiver must be instantiated with either a callable response function or fcent and bandwidth to use a flat response.

Required Args:
N/A
Optional Args:

response (callable): frequency response function (“bandpass”) of receiver.

fcent (float): center frequency of receiver with flat response (MHz)

bandwidth (float): bandwidth of receiver with flat response (MHz)

Trec (float): receiver temperature (K) for radiometer noise level, default: 35

radiometer_noise(signal, pulsar, gain=1, Tsys=None, Tenv=None)[source]

Add radiometer noise to a signal.

Tsys = Tenv + Trec, unless Tsys is given (just Trec if no Tenv)

flux density fluctuations: sigS from Lorimer & Kramer eq 7.12

psrsigsim.telescope.response_from_data(fs, values)[source]

generate a callable response function from discrete data Data are interpolated.

ISM

class psrsigsim.ism.ISM[source]

Class for modeling interstellar medium effects on pulsar signals.

FD_shift(signal, FD_params)[source]

This calculates the delay that will be added due to an arbitrary number of input FD parameters following the NANOGrav standard as defined in Arzoumanian et al. 2016. It will then shift the pulse profiles by the appropriate amount based on these parameters.

FD values should be input in units of seconds, frequency array in MHz FD values can be a list or an array

\[\Delta t_{\rm{FD}} = \sum_{i=1}^{n} c_{i} \log\left({\frac{\nu}{1~\rm{GHz}}}\right)^{i}.\]
convolve_profile(profiles, convolve_array, width=2048)[source]

Function to convolve some array generated by a function with the previously assigned pulsar pulse profiles. Main use case is in convolving exponential scattering tails with the input pulse profiles, however any input array can be convolved.

NOTE: This function only returns the array of convolved profiles, it does NOT reassign the pulsar objects profiles.

Parameters:
profiles [array] : data array of pulse profiles generated with the

‘calc_profiles’ function.

convolve_array [array] : data array representing the function that

will be convolved with the pulse profiles. Should be the same shape as ‘profiles’.

width [int] : number of bins desired from the resulting convolved

profiles. Default is 2048 bins across the profile. Should be the same number as the original input profiles.

disperse(signal, dm)[source]

Function to calculate the dispersion per frequency bin for \(1/\nu^{2}\) dispersion.

\[\Delta t_{\rm{DM}} = 4.15\times 10^{6}~\rm{ms} \times \rm{DM} \times \frac{1}{\nu^{2}}\]
scale_dnu_d(dnu_d, nu_i, nu_f, beta=3.6666666666666665)[source]

Scaling law for scintillation bandwidth as a function of frequency.

Parameters:
dnu_d [float] : scintillation bandwidth [MHz]
nu_i [float] : reference frequency at which du_d was measured [MHz]
nu_f [float] : frequency (or frequency array) to scale dnu_d to [MHz]
beta [float] : preferred scaling law for dnu_d, default is for a

Kolmogorov medium (11/3)

scale_dt_d(dt_d, nu_i, nu_f, beta=3.6666666666666665)[source]

Scaling law for scintillation timescale as a function of frequency.

Parameters:
dt_d [float] : scintillation timescale [seconds]
nu_i [float] : reference frequency at which du_d was measured [MHz]
nu_f [float] : frequency (or frequency array) to scale dnu_d to [MHz]
beta [float] : preferred scaling law for dt_d, default is for a

Kolmoogorov medium (11/3)

scale_tau_d(tau_d, nu_i, nu_f, beta=3.6666666666666665)[source]

Scaling law for the scattering timescale as a function of frequency.

Parameters:
tau_d [float] : scattering timescale [seconds?]
nu_i [float] : reference frequency at which du_d was measured [MHz]
nu_f [float] : frequency (or frequency array) to scale dnu_d to [MHz]
beta [float] : preferred scaling law for tau_d, default is for a

Kolmoogorov medium (11/3)

scatter_broaden(signal, tau_d, ref_freq, beta=3.6666666666666665, convolve=False, pulsar=None)[source]

Function to add scatter broadening delays to simulated data. We offer two methods to do this, one where the delay is calcuated and the pulse signals is directly shifted by the calculated delay (as done in the disperse function), or the scattering delay exponentials are directy convolved with the pulse profiles. If this option is chosen, the scatter broadening must be done BEFORE pulsar.make_pulses() is run.

Parameters:
signal [object] : signal class object which has been previously defined
tau_d [float] : scattering delay [seconds]
ref_freq [float] : reference frequency [MHz] at which tau_d was measured
beta [float] : preferred scaling law for tau_d, default is for a

Kolmoogorov medium (11/3)

convolve [bool] : If False, signal will be directly shifted in time by

scattering delay; if True, scattering delay tails will be directly convolved with the pulse profiles.

pulsar [object] : previously defined pulsar class object with profile

already assigned

IO

class psrsigsim.io.BaseFile(path=None)[source]

Base class for making files for the PsrSigSim Signal object.

append()[source]

Method for append data to an already existing PSS signal file. Must be implemented in subclass!

load()[source]

Method for loading saved PSS signal files. Must be implemented in subclass!

save(signal)[source]

Save PSS signal file to disk. Must be implemented in subclass!

to_psrfits()[source]

Convert file to PSRFITS file. Must be implemented in subclass!

to_txt()[source]

Convert file to txt file. Must be implemented in subclass!

class psrsigsim.io.PSRFITS(path=None, obs_mode=None, template=None, copy_template=False, fits_mode='copy')[source]

A class for saving PsrSigSim signals as PSRFITS standard files.

Parameters:
path: str

name and path of new psrfits file that will be saved

obs_mode: str

what type of observation is the data, SEARCH, PSR, etc.

template: str

the path and name of the template fits file that will be loaded

copy_template: bool

Does nothing?

fits_mode: str

How we want to save the data, right now just ‘copy’ is valid

append(signal)[source]

Method for appending data to an already existing PSS signal file.

copy_psrfit_BinTables(ext_names='all')[source]

Method to copy BinTables from the PSRFITS file given as the template.

Parameters:
ext_names : list, ‘all’

List of BinTable Extensions to copy. Defaults to all, but does not copy DATA array in SUBINT BinTable.

load()[source]

Method for loading saved PSS signal files. These files will have an additional BinTable extension, ‘PSRSIGSIM’, that only contains a header with the various PsrSigSim parameters written for references.

make_signal_from_psrfits()[source]

Method to make a signal from the PSRFITS file given as the template. For subintegrated data will assume the initial period is the pulsar period given in the PSRPARAM header.

TODO: Currently does not support generating ‘SEARCH’ mode data from
a psrfits file
Returns:
psrsigsim.Signal
save(signal, pulsar, phaseconnect=False, parfile=None, MJD_start=56000.0, segLength=60.0, inc_len=0.0, ref_MJD=56000.0, usePint=True, eq_wts=True)[source]

Save PSS signal file to disk. Currently only one mode of doing this is supported. Saved data can be phase connected but PSRFITS file metadata must be edited appropriately as well and requires the following input:

Parameters:
signal [class] : signal type class (currently only filterbank is supported)

used to get the data array to save and other metadata.

pulsar [class] : pulsar type class used to generate the signal, used for

metadata access.

phaseconnect [bool] : If False, will not attempt to phase connect data

rewrite polycos, etc. If True, will attempt to phase connect data and all other inputs must be provided.

parfile [string] : path to par file used to generate the polycos. The observing frequency, and observatory will

come from the par file.

MJD_start [float] : Start MJD of the polyco. Should start no later than the beginning of the observation.
segLength [float] : Length in minutes of the range covered by the polycos generated. Default is 60 minutes.
ref_MJD [float] : initial time to reference the observations to (MJD). This value

should be the start MJD (fraction if necessary) of the first file, default is 56000.0.

inc_len [float] : time difference (days) between reference MJD and new phase connected

MJD, default is 0 (e.g. no time difference).

usePINT [bool] : Method used to generate polycos. Currently only PINT is supported.
eq_wts [bool] : If True (default), replaces the data weights so that each subintegration and

frequency channel have an equal weight in the file. If False, just copies the weights from the template file.

set_sky_info()[source]

Enter various astronomical and observing data into PSRFITS draft.

to_psrfits()[source]

Convert file to PSRFITS file.

to_txt()[source]

Convert file to txt file.

class psrsigsim.io.TxtFile(path=None)[source]

A class for saving PsrSigSim signals as text files. Multiple different text file data types may be supported, but currently only the PSRCHIVE pdv function output is supported.

Parameters:
path: name and path of new text file that will be saved
append()

Method for append data to an already existing PSS signal file. Must be implemented in subclass!

load()

Method for loading saved PSS signal files. Must be implemented in subclass!

save(signal)

Save PSS signal file to disk. Must be implemented in subclass!

save_psrchive_pdv(signal, pulsar)[source]

Function to save simulated data in the same format as the PSRCHIVE pdf function. To avoid large file sizes, every hundred pulses the data will be saved as a text file. Currently one a single polarization (total intensity) is supported. Inputs are:

Parameters:
signal [class] : signal class object, currently only filterbank is supported
pulsar [class] : pulsar class object
filename [string] : desired name of source/output file. Output files will be saved as

‘filename’_#.txt, where # is the chronological number of the files being saved.

to_psrfits()

Convert file to PSRFITS file. Must be implemented in subclass!

to_txt()

Convert file to txt file. Must be implemented in subclass!

Simulate

class psrsigsim.simulate.Simulation(fcent=None, bandwidth=None, sample_rate=None, dtype=<class 'numpy.float32'>, Npols=1, Nchan=512, sublen=None, fold=True, period=None, Smean=None, profiles=None, tobs=None, name=None, dm=None, tau_d=None, tau_d_ref_f=None, aperture=None, area=None, Tsys=None, tscope_name=None, system_name=None, rcvr_fcent=None, rcvr_bw=None, rcvr_name=None, backend_samprate=None, backend_name=None, tempfile=None, parfile=None, psrdict=None)[source]

convenience class for full simulations.

Necessary information includes all minimal parameters for instances of each other class, Signal, Pulsar, ISM, Telescope.

Input may be specified manually, from a pre-made parfile with additional input, e.g. for the Signal, or from a premade dictionary with appropriate keys.

Parameters:
fcent : float]

Central radio frequency (MHz)

bandwidth : float

Radio bandwidth of signal (MHz)

Nsubband : int

Number of sub-bands, default 512 XUPPI backends use 2048 frequency channels divided between the four Stokes parameters, so 512 per Stokes parameter.

sample_rate : float

Sample rate of data (MHz), default: None If no sample_rate is given the observation will default to the 20.48 us per sample (about 50 kHz). This is the sample rate for coherently dedispersed filter banks using XUPPI backends.

sublen : float

Desired length of data subintegration (sec) if subint is True, default: tobs. If left as none but subint is True, then when pulses are made, the sublen will default to the input observation length, tobs

dtype : type

Data type of array, default: np.float32 supported types are: np.float32 and np.int8

fold : bool

If True, the initialized signal will be folded to some number of subintegrations based on sublen (else will just make a single subintegration). If False, the data produced will be single pulse filterbank data. Default is True. NOTE - using False will generate a large amount of data.

period : float

Pulse period (sec)

Smean : float

Mean pulse flux density (Jy)

profile : array or function or Pulse Profile/Portrait Class
Pulse profile or 2-D pulse portrait, this can take four forms:
array - either an array of Gaussian components in the order

[peak phase, width, amplitude] OR A data array representative of the pulse profile, or samples of the profile from phases between 0 and 1. Data array must have more than 3 points.

function - function defining the shape of the profile given a

of input phases. CURRENTLY NOT IMPLEMENTED.

class - predefined PsrSigSim Pulse Profile or Pulse Portrait class

object.

tobs : float

Total simulated observing time in seconds

name : str

Name of pulsar

dm : float

Dispersion measure of the pulsar (pc cm^-3)

tau_d : float

Scattering timescale to use (s)

tau_d_ref_f : float

reference frequency for the input scattering timescale (MHz)

aperture : float

Telescop aperture (m)

area : float

Collecting area (m^2) (if omitted, assume circular single dish)

Tsys : float

System temperature (K) of the telescope (if omitted use Trec)

tscope_name : string

Name of the telescope. If GBT or Arecibo, will use predefined parameters.

system_name : string

Name of telescope system, backend-recviever combination. May be a list.

rcvr_fcent: float

Center frequency of the telescope reciever. May be a list.

rcvr_bw : float

Bandwidth of the telescope reciever. May be a list.

rcvr_name : string

Name of the telescope reciever. May be a list.

backend_samprate : float

Sampling rate (in MHz) of the telescope backend. May be a list.

backend_name : string

Name of the telescope backend. May be a list.

tempfile : string

Path to template psrfits file to use for saving simulated data.

parfile : string

Path to pulsar par file to read in to use for pulsar parameters

psrdict : dictionary

Dictionary of input parameters to generate simualted data from. Keys should be the same as possible input values listed above.

init_ism()[source]

Function to initialize the ISM from the input parameters.

init_profile()[source]

Function to initialize a profile object from input.

init_pulsar()[source]

Function to initialize a pulsar from the input parameters. NOTE - Must have initialized the profile before running this.

init_signal(from_template=False)[source]

Function to initialize a signal from the input parameters.

Parameters:
from_template : bool

If True, will use the input template file to initialize the signal. If False will use other input values to initialize the signal.

init_telescope()[source]

Function to initialize the telescope from input parameters.

params_from_dict(psrdict)[source]

Function to take the input dictionary and assign values from that.

params_from_par(parfile)[source]

Function to take input par file and assign values from that.

save_simulation(outfile='simfits', out_format='psrfits', phaseconnect=False, parfile=None, ref_MJD=56000.0, MJD_start=55999.9861)[source]

Function to save the simulated data in a default format. Currently only PSRFITS is supported.

Parameters:
outfile : string

Path and name of output save file. If not provided, output file is “simfits”.

out_format : string

Format of output file (not case sensitive). Options are: ‘psrfits’ - PSRFITS format. Requires template file. ‘pdv’ - PSRCHIVE pdv format. Output is a text file.

phaseconnect : bool

Make sure to phase connect output data if output format is PSRFITS.

parfile : string

Parfile to use to make phase connection polycos. If none supplied will attempt to create one.

ref_MJD : float

Reference MJD for phase connection.

MJD_start : float

Desired start time of the simulated observation. Needed for phase connection.

simulate(from_template=False)[source]

Function to run the full simulation.

Parameters:
from_template : bool

If True, will use the input template file to initialize the signal. If False will use other input values to initialize the signal.

twoD : bool

If True, will generate a 2-D profile array, else will do a 1-D and will tile the profile in frequency.

Utilities

psrsigsim.utils.make_quant(param, default_unit)[source]

Convenience function to intialize a parameter as an astropy quantity.

Parameters:
param : attribute

Parameter to initialize.

default_unit : string

Name of an astropy unit, set as default for this parameter.

Returns:
An astropy quantity

Examples

self.f0 = make_quant(f0,’MHz’)

psrsigsim.utils.make_par(signal, pulsar, outpar='simpar.par')[source]

Function to create a par file for simulated pulsar.

Parameters:
signal : class

PsrSigSim Signal class object

pulsar : class

PsrSigSim Pulsar class object

outpar : string

Name of output par file.

psrsigsim.utils.shift_t(y, shift, dt=1)[source]

Shift timeseries data in time. Shift array, y, in time by amount, shift. For dt=1 units of samples (including fractional samples) are used. Otherwise, shift and dt are assumed to have the same physical units (i.e. seconds).

Parameters:
y : array like, shape (N,), real

Time series data.

shift : int or float

Amount to shift

dt : float

Time spacing of samples in y (aka cadence).

Returns:
out : ndarray

Time shifted data.

Examples

>>>shift_t(y, 20) # shift data by 20 samples

>>>shift_t(y, 0.35, dt=0.125) # shift data sampled at 8 Hz by 0.35 sec

Uses np.roll() for integer shifts and the Fourier shift theorem with real FFT in general. Defined so positive shift yields a “delay”.