sigpyproc.fourierseries#

class sigpyproc.fourierseries.PowerSpectrum(input_array, header)#

Bases: ndarray

An array class to handle pulsar power spectrum.

Parameters:
  • input_array (ArrayLike) – 1 dimensional array of shape (nsamples)

  • header (Header) – observational metadata

Returns:

1 dimensional power spectra with header

Return type:

ndarray

Notes

Data is converted to 32 bits regardless of original type.

bin2freq(bin_num)#

Return centre frequency of a given bin.

Parameters:

bin_num (int) – Bin number

Returns:

frequency of the given bin

Return type:

float

bin2period(bin_num)#

Return centre period of a given bin.

Parameters:

bin_num (int) – Bin number

Returns:

period of bin

Return type:

float

freq2bin(freq)#

Return nearest bin to a given frequency.

Parameters:

freq (float) – frequency

Returns:

nearest bin to frequency

Return type:

int

period2bin(period)#

Return nearest bin to a given periodicity.

Parameters:

period (float) – periodicity

Returns:

nearest bin to period

Return type:

int

harmonic_fold(nfolds=1)#

Perform Lyne-Ashworth harmonic folding of the power spectrum.

Parameters:

nfolds (int, optional) – number of harmonic folds to perform, by default 1

Returns:

A list of folded spectra where the i th element is the spectrum folded i times.

Return type:

list of PowerSpectrum

class sigpyproc.fourierseries.FourierSeries(input_array, header)#

Bases: ndarray

An array class to handle Fourier series with headers.

Parameters:
  • input_array (ArrayLike) – 1 dimensional array of shape (nsamples)

  • header (Header) – observational metadata

Returns:

1 dimensional fourier series with header

Return type:

ndarray

ifft()#

Perform 1-D complex to real inverse FFT.

Returns:

a time series

Return type:

TimeSeries

form_spec(interpolated=True)#

Form power spectrum.

Parameters:

interpolated (bool, optional) – flag to set nearest bin interpolation, by default True

Returns:

a power spectrum

Return type:

PowerSpectrum

remove_rednoise(startwidth=6, endwidth=100, endfreq=1.0)#

Perform rednoise removal via Presto style method.

Parameters:
  • startwidth (int, optional) – size of initial array for median calculation, by default 6

  • endwidth (int, optional) – size of largest array for median calculation, by default 100

  • endfreq (float, optional) – remove rednoise up to this frequency, by default 1.0

Returns:

whitened fourier series

Return type:

FourierSeries

recon_prof(freq, nharms=32)#

Reconstruct the time domain pulse profile from a signal and its harmonics.

Parameters:
  • freq (float) – frequency of signal to reconstruct

  • nharms (int, optional) – number of harmonics to use in reconstruction, by default 32

Returns:

a pulse profile

Return type:

Profile

to_file(filename=None)#

Write Fourier series to file in sigproc format.

Parameters:

filename (str, optional) – name of file to write to, by default basename.spec

Returns:

output file name

Return type:

str

to_fftfile(basename=None)#

Write spectrum to file in presto .fft format.

Parameters:

basename (str, optional) – basename of .fft and .inf file to be written, by default None

Returns:

name of files written to

Return type:

tuple of str

classmethod read_fft(fftfile, inffile=None)#

Read a presto format .fft file.

Parameters:
  • fftfile (str) – the name of the .fft file to read

  • inffile (str, optional) – the name of the corresponding .inf file, by default None

Returns:

an array containing the whole file contents

Return type:

FourierSeries

Raises:

IOError – If no .inf file found in the same directory of .fft file.

Notes

If inf is None, then the associated .inf file must be in the same directory.

classmethod read_spec(filename)#

Read a sigpyproc format .spec file.

Parameters:

filename (str) – the name of the .spec file to read

Returns:

an array containing the whole file contents

Return type:

FourierSeries

Notes

This is not setup to handle .spec files such as are created by Sigprocs seek module. To do this would require a new header parser for that file format.