LinearTimeSpectrogram#

class radiospectra.spectrogram.LinearTimeSpectrogram(data, time_axis, freq_axis, start, end, t_init=None, t_delt=None, t_label='Time', f_label='Frequency', content='', instruments=None)[source]#

Bases: Spectrogram

Spectrogram evenly sampled in time.

t_delt#

difference between the items on the time axis

Type:

float

Attributes Summary

COPY_PROPERTIES

JOIN_REPEAT

Methods Summary

check_linearity([err, err_factor])

Check linearity of time axis.

combine_frequencies(specs)

Return new spectrogram that contains frequencies from all the spectrograms in spec.

in_interval([start, end])

Return part of spectrogram that lies in [start, end).

intersect_time(specs)

Return slice of spectrograms that is present in all of the ones passed.

join_many(specs[, mk_arr, nonlinear, ...])

Produce new Spectrogram that contains spectrograms joined together in time.

make_array(shape[, dtype])

Function to create an array with shape and dtype.

memmap(filename)

Return function that takes shape and dtype and returns a memory mapped array.

resample_time(new_delt)

Rescale image so that the difference in time between pixels is new_delt seconds.

time_to_x(time)

Return x-coordinate in spectrogram that corresponds to the passed datetime value.

Attributes Documentation

COPY_PROPERTIES = [('time_axis', 1), ('freq_axis', 1), ('instruments', 1), ('start', 0), ('end', 0), ('t_label', 0), ('f_label', 0), ('content', 0), ('t_init', 0), ('t_delt', 0)]#
JOIN_REPEAT = <object object>#

Methods Documentation

check_linearity(err=None, err_factor=None)[source]#

Check linearity of time axis.

If err is given, tolerate absolute derivation from average delta up to err. If err_factor is given,

tolerate up to err_factor * average_delta. If both are given, TypeError is raised. Default to err=0.

Parameters:
  • err (float) – Absolute difference each delta is allowed to diverge from the average. Cannot be used in combination with err_factor.

  • err_factor (float) – Relative difference each delta is allowed to diverge from the average, i.e. err_factor * average. Cannot be used in combination with err.

classmethod combine_frequencies(specs)[source]#

Return new spectrogram that contains frequencies from all the spectrograms in spec.

Only returns time intersection of all of them.

Parameters:

spec (list) – List of spectrograms of which to combine the frequencies into one.

in_interval(start=None, end=None)[source]#

Return part of spectrogram that lies in [start, end).

Parameters:
  • start (None or datetime or parse_time compatible string or time string) – Start time of the part of the spectrogram that is returned. If the measurement only spans over one day, a colon separated string representing the time can be passed.

  • end (None or datetime or parse_time compatible string or time string) – See start.

static intersect_time(specs)[source]#

Return slice of spectrograms that is present in all of the ones passed.

Parameters:

specs (list) – List of spectrograms of which to find the time intersections.

classmethod join_many(specs, mk_arr=None, nonlinear=False, maxgap=0, fill=<object object>)[source]#

Produce new Spectrogram that contains spectrograms joined together in time.

Parameters:
  • specs (list) – List of spectrograms to join together in time.

  • nonlinear (bool) – If True, leave out gaps between spectrograms. Else, fill them with the value specified in fill.

  • maxgap (float, int or None) – Largest gap to allow in second. If None, allow gap of arbitrary size.

  • fill (float or int) – Value to fill missing values (assuming nonlinear=False) with. Can be LinearTimeSpectrogram.JOIN_REPEAT to repeat the values for the time just before the gap.

  • mk_array (function) – Function that is called to create the resulting array. Can be set to LinearTimeSpectrogram.memap(filename) to create a memory mapped result array.

static make_array(shape, dtype=dtype('float32'))[source]#

Function to create an array with shape and dtype.

Parameters:
  • shape (tuple) – shape of the array to create

  • dtype (numpy.dtype) – data-type of the array to create

static memmap(filename)[source]#

Return function that takes shape and dtype and returns a memory mapped array.

Parameters:

filename (str) – File to store the memory mapped array in.

resample_time(new_delt)[source]#

Rescale image so that the difference in time between pixels is new_delt seconds.

Parameters:

new_delt (float) – New delta between consecutive values.

time_to_x(time)[source]#

Return x-coordinate in spectrogram that corresponds to the passed datetime value.

Parameters:

time (parse_time compatible str) – datetime.datetime to find the x coordinate for.