modest.signals package

Submodules

modest.signals.oneDimensionalObject module

class modest.signals.oneDimensionalObject.oneDObjectMeasurement(objectID)[source]

Bases: modest.signals.signalsource.SignalSource

computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]

modest.signals.periodicxraysource module

class modest.signals.periodicxraysource.PeriodicXRaySource(profile=None, avgPhotonFlux=None, pulsedFraction=None, PARFile=None, movePeakToZero=True, normalizeProfile=True, phaseDerivatives=None, pulsarPeriod=None, RA=None, DEC=None, observatoryMJDREF=None, TZRMJD=None, PEPOCH=None, name=None, attitudeStateName='attitude', correlationStateName=None, useProfileColumn=None, startTime=0, extent=None, useTOAprobability=True, useFitted=True, detectorArea=1)[source]

Bases: modest.signals.poissonsource.DynamicPoissonSource, modest.signals.pointsource.PointSource

PeriodicPoissonSource is a class which models the signal from a periodic poisson source, e.g. a pulsar.

This class accepts a large number of initialization inputs required to model such a source. Alternatively, the user can pass a PAR file, and the object will initialize based on that.

FWHM()[source]
MJD2seconds(MJD)[source]

A simple utility function to convert modified Julian date to pulsar time

See also

seconds2MJD()

Parameters:MJD (float) – Modified Julian Date
Returns:Time in seconds
Return type:(float)
computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]

Computes the probability of association

This method computes the probability of association of a signal given the measurement and prior state. This is a conditional probability based on Bayes rule. Bayes rule is given by

\[\textrm{Pr}\left[A_p | \mathbf{y}\right] = \frac{\textrm{Pr}\left[\mathbf{y}|A_p\right] \textrm{Pr}\left[A_p\right]}{\textrm{Pr}\left[\mathbf{y}\right]}\]

Generally, the denominator is not directly computed and will be divided out.

For a periodic point source, there are two possible measurements: angle of arrival and time of arrival. If both of these measurements are included in the measurement dictionary, the probability will be computed as

\[\textrm{Pr}\left[A_p | (\alpha, t)\right] = \mathcal{N}\left[\alpha, \mathbf{S}_\alpha \right] \lambda(t) \bar{\lambda}\]

These sub-components of the probability are not computed here; rather they are computed by the PoissonSource and PointSource parent classes from which this class inherits. So, if something needs to be changed about the computation of association probability, it is likely that it needs to be changed in the parent classes.

If either of these measurements is not included in the measurement dict, then that component of the probability will be set to 1.

Note

The probability computed here is not an “absolute” probability. It only has meaning in relation to other probabilities. In order for this number to be meaningful, it should be normalized with all other possible association probabilities so that their sum is 1. Also note that the probability returns contains \(\delta \alpha\) and \(\delta t\) differential terms. These differential terms are divided out in the normalization process. All the other probabilities must contain these same terms for the comparison to be meaningful and the normalization to be valid.

Parameters:
  • measurement (dict) – A dictionary containing the measured values and their variances
  • stateDict (dict) – A dictionary containing the substates and their values
  • validationThreshold (float) – Unused
Returns:

The probability of association

Return type:

(float)

computeSinglePeriodIntegral()[source]

Compute the integral as a function of time of the pulsar flux.

This will be used later to compute expected value of flux in the case where time is uncertain. Generally this function only needs to be called once at initialization; once the integral is computed it is stored as an attribute and can be accessed on demand. Integral is computed using trapezoidal integration.

generatePhotonArrivals(tMax, t0=0, timeOffset=None, spacecraft=None)[source]

Generate photon arrival measurements

This function generates photon arrivals from the pulsar signal based on the parameters of the simulation. The

getFrequency(observatoryTime)[source]

Compute the current frequency of the pulsar signal

This function uses all available frequency information including derivatives to compute the current frequency of the pulsar signal at the given time. However it does not check for time validity. Some PAR files are valid over only a specified time frame; it is up to the user to verify whether the time given is within that region.

See also

getPeriod()

Parameters:observatoryTime (float) – Time for which frequency is to be computed
Returns:Computed frequency in Hz
Return type:(float)
getPeriod(observatoryTime)[source]

Compute the current period of the pulsar signal

