sigpyproc.block#

class sigpyproc.block.FilterbankBlock(input_array, header, dm=0)#

Bases: ndarray

An array class to handle a discrete block of data in time-major order.

Parameters:
  • input_array (ArrayLike) – 2 dimensional array of shape (nchans, nsamples)

  • header (Header) – observational metadata

  • dm (float, optional) – DM of the input_array, by default 0

Returns:

2 dimensional array of shape (nchans, nsamples) with header metadata

Return type:

ndarray

Notes

Data is converted to 32 bits regardless of original type.

downsample(tfactor=1, ffactor=1)#

Downsample data block in frequency and/or time.

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

Returns:

2 dimensional array of downsampled data

Return type:

FilterbankBlock

Raises:
  • ValueError – If number of channels is not divisible by ffactor.

  • ValueError – If number of time samples is not divisible by tfactor.

normalise(by='mean', chans=True)#

Normalise the data block (Subtract mean/median, divide by std).

Parameters:
  • by (str, optional) – measurement to subtract from each channel, by default “mean”

  • chans (bool, optional) – if True, normalise each channel, by default True

Returns:

A normalised version of the data block

Return type:

FilterbankBlock

get_tim()#

Sum across all frequencies for each time sample.

Returns:

Sum of all channels as timeseries

Return type:

TimeSeries

get_bandpass()#

Average across each time sample for all frequencies.

Returns:

the bandpass of the data

Return type:

ArrayLike

dedisperse(dm, only_valid_samples=False, ref_freq='ch1')#

Dedisperse the block.

Parameters:
  • dm (float) – dm to dedisperse to

  • only_valid_samples (bool, optional) – return a FilterbankBlock with only time samples that contain the full bandwidth, by default False

  • ref_freq (str, optional) – reference frequency to dedisperse to, by default “ch1”

Returns:

a dedispersed version of the block

Return type:

FilterbankBlock

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 with respect to the reference frequency.

dmt_transform(dm, dmsteps=512, ref_freq='ch1')#

Generate a DM-time transform of the data block by dedispersing at adjacent DM values.

Parameters:
  • dm (float) – Central DM to dedisperse to

  • dmsteps (int, optional) – Number of adjacent DMs to dedisperse to, by default 512

  • ref_freq (str, optional) – Reference frequency to dedisperse to, by default “ch1”

Returns:

2 dimensional array of DM-time transform

Return type:

FilterbankBlock

to_file(filename=None)#

Write the data to file.

Parameters:

filename (str, optional) – name of the output file, by default basename_split_start_to_end.fil

Returns:

name of output file

Return type:

str