예제 #1
0
def differentlength_evaluation(input_generator,
                               branches,
                               Plot,
                               reference=None):
    length_ref = [2**15, 2**16, 2**17]
    length_iden = [2**15, 2**16, 2**17]
    input_generator_ref = input_generator
    input_generator_iden = input_generator
    for signal_length, ref_length in zip(length_iden, length_ref):
        input_generator_ref.SetLength(ref_length)
        input_ref = input_generator_ref.GetOutput()
        filter_spec_tofind = nlsp.log_weightingfilter(branches=branches,
                                                      input=input_ref)
        ref_nlsystem = nlsp.HammersteinGroupModel_up(
            input_signal=input_ref,
            nonlinear_functions=nlsp.nl_branches(
                nlsp.function_factory.power_series, branches),
            filter_irs=filter_spec_tofind,
            max_harmonics=range(1, branches + 1))

        sweep = nlsp.NovakSweepGenerator_Sine(
            sampling_rate=input_ref.GetSamplingRate(), length=len(input_ref))
        ref_nlsystem.SetInput(sweep.GetOutput())
        init_coeffs, non = nlsp.nonlinearconvolution_powerseries_temporalreversal(
            sweep, ref_nlsystem.GetOutput(), branches=branches)
        init_coeffs = nlsp.change_length_filterkernels(init_coeffs,
                                                       filter_length)
        ref_nlsystem.SetInput(input_ref)
        found_filter_spec, nl_functions = nlsp.adaptive_identification_legendre(
            input_generator=input_generator_ref,
            outputs=ref_nlsystem.GetOutput(),
            branches=branches,
            init_coeffs=init_coeffs)

        input_generator_iden.SetLength(signal_length)
        input_iden = input_generator_iden.GetOutput()
        iden_nlsystem = nlsp.HammersteinGroupModel_up(
            input_signal=input_iden,
            nonlinear_functions=nl_functions,
            filter_irs=found_filter_spec,
            max_harmonics=range(1, branches + 1))
        if reference is not None:
            reference = nlsp.change_length_signal(reference,
                                                  length=len(input_ref))
            ref_nlsystem.SetInput(reference)
            iden_nlsystem.SetInput(reference)

        if Plot is True:
            plot.relabelandplotphase(
                sumpf.modules.FourierTransform(
                    ref_nlsystem.GetOutput()).GetSpectrum(),
                "Reference Output", False)
            plot.relabelandplotphase(
                sumpf.modules.FourierTransform(
                    iden_nlsystem.GetOutput()).GetSpectrum(),
                "Identified Output", True)
        print "SNR between Reference(length:%r) and Identified output(length:%r) : %r" % (
            len(input_ref), len(input_iden),
            nlsp.snr(ref_nlsystem.GetOutput(), iden_nlsystem.GetOutput()))
def differentlength_evaluation(input_generator,
                               branches,
                               iden_method,
                               Plot,
                               reference=None):
    """
    Evaluation of System Identification method by hgm virtual nl system
    nonlinear system - virtual hammerstein group model with power series polynomials as nl function and bandpass filters
                        as linear functions
    inputsignal - signal signal
    plot - the original filter spectrum and the identified filter spectrum, the reference output and identified output
    expectation - utmost similarity between the two spectrums
    """
    length_ref = [2**15, 2**16, 2**17]
    length_iden = [2**15, 2**16, 2**17]
    input_generator_ref = input_generator
    input_generator_iden = input_generator
    for signal_length, ref_length in zip(length_iden, length_ref):
        input_generator_ref.SetLength(ref_length)
        input_ref = input_generator_ref.GetOutput()
        filter_spec_tofind = nlsp.log_weightingfilter(branches=branches,
                                                      input=input_ref)
        ref_nlsystem = nlsp.HammersteinGroupModel_up(
            input_signal=input_ref,
            nonlinear_functions=nlsp.nl_branches(
                nlsp.function_factory.power_series, branches),
            filter_irs=filter_spec_tofind,
            max_harmonics=range(1, branches + 1))
        found_filter_spec, nl_functions = iden_method(input_generator,
                                                      ref_nlsystem.GetOutput(),
                                                      branches)

        input_generator_iden.SetLength(signal_length)
        input_iden = input_generator_iden.GetOutput()
        iden_nlsystem = nlsp.HammersteinGroupModel_up(
            input_signal=input_iden,
            nonlinear_functions=nl_functions,
            filter_irs=found_filter_spec,
            max_harmonics=range(1, branches + 1))
        if reference is not None:
            reference = nlsp.change_length_signal(reference,
                                                  length=len(input_ref))
            ref_nlsystem.SetInput(reference)
            iden_nlsystem.SetInput(reference)

        if Plot is True:
            plot.relabelandplotphase(
                sumpf.modules.FourierTransform(
                    ref_nlsystem.GetOutput()).GetSpectrum(),
                "Reference Output", False)
            plot.relabelandplotphase(
                sumpf.modules.FourierTransform(
                    iden_nlsystem.GetOutput()).GetSpectrum(),
                "Identified Output", True)
        print "SNR between Reference(length:%r) and Identified output(length:%r) : %r" % (
            len(input_ref), len(input_iden),
            nlsp.snr(ref_nlsystem.GetOutput(), iden_nlsystem.GetOutput()))
