def theoretical_evaluation():
    puretone_freq = 10000
    input_tone = sumpf.modules.SineWaveGenerator(frequency=puretone_freq,
                                                 phase=0.0,
                                                 samplingrate=sampling_rate,
                                                 length=length)
    sine = input_tone.GetSignal()
    input_tone.SetFrequency(2 * puretone_freq)
    sine_2 = input_tone.GetSignal()
    input_tone.SetFrequency(3 * puretone_freq)
    sine_3 = input_tone.GetSignal()
    input_tone.SetPhaseInDegrees(90)
    cos = input_tone.GetSignal()
    input_tone.SetFrequency(2 * puretone_freq)
    cos_2 = input_tone.GetSignal()
    input_tone.SetFrequency(3 * puretone_freq)
    cos_3 = input_tone.GetSignal()

    theoreticl_op_2 = sumpf.modules.ConstantSignalGenerator(value=0.5,samplingrate=sine.GetSamplingRate(),length=len(sine)).GetSignal() - \
                    sumpf.modules.AmplifySignal(factor=0.5,input=cos_2).GetOutput()
    theoreticl_op_3 = sumpf.modules.AmplifySignal(factor=3.0/4.0,input=sine).GetOutput() - \
                      sumpf.modules.AmplifySignal(factor=3.0/4.0,input=sine_3).GetOutput()

    branch_simple_2 = nlsp.HammersteinModel(
        input_signal=sine, nonlin_func=nlsp.function_factory.power_series(2))
    branch_simple_3 = nlsp.HammersteinModel(
        input_signal=sine, nonlin_func=nlsp.function_factory.power_series(3))
    branch_up_2 = nlsp.AliasCompensatingHammersteinModelUpandDown(
        input_signal=sine,
        nonlin_func=nlsp.function_factory.power_series(2),
        max_harm=2)
    branch_up_3 = nlsp.AliasCompensatingHammersteinModelUpandDown(
        input_signal=sine,
        nonlin_func=nlsp.function_factory.power_series(3),
        max_harm=3)
    branch_lp_2 = nlsp.AliasCompensatingHammersteinModelLowpass(
        input_signal=sine,
        nonlin_func=nlsp.function_factory.power_series(2),
        max_harm=2)
    branch_lp_3 = nlsp.AliasCompensatingHammersteinModelLowpass(
        input_signal=sine,
        nonlin_func=nlsp.function_factory.power_series(3),
        max_harm=3)
    snr_simple_2 = nlsp.snr(theoreticl_op_2, branch_simple_2.GetOutput())
    snr_simple_3 = nlsp.snr(theoreticl_op_3, branch_simple_3.GetOutput())
    snr_up_2 = nlsp.snr(theoreticl_op_2, branch_up_2.GetOutput())
    snr_up_3 = nlsp.snr(theoreticl_op_3, branch_up_3.GetOutput())
    snr_lp_2 = nlsp.snr(theoreticl_op_2, branch_lp_2.GetOutput())
    snr_lp_3 = nlsp.snr(theoreticl_op_3, branch_lp_3.GetOutput())
    # plot.relabelandplot(sumpf.modules.FourierTransform(branch_simple.GetOutput()).GetSpectrum(),"simpleout",show=False)
    plot.relabelandplot(branch_up_2.GetOutput(), "upout", show=False)
    # plot.relabelandplot(sumpf.modules.FourierTransform(branch_lp.GetOutput()).GetSpectrum(),"lpout",show=False)
    plot.relabelandplot(theoreticl_op_2, "theoryout", show=True)
    # plot.relabelandplot(sumpf.modules.FourierTransform(ip_sine).GetSpectrum(),"input",show=True)
    # print "simple,2nd degree:%r" %snr_simple_2
    # print "simple,3rd degree:%r" %snr_simple_3
    print "up,2nd degree:%r" % snr_up_2
    print "up,3rd degree:%r" % snr_up_3
    print "lp,2nd degree:%r" % snr_lp_2
    print "lp,3rd degree:%r" % snr_lp_3
