Пример #1
0
def experience():
	_, _, acc = simulation(0, [ [0 for k in range(2*n) ] ])
	

	frf_ref, acc = frf_multiple_sensors(1, acc)
	error_ref = itp.global_error(frf_ref)
	error_list = []
	
	for k in range(MAKEREF):
		print(k)
		frf_undamaged, acc = frf_multiple_sensors(1, acc)
		error_undamaged = itp.global_error(frf_undamaged)
		error_list += [minus_list(error_undamaged, error_ref)]

	threshold = [ 0 for k in range(CAPTVALUE)]
	
	for k in range(1,CAPTVALUE-1):
		e_list = tool.get_lines(error_list,k)
		threshold[k] = max(e_list)
		if (0):
			plt.hist(e_list, bins = 10)
			plt.title("Error repartition for sensor: " + str(k))
			plt.legend()
			plt.show()
	
	parser.writeValues3("data/threshold1_noise.txt",threshold)
	print("Threshold writed in data/threshold1_noise.txt")
Пример #2
0
def experience():
	_, _, acc = simulation(0, [ [0 for k in range(2*n) ] ])
	

	frf_ref, acc = frf_multiple_sensors(1, acc)
	error_ref = itp.global_error(frf_ref)
	error_list = []
	if(1):
		for k in range(MAKEREF):
			print(k)
			frf_undamaged, acc = frf_multiple_sensors(1, acc)
			error_undamaged = itp.global_error(frf_undamaged)
			error_list += [minus_list(error_undamaged, error_ref)]

		av, std = av_std(error_list)
	
		threshold = [ av[k] + 2*std[k] for k in range(CAPTVALUE) ]
	
		parser.writeValues3("data/threshold.txt",threshold)
	else:
		threshold = parser.get3("data/threshold.txt")
	
	frf_damaged, acc = frf_multiple_sensors(2, acc)
	error_damaged = itp.global_error(frf_damaged)
	diff = minus_list(error_damaged, error_ref)
	
	for k in range(CAPTVALUE):
		if( diff[k] > threshold[k] ):
			print("Damage detected on sensor: " + str(k))
	
	plt.plot(threshold, label = 'Threshold')
	plt.plot(diff, label = 'Damage')
	plt.legend()
	plt.show()
Пример #3
0
def experience():
    _, _, acc = simulation(0, [[0 for k in range(2 * n)]])

    frf_ref, acc = frf_multiple_sensors(1, acc)
    error_ref = itp.global_error(frf_ref)

    detect_damage1 = [0 for k in range(CAPTVALUE)]
    detect_damage2 = [0 for k in range(CAPTVALUE)]
    detect_damage1_inv = [0 for k in range(CAPTVALUE)]
    detect_damage2_inv = [0 for k in range(CAPTVALUE)]

    threshold1 = parser.get3("data/threshold1.txt")
    threshold2 = parser.get3("data/threshold2.txt")

    threshold1_inv = parser.get3("data/threshold1_inv.txt")
    threshold2_inv = parser.get3("data/threshold2_inv.txt")

    for k in range(MAKEREF):
        print(k)
        frf_damaged, acc = frf_multiple_sensors(2, acc)
        error_damaged = itp.global_error(frf_damaged)
        error_damaged_inv = itp.global_error(minus_list(frf_ref, frf_damaged))
        diff = minus_list(error_damaged, error_ref)
        for x in range(CAPTVALUE):
            if diff[x] > threshold1[x]:
                detect_damage1[x] = detect_damage1[x] + 1
            if diff[x] > threshold2[x]:
                detect_damage2[x] = detect_damage2[x] + 1
            if error_damaged_inv[x] > threshold1_inv[x]:
                detect_damage1_inv[x] = detect_damage1_inv[x] + 1
            if error_damaged_inv[x] > threshold2_inv[x]:
                detect_damage2_inv[x] = detect_damage2_inv[x] + 1

    parser.writeValues3("data/detect_damage_1_" + str(DAMAGE) + "percent.txt",
                        detect_damage1)
    parser.writeValues3("data/detect_damage_2_" + str(DAMAGE) + "percent.txt",
                        detect_damage2)

    parser.writeValues3(
        "data/detect_damage_1_inv_" + str(DAMAGE) + "percent.txt",
        detect_damage1_inv)
    parser.writeValues3(
        "data/detect_damage_2_inv_" + str(DAMAGE) + "percent.txt",
        detect_damage2_inv)

    print("Detect_damage writed in data/detect_damage_i_" + str(DAMAGE) +
          "percent.txt")

    plt.plot(detect_damage1, label='Simple Threshold')
    plt.plot(detect_damage2, label='With Gaussiennes')

    plt.plot(detect_damage1_inv, label='Simple Threshold Inv')
    plt.plot(detect_damage2_inv, label='With Gaussiennes Inv')

    plt.title("Damage: " + str(DAMAGE) + "%")
    plt.legend()
    plt.show()