예제 #3
0
def doublehgm_samenl_evaluation(input_generator,
                                branches,
                                iden_method,
                                Plot,
                                reference=None):
    input_signal = input_generator.GetOutput()
    filter_spec_tofind1 = nlsp.log_bpfilter(branches=branches,
                                            input=input_signal)
    filter_spec_tofind2 = nlsp.log_chebyfilter(branches=branches,
                                               input=input_signal)
    ref_nlsystem = nlsp.HammersteinGroup_Series(
        input_signal=input_signal,
        nonlinear_functions=(nlsp.nl_branches(
            nlsp.function_factory.power_series, branches),
                             nlsp.nl_branches(
                                 nlsp.function_factory.power_series,
                                 branches)),
        filter_irs=(filter_spec_tofind1, filter_spec_tofind2),
        max_harmonics=(range(1, branches + 1), range(1, branches + 1)),
        hgm_type=(nlsp.HammersteinGroupModel_up,
                  nlsp.HammersteinGroupModel_up))

    found_filter_spec, nl_functions = iden_method(input_generator,
                                                  ref_nlsystem.GetOutput(2),
                                                  branches)
    iden_nlsystem = nlsp.HammersteinGroupModel_up(
        input_signal=input_signal,
        nonlinear_functions=nl_functions,
        filter_irs=found_filter_spec,
        max_harmonics=range(1, branches + 1))
    if reference is not None:
        reference = nlsp.change_length_signal(reference,
                                              length=len(input_signal))
        ref_nlsystem = nlsp.HammersteinGroup_Series(
            input_signal=reference,
            nonlinear_functions=(nlsp.nl_branches(
                nlsp.function_factory.power_series, branches),
                                 nlsp.nl_branches(
                                     nlsp.function_factory.power_series,
                                     branches)),
            filter_irs=(filter_spec_tofind1, filter_spec_tofind2),
            max_harmonics=(range(1, branches + 1), range(1, branches + 1)),
            hgm_type=(nlsp.HammersteinGroupModel_up,
                      nlsp.HammersteinGroupModel_up))
        iden_nlsystem.SetInput(reference)

    if Plot is True:
        plot.relabelandplotphase(sumpf.modules.FourierTransform(
            ref_nlsystem.GetOutput(2)).GetSpectrum(),
                                 "Reference System",
                                 show=False)
        plot.relabelandplotphase(sumpf.modules.FourierTransform(
            iden_nlsystem.GetOutput()).GetSpectrum(),
                                 "Identified System",
                                 show=True)
    print "SNR between Reference and Identified output for double hgm same nl: %r" % nlsp.snr(
        ref_nlsystem.GetOutput(2), iden_nlsystem.GetOutput())