def lowpass_evaluation():
    print "lowpass evaluation"
    for order in range(1, degree + 1):
        branch_lp_butter = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=input_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(1),
            max_harm=order,
            filterfunction=sumpf.modules.FilterGenerator.BUTTERWORTH(order=10))
        branch_lp_cheby1 = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=input_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(1),
            max_harm=order,
            filterfunction=sumpf.modules.FilterGenerator.CHEBYCHEV1(
                order=10, ripple=6.0))
        butter_spec = nlsp.relabel(
            sumpf.modules.FourierTransform(
                branch_lp_butter.GetOutput()).GetSpectrum(),
            "butterworth lp branch")
        chebyshev_spec = nlsp.relabel(
            sumpf.modules.FourierTransform(
                branch_lp_cheby1.GetOutput()).GetSpectrum(),
            "chebyshev lp branch")
        input_spec = nlsp.relabel(
            sumpf.modules.FourierTransform(input_sweep_signal).GetSpectrum(),
            "input spec")
        if Plot is True:
            plot.log()
            plot.plot(butter_spec, show=False)
            plot.plot(input_spec, show=False)
            plot.plot(chebyshev_spec, show=True)
def higher_nonlinearity_evaluation():
    sampling_rate = 48000
    sweep_start_freq = 20.0
    sweep_stop_freq = 24000.0
    length = 2**15
    degree = 5
    input_signal = nlsp.NovakSweepGenerator_Sine(
        sampling_rate=sampling_rate,
        length=length,
        start_frequency=sweep_start_freq,
        stop_frequency=sweep_stop_freq)
    # input_signal = sumpf.modules.SweepGenerator(samplingrate=sampling_rate,length=length)
    normal = sumpf.modules.NoiseGenerator.GaussianDistribution(
        mean=0.0, standard_deviation=1.0)
    wgn_normal = nlsp.WhiteGaussianGenerator(sampling_rate=sampling_rate,
                                             length=length,
                                             start_frequency=20.0,
                                             stop_frequency=24000.0,
                                             distribution=normal)
    frequencies = [
        100, 500, 1000, 2000, 4000, 5000, 10000, 15000, 18000, 20000, 24000
    ]
    puretones = nlsp.generate_puretones(frequencies, sampling_rate, length)
    input_sweep_signal = input_signal.GetOutput()
    model_up_ref = nlsp.AliasCompensatingHammersteinModelUpandDown(
        input_signal=input_sweep_signal,
        nonlin_func=nlsp.function_factory.power_series(degree),
        max_harm=degree)
    model_lp_ref = nlsp.AliasCompensatingHammersteinModelLowpass(
        input_signal=input_sweep_signal,
        nonlin_func=nlsp.function_factory.power_series(degree),
        max_harm=degree)
    model_up_ref = model_up_ref.GetOutput()
    model_lp_ref = model_lp_ref.GetOutput()
    for factor in range(degree - 2, degree + 2):
        model_up = nlsp.AliasCompensatingHammersteinModelUpandDown(
            input_signal=input_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(degree),
            max_harm=factor)
        model_lp = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=input_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(degree),
            max_harm=factor)
        model_up = model_up.GetOutput()
        model_lp = model_lp.GetOutput()
        print "Upsampling HM, nonlinearity degree:%r, Alias compensation factor:%r, SNR:%r" % (
            degree, factor,
            nlsp.snr(model_up_ref, model_up, freqrange=[20.0, 24000.0]))
        print "Lowpass HM, nonlinearity degree:%r, Alias compensation factor:%r, SNR:%r" % (
            degree, factor,
            nlsp.snr(model_lp_ref, model_lp, freqrange=[20.0, 24000.0]))
