DirectDemod: Modules documentation

Signal object

class directdemod.comm.commSignal(sampRate, sig=array([], dtype=float64), chunker=None)[source]

This is an object used to store a signal and its properties

__init__(sampRate, sig=array([], dtype=float64), chunker=None)[source]

Initialize the object

Parameters
  • sampRate (int) – sampling rate in Hz, will be forced to be an integer

  • sig (numpy array, optional) – must be one dimentional, will be forced to be a numpy array

  • chunker (chunker, optional) – Chunking object, if this signal is going to be processed in chunks

bwLim(tsampRate, strict=False, uniq='abcd')[source]

Limit the bandwidth by downsampling

Parameters
  • tsampRate (int) – target sample rate

  • strict (bool, optional) – if true, the target sample rate will be matched exactly

  • uniq (str, optional) – in case chunked signal, uniq is to differentiate different bwLim funcs

Returns

Updated signal (self)

Return type

commSignal

extend(sig)[source]

Adds another signal to this one at the tail end

Parameters

sig (commSignal) – Signal to be added

Returns

Updated signal (self)

Return type

commSignal

filter(filt)[source]

Apply a filter to the signal

Parameters

filt (filter) – filter object

Returns

Updated signal (self)

Return type

commSignal

funcApply(func)[source]

Applies a function to the signal

Parameters

func (function) – function to be applied

Returns

Updated signal (self)

Return type

commSignal

property length

get length of signal

Type

int

offsetFreq(freqOffset)[source]

Offset signal by a frequency by multiplying a complex envelope

Parameters

freqOffset (float) – offset frequency in Hz

Returns

Signal offset by given frequency (self)

Return type

commSignal

property sampRate

get sampling rate of signal

Type

int

property signal

get signal

Type

numpy array

updateSignal(sig)[source]

Updates the signal

Parameters

sig (numpy array) – New signal array

Returns

Updated signal (self)

Return type

commSignal

Specific applications

class directdemod.decode_noaa.decode_noaa(sigsrc, offset, bw=None)[source]

Object to decode NOAA APT

__init__(sigsrc, offset, bw=None)[source]

Initialize the object

Parameters
  • sigsrc (commSignal) – IQ data source

  • offset (float) – Frequency offset of source in Hz

  • bw (int, optional) – Bandwidth

property channelID

get channel ID’s

Returns

[channelIDA, channelIDB]

Return type

list

getAccurateSync(useNormCorrelate=True)[source]

Get the sync locations: at highest sampling rate

Parameters

useNormCorrelate (bool, optional) – Whether to use normalized correlation or not

Returns

A list of locations of sync in sample number (start of sync)

Return type

list

property getAudio

Get the audio from data

Returns

An audio signal

Return type

commSignal

property getColor

Get false color image (EXPERIMENTAL)

Returns

A matrix list of pixel

Return type

numpy array

getCrudeSync()[source]

Get the sync locations: at constants.NOAA_CRUDESYNCSAMPRATE sampling rate

Returns

A list of locations of sync in sample number (start of sync)

Return type

list

property getImage

Get the image from data

Returns

A matrix of pixel values

Return type

numpy array

property getImageA

Get Image A from the extracted image

Returns

A matrix list of pixel

Return type

numpy array

property getImageB

Get Image B from the extracted image

Returns

A matrix list of pixel

Return type

numpy array

getMapImage(cTime, destFileRot, destFileNoRot, satellite, tleFile=None)[source]

Get the map overlay of the image

Parameters
  • cTime (datetime) – Time of start of capture in UTC

  • tleFile (str, optional) – TLE file location, pulls latest from internet if not given

  • destFile (str) – location where to store the image

  • satellite (str) – Satellite name, ex: NOAA 19 etc.

property useful

10 consecutive syncs apart by 0.5s+-error

Returns

0 if not found, 1 if found

Return type

int

Type

See if some data was found or not

class directdemod.decode_afsk1200.decode_afsk1200(sigsrc, offset, bw)[source]

Object to decode AFSK1200

__init__(sigsrc, offset, bw)[source]