def differentbranches_evaluation(input_generator,
                                 branches,
                                 iden_method,
                                 Plot,
                                 reference=None):
    ref_branches = 3
    for branches in range(1, branches):
        input_signal = input_generator.GetOutput()

        filter_spec_tofind = nlsp.log_weightingfilter(branches=ref_branches,
                                                      input=input_signal)
        ref_nlsystem = nlsp.HammersteinGroupModel_up(
            input_signal=input_signal,
            nonlinear_functions=nlsp.nl_branches(
                nlsp.function_factory.power_series, ref_branches),
            filter_irs=filter_spec_tofind,
            max_harmonics=range(1, ref_branches + 1))

        found_filter_spec, nl_functions = iden_method(input_generator,
                                                      ref_nlsystem.GetOutput(),
                                                      branches)
        iden_nlsystem = nlsp.HammersteinGroupModel_up(
            input_signal=input_signal,
            nonlinear_functions=nl_functions,
            filter_irs=found_filter_spec,
            max_harmonics=range(1, branches + 1))
        if reference is not None:
            reference = nlsp.change_length_signal(reference,
                                                  length=len(input_signal))
            ref_nlsystem.SetInput(reference)
            iden_nlsystem.SetInput(reference)
        if Plot is True:
            plot.relabelandplotphase(
                sumpf.modules.FourierTransform(
                    ref_nlsystem.GetOutput()).GetSpectrum(),
                "Reference Output", False)
            plot.relabelandplotphase(
                sumpf.modules.FourierTransform(
                    iden_nlsystem.GetOutput()).GetSpectrum(),
                "Identified Output", True)
        print "SNR between Reference and Identified output : %r, with number of ref_branches: %r and iden_branches: %r" % (
            nlsp.snr(ref_nlsystem.GetOutput(),
                     iden_nlsystem.GetOutput()), ref_branches, branches)
예제 #5
0
def softclipping_evaluation(input_generator,
                            branches,
                            iden_method,
                            Plot,
                            reference=None):
    """
    Evaluation of System Identification method by soft clipping system
    nonlinear system - virtual clipping systems which soft clips the signal amplitute which are not in the threshold range
    plot - the virtual nl system output and the identified nl system output
    expectation - utmost similarity between the two outputs
    """
    thresholds = [-1.0, 1.0]
    power = 1.0 / 3.0
    input_signal = input_generator.GetOutput()
    ref_nlsystem = nlsp.NLClipSignal(thresholds=thresholds, power=power)
    ref_nlsystem.SetInput(input_signal)

    found_filter_spec, nl_functions = iden_method(input_generator,
                                                  ref_nlsystem.GetOutput(),
                                                  branches)
    iden_nlsystem = nlsp.HammersteinGroupModel_up(
        input_signal=input_signal,
        nonlinear_functions=nl_functions,
        filter_irs=found_filter_spec,
        max_harmonics=range(1, branches + 1))
    if reference is not None:
        ref_nlsystem.SetInput(reference)
        iden_nlsystem.SetInput(reference)

    if Plot is True:
        plot.relabelandplotphase(sumpf.modules.FourierTransform(
            ref_nlsystem.GetOutput()).GetSpectrum(),
                                 "Reference System",
                                 show=False)
        plot.relabelandplotphase(sumpf.modules.FourierTransform(
            iden_nlsystem.GetOutput()).GetSpectrum(),
                                 "Identified System",
                                 show=True)
    print "SNR between Reference and Identified output for soft clipping: %r" % nlsp.snr(
        ref_nlsystem.GetOutput(), iden_nlsystem.GetOutput())