def reliability_evaluation_puretone():
    length = 2**15
    for max_harm in range(3, 6):
        frequencies = [100, 500, 1000, 2000, 4000]
        puretones = nlsp.generate_puretones(frequencies, sampling_rate, length)
        ip_signal = puretones
        nl_degree = max_harm
        model_simple = nlsp.HammersteinModel(
            input_signal=puretones,
            nonlin_func=nlsp.function_factory.power_series(nl_degree))
        model_up = nlsp.AliasCompensatingHammersteinModelUpandDown(
            input_signal=ip_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree),
            max_harm=max_harm)
        model_lp = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=ip_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree),
            max_harm=max_harm)
        # plot.relabelandplot(sumpf.modules.FourierTransform(model_simple.GetOutput()).GetSpectrum(),"Uncompensated",show=False)
        # plot.relabelandplot(sumpf.modules.FourierTransform(model_up.GetOutput()).GetSpectrum(),"Upsampling",show=False)
        # plot.relabelandplot(sumpf.modules.FourierTransform(model_lp.GetOutput()).GetSpectrum(),"Lowpass filtering",show=True)

        plot.relabelandplot(model_simple.GetOutput(),
                            "Uncompensated",
                            show=False)
        plot.relabelandplot(model_up.GetOutput(), "upsampling", show=False)
        plot.relabelandplot(model_lp.GetOutput(), "lowpass", show=True)

        print "maxharmonics: %r" % max_harm
        print "snr between simple HGM and upsampling HGM: %r" % nlsp.snr(
            model_simple.GetOutput(), model_up.GetOutput())
        print "snr between simple HGM and lowpass HGM: %r" % nlsp.snr(
            model_simple.GetOutput(), model_lp.GetOutput())
        print
def puretone_evaluation():
    """
    Evaluation of alias compensation of hammerstein branch using pure tones.
    Puretone of certain frequency is given to different hammerstein branches with different Aliasing compensation.
    The order of the harmonics produces is changed and the output of different models are plotted.
    We observe the lowpass aliasing compensation completely filters out the signal harmonics even when they are in the
    baseband freq.
    """
    print "puretone evaluation"
    for i in range(1, degree + 1):
        input_tone = nlsp.generate_puretones([10000], sampling_rate, length)
        branch_simple = nlsp.HammersteinModel(
            input_signal=input_tone,
            nonlin_func=nlsp.function_factory.power_series(i))
        branch_up = nlsp.AliasCompensatingHammersteinModelUpandDown(
            input_signal=input_tone,
            nonlin_func=nlsp.function_factory.power_series(i),
            max_harm=i)
        branch_lp = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=input_tone,
            nonlin_func=nlsp.function_factory.power_series(i),
            max_harm=i)
        print "Pure tone evaluation"
        print "Order: %r" % i
        print "SNR of simple h. branch: %r" % nlsp.snr(
            input_tone, branch_simple.GetOutput())
        print "SNR of upsample h. branch: %r" % nlsp.snr(
            input_tone, branch_up.GetOutput())
        print "SNR of lowpass h. branch: %r" % nlsp.snr(
            input_tone, branch_lp.GetOutput())
        print "MSE of simple h. branch: %r" % nlsp.mean_squared_error_time(
            input_tone, branch_simple.GetOutput())
        print "MSE of upsample h. branch: %r" % nlsp.mean_squared_error_time(
            input_tone, branch_up.GetOutput())
        print "MSE of lowpass h. branch: %r" % nlsp.mean_squared_error_time(
            input_tone, branch_lp.GetOutput())
        if Plot is True:
            plot.log()
            branch_simple_spectrum = nlsp.relabel(
                sumpf.modules.FourierTransform(
                    branch_simple.GetOutput()).GetSpectrum(),
                "%d Simple Hammerstein Branch" % i)
            plot.plot(branch_simple_spectrum, show=False)
            branch_up_spectrum = nlsp.relabel(
                sumpf.modules.FourierTransform(
                    branch_up.GetOutput()).GetSpectrum(),
                "%d Upsampling Hammerstein Branch" % i)
            plot.plot(branch_up_spectrum, show=False)
            branch_lp_spectrum = nlsp.relabel(
                sumpf.modules.FourierTransform(
                    branch_lp.GetOutput()).GetSpectrum(),
                "%d Lowpass Hammerstein Branch" % i)
            plot.plot(branch_lp_spectrum, show=True)