This function uses all available frequency information including derivatives to compute the current period of the pulsar signal at the given time. However it does not check for time validity. Some PAR files are valid over only a specified time frame; it is up to the user to verify whether the time given is within that region.

See also

getFrequency()

Parameters:observatoryTime (float) – Time for which period is to be computed
Returns:Computed period in seconds
Return type:(float)
getPhase(observatoryTime)[source]

Compute the current phase of the pulsar signal.

This method uses all available frequency/phase information including derivatives. However, it does not check for validity of the time passed. Some PAR files are valid over only a specific region of time, and this function will not verify that the time given is within that time window.

It is up to the user to verify the validity of the results.

Args:
observatoryTime (float): Local time at which flux is to be computed.
Returns:
(float): Current pulsar phase
getPulseFromPhase(phase)[source]

Returns the value of the signal given the signal phase

This function uses the signal profile to compute the value of the signal given the signal phase. It uses simple linear interpolation to find the value.

Parameters:phase (float) – The phase number of the signal. Phase can be any numerical value; the fractional phase will be computed by taking remainder of the value divided by 1.
Returns:The value of the signal at the given phase
Return type:(float)
getSignal(observatoryTime, tVar=None)[source]

getSignal is responsible for returning the photon flux from the pulsar at a given time

The getSignal method is the method which is responsible for returning the current value of flux from the signal source at a given time. If there is uncertainty in the time, then the expected value of the signal is returned. Uncertainty in time is indicated by the optional tVar argument.

In every case, the method calls the getPhase method to determine the current signal source phase. If no uncertainty in time is passed, then the getPulseFromPhase method is called to lookup/interpolate the current flux based on the phase and the signal profile.

If a value is passed for tVar, then the process is more complicated. Rather than simply look up the signal value from the phase, the function returns an approximation of the expected value of the signal, given the mean and variance of time.

Normally, the expected value would be computed by integrating the product of the true distribution of time (probably a normal distribution) with the flux as a function of time. However, due to the non-analytical nature of the flux function, the direct computation of this integral is intractable. To overcome this limitation, the time distributuion is approximated as a moment-matched uniform distribution. Using this approximation, the approximate integral may be directly computed simply by looking up the start and end values of singlePeriodIntegral, and dividing by the appropriate scaling factor.

Parameters:
  • observatoryTime (float) – The time for which to compute the signal
  • tVar (float) – The variance of the time estimate (optional)
Returns:

The signal at the requested time, in photons/second

Return type:

(float)

getSignalMJD(MJD)[source]

getSignalMJD is a wrapper function that returns the photon flux at a given Modified Julian Date

See also

getSignal()

Parameters:MJD (float) – The Modified Jullian Date for which flux is to be returned
Returns:The signal at the requested date
Return type:(float)
plot(nPeriods=1, tVar=None, figureHandle=None, nPoints=1000)[source]

Plots the pulsar profile

This is a simple visualization function that generates a plot of the pulsar profile over a specified number of pulsar periods. Optionally, you can also specify a time uncertainty to see how the effective profile changes with time uncertainty.

Parameters:
  • nPeriods (float) – Number of periods to plot
  • tVar (float) – Variance of time uncertainty. If set to None then no uncertainty is included.
  • figureHandle – Optional handle to an existing figure
  • nPoints (int) – Number of points to plot
processPARFile(PARFile, replaceCurrentValues=False)[source]

Read a PAR file passed by the user and change/initialize object attributes accordingly.

PAR files are a semi-standardized way to store information about pulsars. Most PAR files contain, at a minimum, the name of the pulsar, the sky coordinates of the pulsar (i.e. right ascension and declination) and frequency information about the pulsar. They may also contain other helpful information such as reported glitches, pulsar binary model information, etc. Rather than force the user to enter all this information manually, the object can initialize from a PAR file and gather the relevant information on its own.

In order to further simplify the pulsar object initialization pipeline, this method also processes additional information found in the PAR file which isn’t part of the standard PAR file format. This includes information like source extent (i.e. how big is the object in the sky), source flux (photons per second per unit area, energy per second per unit area), pulsed fraction, and pulse profile. This information is not normally included in a PAR file. However, it is relatively easy to add it manually, and this simplifies workflow by keeping all the relevant information about the pulsar in one file.

Parameters:
  • PARFile (str) – Path to PAR file to be read
  • replaceCurrentValues (bool) – Determines whether previously stored values will be overwritten by values found in the PAR file