예제 #6
0
def wgnasreference():

    branches = 3
    sampling_rate = 48000.0
    length = 2**18
    start_freq = 100.0
    stop_freq = 20000.0
    fade_out = 0.00
    fade_in = 0.00
    filter_taps = 2**11

    # input generator
    sine_g = nlsp.NovakSweepGenerator_Sine(sampling_rate=sampling_rate,
                                           length=length,
                                           start_frequency=start_freq,
                                           stop_frequency=stop_freq,
                                           fade_out=fade_out,
                                           fade_in=fade_in)
    cos_g = nlsp.NovakSweepGenerator_Cosine(sampling_rate=sampling_rate,
                                            length=length,
                                            start_frequency=start_freq,
                                            stop_frequency=stop_freq,
                                            fade_out=fade_out,
                                            fade_in=fade_in)

    # real world reference system, load input and output noise and sweeps
    load_noise = sumpf.modules.SignalFile(
        filename=
        "C:/Users/diplomand.8/Desktop/nl_recordings/rec_4_ls/Noise18.npz",
        format=sumpf.modules.SignalFile.WAV_FLOAT)
    load_sine = sumpf.modules.SignalFile(
        filename="C:/Users/diplomand.8/Desktop/nl_recordings/rec_4_ls/sine.npz",
        format=sumpf.modules.SignalFile.WAV_FLOAT)
    load_cosine = sumpf.modules.SignalFile(
        filename="C:/Users/diplomand.8/Desktop/nl_recordings/rec_4_ls/cos.npz",
        format=sumpf.modules.SignalFile.WAV_FLOAT)
    output_noise = sumpf.modules.SplitSignal(data=load_noise.GetSignal(),
                                             channels=[1]).GetOutput()
    input_noise = sumpf.modules.SplitSignal(data=load_noise.GetSignal(),
                                            channels=[0]).GetOutput()
    output_sine = sumpf.modules.SplitSignal(data=load_sine.GetSignal(),
                                            channels=[1]).GetOutput()
    output_cos = sumpf.modules.SplitSignal(data=load_cosine.GetSignal(),
                                           channels=[1]).GetOutput()
    impulse = sumpf.modules.ImpulseGenerator(
        length=filter_taps, samplingrate=sampling_rate).GetSignal()

    # initialize hgm
    iden_nlsystem = nlsp.HammersteinGroupModel_up(
        max_harmonics=range(1, branches + 1),
        nonlinear_functions=nlsp.nl_branches(
            nlsp.function_factory.power_series, branches),
        filter_irs=[
            impulse,
        ] * branches)

    # only sine based system identification
    found_filter_spec_sine, nl_function_sine = nlsp.nonlinearconvolution_powerseries_temporalreversal(
        sine_g, output_sine, branches)
    iden_nlsystem.SetInput(signal=input_noise)
    iden_nlsystem.SetNLFunctions(nl_function_sine)
    iden_nlsystem.SetFilterIRS(found_filter_spec_sine)
    plot.relabelandplotphase(sumpf.modules.FourierTransform(
        iden_nlsystem.GetOutput()).GetSpectrum(),
                             "Identified power noise",
                             show=False)
    print "SNR between Reference and Identified output Sine: %r" % nlsp.snr(
        output_noise, iden_nlsystem.GetOutput())

    # only cosine based system identification
    found_filter_spec_cos, nl_function_cos = nlsp.nonlinearconvolution_chebyshev_temporalreversal(
        cos_g, output_cos, branches)
    iden_nlsystem.SetInput(signal=input_noise)
    iden_nlsystem.SetNLFunctions(nl_function_cos)
    iden_nlsystem.SetFilterIRS(found_filter_spec_cos)
    plot.relabelandplotphase(sumpf.modules.FourierTransform(
        iden_nlsystem.GetOutput()).GetSpectrum(),
                             "Identified cheby noise",
                             show=False)
    print "SNR between Reference and Identified output Cos: %r" % nlsp.snr(
        output_noise, iden_nlsystem.GetOutput())

    # only noise based system identification
    found_filter_spec_adapt, nl_function_adapt = nlsp.adaptive_identification(
        input_generator=input_noise,
        outputs=output_noise,
        iterations=1,
        branches=branches,
        step_size=0.1,
        filtertaps=filter_taps,
        algorithm=nlsp.multichannel_nlms,
        Plot=False)
    iden_nlsystem.SetInput(signal=input_noise)
    iden_nlsystem.SetNLFunctions(nl_function_adapt)
    iden_nlsystem.SetFilterIRS(found_filter_spec_adapt)
    plot.relabelandplotphase(sumpf.modules.FourierTransform(
        iden_nlsystem.GetOutput()).GetSpectrum(),
                             "Identified Adapt noise",
                             show=False)
    print "SNR between Reference and Identified output Adapt: %r" % nlsp.snr(
        output_noise, iden_nlsystem.GetOutput())

    # sine based as init coeff for noise based system identification
    found_filter_spec_sine_reducedlength = nlsp.change_length_filterkernels(
        found_filter_spec_sine, length=filter_taps)
    found_filter_spec_sineadapt, nl_function_sineadapt = nlsp.adaptive_identification(
        input_generator=input_noise,
        outputs=output_noise,
        iterations=1,
        branches=branches,
        step_size=0.1,
        filtertaps=filter_taps,
        algorithm=nlsp.multichannel_nlms,
        Plot=False,
        init_coeffs=found_filter_spec_sine_reducedlength)
    iden_nlsystem.SetInput(signal=input_noise)
    iden_nlsystem.SetNLFunctions(nl_function_sineadapt)
    iden_nlsystem.SetFilterIRS(found_filter_spec_sineadapt)
    plot.relabelandplotphase(sumpf.modules.FourierTransform(
        iden_nlsystem.GetOutput()).GetSpectrum(),
                             "Identified power Adapt noise",
                             show=False)
    print "SNR between Reference and Identified output Sine Adapt: %r" % nlsp.snr(
        output_noise, iden_nlsystem.GetOutput())

    # cos based as init coeff for noise based system identification
    found_filter_spec_cos_reducedlength = nlsp.change_length_filterkernels(
        found_filter_spec_cos, length=filter_taps)
    found_filter_spec_cosadapt, nl_function_cosadapt = nlsp.adaptive_identification(
        input_generator=input_noise,
        outputs=output_noise,
        iterations=1,
        branches=branches,
        step_size=0.1,
        filtertaps=filter_taps,
        algorithm=nlsp.multichannel_nlms,
        Plot=False,
        init_coeffs=found_filter_spec_cos_reducedlength,
        nonlinear_func=nlsp.function_factory.chebyshev1_polynomial)
    iden_nlsystem.SetInput(signal=input_noise)
    iden_nlsystem.SetNLFunctions(nl_function_cosadapt)
    iden_nlsystem.SetFilterIRS(found_filter_spec_cosadapt)
    plot.relabelandplotphase(sumpf.modules.FourierTransform(
        iden_nlsystem.GetOutput()).GetSpectrum(),
                             "Identified chebyshev Adapt noise",
                             show=False)
    print "SNR between Reference and Identified output Cos Adapt: %r" % nlsp.snr(
        output_noise, iden_nlsystem.GetOutput())

    plot.relabelandplotphase(
        sumpf.modules.FourierTransform(output_noise).GetSpectrum(),
        "Reference Noise",
        show=True)