Пример #4
0
def experience(dam=0):
    freqs = frf_multiple_sensors("data/FRF_ref" + indic + ".txt",
                                 "data/FRF_inf" + indic + ".txt",
                                 "data/FRF_sup" + indic + ".txt",
                                 "data/FRF_damaged" + indic + ".txt",
                                 d=dam)
    #print(freqs)
    ref = parser.get2("data/FRF_ref" + indic + ".txt")
    #inf = parser.get2("data/FRF_inf"+indic+".txt")
    #sup = parser.get2("data/FRF_sup"+indic+".txt")
    #frf_damaged = numpy.transpose(parser.get2("data/FRF_damaged"+indic+".txt"))
    frf_damaged = parser.get2("data/FRF_damaged" + indic + ".txt")

    M = matrix_M(mass)
    K = matrix_K(stiffness_undamaged)
    C = matrix_C(M, K, 0.005, 0.005)
    n = len(ref)
    if (0):
        for i in range(n):
            if (i % 10 == 0):
                #print(freqs[i])
                freq = freqs[i][0]
                #theo = frf_theo(freq, EXCITED_SENSOR, M, K, C)
                #plt.plot(np.absolute(theo), label = "Theorical")
                plt.plot(np.absolute(ref[i]), label="Undamaged")
                plt.plot(np.absolute(frf_damaged[i]), label="Damaged")
                plt.xlabel('Sensors')
                plt.ylabel('FRF')
                plt.title('freq: ' + str(freq))
                plt.legend()
                #plt.pause(delta)
                #plt.clf()
                plt.show()

    error_ref = itp.global_error(ref)
    error_damaged = itp.global_error(frf_damaged)
    diff = minus_list(error_damaged, error_ref)
    if (0):
        plt.plot(pos, diff)
        plt.plot(pos, z)
        plt.show()

    #pr.printRef(ref,inf,sup)
    #pr.printAll(ref,inf,sup, frf_damaged)
    #e = itp.if_out(inf,sup,frf_damaged)
    #pr.print_pos(e)
    #pr.print_minus(ref,frf_damaged)
    return diff