def harmonics_evaluation():
    degree = 5
    length = 2**18
    input_signal = nlsp.NovakSweepGenerator_Sine(
        sampling_rate=sampling_rate,
        length=length,
        start_frequency=sweep_start_freq,
        stop_frequency=sweep_stop_freq)
    input_sweep_signal = input_signal.GetOutput()

    for i in range(degree, degree + 1):
        prp = sumpf.modules.ChannelDataProperties()
        prp.SetSignal(input_sweep_signal)
        filter = sumpf.modules.FilterGenerator(
            filterfunction=sumpf.modules.FilterGenerator.BUTTERWORTH(
                order=100),
            frequency=24000.0,
            transform=False,
            resolution=prp.GetResolution(),
            length=prp.GetSpectrumLength()).GetSpectrum()
        filter_ir = sumpf.modules.InverseFourierTransform(filter).GetSignal()
        branch_simple = nlsp.HammersteinModel(
            input_signal=input_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(i),
            filter_impulseresponse=filter_ir)
        branch_up = nlsp.AliasCompensatingHammersteinModelUpandDown(
            input_signal=input_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(i),
            max_harm=i,
            filter_impulseresponse=filter_ir)
        branch_lp = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=input_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(i),
            max_harm=i,
            filter_impulseresponse=filter_ir)
        harm_simple = nlsp.get_nl_impulse_response(input_signal,
                                                   branch_simple.GetOutput())
        harm_up = nlsp.get_nl_impulse_response(input_signal,
                                               branch_up.GetOutput())
        harm_lowpass = nlsp.get_nl_impulse_response(input_signal,
                                                    branch_lp.GetOutput())
        plot.relabelandplot(harm_simple, "simple HM", show=True)
        plot.relabelandplot(harm_up, "upsampling HM", show=True)
        plot.relabelandplot(harm_lowpass, "lowpass HM", show=True)
        print nlsp.harmonicsvsall_energyratio_nl(input_signal,
                                                 branch_simple.GetOutput(), i)
        print nlsp.harmonicsvsall_energyratio_nl(input_signal,
                                                 branch_up.GetOutput(), i)
        print nlsp.harmonicsvsall_energyratio_nl(input_signal,
                                                 branch_lp.GetOutput(), i)
        print
        print
def wgn_evaluation():
    degree = 5
    print "wgn evaluation"
    for degree in range(3, degree + 1):
        wgn = sumpf.modules.NoiseGenerator(
            sumpf.modules.NoiseGenerator.GaussianDistribution(
                mean=0.0, standard_deviation=1.0),
            samplingrate=sampling_rate,
            length=length)
        prp = sumpf.modules.ChannelDataProperties()
        prp.SetSignal(wgn.GetSignal())
        filter = sumpf.modules.RectangleFilterGenerator(
            resolution=prp.GetResolution(),
            length=prp.GetSpectrumLength()).GetSpectrum()
        ref = nlsp.HammersteinModel(
            input_signal=wgn.GetSignal(),
            nonlin_func=nlsp.function_factory.power_series(degree),
            filter_impulseresponse=sumpf.modules.InverseFourierTransform(
                filter).GetSignal()).GetOutput()
        model_simple = nlsp.HammersteinModel(
            input_signal=wgn.GetSignal(),
            nonlin_func=nlsp.function_factory.power_series(degree))
        model_up = nlsp.AliasCompensatingHammersteinModelUpandDown(
            input_signal=wgn.GetSignal(),
            nonlin_func=nlsp.function_factory.power_series(degree),
            max_harm=degree)
        model_lp = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=wgn.GetSignal(),
            nonlin_func=nlsp.function_factory.power_series(degree),
            max_harm=degree)
        print "degree %r" % degree
        print nlsp.snr(model_simple.GetOutput(), ref)
        print nlsp.snr(model_up.GetOutput(), ref)
        print nlsp.snr(model_lp.GetOutput(), ref)
        print
        print
        if Plot is True:
            plot.relabelandplot(sumpf.modules.FourierTransform(
                model_up.GetOutput()).GetSpectrum(),
                                "Upsampling HM",
                                show=False)
            plot.relabelandplot(
                sumpf.modules.FourierTransform(ref).GetSpectrum(),
                "Upsampling HM Ref")
            plot.relabelandplot(sumpf.modules.FourierTransform(
                model_lp.GetOutput()).GetSpectrum(),
                                "Lowpass HM",
                                show=False)
            plot.relabelandplot(
                sumpf.modules.FourierTransform(ref).GetSpectrum(),
                "Lowpass HM Ref")