예제 #7
0
def loudspeaker_model_adaptive():
    """
    Realworld nonlinear system(Loudspeaker) Model using adaptive system identification
    """
    branches = 5
    filter_taps = 2**11

    # real world reference system, load input and output noise
    load_noise = sumpf.modules.SignalFile(
        filename=
        "C:/Users/diplomand.8/Desktop/nl_recordings/rec_4_db/Noise18.npz",
        format=sumpf.modules.SignalFile.WAV_FLOAT)
    output_noise = sumpf.modules.SplitSignal(data=load_noise.GetSignal(),
                                             channels=[1]).GetOutput()
    input_noise = sumpf.modules.SplitSignal(data=load_noise.GetSignal(),
                                            channels=[0]).GetOutput()
    impulse = sumpf.modules.ImpulseGenerator(
        length=filter_taps,
        samplingrate=input_noise.GetSamplingRate()).GetSignal()

    # initialize hgm
    iden_nlsystem = nlsp.HammersteinGroupModel_up(
        max_harmonics=range(1, branches + 1),
        nonlinear_functions=nlsp.nl_branches(
            nlsp.function_factory.power_series, branches),
        filter_irs=[
            impulse,
        ] * branches)

    # only noise based adaptive system identification
    found_filter_spec_adapt, nl_function_adapt = nlsp.adaptive_identification(
        input_generator=input_noise,
        outputs=output_noise,
        iterations=1,
        branches=branches,
        step_size=0.1,
        filtertaps=filter_taps,
        algorithm=nlsp.multichannel_nlms,
        Plot=False)
    iden_nlsystem.SetInput(input_noise)
    iden_nlsystem.SetNLFunctions(nl_function_adapt)
    iden_nlsystem.SetFilterIRS(found_filter_spec_adapt)
    plot.relabelandplotphase(sumpf.modules.FourierTransform(
        iden_nlsystem.GetOutput()).GetSpectrum(),
                             "Identified Adapt sine",
                             show=False)
    print "SNR between Reference and Identified output Noise signal: %r" % nlsp.snr(
        output_noise, iden_nlsystem.GetOutput())
    plot.relabelandplotphase(
        sumpf.modules.FourierTransform(output_noise).GetSpectrum(),
        "Reference Noise",
        show=True)

    load_sample = sumpf.modules.SignalFile(
        filename=
        "C:/Users/diplomand.8/Desktop/nl_recordings/rec_4_db/Speech1.npz",
        format=sumpf.modules.SignalFile.WAV_FLOAT)

    output_sample = sumpf.modules.SplitSignal(data=load_sample.GetSignal(),
                                              channels=[1]).GetOutput()
    input_sample = sumpf.modules.SplitSignal(data=load_sample.GetSignal(),
                                             channels=[0]).GetOutput()

    iden_nlsystem.SetInput(input_sample)

    # save the output to the directory
    iden = sumpf.modules.SignalFile(
        filename=
        "C:/Users/diplomand.8/Desktop/nl_recordings/rec_4_db/sim/identified",
        signal=iden_nlsystem.GetOutput(),
        format=sumpf.modules.SignalFile.WAV_FLOAT)
    ref = sumpf.modules.SignalFile(
        filename=
        "C:/Users/diplomand.8/Desktop/nl_recordings/rec_4_db/sim/reference",
        signal=output_sample,
        format=sumpf.modules.SignalFile.WAV_FLOAT)
    inp = sumpf.modules.SignalFile(
        filename=
        "C:/Users/diplomand.8/Desktop/nl_recordings/rec_4_db/sim/input",
        signal=input_sample,
        format=sumpf.modules.SignalFile.WAV_FLOAT)
    print "Distortion box, SNR between Reference and Identified output Sample,nl: %r" % nlsp.snr(
        output_sample, iden_nlsystem.GetOutput())