Пример #5
0
def experience():
    _, _, acc = simulation(0, [[0 for k in range(2 * n)]])

    frf_ref, acc = frf_multiple_sensors(1, acc)
    error_ref = itp.global_error(frf_ref)
    error_list = []
    error_list2 = []

    for k in range(MAKEREF):
        print(k)
        frf_undamaged, acc = frf_multiple_sensors(1, acc)
        error_undamaged = itp.global_error(frf_undamaged)
        error_list += [minus_list(error_undamaged, error_ref)]
        error_undamaged2 = itp.global_error(minus_list(frf_ref, frf_undamaged))
        error_list2 += [error_undamaged2]

    threshold = [0 for k in range(CAPTVALUE)]
    threshold_inv = [0 for k in range(CAPTVALUE)]

    av, std = av_std(error_list)
    av_inv, std_inv = av_std(error_list2)

    #threshold2
    threshold_gauss = [av[k] + 2 * std[k] for k in range(CAPTVALUE)]
    threshold_gauss_inv = [
        av_inv[k] + 2 * std_inv[k] for k in range(CAPTVALUE)
    ]

    for k in range(1, CAPTVALUE - 1):
        e_list = tool.get_lines(error_list, k)
        e_list2 = tool.get_lines(error_list2, k)
        threshold[k] = max(e_list)
        threshold_inv[k] = max(e_list2)
        if (0):
            plt.hist(e_list, bins=10)
            plt.title("Error repartition for sensor: " + str(k))
            plt.legend()
            plt.show()

    parser.writeValues3("data/threshold1_noise" + str(NOISE) + ".txt",
                        threshold)
    parser.writeValues3("data/threshold2_noise" + str(NOISE) + ".txt",
                        threshold_gauss)
    parser.writeValues3("data/threshold1_inv_noise" + str(NOISE) + ".txt",
                        threshold_inv)
    parser.writeValues3("data/threshold2_inv_noise" + str(NOISE) + ".txt",
                        threshold_gauss_inv)
    print("Thresholds writed in data/threshold_noise.txt")
Пример #6
0
def experience():
    _, _, acc = simulation(0, [[0 for k in range(2 * n)]])

    frf_ref, acc = frf_multiple_sensors(1, acc)
    error_ref = itp.global_error(frf_ref)
    error_list = []
    for k in range(MAKEREF):
        print(k)
        frf_undamaged, acc = frf_multiple_sensors(1, acc)
        error_undamaged = itp.global_error(frf_undamaged)
        error_list += [minus_list(error_undamaged, error_ref)]

    av, std = av_std(error_list)

    threshold = [av[k] + 2 * std[k] for k in range(CAPTVALUE)]

    parser.writeValues3("data/threshold2.txt", threshold)
    print("Threshold writed in data/threshold2.txt")
Пример #7
0
def experience():
    #frf_list_ref = main.frf_multiple_capter_simu_ref()
    frf_list_ref = [
        parser.get2("FRF_ref" + str(i) + ".txt") for i in range(main.MAKEREF)
    ]

    #frf_undamaged = numpy.transpose(main.frf_multiple_capter_simu_undamaged("FRF_undamaged.txt"))
    frf_undamaged = numpy.transpose(parser.get2("FRF_undamaged.txt"))

    #frf_damaged = numpy.transpose(main.frf_multiple_capter_simu_damaged("FRF_damaged.txt"))
    frf_damaged = numpy.transpose(parser.get2("FRF_damaged.txt"))

    print(
        "*************************\n Average frf calcul \n *************************"
    )

    nb_frf = len(frf_list_ref)
    nb_sensor = len(frf_list_ref[0])
    nb_freq = len(frf_list_ref[0][0])

    print("Nombre de frf par capteur et par frequence:" + str(nb_frf))
    print("Nombre de capteur:" + str(nb_sensor))
    print("Nombre de frequences:" + str(nb_freq))

    f_sampl_undamaged = freq_sampl("f_sampl_undamaged.txt")
    f_sampl_damaged = freq_sampl("f_sampl_damaged.txt")
    print("Frequence d'echantillonage (undamaged): " + str(f_sampl_undamaged))
    print("Frequence d'echantillonage (damaged): " + str(f_sampl_damaged))

    ref, inf, sup = interpolation.create_ref(frf_list_ref)

    #printRef(ref,inf,sup)

    error_ref = interpolation.global_error(ref)
    error_undamaged = interpolation.global_error(frf_undamaged)
    error_damaged = interpolation.global_error(frf_damaged)

    undamaged = [0 for i in range(nb_sensor - 4)]
    damaged = [0 for i in range(nb_sensor - 4)]
    for i in range(2, nb_sensor - 2):
        undamaged[i - 2] = error_undamaged[i] - error_ref[i]
        damaged[i - 2] = error_damaged[i] - error_ref[i]
    """
	print("*************************\n Errors \n *************************")
	#print("Error ref: ")
	#print(error_ref)
	print("Undamaged state: ")
	print(undamaged)
	print("Damaged state: ")
	print(damaged)
	plt.plot(error_ref)
	plt.plot(error_undamaged)
	plt.plot(error_damaged)
	plt.show()
	"""
    """
	plt.plot(undamaged, label = "Undamaged")
	plt.plot(damaged, label = "Damaged")
	plt.xlabel("Global error")
	plt.legend()
	plt.show()
	
	erreur_brut = interpolation.diff_with_ref(frf_damaged, ref)
	plt.plot(erreur_brut)
	plt.xlabel("Erreur brute")
	plt.legend()
	plt.show()
	"""

    printAll(ref, inf, sup, frf_undamaged, frf_damaged)