def linearity_evaluation():
    print "linearity evaluation"
    for i in range(3, degree + 1):
        max_harm = i
        nl_degree = i
        sweep_start_freq = 20.0
        sweep_stop_freq = 4000.0
        ip_sweep_signal = sumpf.modules.SweepGenerator(
            samplingrate=sampling_rate,
            length=length,
            start_frequency=sweep_start_freq,
            stop_frequency=sweep_stop_freq).GetSignal()
        model_simple = nlsp.HammersteinModel(
            input_signal=ip_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree))
        model_up = nlsp.AliasCompensatingHammersteinModelUpandDown(
            input_signal=ip_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree),
            max_harm=max_harm)
        model_lp = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=ip_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree),
            max_harm=max_harm)
        simple_ref = model_simple.GetOutput()
        up_ip = model_up.GetOutput()
        lp_ip = model_lp.GetOutput()
        print "degree %r" % i
        print nlsp.snr(simple_ref, simple_ref)
        print nlsp.snr(up_ip, simple_ref)
        print nlsp.snr(lp_ip, simple_ref)
        print
        print
        if Plot is True:
            plot.log()
            plot.relabelandplot(sumpf.modules.FourierTransform(
                model_simple.GetOutput()).GetSpectrum(),
                                "Reference",
                                show=False)
            plot.relabelandplot(sumpf.modules.FourierTransform(
                model_up.GetOutput()).GetSpectrum(),
                                "Upsampling HM",
                                show=False)
            plot.relabelandplot(sumpf.modules.FourierTransform(
                model_lp.GetOutput()).GetSpectrum(),
                                "Lowpass HM",
                                show=True)
def sweep_evaluation():
    """
    Evaluation of alias compensation of hammerstein branch using sweep.
    Sweep(20 to 20000Hz) of sampling rate 48000 samples/sec is upsampled to 96000 samples/sec and given to upsampling
    and lowpass filtering Alias compensation. And the maximum harmonic of the hammerstein branches is changed to two
    and the energy of the branches is evaluated.
    The energy of the desired band and undesired band should be equal for both upsampling and lowpass filtering alias
    compensation.
    """
    print "sweep evaluation"
    for i in range(1, degree + 1):
        up_sweep_signal = sumpf.modules.ResampleSignal(
            signal=input_sweep_signal,
            samplingrate=input_sweep_signal.GetSamplingRate() * i).GetOutput()
        branch = nlsp.HammersteinModel(
            input_signal=up_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(i))
        branch_up = nlsp.AliasCompensatingHammersteinModelUpandDown(
            input_signal=up_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(1),
            max_harm=i)
        branch_lp = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=up_sweep_signal,
            nonlin_func=nlsp.function_factory.power_series(1),
            max_harm=i,
            filterfunction=sumpf.modules.FilterGenerator.BUTTERWORTH(
                order=100))
        snr = nlsp.snr(
            input_sweep_signal,
            sumpf.modules.ResampleSignal(
                signal=branch.GetOutput(),
                samplingrate=input_sweep_signal.GetSamplingRate()).GetOutput())
        snr_up = nlsp.snr(
            input_sweep_signal,
            sumpf.modules.ResampleSignal(
                signal=branch_up.GetOutput(),
                samplingrate=input_sweep_signal.GetSamplingRate()).GetOutput())
        snr_lp = nlsp.snr(
            input_sweep_signal,
            sumpf.modules.ResampleSignal(
                signal=branch_lp.GetOutput(),
                samplingrate=input_sweep_signal.GetSamplingRate()).GetOutput())
        print snr
        print snr_up
        print snr_lp
        print