예제 #8
0
def doublehgm_same_evaluation(input_generator,
                              branches,
                              iden_method,
                              Plot,
                              reference=None):
    """
    Evaluation of System Identification method by double hgm virtual nl system with same nonlinear degree and filters
    nonlinear system - two virtual hammerstein group model with power series polynomials as nl function and bandpass
                        filters as linear functions
    plot - the original filter spectrum and the identified filter spectrum, the reference output and identified output
    expectation - utmost similarity between the two spectrums
    """
    input_signal = input_generator.GetOutput()
    filter_spec_tofind = nlsp.log_bpfilter(branches=branches,
                                           input=input_signal)
    ref_nlsystem = nlsp.HammersteinGroup_Series(
        input_signal=input_signal,
        nonlinear_functions=(nlsp.nl_branches(
            nlsp.function_factory.power_series, branches),
                             nlsp.nl_branches(
                                 nlsp.function_factory.power_series,
                                 branches)),
        filter_irs=(filter_spec_tofind, filter_spec_tofind),
        max_harmonics=(range(1, branches + 1), range(1, branches + 1)),
        hgm_type=(nlsp.HammersteinGroupModel_up,
                  nlsp.HammersteinGroupModel_up))

    found_filter_spec, nl_functions = iden_method(input_generator,
                                                  ref_nlsystem.GetOutput(2),
                                                  branches)
    iden_nlsystem = nlsp.HammersteinGroupModel_up(
        input_signal=input_signal,
        nonlinear_functions=nl_functions,
        filter_irs=found_filter_spec,
        max_harmonics=range(1, branches + 1))
    if reference is not None:
        reference = nlsp.change_length_signal(reference,
                                              length=len(input_signal))
        ref_nlsystem = nlsp.HammersteinGroup_Series(
            input_signal=reference,
            nonlinear_functions=(nlsp.nl_branches(
                nlsp.function_factory.power_series, branches),
                                 nlsp.nl_branches(
                                     nlsp.function_factory.power_series,
                                     branches)),
            filter_irs=(filter_spec_tofind, filter_spec_tofind),
            max_harmonics=(range(1, branches + 1), range(1, branches + 1)),
            hgm_type=(nlsp.HammersteinGroupModel_up,
                      nlsp.HammersteinGroupModel_up))
        iden_nlsystem.SetInput(reference)
    if Plot is True:
        plot.relabelandplotphase(sumpf.modules.FourierTransform(
            ref_nlsystem.GetOutput(2)).GetSpectrum(),
                                 "Reference System",
                                 show=False)
        plot.relabelandplotphase(sumpf.modules.FourierTransform(
            iden_nlsystem.GetOutput()).GetSpectrum(),
                                 "Identified System",
                                 show=True)
    print "SNR between Reference and Identified output for double hgm all same: %r" % nlsp.snr(
        ref_nlsystem.GetOutput(2), iden_nlsystem.GetOutput())