Пример #8
0
def experience():
    s, _, acc = simulation(0, [[0 for k in range(2 * n)]], 0)
    std_noise = s[0]

    frf_ref, acc = frf_multiple_sensors(1, acc, std_noise)
    error_ref = itp.global_error(frf_ref)

    detect_damage1 = [0 for k in range(CAPTVALUE)]
    detect_damage2 = [0 for k in range(CAPTVALUE)]
    detect_damage1_inv = [0 for k in range(CAPTVALUE)]
    detect_damage2_inv = [0 for k in range(CAPTVALUE)]

    threshold1 = parser.get3("data/threshold1_noise" + str(NOISE) + ".txt")
    threshold2 = parser.get3("data/threshold2_noise" + str(NOISE) + ".txt")
    threshold1_inv = parser.get3("data/threshold1_inv_noise" + str(NOISE) +
                                 ".txt")
    threshold2_inv = parser.get3("data/threshold2_inv_noise" + str(NOISE) +
                                 ".txt")

    quantification1 = [0 for k in range(CAPTVALUE)]
    quantification2 = [0 for k in range(CAPTVALUE)]
    quantification1_inv = [0 for k in range(CAPTVALUE)]
    quantification2_inv = [0 for k in range(CAPTVALUE)]

    for k in range(MAKEREF):
        print(k)
        frf_damaged, acc = frf_multiple_sensors(2, acc, std_noise)
        error_damaged = itp.global_error(frf_damaged)
        error_damaged_inv = itp.global_error(minus_list(frf_ref, frf_damaged))
        diff = minus_list(error_damaged, error_ref)
        #threshold1
        ind_max1, ind_max2, max1, max2 = two_max_ind(
            minus_list(diff, threshold1))
        if max1 > 0:
            detect_damage1[ind_max1] = detect_damage1[ind_max1] + 1
            quantification1[ind_max1] = quantification1[ind_max1] + max1
        if max2 > 0:
            detect_damage1[ind_max2] = detect_damage1[ind_max2] + 1
            quantification1[ind_max2] = quantification1[ind_max2] + max2
        #threshold2
        ind_max1, ind_max2, max1, max2 = two_max_ind(
            minus_list(diff, threshold2))
        if max1 > 0:
            detect_damage2[ind_max1] = detect_damage2[ind_max1] + 1
            quantification2[ind_max1] = quantification2[ind_max1] + max1
        if max2 > 0:
            detect_damage2[ind_max2] = detect_damage2[ind_max2] + 1
            quantification2[ind_max2] = quantification2[ind_max2] + max2
        #threshold_inv1
        ind_max1, ind_max2, max1, max2 = two_max_ind(
            minus_list(error_damaged_inv, threshold1_inv))
        if max1 > 0:
            detect_damage1_inv[ind_max1] = detect_damage1_inv[ind_max1] + 1
            quantification1_inv[
                ind_max1] = quantification1_inv[ind_max1] + max1
        if max2 > 0:
            detect_damage1_inv[ind_max2] = detect_damage1_inv[ind_max2] + 1
            quantification1_inv[
                ind_max2] = quantification1_inv[ind_max2] + max2
        #threshold_inv2
        ind_max1, ind_max2, max1, max2 = two_max_ind(
            minus_list(error_damaged_inv, threshold2_inv))
        if max1 > 0:
            detect_damage2_inv[ind_max1] = detect_damage2_inv[ind_max1] + 1
            quantification2_inv[
                ind_max1] = quantification2_inv[ind_max1] + max1
        if max2 > 0:
            detect_damage2_inv[ind_max2] = detect_damage2_inv[ind_max2] + 1
            quantification2_inv[
                ind_max2] = quantification2_inv[ind_max2] + max2

    parser.writeValues3(
        "data/detect_damage_1_" + str(DAMAGE) + "percent_noise" + str(NOISE) +
        "_max.txt", detect_damage1)
    parser.writeValues3(
        "data/detect_damage_2_" + str(DAMAGE) + "percent_noise" + str(NOISE) +
        "_max.txt", detect_damage2)
    parser.writeValues3(
        "data/detect_damage_1_inv_" + str(DAMAGE) + "percent_noise" +
        str(NOISE) + "_max.txt", detect_damage1_inv)
    parser.writeValues3(
        "data/detect_damage_2_inv_" + str(DAMAGE) + "percent_noise" +
        str(NOISE) + "_max.txt", detect_damage2_inv)
    print("Detect_damage writed in data/detect_damage_i_" + str(DAMAGE) +
          "percent_noise" + str(NOISE) + "_max.txt")

    for k in range(1, CAPTVALUE - 1):
        if detect_damage1[k] > 0:
            quantification1[k] = (quantification1[k] /
                                  detect_damage1[k]) / threshold1[k]
        if detect_damage2[k] > 0:
            quantification2[k] = (quantification2[k] /
                                  detect_damage2[k]) / threshold2[k]
        if detect_damage1_inv[k] > 0:
            quantification1_inv[k] = (
                quantification1_inv[k] /
                detect_damage1_inv[k]) / threshold1_inv[k]
        if detect_damage2_inv[k] > 0:
            quantification2_inv[k] = (
                quantification2_inv[k] /
                detect_damage2_inv[k]) / threshold2_inv[k]

    parser.writeValues3(
        "data/quantification1_" + str(DAMAGE) + "damage_" + str(NOISE) +
        "noise.txt", quantification1)
    parser.writeValues3(
        "data/quantification2_" + str(DAMAGE) + "damage_" + str(NOISE) +
        "noise.txt", quantification2)
    parser.writeValues3(
        "data/quantification1_inv_" + str(DAMAGE) + "damage_" + str(NOISE) +
        "noise.txt", quantification1_inv)
    parser.writeValues3(
        "data/quantification2_inv_" + str(DAMAGE) + "damage_" + str(NOISE) +
        "noise.txt", quantification2_inv)

    print("Quantification writed in data/quantification_i_" + str(DAMAGE) +
          "damage_" + str(NOISE) + "noise.txt")

    for k in range(CAPTVALUE):
        if detect_damage1[k] > 0:
            print("Threshold 1: damage detected on sensor " + str(k) +
                  "with quantification : " + str(quantification1[k]))

    for k in range(CAPTVALUE):
        if detect_damage2[k] > 0:
            print("Threshold 2: damage detected on sensor " + str(k) +
                  "with quantification : " + str(quantification2[k]))

    for k in range(CAPTVALUE):
        if detect_damage1_inv[k] > 0:
            print("Threshold 1 inv: damage detected on sensor " + str(k) +
                  "with quantification : " + str(quantification1_inv[k]))

    for k in range(CAPTVALUE):
        if detect_damage2_inv[k] > 0:
            print("Threshold 2 inv: damage detected on sensor " + str(k) +
                  "with quantification : " + str(quantification2_inv[k]))

    plt.plot(detect_damage1, label='Simple Threshold')
    plt.plot(detect_damage2, label='With Gaussiennes')
    plt.plot(detect_damage1_inv, label='Simple Threshold Inv')
    plt.plot(detect_damage2_inv, label='With Gaussiennes Inv')
    plt.title("Damage: " + str(DAMAGE) + "%")
    plt.legend()
    plt.show()