def reliability_evaluation_sweep():
    length = 2**15
    for max_harm in range(1, 6):
        sweep = nlsp.NovakSweepGenerator_Sine(sampling_rate=sampling_rate,
                                              length=length,
                                              start_frequency=20.0,
                                              stop_frequency=2000.0)
        ip_signal = sweep.GetOutput()
        nl_degree = max_harm
        model_simple = nlsp.HammersteinModel(
            input_signal=ip_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree))
        model_up = nlsp.AliasCompensatingHammersteinModelUpandDown(
            input_signal=ip_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree),
            max_harm=max_harm)
        model_lp = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=ip_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree),
            max_harm=max_harm)
        # plot.relabelandplot(sumpf.modules.FourierTransform(model_simple.GetOutput()).GetSpectrum(),"simple",show=False)
        # plot.relabelandplot(sumpf.modules.FourierTransform(model_up.GetOutput()).GetSpectrum(),"upsampling",show=False)
        # plot.relabelandplot(sumpf.modules.FourierTransform(model_lp.GetOutput()).GetSpectrum(),"lowpass",show=True)

        plot.relabelandplot(model_simple.GetOutput(),
                            "Uncompensated",
                            show=False)
        plot.relabelandplot(model_up.GetOutput(), "Upsampling", show=False)
        plot.relabelandplot(model_lp.GetOutput(),
                            "Lowpass filtering",
                            show=True)

        print "maxharmonics: %r" % max_harm
        print "snr between simple HGM and upsampling HGM: %r" % nlsp.snr(
            model_simple.GetOutput(), model_up.GetOutput())
        print "snr between simple HGM and lowpass HGM: %r" % nlsp.snr(
            model_simple.GetOutput(), model_lp.GetOutput())
        print "snr between simple HGM and upsampling HGM magnitude: %r" % nlsp.snr_magnitude(
            model_simple.GetOutput(), model_up.GetOutput())
        print "snr between simple HGM and lowpass HGM magnitude: %r" % nlsp.snr_magnitude(
            model_simple.GetOutput(), model_lp.GetOutput())
        print
def reliability_evaluation_noise():
    length = 2**18
    normal = sumpf.modules.NoiseGenerator.GaussianDistribution(
        mean=0.0, standard_deviation=1.0)
    wgn_normal = nlsp.WhiteGaussianGenerator(sampling_rate=sampling_rate,
                                             length=length,
                                             start_frequency=20.0,
                                             stop_frequency=2000.0,
                                             distribution=normal)
    # wgn_normal = sumpf.modules.NoiseGenerator(distribution=normal,samplingrate=sampling_rate,length=length)
    ip_signal = wgn_normal.GetOutput()
    for max_harm in range(2, 3):
        nl_degree = max_harm
        model_simple = nlsp.HammersteinModel(
            input_signal=ip_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree))
        model_up = nlsp.AliasCompensatingHammersteinModelUpandDown(
            input_signal=ip_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree),
            max_harm=max_harm)
        model_lp = nlsp.AliasCompensatingHammersteinModelLowpass(
            input_signal=ip_signal,
            nonlin_func=nlsp.function_factory.power_series(nl_degree),
            max_harm=max_harm)
        # plot.relabelandplot(sumpf.modules.FourierTransform(model_simple.GetOutput()).GetSpectrum(),"simple",show=False)
        # plot.relabelandplot(sumpf.modules.FourierTransform(model_up.GetOutput()).GetSpectrum(),"upsampling",show=False)
        # plot.relabelandplot(sumpf.modules.FourierTransform(model_lp.GetOutput()).GetSpectrum(),"lowpass",show=True)

        # plot.relabelandplot(model_simple.GetOutput(),"simple",show=False)
        # plot.relabelandplot(model_up.GetOutput(),"upsampling",show=False)
        # plot.relabelandplot(model_lp.GetOutput(),"lowpass",show=True)

        print "maxharmonics: %r" % max_harm
        print "snr between simple HGM and upsampling HGM: %r" % nlsp.snr(
            model_simple.GetOutput(), model_up.GetOutput())
        print "snr between simple HGM and lowpass HGM: %r" % nlsp.snr(
            model_simple.GetOutput(), model_lp.GetOutput())
        print