예제 #9
0
def doublehgm_different_evaluation(input_generator,
                                   branches,
                                   Plot,
                                   reference=None):
    input_signal = input_generator.GetOutput()
    filter_spec_tofind1 = nlsp.log_bpfilter(branches=branches,
                                            input=input_signal)
    filter_spec_tofind2 = nlsp.log_chebyfilter(branches=branches,
                                               input=input_signal)

    sweep = nlsp.NovakSweepGenerator_Sine(
        sampling_rate=input_signal.GetSamplingRate(), length=len(input_signal))
    ref_nlsystem = nlsp.HammersteinGroup_Series(
        input_signal=sweep.GetOutput(),
        nonlinear_functions=(nlsp.nl_branches(
            nlsp.function_factory.power_series, branches),
                             nlsp.nl_branches(
                                 nlsp.function_factory.chebyshev1_polynomial,
                                 branches)),
        filter_irs=(filter_spec_tofind1, filter_spec_tofind2),
        max_harmonics=(range(1, branches + 1), range(1, branches + 1)),
        hgm_type=(nlsp.HammersteinGroupModel_up,
                  nlsp.HammersteinGroupModel_up))
    init_coeffs, non = nlsp.nonlinearconvolution_powerseries_temporalreversal(
        sweep, ref_nlsystem.GetOutput(2), branches=branches)
    init_coeffs = nlsp.change_length_filterkernels(init_coeffs, filter_length)
    ref_nlsystem = nlsp.HammersteinGroup_Series(
        input_signal=input_signal,
        nonlinear_functions=(nlsp.nl_branches(
            nlsp.function_factory.power_series, branches),
                             nlsp.nl_branches(
                                 nlsp.function_factory.chebyshev1_polynomial,
                                 branches)),
        filter_irs=(filter_spec_tofind1, filter_spec_tofind2),
        max_harmonics=(range(1, branches + 1), range(1, branches + 1)),
        hgm_type=(nlsp.HammersteinGroupModel_up,
                  nlsp.HammersteinGroupModel_up))
    found_filter_spec, nl_functions = nlsp.adaptive_identification_legendre(
        input_generator=input_generator,
        outputs=ref_nlsystem.GetOutput(2),
        branches=branches,
        init_coeffs=init_coeffs)

    iden_nlsystem = nlsp.HammersteinGroupModel_up(
        input_signal=input_signal,
        nonlinear_functions=nl_functions,
        filter_irs=found_filter_spec,
        max_harmonics=range(1, branches + 1))
    if reference is not None:
        reference = nlsp.change_length_signal(reference,
                                              length=len(input_signal))
        ref_nlsystem = nlsp.HammersteinGroup_Series(
            input_signal=reference,
            nonlinear_functions=(
                nlsp.nl_branches(nlsp.function_factory.power_series, branches),
                nlsp.nl_branches(nlsp.function_factory.chebyshev1_polynomial,
                                 branches)),
            filter_irs=(filter_spec_tofind1, filter_spec_tofind2),
            max_harmonics=(range(1, branches + 1), range(1, branches + 1)),
            hgm_type=(nlsp.HammersteinGroupModel_up,
                      nlsp.HammersteinGroupModel_up))
        iden_nlsystem.SetInput(reference)
    if Plot is True:
        plot.relabelandplotphase(sumpf.modules.FourierTransform(
            ref_nlsystem.GetOutput(2)).GetSpectrum(),
                                 "Reference System",
                                 show=False)
        plot.relabelandplotphase(sumpf.modules.FourierTransform(
            iden_nlsystem.GetOutput()).GetSpectrum(),
                                 "Identified System",
                                 show=True)
    print "SNR between Reference and Identified output for double hgm different: %r" % nlsp.snr(
        ref_nlsystem.GetOutput(2), iden_nlsystem.GetOutput())