Returns:

Tuple containing the right ascension and declination of the source found in the PAR file

Return type:

(float, float)

processProfile(profile, normalizeProfile=True, movePeakToZero=True, useProfileColumn=None)[source]

processProfile reads in a series of data points representing the pulsar’s pulse profile, and processes it for use in generating signals.

Parameters:
  • profle – Either a string pointing to a file, or a list of values representing the profile
  • normalizeProfile (bool) – Determines whether to normalize the profile to be between zero and one.
  • movePeakToZero (bool) – Determines whether the max value of the profile will be shifted to zero. This is fairly standard convention.
  • useProfileColumn (int) – Optionally, determine which column of the profile file is contains the profile information. Different profile files have various numbers of columns. By default, method will use the last column.
seconds2MJD(seconds)[source]

A simple utility function to convert seconds to Modified Julian Date

See also

MJD2seconds()

Parameters:seconds (float) – Time in seconds
Returns:Time in Modified Julian Date
Return type:(float)
signalIntegral(tStart, tStop, state=None)[source]

Computes the definite integral of the signal over a given time interval.

This function computes the definite integral of flux over the specified time interval. Mathematically:

\[\Lambda(t_0, T) = \int_{t_0}^T \lambda(t) dT\]

The function uses the periodic nature of the signal in conjuction with the previously computed singlePeriodIntegral to simplify the computation. Specifically, the integral needs to be computed only once.

This is a precise expression for the number of photons expected during that time interval. For relatively small time intervals, the integral may be reasonably approximated by

\[\Lambda(T, T+\Delta T) = \int_{T}^{T+\Delta T} \lambda(t) dT \approx \lambda(t) \Delta T\]

In that case, this function is not ideal, as it increases computational expense without much added benefit. However in the case of large time intervals, this function will give more accurate results.

Parameters:
  • tStart (float) – Start time of the definite integralTStart
  • tStop (float) – Stop time of the definite integral
  • state – Optionally, a state object which contains a signal delay
Returns:

The definite integral of the signal.

Return type:

(float)

speedOfLight()[source]
TZRMJD = None

TZRMJD stores the Modified Julian Date (MJD) corresponding to t=0 seconds (for the purpose of computing the pulsar phase)

TZeroDiff = None

TZeroDiff is the time difference between the pulsar’s t zero (i.e. PEPOCH) and the observatory’s tZero. This amount is subtracted from the observatory time in calculations of flux, period, etc. to sync observatory time with the pulsar parameter’s reference time

avgPhotonFlux = None

averagePhotonFlux is the mean value of photons expected to # arrive from the signal per second (units of photons/second)

covDEC = None

Spatial covariance of source in declination

covRA = None

Spatial covariance of source in right-ascension

covX = None

Cross-correlation of spatial covariance terms

detectorArea = None

Allows user to specify area of detector by which flux is multiplied. Must be in compatible units as flux (i.e. if flux is in photons / cm^2 / s then detectorArea must be in cm^2). Default is 1.

extent = None

Specifies the spatial extent of the pulsar

fittedPhaseDerivatives = None

Alternative phase derivatives, derived by fitting rather than taking max.

fluxERG = None

Energy flux in ergs per unit area

fluxKEV = None

Energy flux in KEV per unit area

name = None

name is an arbitrary string that is used to identify the signal. Can be set to whatever the user wants, since it is only used for display purposes. Usually set to the astrophysical signal’s name (i.e. “Crab Pulsar” or “PSR B0531+21”)

normalizeProfile = None

normalizeProfile is a boolean flag used to indicate whether the profile is normalized from zero to one. If so, then the signal should be multiplied by #peakAmplitude.

observatoryMJDREF = None

observatoryMJDREF stores the MJD corresponding to t=0 seconds for photon observations

phaseDerivatives = None

Stores the derivatives of phase with respect to time

phaseDerivatives is a dict which contains the derivatives of phase with respect to time. The 0th derivative of phase is simply a constant phase offset (zero by default). The 1st derivative of phase is frequency. Higher order derivatives reflect the change in frequency with respect to time.

The dict keys should be integers which indicate the order of the derivative. e.g.

>>> phaseDerivatives = {0: 0, 1: 29.7417, 2: -3.7184e-19, 3: 1.1949e-20}

(Phase derivatives shown for Crab Nebula pulsar)

