# Path: Modules/SignalData.py
# class Signal(object):
#     def __init__(self, filename=None, filetype=None, filedata=None, Fsample=None, Fcentre=None):
#     def setvalues(self, filename, filetype, Fsample, Fcentre, filedata=None):
#     def setdatavalue(self, filedata):
#     def getvalues(self):
# 
# Path: Modules/fourier.py
# def CalcFourier(signal):
# def CalcFourierPower(signal, fs, fc):
# def CalcIFourier(signal):
#     N = transform.shape[0]


import numpy as np
import matplotlib.pyplot as plt
from Modules import SignalData
from Modules import fourier
            Instance of class SignalData.
        chunksize : int
            Size of one signal chunk processed each time, preferred 
            power of two for faster FFT computation.
        number : int
            Number of rows to be interleaved to help reduce memory consumption.

    """

    signal = SignalInfo.filedata
    len_signal = len(signal)
    chunknumber = int(len_signal // chunksize)

    for i in range(0, chunknumber):

        startslice = i * chunksize
        endslice = startslice + chunksize

        signal_chunk = signal[startslice:endslice]
        signal_chunk_iq = np.empty(
            signal_chunk.shape[0] // 2, dtype=np.complex64)

        signal_chunk_iq.real = signal_chunk[::2] - 127.5
        signal_chunk_iq.imag = signal_chunk[1::2] - 127.5

        ''' fft start + shifting '''
        signalFFT = fourier.CalcFourier(
            signal_chunk_iq)

        ''' fft shifted signal power '''

# Path: Modules/SignalData.py
# class Signal(object):
#     def __init__(self, filename=None, filetype=None, filedata=None, Fsample=None, Fcentre=None):
#     def setvalues(self, filename, filetype, Fsample, Fcentre, filedata=None):
#     def setdatavalue(self, filedata):
#     def getvalues(self):
# 
# Path: Modules/fourier.py
# def CalcFourier(signal):
# def CalcFourierPower(signal, fs, fc):
# def CalcIFourier(signal):
#     N = transform.shape[0]


# Path: Modules/waterfall.py
import numpy as np
import matplotlib.pyplot as plt
from Modules import SignalData
from Modules import fourier

            Instance of class SignalData.
        chunksize : int
            Size of one signal chunk processed each time, preferred 
            power of two for faster FFT computation.
        number : int
            Number of rows to be interleaved to help reduce memory consumption.

    """

    signal = SignalInfo.filedata
    len_signal = len(signal)
    chunknumber = int(len_signal // chunksize)

    for i in range(0, chunknumber):

        startslice = i * chunksize
        endslice = startslice + chunksize

        signal_chunk = signal[startslice:endslice]
        signal_chunk_iq = np.empty(
            signal_chunk.shape[0] // 2, dtype=np.complex64)

        signal_chunk_iq.real = signal_chunk[::2] - 127.5
        signal_chunk_iq.imag = signal_chunk[1::2] - 127.5

        ''' fft start + shifting '''
        signalFFT = fourier.CalcFourier(
            signal_chunk_iq)

        ''' fft shifted signal power '''

        frequency, transform = fourier.CalcFourierPower(