Initialize the object

Parameters
  • sigsrc (commSignal) – IQ data source

  • offset (float) – Frequency offset of source in Hz

  • bw (int, optional) – Bandwidth

decode_nrzi()[source]

Decode NRZI

Parameters

nrzi (list) – the NRZI bits

Returns

decoded NRZI bits

Return type

list

find_bit_stuffing()[source]

To find bit stuffing

Parameters

code_bit (list) – the bits

Returns

bit stuffing status

Return type

list

property getMsg

Get the message from data

Returns

string: A string of message data

reduce_stuffed_bit(stuffed_bit)[source]

To remove stuffed bits

Parameters
  • code_bit (list) – the bits

  • stuffed_bit (list) – the result from find_bit_stuffing()

Returns

bits free from stuffing

Return type

list

property useful

See if atleast one message was found or not

Returns

0 if not found, 1 if found

Return type

int

class directdemod.decode_funcube.decode_funcube(sigsrc, offset, bw, center_frequency, signal_freq, corrfreq=False)[source]

Object to decode Funcube

__init__(sigsrc, offset, bw, center_frequency, signal_freq, corrfreq=False)[source]

Initialize the object

Parameters
  • sigsrc (commSignal) – IQ data source

  • offset (float) – Frequency offset of source in Hz

  • bw (int, optional) – Bandwidth

property getSyncs

Get syncs of Funcube

Returns

list of detected syncs

Return type

list

property useful

See if signal was found

Returns

0 if not found, 1 if found

Return type

int

class directdemod.decode_meteorm2.decode_meteorm2(sigsrc, offset, bw)[source]

Object to decode Meteor m2

__init__(sigsrc, offset, bw)[source]

Initialize the object

Parameters
  • sigsrc (commSignal) – IQ data source

  • offset (float) – Frequency offset of source in Hz

  • bw (int, optional) – Bandwidth

property getSyncs

Get syncs of Meteor M2

Returns

list of detected syncs

Return type

list

property useful

See if signal was found

Returns

0 if not found, 1 if found

Return type

int

Filters

class directdemod.filters.filter(b, a, storeState=True, zeroPhase=False, initOut=None)[source]

This is a parent object of all filters, it implements all the necessary properties. Refer to experiment 3 for details.

__init__(b, a, storeState=True, zeroPhase=False, initOut=None)[source]

Initialize the object

Parameters
  • b (list) – list of ‘b’ constants of filter

  • a (list) – list of ‘a’ constants of filter

  • storeState (bool, optional) – Whether the filter state must be stored. Useful when filtering a chunked signal to avoid border effects.

  • zeroPhase (bool, optional) – Whether the filter has to provide zero phase error to the input i.e. no delay in the output (Note: Enabling this will disable ‘storeState’ and ‘initOut’)

  • initOut (list, optional) – Initial condition of the filter

applyOn(x)[source]

Apply the filter to a given array of signal

Parameters

x (numpy array) – The signal array on which the filter needs to be applied

Returns

Filtered signal array

Return type

numpy array

property getA

Get ‘a’ of the filter

Type

list

property getB

Get ‘b’ of the filter

Type

list

class directdemod.filters.rollingAverage(n=3, storeState=True, zeroPhase=False, initOut=None)[source]

A simple rolling average filter

__init__(n=3, storeState=True, zeroPhase=False, initOut=None)[source]

Initialize the object

Parameters
  • n (int, optional) – size of the rolling window

  • storeState (bool, optional) – Whether the filter state must be stored. Useful when filtering a chunked signal to avoid border effects.

  • zeroPhase (bool, optional) – Whether the filter has to provide zero phase error to the input i.e. no delay in the output (Note: Enabling this will disable ‘storeState’ and ‘initOut’)

  • initOut (list, optional) – Initial condition of the filter

class directdemod.filters.blackmanHarris(n, storeState=True, zeroPhase=False, initOut=None)[source]

Blackman Harris filter

__init__(n, storeState=True, zeroPhase=False, initOut=None)[source]

Initialize the object