profile = None

profile is a numpy array containing the numerical value of flux over a single period of the signal.

The profile array contains the signal profile of the pulsar (or periodic source) being modeled. If the user selected to normalize the profle, then the profile will be normalized from zero to one, and then scaled based on the average flux value. If the profile is not normalized, then the raw values will be used for computing the signal. If the profile is normalized but no average flux value is received, a warning will be issued.

pulsarPeriod = None

pulsarPeriod is the amouont of time (in seconds) for one complete pulsar pulse.

pulsedFraction = None

pulsedFraction is a value from 0 to 1 which indicates what percentage of the avgPhotonFlux is “pulsed” and what percentage is constant/background

useFitted = None

Some PAR files (specifically ones generated by us) contain two frequencies; a “fitted” frequency (computed by fitting a quadratic to the histogram max function) and a non fitted (computed by just taking the max of the histogram function). This flag specifies which one to use if both are present.

modest.signals.pointsource module

class modest.signals.pointsource.PointSource(RA, DEC, extent=None, attitudeStateName='attitude', useUnitVector=True)[source]

Bases: modest.signals.signalsource.SignalSource

RaDec()[source]
computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
generateArrivalVector(attitudeQ, AOA_StdDev=None)[source]
unitVec(RaDec=None)[source]

modest.signals.poissonsource module

class modest.signals.poissonsource.DynamicPoissonSource(averageFlux, maxFlux=None, correlationStateName='correlation', startTime=0, useTOAprobability=True)[source]

Bases: modest.signals.poissonsource.PoissonSource

computeAssociationProbability(measurement, stateDict)[source]
getSignal(t, tVar=None, state=None)[source]
class modest.signals.poissonsource.PoissonSource(flux, startTime=0, useTOAprobability=True)[source]

Bases: modest.signals.signalsource.SignalSource

computeAssociationProbability(currentFlux, measurement)[source]
class modest.signals.poissonsource.StaticPoissonSource(flux, startTime=0, useTOAprobability=True)[source]

Bases: modest.signals.poissonsource.PoissonSource

computeAssociationProbability(measurement)[source]
generateEvents(tMax, t0=0)[source]

modest.signals.signalsource module

class modest.signals.signalsource.SignalSource(stateObjectID=None)[source]

Bases: object

computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
signalID()[source]
nextSignalID = 0

modest.signals.staticxraypointsource module

class modest.signals.staticxraypointsource.StaticXRayPointSource(RA, DEC, photonCountRate=None, photonEnergyFlux=None, energyRangeKeV=[2, 10], detectorArea=1, detectorFOV=3.141592653589793, attitudeStateName='attitude', name=None, startTime=0, extent=0, useUnitVector=True, useTOAprobability=True)[source]

Bases: modest.signals.pointsource.PointSource, modest.signals.poissonsource.StaticPoissonSource

computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
generatePhotonArrivals(tMax, t0=0, attitude=None, FOV=None, AOA_StdDev=None, TOA_StdDev=None)[source]

modest.signals.uniformnoisexraysource module

class modest.signals.uniformnoisexraysource.UniformNoiseXRaySource(photonFlux=None, energyRangeKeV=[2, 10], detectorFOV=180, detectorArea=1, startTime=0, useTOAprobability=True)[source]

Bases: modest.signals.poissonsource.StaticPoissonSource

computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
generatePhotonArrivals(tMax, t0=0, position=None, attitude=None, FOV=None, AOA_StdDev=None, TOA_StdDev=None)[source]
generateUniformArrivalVectors(nVectors, FOV=None)[source]

modest.signals.xraysource module

class modest.signals.xraysource.PeriodicXRaySource(profile, avgPhotonFlux=None, pulsedFraction=None, PARFile=None, movePeakToZero=True, normalizeProfile=True, phaseDerivatives=None, pulsarPeriod=None, RA=None, DEC=None, TZRMJD=None, name=None, attitudeStateName='attitude', correlationStateName=None, useProfileColumn=None)[source]

Bases: modest.signals.poissonsource.DynamicPoissonSource, modest.signals.pointsource.PointSource

