コード例 #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
ファイル: localization.py プロジェクト: jrogala/SurMeca
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 make_stat(inFile):
    avg_undamaged, avg_damaged = [0 for k in range(CAPTVALUE)
                                  ], [0 for k in range(CAPTVALUE)]
    std_undamaged, std_damaged = [0 for k in range(CAPTVALUE)
                                  ], [0 for k in range(CAPTVALUE)]

    l_damaged, l_undamaged = [], []

    for k in range(NB_EXP):
        print("exp: " + str(k))
        l1 = experience(dam=0)
        l2 = experience(dam=DAMAGE)
        l_undamaged += [l1]
        l_damaged += [l2]

    av_undamaged, std_undamaged = av_std(l_undamaged)
    av_damaged, std_damaged = av_std(l_damaged)

    #print(av_undamaged)
    #print(av_damaged)
    #print(std_undamaged)
    #print(std_damaged)

    parser.writeValues3(inFile + "avu.txt", av_undamaged)
    parser.writeValues3(inFile + "stdu.txt", std_undamaged)
    parser.writeValues3(inFile + "avd.txt", av_damaged)
    parser.writeValues3(inFile + "stdd.txt", std_undamaged)

    return av_undamaged, std_undamaged, av_damaged, std_damaged
コード例 #4
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()
コード例 #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 = []
    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")
コード例 #6
0
ファイル: threshold_noise.py プロジェクト: jrogala/SurMeca
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")
コード例 #7
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()