Stack

class baseband_tasks.integration.Stack(ih, n_phase, phase, *, start=0, average=True, samples_per_frame=1, dtype=None)[source] [edit on github]

Bases: baseband_tasks.base.BaseTaskBase

Create a stream of pulse profiles.

Parameters
ihtask or baseband stream reader

Input data stream, with time as the first axis.

n_phaseint

Number of bins per pulse period.

phasecallable

Should return pulse phases for given input time(s), passed in as an ‘~astropy.time.Time’ object. The output should be an array of float, and has to include the cycle count.

startTime or int, optional

Time or offset at which to start the integration. If an offset or if step is integer, the actual start time will the underlying sample time nearest to the requested one. Default: 0 (start of stream).

averagebool, optional

Whether the output pulse profile should be the average of all entries that contributed to it, or rather the sum, in a structured array that holds both 'data' and 'count' items.

samples_per_frameint, optional

Number of sample times to process in one go. This can be used to optimize the process, though with many samples per pulse period the default of 1 should be fine.

dtypedtype, optional

Output dtype. Generally, the default of the dtype of the underlying stream is good enough, but can be used to increase precision. Note that if average=True, it is the user’s responsibilty to pass in a structured dtype.

See also

Fold

to calculate pulse profiles integrated over a given amount of time.

Notes

One can follow this with a Integrate task to average over multiple pulses.

If there are only few input samples per cycle, one can avoid a large overhead in calculating phases by ensuring samples_per_frame of the underlying stream is not too small (larger than, say, 20).

Since phase bins are typically not an integer multiple of the underlying bin spacing, the integrated samples will generally not contain the same number of samples. The actual number of samples is counted, and for average=True, the sums have been divided by these counts, with bins with no points set to NaN. For average=False, the arrays returned by read are structured arrays with data and count fields.