MJD2seconds(MJD)[source]
computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
computeSinglePeriodIntegral()[source]
static dms2rad(d, m, s)[source]
generatePhotonArrivals(tMax, t0=0, position=None, attitude=None, FOV=None)[source]
getPhase(observatoryTime)[source]
getPulseFromPhase(phase)[source]
getSignal(observatoryTime, tVar=None, state=None)[source]
getSignalMJD(MJD)[source]
static hms2rad(h, m, s)[source]
plot(nPeriods=1, tVar=None, figureHandle=None, nPoints=1000)[source]
processPARFile(PARFile, replaceCurrentValues=False)[source]
processProfile(profile, normalizeProfile=True, movePeakToZero=True, useProfileColumn=None)[source]
seconds2MJD(seconds)[source]
signalIntegral(tStart, tStop, state=None)[source]
speedOfLight()[source]
class modest.signals.xraysource.StaticXRayPointSource(RA, DEC, peakPhotonFlux, attitudeStateName='attitude')[source]

Bases: modest.signals.pointsource.PointSource, modest.signals.poissonsource.StaticPoissonSource

computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
class modest.signals.xraysource.UniformNoiseXRaySource(photonFlux)[source]

Bases: modest.signals.poissonsource.StaticPoissonSource

computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
generatePhotonArrivals(tMax, t0=0, position=None, attitude=None, FOV=None)[source]

Module contents

class modest.signals.SignalSource(stateObjectID=None)[source]

Bases: object

computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
signalID()[source]
nextSignalID = 0
class modest.signals.PointSource(RA, DEC, extent=None, attitudeStateName='attitude', useUnitVector=True)[source]

Bases: modest.signals.signalsource.SignalSource

RaDec()[source]
computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
generateArrivalVector(attitudeQ, AOA_StdDev=None)[source]
unitVec(RaDec=None)[source]
class modest.signals.StaticPoissonSource(flux, startTime=0, useTOAprobability=True)[source]

Bases: modest.signals.poissonsource.PoissonSource

computeAssociationProbability(measurement)[source]
generateEvents(tMax, t0=0)[source]
class modest.signals.DynamicPoissonSource(averageFlux, maxFlux=None, correlationStateName='correlation', startTime=0, useTOAprobability=True)[source]

Bases: modest.signals.poissonsource.PoissonSource

computeAssociationProbability(measurement, stateDict)[source]
getSignal(t, tVar=None, state=None)[source]
class modest.signals.PointSource(RA, DEC, extent=None, attitudeStateName='attitude', useUnitVector=True)[source]

Bases: modest.signals.signalsource.SignalSource

RaDec()[source]
computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
generateArrivalVector(attitudeQ, AOA_StdDev=None)[source]
unitVec(RaDec=None)[source]
class modest.signals.StaticXRayPointSource(RA, DEC, photonCountRate=None, photonEnergyFlux=None, energyRangeKeV=[2, 10], detectorArea=1, detectorFOV=3.141592653589793, attitudeStateName='attitude', name=None, startTime=0, extent=0, useUnitVector=True, useTOAprobability=True)[source]

Bases: modest.signals.pointsource.PointSource, modest.signals.poissonsource.StaticPoissonSource

computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
generatePhotonArrivals(tMax, t0=0, attitude=None, FOV=None, AOA_StdDev=None, TOA_StdDev=None)[source]
class modest.signals.UniformNoiseXRaySource(photonFlux=None, energyRangeKeV=[2, 10], detectorFOV=180, detectorArea=1, startTime=0, useTOAprobability=True)[source]

Bases: modest.signals.poissonsource.StaticPoissonSource

computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]
generatePhotonArrivals(tMax, t0=0, position=None, attitude=None, FOV=None, AOA_StdDev=None, TOA_StdDev=None)[source]
generateUniformArrivalVectors(nVectors, FOV=None)[source]
class modest.signals.PeriodicXRaySource(profile=None, avgPhotonFlux=None, pulsedFraction=None, PARFile=None, movePeakToZero=True, normalizeProfile=True, phaseDerivatives=None, pulsarPeriod=None, RA=None, DEC=None, observatoryMJDREF=None, TZRMJD=None, PEPOCH=None, name=None, attitudeStateName='attitude', correlationStateName=None, useProfileColumn=None, startTime=0, extent=None, useTOAprobability=True, useFitted=True, detectorArea=1)[source]

Bases: modest.signals.poissonsource.DynamicPoissonSource, modest.signals.pointsource.PointSource

PeriodicPoissonSource is a class which models the signal from a periodic poisson source, e.g. a pulsar.

