sigpyproc.Filterbank¶
-
class
sigpyproc.Filterbank.Filterbank[source]¶ Bases:
objectNew Class exporting methods for the manipulation of frequency-major order pulsar data.
Notes
The Filterbank class should never be instantiated directly. Instead it should be inherited by data reading classes.
-
applyChannelMask(chanmask, outfilename=None, gulp=512, back_compatible=True, **kwargs)[source]¶ Set the data in the given channels to zero.
- Parameters
chanmask (list) – binary channel mask (0 for bad channel, 1 for good)
outfilename (str, optional) – name of the output filterbank file, by default
basename_masked.filgulp (int, optional) – number of samples in each read, by default 512
back_compatible (bool, optional) – sigproc compatibility flag, by default True
- Returns
name of output file
- Return type
-
bandpass(gulp=512, **kwargs)[source]¶ Average across each time sample for all frequencies.
- Parameters
gulp (int, optional) – number of samples in each read, by default 512
- Returns
the bandpass of the data
- Return type
-
collapse(gulp=512, start=0, nsamps=None, **kwargs)[source]¶ Sum across all frequencies for each time sample.
- Parameters
- Returns
A zero-DM time series
- Return type
-
dedisperse(dm, gulp=10000, **kwargs)[source]¶ Dedisperse the data to a time series.
- Parameters
- Returns
a dedispersed time series
- Return type
Notes
If gulp < maximum dispersion delay, gulp is taken to be twice the maximum dispersion delay.
-
downsample(tfactor=1, ffactor=1, gulp=512, filename=None, back_compatible=True, **kwargs)[source]¶ Downsample data in time and/or frequency and write to file.
- Parameters
tfactor (int, optional) – factor by which to downsample in time, by default 1
ffactor (int, optional) – factor by which to downsample in frequency, by default 1
gulp (int, optional) – number of samples in each read, by default 512
filename (str, optional) – name of file to write to, by default
basename_tfactor_ffactor.filback_compatible (bool, optional) – sigproc compatibility flag (legacy code), by default True
- Returns
output file name
- Return type
- Raises
ValueError – If number of channels is not divisible by ffactor.
-
fold(period, dm, accel=0, nbins=50, nints=32, nbands=32, gulp=10000, **kwargs)[source]¶ Fold data into discrete phase, subintegration and subband bins.
- Parameters
period (float) – period in seconds to fold with
dm (float) – dispersion measure to dedisperse to
accel (float, optional) – acceleration in m/s/s to fold with, by default 0
nbins (int, optional) – number of phase bins in output, by default 50
nints (int, optional) – number of subintegrations in output, by default 32
nbands (int, optional) – number of subbands in output, by default 32
gulp (int, optional) – number of samples in each read, by default 10000
- Returns
3 dimensional data cube
- Return type
- Raises
ValueError – If nbands * nints * nbins is too large
Notes
If gulp < maximum dispersion delay, gulp is taken to be twice the maximum dispersion delay.
-
getChan(chan, gulp=512, **kwargs)[source]¶ Retrieve a single frequency channel from the data.
- Parameters
- Returns
selected channel as a time series
- Return type
- Raises
ValueError – If chan is out of range (chan < 0 or chan > total channels).
-
getStats(gulp=512, **kwargs)[source]¶ Retrieve channelwise statistics of data.
- Parameters
gulp (int, optional) – number of samples in each read, by default 512
creates following instance attributes (Function) –
chan_means: the mean value of each channelchan_vars: the variance of each channelchan_stdevs: the standard deviation of each channelchan_skews: the skewness of each channelchan_kurts: the kurtosis of each channelchan_max: the maximum value of each channelchan_min: the minimum value of each channel
-
invertFreq(gulp=512, start=0, nsamps=None, filename=None, back_compatible=True, **kwargs)[source]¶ Invert the frequency ordering of the data and write new data to a new file.
- Parameters
gulp (int, optional) – number of samples in each read, by default 512
start (int, optional) – start sample, by default 0
nsamps (int, optional) – number of samples to read, by default all
filename (str, optional) – name of output file, by default
basename_inverted.filback_compatible (bool, optional) – sigproc compatibility flag (legacy code), by default True
- Returns
name of output file
- Return type
-
removeBandpass(gulp=512, filename=None, back_compatible=True, **kwargs)[source]¶ Remove the bandpass from the data and write new data to a new file.
- Parameters
- Returns
name of output file
- Return type
- Raises
TypeError – If nbits of input file is < 8.
-
removeZeroDM(gulp=512, filename=None, back_compatible=True, **kwargs)[source]¶ Remove the channel-weighted zero-DM from the data and write to disk.
- Parameters
- Returns
name of output file
- Return type
Notes
Based on Presto implementation of Eatough, Keane & Lyne 2009
-
setNthreads(nthreads=None)[source]¶ Set the number of threads available to OpenMP.
- Parameters
nthreads (int, optional) – number of threads to use, by default 4
-
split(start, nsamps, filename=None, gulp=1024, back_compatible=True, **kwargs)[source]¶ Split data in time.
- Parameters
start (int) – start sample of split
nsamps (int) – number of samples in split
filename (str, optional) – name of output file, by default
basename_start_start+nsamps.filgulp (int, optional) – number of samples in each read, by default 1024
back_compatible (bool, optional) – sigproc compatibility flag (legacy code), by default True
- Returns
name of new file
- Return type
-
splitToBands(chanpersub, chanstart=0, gulp=1024, back_compatible=True, **kwargs)[source]¶ Split the data into component Sub-bands and write to disk.
- Parameters
- Returns
names of all files written to disk
- Return type
list of str
Notes
Filterbanks are written to disk with names based on sub-band number.
-
splitToChans(gulp=1024, back_compatible=True, **kwargs)[source]¶ Split the data into component channels and write each to file.
- Parameters
- Returns
names of all files written to disk
- Return type
list of str
Notes
Time series are written to disk with names based on channel number.
-
subband(dm, nsub, filename=None, gulp=10000, **kwargs)[source]¶ Produce a set of dedispersed subbands from the data.
- Parameters
- Returns
name of output subbands file
- Return type
-
-
class
sigpyproc.Filterbank.FilterbankBlock(input_array, header)[source]¶ Bases:
numpy.ndarrayClass to handle a discrete block of data in time-major order.
- Parameters
input_array (
numpy.ndarray) – 2 dimensional array of shape (nchans, nsamples)header (
Header) – observational metadata
- Returns
2 dimensional array of shape (nchans, nsamples) with header metadata
- Return type
Notes
Data is converted to 32 bits regardless of original type.
-
dedisperse(dm, only_valid_samples=False)[source]¶ Dedisperse the block.
- Parameters
- Returns
a dedispersed version of the block
- Return type
- Raises
ValueError – If there are not enough time samples to dedisperse.
Notes
Frequency dependent delays are applied as rotations to each channel in the block.
-
downsample(tfactor=1, ffactor=1)[source]¶ Downsample data block in frequency and/or time.
- Parameters
- Returns
2 dimensional array of downsampled data
- Return type
- Raises
ValueError – If number of channels is not divisible by ffactor.
-
get_bandpass()[source]¶ Average across each time sample for all frequencies.
- Returns
the bandpass of the data
- Return type
-
normalise()[source]¶ Divide each frequency channel by its average.
- Returns
normalised version of the data
- Return type