Parameters
  • n (int) – size of the window

  • storeState (bool, optional) – Whether the filter state must be stored. Useful when filtering a chunked signal to avoid border effects.

  • zeroPhase (bool, optional) – Whether the filter has to provide zero phase error to the input i.e. no delay in the output (Note: Enabling this will disable ‘storeState’ and ‘initOut’)

  • initOut (list, optional) – Initial condition of the filter

class directdemod.filters.hamming(n, storeState=True, zeroPhase=False, initOut=None)[source]

Hamming filter

__init__(n, storeState=True, zeroPhase=False, initOut=None)[source]

Initialize the object

Parameters
  • n (int) – size of the window

  • storeState (bool, optional) – Whether the filter state must be stored. Useful when filtering a chunked signal to avoid border effects.

  • zeroPhase (bool, optional) – Whether the filter has to provide zero phase error to the input i.e. no delay in the output (Note: Enabling this will disable ‘storeState’ and ‘initOut’)

  • initOut (list, optional) – Initial condition of the filter

class directdemod.filters.gaussian(n, sigma, storeState=True, zeroPhase=False, initOut=None)[source]

Gaussian filter

__init__(n, sigma, storeState=True, zeroPhase=False, initOut=None)[source]

Initialize the object

Parameters
  • n (int) – size of the window

  • sigma (float) – The standard deviation

  • storeState (bool, optional) – Whether the filter state must be stored. Useful when filtering a chunked signal to avoid border effects.

  • zeroPhase (bool, optional) – Whether the filter has to provide zero phase error to the input i.e. no delay in the output (Note: Enabling this will disable ‘storeState’ and ‘initOut’)

  • initOut (list, optional) – Initial condition of the filter

class directdemod.filters.butter(Fs, cutoffA, cutoffB=None, n=6, typeFlt=0, storeState=True, zeroPhase=False, initOut=None)[source]

Butterworth filter

__init__(Fs, cutoffA, cutoffB=None, n=6, typeFlt=0, storeState=True, zeroPhase=False, initOut=None)[source]

Initialize the object

Parameters
  • Fs (int) – Sampling frequency of signal

  • cutoffA (float) – desired cutoff A of filter in Hz

  • cutoffB (float, optional) – desired cutoff B of filter in Hz

  • n (int, optional) – Order of filter

  • type (constant, optional) – constants.FLT_LP to constants.FLT_BS, see constants module

  • storeState (bool, optional) – Whether the filter state must be stored. Useful when filtering a chunked signal to avoid border effects.

  • zeroPhase (bool, optional) – Whether the filter has to provide zero phase error to the input i.e. no delay in the output (Note: Enabling this will disable ‘storeState’ and ‘initOut’)

  • initOut (list, optional) – Initial condition of the filter

class directdemod.filters.remez(Fs, bands, gains, ntaps=128, storeState=True, zeroPhase=False, initOut=None)[source]

Remez band filter

__init__(Fs, bands, gains, ntaps=128, storeState=True, zeroPhase=False, initOut=None)[source]

Initialize the object

Parameters
  • Fs (int) – sampling frequency in Hz

  • bands (list) – non-overlapping list of bands (in Hz) in increasing order. e.g [[0, 100], [400, 500], [600, 700]]

  • gains (float) – Corresponding gains of the bands e.g. [0, 1, 0.5]

  • ntaps (int, optional) – Number of taps of filter (number of terms in filter)

  • storeState (bool, optional) – Whether the filter state must be stored. Useful when filtering a chunked signal to avoid border effects.

  • zeroPhase (bool, optional) – Whether the filter has to provide zero phase error to the input i.e. no delay in the output (Note: Enabling this will disable ‘storeState’ and ‘initOut’)

  • initOut (list, optional) – Initial condition of the filter

class directdemod.filters.blackmanHarrisConv(n=151)[source]

Blackman Harris filter (by convolving, Not recommended for large signals)

__init__(n=151)[source]

Initialize the object

Parameters

n (int, optional) – size of the window

applyOn(sig)[source]

Apply the filter to a given array of signal

Parameters

x (numpy array) – The signal array on which the filter needs to be applied