This class accepts a large number of initialization inputs required to model such a source. Alternatively, the user can pass a PAR file, and the object will initialize based on that.

FWHM()[source]
MJD2seconds(MJD)[source]

A simple utility function to convert modified Julian date to pulsar time

See also

seconds2MJD()

Parameters:MJD (float) – Modified Julian Date
Returns:Time in seconds
Return type:(float)
computeAssociationProbability(measurement, stateDict, validationThreshold=0)[source]

Computes the probability of association

This method computes the probability of association of a signal given the measurement and prior state. This is a conditional probability based on Bayes rule. Bayes rule is given by

\[\textrm{Pr}\left[A_p | \mathbf{y}\right] = \frac{\textrm{Pr}\left[\mathbf{y}|A_p\right] \textrm{Pr}\left[A_p\right]}{\textrm{Pr}\left[\mathbf{y}\right]}\]

Generally, the denominator is not directly computed and will be divided out.

For a periodic point source, there are two possible measurements: angle of arrival and time of arrival. If both of these measurements are included in the measurement dictionary, the probability will be computed as

\[\textrm{Pr}\left[A_p | (\alpha, t)\right] = \mathcal{N}\left[\alpha, \mathbf{S}_\alpha \right] \lambda(t) \bar{\lambda}\]

These sub-components of the probability are not computed here; rather they are computed by the PoissonSource and PointSource parent classes from which this class inherits. So, if something needs to be changed about the computation of association probability, it is likely that it needs to be changed in the parent classes.

If either of these measurements is not included in the measurement dict, then that component of the probability will be set to 1.

Note

The probability computed here is not an “absolute” probability. It only has meaning in relation to other probabilities. In order for this number to be meaningful, it should be normalized with all other possible association probabilities so that their sum is 1. Also note that the probability returns contains \(\delta \alpha\) and \(\delta t\) differential terms. These differential terms are divided out in the normalization process. All the other probabilities must contain these same terms for the comparison to be meaningful and the normalization to be valid.

Parameters:
  • measurement (dict) – A dictionary containing the measured values and their variances
  • stateDict (dict) – A dictionary containing the substates and their values
  • validationThreshold (float) – Unused
Returns:

The probability of association

Return type:

(float)

computeSinglePeriodIntegral()[source]

Compute the integral as a function of time of the pulsar flux.

This will be used later to compute expected value of flux in the case where time is uncertain. Generally this function only needs to be called once at initialization; once the integral is computed it is stored as an attribute and can be accessed on demand. Integral is computed using trapezoidal integration.

generatePhotonArrivals(tMax, t0=0, timeOffset=None, spacecraft=None)[source]

Generate photon arrival measurements

This function generates photon arrivals from the pulsar signal based on the parameters of the simulation. The

getFrequency(observatoryTime)[source]

Compute the current frequency of the pulsar signal

This function uses all available frequency information including derivatives to compute the current frequency of the pulsar signal at the given time. However it does not check for time validity. Some PAR files are valid over only a specified time frame; it is up to the user to verify whether the time given is within that region.

See also

getPeriod()

Parameters:observatoryTime (float) – Time for which frequency is to be computed
Returns:Computed frequency in Hz
Return type:(float)
getPeriod(observatoryTime)[source]

Compute the current period of the pulsar signal

This function uses all available frequency information including derivatives to compute the current period of the pulsar signal at the given time. However it does not check for time validity. Some PAR files are valid over only a specified time frame; it is up to the user to verify whether the time given is within that region.

See also

getFrequency()

Parameters:observatoryTime (float) – Time for which period is to be computed
Returns:Computed period in seconds
Return type:(float)
getPhase(observatoryTime)[source]

Compute the current phase of the pulsar signal.

This method uses all available frequency/phase information including derivatives. However, it does not check for validity of the time passed. Some PAR files are valid over only a specific region of time, and this function will not verify that the time given is within that time window.

It is up to the user to verify the validity of the results.

Args:
observatoryTime (float): Local time at which flux is to be computed.
Returns:
(float): Current pulsar phase
getPulseFromPhase(phase)[source]

Returns the value of the signal given the signal phase

This function uses the signal profile to compute the value of the signal given the signal phase. It uses simple linear interpolation to find the value.

