sigpyproc.utils#

class sigpyproc.utils.AttrDict(*args, **kwargs)#

Bases: dict

sigpyproc.utils.roll_array(arr, shift, axis=0)#

Roll the elements in the array by shift positions along the given axis.

The shift direction is from the end towards the beginning of the axis, opposite to the shift direction of roll().

Parameters:
  • arr (ArrayLike) – input array to roll

  • shift (int) – number of bins to shift by

  • axis (int) – axis to roll along, by default 0

Returns:

shifted numpy array

Return type:

ndarray

sigpyproc.utils.nearest_factor(num, fac)#

Find nearest factor Calculates the factor of num, which is closest to fac.

Parameters:
  • num (int) – number that we wish to factor

  • fac (int) – number around which we wish to find factor

Returns:

nearest factor

Return type:

int

sigpyproc.utils.get_logger(name, level=20, quiet=False)#

Get a fancy logging utility using Rich library.

Parameters:
  • name (str) – logger name

  • level (int or str, optional) – logging level, by default logging.INFO

  • quiet (bool, optional) – if True set level as logging.WARNING, by default False

Returns:

a logging object

Return type:

logging.Logger

sigpyproc.utils.time_after_nsamps(tstart, tsamp, nsamps=0)#

Get precise time nsamps after input tstart. If nsamps is not given then just return tstart.

Parameters:
  • tstart (float) – starting mjd.

  • tsamp (float) – sampling time in seconds.

  • nsamps (int, optional) – number of samples, by default 0

Returns:

Astropy Time object after given nsamps

Return type:

Time

sigpyproc.utils.duration_string(duration)#

Convert duration in seconds to human readable string.

Parameters:

duration (float) – duration in seconds

Returns:

human readable duration string

Return type:

str

class sigpyproc.utils.FrequencyChannels(freqs)#

Bases: object

FrequencyChannels class to handle frequency channels.

Parameters:

freqs (ArrayLike) – array of frequencies

property array#

Get the frequency array.

Type:

ndarray

property nchans#

Number of channels.

Type:

float

property fch1#

Central frequency of the first channel.

Type:

float

property foff#

Channel width.

Type:

float

property ftop#

Frequency (edge) of the top channel.

Type:

float

property fcenter#

Central frequency of the whole band.

Type:

float

property fbottom#

Frequency (edge) of the bottom channel.

Type:

float

property bandwidth#

Bandwidth.

Type:

float

classmethod from_sig(fch1, foff, nchans)#
classmethod from_pfits(fcenter, bandwidth, nchans)#