Returns

Filtered signal array

Return type

numpy array

Demodulators

class directdemod.demod_fm.demod_fm(storeState=True)[source]

Object for FM demodulation

__init__(storeState=True)[source]

Initialize the object

Parameters

storeState (bool) – Store state? Helps if signal is chunked

demod(sig)[source]

FM demod a given complex IQ array

Parameters

sig (numpy array) – numpy array with IQ in complex form

Returns

FM demodulated array

Return type

numpy array

class directdemod.demod_am.demod_am[source]

AM demodulation by hilbert’s transform

demod(sig)[source]

AM demodulation by hilbert’s transform

Parameters

sig (numpy array) – Signal array to be demodulated

Returns

Demodulated signal

Return type

numpy array

class directdemod.demod_fm.demod_fmAD(storeState=True)[source]

Object for FM demodulation (Alternative method using angle differentiation)

__init__(storeState=True)[source]

Initialize the object

Parameters

storeState (bool) – Store state? Helps if signal is chunked

demod(sig)[source]

FM demod a given complex IQ array

Parameters

sig (numpy array) – numpy array with IQ in complex form

Returns

FM demodulated array

Return type

numpy array

class directdemod.demod_am.demod_amFLT(Fs, cutoff)[source]

AM demodulation by low pass filter

__init__(Fs, cutoff)[source]

Initialize the object

Parameters

cutoff (int) – lowpass cutoff frequency in Hz

demod(sig)[source]

AM demodulation by low pass filter

Parameters

sig (numpy array) – Signal array to be demodulated

Returns

Demodulated signal

Return type

numpy array

Sources

class directdemod.source.IQwav(filename, givenSampFreq=None)[source]

An IQ.wav file source, typically an output recorded from SDRSHARP or other similar software

__init__(filename, givenSampFreq=None)[source]

Initialize the object

Parameters

filename (str) – filename of the IQ.wav file

property length

get source length

Type

int

limitData(initOffset=None, finalLimit=None)[source]

Limit source data

Parameters
  • initOffset (int, optional) – starting index

  • finalLimit (int, optional) – ending index

read(fromIndex, toIndex=None)[source]

Read source data

Parameters
  • fromIndex (int) – starting index

  • toIndex (int, optional) – ending index. If not provided, the element at location given by fromIndex is returned

Returns

Complex IQ numbers in an array

Return type

numpy array

property sampFreq

get sampling freq of source

Type

int

property sourceType

get source type

Type

int

Sinks

class directdemod.sink.wavFile(filename, sig)[source]

This object is used to write wav files

__init__(filename, sig)[source]

Initialize the object

Parameters
  • filename (str) – filename of the wav file

  • sig (commSignal) – signal to be written

property write

writes the signal to file

Type

sig (wavFile)

class directdemod.sink.image(filename, mat)[source]

This object is used to display and write images

__init__(filename, mat)[source]

Initialize the object

Parameters
  • filename (str) – filename of the image file

  • mat (list) – a matrix of pixel values

property show

shows the image

Type

sig (image)

property write

writes the image to file

Type

sig (image)

Chunking helper

class directdemod.chunker.chunker(sigsrc, chunkSize=20000000)[source]

This object is just to help in chunking process

__init__(sigsrc, chunkSize=20000000)[source]

Initialize the object

Parameters
  • sampRate (commSignal) – commSignal object to be chunked

  • chunkSize (int, optional) – chunk size

get(name, init=None)[source]

get a variable value for to be used during chunking

Parameters
  • name (str) – name of the variable

  • init (anything) – initialize variable to this, if undefined previously

Returns

value of variable

Return type

anything

property getChunks

get the created chunks

Type

list

set(name, value)[source]

set a variable for to be used during chunking

Parameters
  • name (str) – name of the variable

  • value (anything, optional) – value of variable

Logging

class directdemod.log.log(file=None, console=False)[source]

Object for logging

__init__(file=None, console=False)[source]

Initialize the object

Parameters
  • file (str, optional) – Filename, if log is to be stored into a file

  • console (bool, optional) – Enables console logging