Parameters:phase (float) – The phase number of the signal. Phase can be any numerical value; the fractional phase will be computed by taking remainder of the value divided by 1.
Returns:The value of the signal at the given phase
Return type:(float)
getSignal(observatoryTime, tVar=None)[source]

getSignal is responsible for returning the photon flux from the pulsar at a given time

The getSignal method is the method which is responsible for returning the current value of flux from the signal source at a given time. If there is uncertainty in the time, then the expected value of the signal is returned. Uncertainty in time is indicated by the optional tVar argument.

In every case, the method calls the getPhase method to determine the current signal source phase. If no uncertainty in time is passed, then the getPulseFromPhase method is called to lookup/interpolate the current flux based on the phase and the signal profile.

If a value is passed for tVar, then the process is more complicated. Rather than simply look up the signal value from the phase, the function returns an approximation of the expected value of the signal, given the mean and variance of time.

Normally, the expected value would be computed by integrating the product of the true distribution of time (probably a normal distribution) with the flux as a function of time. However, due to the non-analytical nature of the flux function, the direct computation of this integral is intractable. To overcome this limitation, the time distributuion is approximated as a moment-matched uniform distribution. Using this approximation, the approximate integral may be directly computed simply by looking up the start and end values of singlePeriodIntegral, and dividing by the appropriate scaling factor.

Parameters:
  • observatoryTime (float) – The time for which to compute the signal
  • tVar (float) – The variance of the time estimate (optional)
Returns:

The signal at the requested time, in photons/second

Return type:

(float)

getSignalMJD(MJD)[source]

getSignalMJD is a wrapper function that returns the photon flux at a given Modified Julian Date

See also

getSignal()

Parameters:MJD (float) – The Modified Jullian Date for which flux is to be returned
Returns:The signal at the requested date
Return type:(float)
plot(nPeriods=1, tVar=None, figureHandle=None, nPoints=1000)[source]

Plots the pulsar profile

This is a simple visualization function that generates a plot of the pulsar profile over a specified number of pulsar periods. Optionally, you can also specify a time uncertainty to see how the effective profile changes with time uncertainty.

Parameters:
  • nPeriods (float) – Number of periods to plot
  • tVar (float) – Variance of time uncertainty. If set to None then no uncertainty is included.
  • figureHandle – Optional handle to an existing figure
  • nPoints (int) – Number of points to plot
processPARFile(PARFile, replaceCurrentValues=False)[source]

Read a PAR file passed by the user and change/initialize object attributes accordingly.

PAR files are a semi-standardized way to store information about pulsars. Most PAR files contain, at a minimum, the name of the pulsar, the sky coordinates of the pulsar (i.e. right ascension and declination) and frequency information about the pulsar. They may also contain other helpful information such as reported glitches, pulsar binary model information, etc. Rather than force the user to enter all this information manually, the object can initialize from a PAR file and gather the relevant information on its own.

In order to further simplify the pulsar object initialization pipeline, this method also processes additional information found in the PAR file which isn’t part of the standard PAR file format. This includes information like source extent (i.e. how big is the object in the sky), source flux (photons per second per unit area, energy per second per unit area), pulsed fraction, and pulse profile. This information is not normally included in a PAR file. However, it is relatively easy to add it manually, and this simplifies workflow by keeping all the relevant information about the pulsar in one file.

Parameters:
  • PARFile (str) – Path to PAR file to be read
  • replaceCurrentValues (bool) – Determines whether previously stored values will be overwritten by values found in the PAR file
Returns:

Tuple containing the right ascension and declination of the source found in the PAR file

Return type:

(float, float)

processProfile(profile, normalizeProfile=True, movePeakToZero=True, useProfileColumn=None)[source]

processProfile reads in a series of data points representing the pulsar’s pulse profile, and processes it for use in generating signals.

Parameters:
  • profle – Either a string pointing to a file, or a list of values representing the profile
  • normalizeProfile (bool) – Determines whether to normalize the profile to be between zero and one.
  • movePeakToZero (bool) – Determines whether the max value of the profile will be shifted to zero. This is fairly standard convention.
  • useProfileColumn (int) – Optionally, determine which column of the profile file is contains the profile information. Different profile files have various numbers of columns. By default, method will use the last column.
seconds2MJD(seconds)[source]

A simple utility function to convert seconds to Modified Julian Date

See also

MJD2seconds()

