sigpyproc.fourierseries#

Classes for handling 1D Fourier series data.

This module contains the PowerSpectrum and FourierSeries classes for handling Fourier transformed data.

Classes

FourierSeries

An array class to handle complex Fourier series.

PowerSpectrum

An array class to handle Fourier Power spectrum.

class sigpyproc.fourierseries.FourierSeries(data, header)[source]#

Bases: object

An array class to handle complex Fourier series.

Parameters:
dataArrayLike

1-D fourier series array.

headerHeader

Header object containing metadata.

Attributes:
header

Metadata header object.

data

Fourier series data array.

binwidth

Fourier bin width.

Methods

deredden([start_width, end_width, end_freq])

Perform rednoise removal via Presto-style method.

form_spec(*[, interpolate])

Form the power spectrum.

from_fft(fftfile[, inffile])

Read a Presto format .fft file.

from_spec(filename)

Read a sigpyproc format .spec file.

ifft([ifftn])

Perform 1-D complex to real inverse FFT.

multiply(other)

Multiply two Fourier series together.

recon_prof(freq[, nharms])

Reconstruct the time-domain pulse profile.

to_fft([basename])

Write Fourier series to file in presto .fft format.

to_spec([filename])

Write Fourier series in sigproc format.

property data#

Fourier series data array.

Returns:
NDArray[complex64]

1-D fourier series array.

property header#

Metadata header object.

Returns:
Header

Header object containing metadata.

property binwidth#

Fourier bin width.

Returns:
float

Width of each frequency bin.

ifft(ifftn=None)[source]#

Perform 1-D complex to real inverse FFT.

Parameters:
ifftnCallable[[np.ndarray, int], np.ndarray], optional

The ifft function to use. Own ifft implementation can be used, e.g. pyfftw.interfaces.numpy_fft.irfft, by default None.

Returns:
TimeSeries

The real-valued time series.

form_spec(*, interpolate=False)[source]#

Form the power spectrum.

Parameters:
interpolatebool, optional

Interpolate using nearest bins, by default False.

Returns:
PowerSpectrum

The power spectrum.

deredden(start_width=6, end_width=100, end_freq=6.0)[source]#

Perform rednoise removal via Presto-style method.

Parameters:
start_widthint, optional

Initial window size in the range (2, 50), by default 6.

end_widthint, optional

Final window size in the range (50, 500), by default 100.

end_freqfloat, optional

The highest frequency where the windowing increases in the range (0.1, 10), by default 6.0.

Returns:
FourierSeries

Whitened fourier series.

recon_prof(freq, nharms=32)[source]#

Reconstruct the time-domain pulse profile.

Parameters:
freqfloat

Frequency of signal to reconstruct.

nharmsint, optional

Number of harmonics to use in reconstruction, by default 32.

Returns:
Profile

The reconstructed pulse profile.

multiply(other)[source]#

Multiply two Fourier series together.

Parameters:
otherFourierSeries | ArrayLike

Fourier series to multiply with.

Returns:
FourierSeries

The product of the two Fourier series.

to_fft(basename=None)[source]#

Write Fourier series to file in presto .fft format.

Parameters:
basenamestr, optional

File basename for output .fft and .inf file, by default None.

Returns:
str

Output .fft file name.

Notes

Method also writes a corresponding .inf file from the header data.

to_spec(filename=None)[source]#

Write Fourier series in sigproc format.

Parameters:
filenamestr, optional

Name of file to write to, by default basename.spec.

Returns:
str

Output .spec file name.

classmethod from_fft(fftfile, inffile=None)[source]#

Read a Presto format .fft file.

Parameters:
fftfilestr | Path

Name of the .fft file to read.

inffilestr | Path, optional

Name of the corresponding .inf file, by default None.

Returns:
FourierSeries

Fourier series object.

Notes

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

classmethod from_spec(filename)[source]#

Read a sigpyproc format .spec file.

Parameters:
filenamestr | Path

Name of the .spec file to read.

Returns:
FourierSeries

Fourier series object.

Notes

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

class sigpyproc.fourierseries.PowerSpectrum(data, header)[source]#

Bases: object

An array class to handle Fourier Power spectrum.

Parameters:
dataArrayLike

1-D power spectrum array.

headerHeader

Header object containing metadata.

Attributes:
data

Power spectrum data array.

header

Metadata header object.

Methods

bin2freq(r)

Compute centre frequency of a given bin.

bin2period(r)

Compute centre period of a given bin.

freq2bin(freq)

Compute nearest bin to a given frequency.

harmonic_fold([nfolds])

Perform Lyne-Ashworth harmonic folding of the power spectrum.

period2bin(period)

Compute nearest bin to a given periodicity.

property data#

Power spectrum data array.

Returns:
NDArray[float32]

1-D power spectrum array.

property header#

Metadata header object.

Returns:
Header

Header object containing metadata.

bin2freq(r)[source]#

Compute centre frequency of a given bin.

Parameters:
rint

Fourier bin number.

Returns:
float

Frequency of the given bin.

bin2period(r)[source]#

Compute centre period of a given bin.

Parameters:
rint

Fourier bin number.

Returns:
float

Period of the given bin.

freq2bin(freq)[source]#

Compute nearest bin to a given frequency.

Parameters:
freqfloat

Frequency.

Returns:
int

Nearest bin to frequency.

period2bin(period)[source]#

Compute nearest bin to a given periodicity.

Parameters:
periodfloat

Period.

Returns:
int

Nearest bin to period.

harmonic_fold(nfolds=1)[source]#

Perform Lyne-Ashworth harmonic folding of the power spectrum.

Parameters:
nfoldsint, optional

Number of harmonic folds to perform, by default 1.

Returns:
list[PowerSpectrum]

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