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 integersig (
numpy array
, optional) – must be one dimentional, will be forced to be a numpy arraychunker (
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 ratestrict (
bool
, optional) – if true, the target sample rate will be matched exactlyuniq (
str
, optional) – in case chunked signal, uniq is to differentiate different bwLim funcs
- Returns
Updated signal (self)
- Return type
-
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
-
filter
(filt)[source]¶ Apply a filter to the signal
- Parameters
filt (
filter
) – filter object- Returns
Updated signal (self)
- Return type
-
funcApply
(func)[source]¶ Applies a function to the signal
- Parameters
func (function) – function to be applied
- Returns
Updated signal (self)
- Return type
-
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
-
property
sampRate
¶ get sampling rate of signal
- Type
int
-
property
signal
¶ get signal
- Type
numpy array
-
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 sourceoffset (
float
) – Frequency offset of source in Hzbw (
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 UTCtleFile (
str
, optional) – TLE file location, pulls latest from internet if not givendestFile (
str
) – location where to store the imagesatellite (
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 sourceoffset (
float
) – Frequency offset of source in Hzbw (
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 bitsstuffed_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 sourceoffset (
float
) – Frequency offset of source in Hzbw (
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 sourceoffset (
float
) – Frequency offset of source in Hzbw (
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 filtera (
list
) – list of ‘a’ constants of filterstoreState (
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 windowstoreState (
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 windowstoreState (
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 windowstoreState (
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 windowsigma (
float
) – The standard deviationstoreState (
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 signalcutoffA (
float
) – desired cutoff A of filter in HzcutoffB (
float
, optional) – desired cutoff B of filter in Hzn (
int
, optional) – Order of filtertype (
constant
, optional) – constants.FLT_LP to constants.FLT_BS, see constants modulestoreState (
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 Hzbands (
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
-
Demodulators¶
-
class
directdemod.demod_fm.
demod_fm
(storeState=True)[source]¶ Object for FM demodulation
-
class
directdemod.demod_fm.
demod_fmAD
(storeState=True)[source]¶ Object for FM demodulation (Alternative method using angle differentiation)
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 indexfinalLimit (
int
, optional) – ending index
-
read
(fromIndex, toIndex=None)[source]¶ Read source data
- Parameters
fromIndex (
int
) – starting indextoIndex (
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
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 chunkedchunkSize (
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 variableinit (
anything
) – initialize variable to this, if undefined previously
- Returns
value of variable
- Return type
anything
-
property
getChunks
¶ get the created chunks
- Type
list
-