Parameters:seconds (float) – Time in seconds
Returns:Time in Modified Julian Date
Return type:(float)
signalIntegral(tStart, tStop, state=None)[source]

Computes the definite integral of the signal over a given time interval.

This function computes the definite integral of flux over the specified time interval. Mathematically:

\[\Lambda(t_0, T) = \int_{t_0}^T \lambda(t) dT\]

The function uses the periodic nature of the signal in conjuction with the previously computed singlePeriodIntegral to simplify the computation. Specifically, the integral needs to be computed only once.

This is a precise expression for the number of photons expected during that time interval. For relatively small time intervals, the integral may be reasonably approximated by

\[\Lambda(T, T+\Delta T) = \int_{T}^{T+\Delta T} \lambda(t) dT \approx \lambda(t) \Delta T\]

In that case, this function is not ideal, as it increases computational expense without much added benefit. However in the case of large time intervals, this function will give more accurate results.

Parameters:
  • tStart (float) – Start time of the definite integralTStart
  • tStop (float) – Stop time of the definite integral
  • state – Optionally, a state object which contains a signal delay
Returns:

The definite integral of the signal.

Return type:

(float)

speedOfLight()[source]
TZRMJD = None

TZRMJD stores the Modified Julian Date (MJD) corresponding to t=0 seconds (for the purpose of computing the pulsar phase)

TZeroDiff = None

TZeroDiff is the time difference between the pulsar’s t zero (i.e. PEPOCH) and the observatory’s tZero. This amount is subtracted from the observatory time in calculations of flux, period, etc. to sync observatory time with the pulsar parameter’s reference time

avgPhotonFlux = None

averagePhotonFlux is the mean value of photons expected to # arrive from the signal per second (units of photons/second)

covDEC = None

Spatial covariance of source in declination

covRA = None

Spatial covariance of source in right-ascension

covX = None

Cross-correlation of spatial covariance terms

detectorArea = None

Allows user to specify area of detector by which flux is multiplied. Must be in compatible units as flux (i.e. if flux is in photons / cm^2 / s then detectorArea must be in cm^2). Default is 1.

extent = None

Specifies the spatial extent of the pulsar

fittedPhaseDerivatives = None

Alternative phase derivatives, derived by fitting rather than taking max.

fluxERG = None

Energy flux in ergs per unit area

fluxKEV = None

Energy flux in KEV per unit area

name = None

name is an arbitrary string that is used to identify the signal. Can be set to whatever the user wants, since it is only used for display purposes. Usually set to the astrophysical signal’s name (i.e. “Crab Pulsar” or “PSR B0531+21”)

normalizeProfile = None

normalizeProfile is a boolean flag used to indicate whether the profile is normalized from zero to one. If so, then the signal should be multiplied by #peakAmplitude.

observatoryMJDREF = None

observatoryMJDREF stores the MJD corresponding to t=0 seconds for photon observations

phaseDerivatives = None

Stores the derivatives of phase with respect to time

phaseDerivatives is a dict which contains the derivatives of phase with respect to time. The 0th derivative of phase is simply a constant phase offset (zero by default). The 1st derivative of phase is frequency. Higher order derivatives reflect the change in frequency with respect to time.

The dict keys should be integers which indicate the order of the derivative. e.g.

>>> phaseDerivatives = {0: 0, 1: 29.7417, 2: -3.7184e-19, 3: 1.1949e-20}

(Phase derivatives shown for Crab Nebula pulsar)

profile = None

profile is a numpy array containing the numerical value of flux over a single period of the signal.

The profile array contains the signal profile of the pulsar (or periodic source) being modeled. If the user selected to normalize the profle, then the profile will be normalized from zero to one, and then scaled based on the average flux value. If the profile is not normalized, then the raw values will be used for computing the signal. If the profile is normalized but no average flux value is received, a warning will be issued.

pulsarPeriod = None

pulsarPeriod is the amouont of time (in seconds) for one complete pulsar pulse.

pulsedFraction = None

pulsedFraction is a value from 0 to 1 which indicates what percentage of the avgPhotonFlux is “pulsed” and what percentage is constant/background

useFitted = None

Some PAR files (specifically ones generated by us) contain two frequencies; a “fitted” frequency (computed by fitting a quadratic to the histogram max function) and a non fitted (computed by just taking the max of the histogram function). This flag specifies which one to use if both are present.