Add files via upload
This commit is contained in:
24
3D_app/Bscan_Cscan_trait.py
Normal file
24
3D_app/Bscan_Cscan_trait.py
Normal file
@ -0,0 +1,24 @@
|
||||
from selection_filtre import *
|
||||
from filtrage import *
|
||||
def Bscant(data_input,sel1,sel2,sel3,fs_1, cut_off_1, order_1, window_size_1,fs_2, cut_off_2, order_2, window_size2):
|
||||
tab=[]
|
||||
size_data_input=np.shape(data_input)
|
||||
for i in range (0,size_data_input[1]-1):
|
||||
l=switch_case(data_input[:,i],sel1)
|
||||
l2=switch_case(l,sel2, fs_1, cut_off_1, order_1, window_size_1)
|
||||
l3=switch_case(l,sel3, fs_2, cut_off_2, order_2, window_size2)
|
||||
tab.append(l3)
|
||||
return tab
|
||||
|
||||
def Cscant(data_input,sel1,sel2,sel3,fs_1, cut_off_1, order_1, window_size_1,fs_2, cut_off_2, order_2, window_size2):
|
||||
tab1=[]
|
||||
tab=[]
|
||||
size_data_input=np.shape(data_input)
|
||||
for i in range(0,size_data_input[0]-1):
|
||||
for i in range (0,size_data_input[2]-1):
|
||||
l=switch_case(data_input[:,i],sel1)
|
||||
l2=switch_case(l,sel2, fs_1, cut_off_1, order_1, window_size_1)
|
||||
l3=switch_case(l,sel3, fs_2, cut_off_2, order_2, window_size2)
|
||||
tab1.append(l3)
|
||||
tab.append(tab1)
|
||||
return tab
|
480
3D_app/ascan.py
Normal file
480
3D_app/ascan.py
Normal file
@ -0,0 +1,480 @@
|
||||
import dash
|
||||
from dash import html, callback, Input, Output, dcc
|
||||
import dash_bootstrap_components as dbc
|
||||
import plotly.graph_objects as go
|
||||
import numpy as np
|
||||
import plotly.express as px
|
||||
import plotly.io as pio
|
||||
from util import *
|
||||
from filtrage import *
|
||||
from selection_filtre import *
|
||||
from Bscan_Cscan_trait import *
|
||||
|
||||
|
||||
dash.register_page(
|
||||
__name__, path="/ascan", title="A-Scan filters", name="A-Scan filters"
|
||||
)
|
||||
|
||||
# on définit le dossier et les fichiers à lire
|
||||
dossier = "Dataset/Shear_Wave_Rot00_CSV_Data"
|
||||
fichiers_selectionnes = [
|
||||
"Shear_x001-x101_y{:03d}_Rot00.csv".format(i) for i in range(10, 13)
|
||||
]
|
||||
|
||||
# on lit les fichiers et on les met dans un tableau
|
||||
pre_volume = np.array(lire_fichier_csv(dossier, fichiers_selectionnes))
|
||||
volume = pre_volume[:, :, :]
|
||||
data_traits = volume
|
||||
dim_x, dim_y, dim_z = volume.shape
|
||||
|
||||
X, Y, Z = np.mgrid[0:dim_x, 0:dim_y, 0:dim_z]
|
||||
# on définit le thème de l'application
|
||||
pio.templates.default = "plotly_dark"
|
||||
|
||||
configAScan = {
|
||||
"toImageButtonOptions": {
|
||||
"format": "svg", # one of png, svg, jpeg, webp
|
||||
"filename": "A-Scan",
|
||||
"height": 1000,
|
||||
"width": 1400,
|
||||
"scale": 1, # Multiply title/legend/axis/canvas sizes by this factor
|
||||
},
|
||||
"displaylogo": False,
|
||||
}
|
||||
layout = html.Div(
|
||||
[
|
||||
dbc.Row(
|
||||
[
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Select(
|
||||
id="select-ascan-filter1",
|
||||
options=[
|
||||
{"label": "transformer du Hilbert", "value": "1"},
|
||||
],
|
||||
value=1,
|
||||
style={"margin-bottom": "15px"},
|
||||
),
|
||||
],
|
||||
width=3,
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Select(
|
||||
id="select-ascan-filter2",
|
||||
options=[
|
||||
{"label": "sans filtre ", "value": "2"},
|
||||
{"label": "filtre passe bas ", "value": "3"},
|
||||
{"label": "filtre de moyenne mobile", "value": "4"},
|
||||
{"label": "filtre adaptatif (wiener)", "value": "5"},
|
||||
{
|
||||
"label": "filtre à réponse impulsionnelle infinie",
|
||||
"value": "6",
|
||||
},
|
||||
{
|
||||
"label": "filtre à réponse impulsionnelle finie",
|
||||
"value": "7",
|
||||
},
|
||||
],
|
||||
value=2,
|
||||
style={"margin-bottom": "15px"},
|
||||
),
|
||||
],
|
||||
width=3,
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Select(
|
||||
id="select-ascan-filter3",
|
||||
options=[
|
||||
{"label": "sans filtre ", "value": "2"},
|
||||
{"label": "filtre passe bas ", "value": "3"},
|
||||
{"label": "filtre de moyenne mobile", "value": "4"},
|
||||
{"label": "filtre adaptatif (wiener)", "value": "5"},
|
||||
{
|
||||
"label": "filtre à réponse impulsionnelle infinie",
|
||||
"value": "6",
|
||||
},
|
||||
{
|
||||
"label": "filtre à réponse impulsionnelle finie",
|
||||
"value": "7",
|
||||
},
|
||||
],
|
||||
value=2,
|
||||
style={"margin-bottom": "15px"},
|
||||
),
|
||||
],
|
||||
width=3,
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Label(
|
||||
"applique les filtres selections sur tous les data",
|
||||
style={"marginRight": "5px"},
|
||||
),
|
||||
dbc.Button(
|
||||
id="button-validate-filter",
|
||||
children=dbc.Spinner(
|
||||
html.Div("Valider", id="loading"), show_initially=False
|
||||
),
|
||||
color="primary",
|
||||
style={"marginBottom": "15px"},
|
||||
),
|
||||
],
|
||||
width=3,
|
||||
),
|
||||
]
|
||||
),
|
||||
dbc.Row(
|
||||
[
|
||||
dbc.Col(
|
||||
[html.Br(), html.B(" paramètre du 1er filtre ")],
|
||||
width=2,
|
||||
style={"textAlign": "center"},
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Label("Fs ", html_for="Fs "),
|
||||
dbc.Input(
|
||||
id="input-ascan-solo-fs",
|
||||
type="number",
|
||||
placeholder="Fs",
|
||||
value=1,
|
||||
step=0.1,
|
||||
),
|
||||
],
|
||||
width=1,
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Label("cut off ", html_for="cut off"),
|
||||
dbc.Input(
|
||||
id="input-ascan-solo-cutoff",
|
||||
type="number",
|
||||
placeholder="cut_off",
|
||||
value=1,
|
||||
step=0.1,
|
||||
),
|
||||
],
|
||||
width=1,
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Label("order ", html_for="order"),
|
||||
dbc.Input(
|
||||
id="input-ascan-solo-order",
|
||||
type="number",
|
||||
placeholder="order",
|
||||
value=1,
|
||||
step=1,
|
||||
),
|
||||
],
|
||||
width=1,
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Label("window size ", html_for="window size"),
|
||||
dbc.Input(
|
||||
id="input-ascan-solo-windowsize",
|
||||
type="number",
|
||||
placeholder="window_size",
|
||||
value=1,
|
||||
step=1,
|
||||
),
|
||||
],
|
||||
width=1,
|
||||
),
|
||||
dbc.Col(
|
||||
[html.Br(), html.B(" paramètre du 2e filtre ")],
|
||||
width=2,
|
||||
style={"textAlign": "center"},
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Label("Fs ", html_for="Fs "),
|
||||
dbc.Input(
|
||||
id="input-ascan-solo-fs-2",
|
||||
type="number",
|
||||
placeholder="Fs",
|
||||
value=1,
|
||||
step=0.1,
|
||||
),
|
||||
],
|
||||
width=1,
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Label("cut off ", html_for="cut off"),
|
||||
dbc.Input(
|
||||
id="input-ascan-solo-cutoff-2",
|
||||
type="number",
|
||||
placeholder="cut_off",
|
||||
value=1,
|
||||
step=0.1,
|
||||
),
|
||||
],
|
||||
width=1,
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Label("order ", html_for="order"),
|
||||
dbc.Input(
|
||||
id="input-ascan-solo-order-2",
|
||||
type="number",
|
||||
placeholder="order",
|
||||
value=1,
|
||||
step=1,
|
||||
),
|
||||
],
|
||||
width=1,
|
||||
),
|
||||
dbc.Col(
|
||||
[
|
||||
dbc.Label("window size ", html_for="window size"),
|
||||
dbc.Input(
|
||||
id="input-ascan-solo-windowsize-2",
|
||||
type="number",
|
||||
placeholder="window_size",
|
||||
value=1,
|
||||
step=1,
|
||||
),
|
||||
],
|
||||
width=1,
|
||||
),
|
||||
]
|
||||
),
|
||||
dbc.Row(
|
||||
[
|
||||
dbc.Col(
|
||||
dcc.Graph(
|
||||
id="heatmap-ascan-solo",
|
||||
config=configAScan,
|
||||
style={"marginBottom": "15px"},
|
||||
), # 'fig' is your 2D plotly figure
|
||||
width=12,
|
||||
),
|
||||
dbc.Col(
|
||||
dcc.Graph(
|
||||
id="heatmap-fft-solo",
|
||||
config=configAScan,
|
||||
style={"marginBottom": "15px"},
|
||||
), # 'fig' is your 2D plotly figure
|
||||
width=8,
|
||||
),
|
||||
dbc.Col(
|
||||
dcc.Graph(
|
||||
id="heatmap-bscan-solo",
|
||||
config=configAScan,
|
||||
style={"marginBottom": "15px"},
|
||||
), # 'fig' is your 2D plotly figure
|
||||
width=4,
|
||||
),
|
||||
]
|
||||
),
|
||||
dbc.Label("x"),
|
||||
dcc.Slider(
|
||||
id="layer-slider-ascan-solo-x",
|
||||
min=1,
|
||||
max=dim_z,
|
||||
value=1,
|
||||
step=1,
|
||||
marks={
|
||||
str(i): str(i) for i in range(1, dim_z + 1, max(1, int(dim_z / 20)))
|
||||
},
|
||||
),
|
||||
dbc.Label("y"),
|
||||
dcc.Slider(
|
||||
id="layer-slider-ascan-solo-y",
|
||||
min=1,
|
||||
max=dim_x,
|
||||
value=1,
|
||||
step=1,
|
||||
marks={
|
||||
str(i): str(i) for i in range(1, dim_x + 1, max(1, int(dim_x / 20)))
|
||||
},
|
||||
),
|
||||
dbc.Label("z"),
|
||||
dcc.RangeSlider(
|
||||
id="layer-slider-ascan-solo-z",
|
||||
min=1,
|
||||
max=dim_y,
|
||||
value=[dim_y / dim_y, dim_y],
|
||||
step=1,
|
||||
marks={
|
||||
str(i): str(i) for i in range(1, dim_y + 1, max(1, int(dim_y / 20)))
|
||||
},
|
||||
),
|
||||
],
|
||||
style={"padding": "20px"},
|
||||
)
|
||||
|
||||
|
||||
# callback to update filter values
|
||||
@callback(
|
||||
[
|
||||
Output("input-ascan-solo-fs", "disabled"),
|
||||
Output("input-ascan-solo-cutoff", "disabled"),
|
||||
Output("input-ascan-solo-order", "disabled"),
|
||||
Output("input-ascan-solo-windowsize", "disabled"),
|
||||
Output("input-ascan-solo-fs-2", "disabled"),
|
||||
Output("input-ascan-solo-cutoff-2", "disabled"),
|
||||
Output("input-ascan-solo-order-2", "disabled"),
|
||||
Output("input-ascan-solo-windowsize-2", "disabled"),
|
||||
],
|
||||
[
|
||||
Input("select-ascan-filter2", "value"),
|
||||
Input("select-ascan-filter3", "value"),
|
||||
],
|
||||
)
|
||||
def update_filter_values(select_filtre_1, select_filtre_2):
|
||||
fs_1 = True
|
||||
cutoff_1 = True
|
||||
ordre_1 = True
|
||||
windowsize_1 = True
|
||||
fs_2 = True
|
||||
cutoff_2 = True
|
||||
ordre_2 = True
|
||||
windowsize_2 = True
|
||||
if int(select_filtre_1) == 3:
|
||||
fs_1 = False
|
||||
cutoff_1 = False
|
||||
ordre_1 = False
|
||||
if int(select_filtre_2) == 3:
|
||||
fs_2 = False
|
||||
cutoff_2 = False
|
||||
ordre_2 = False
|
||||
if int(select_filtre_1) in (4, 5, 6, 7):
|
||||
windowsize_1 = False
|
||||
if int(select_filtre_2) in (4, 5, 6, 7):
|
||||
windowsize_2 = False
|
||||
return [
|
||||
fs_1,
|
||||
cutoff_1,
|
||||
ordre_1,
|
||||
windowsize_1,
|
||||
fs_2,
|
||||
cutoff_2,
|
||||
ordre_2,
|
||||
windowsize_2,
|
||||
]
|
||||
|
||||
|
||||
# callback to update the heatmap
|
||||
@callback(
|
||||
[
|
||||
Output("heatmap-ascan-solo", "figure"),
|
||||
Output("heatmap-bscan-solo", "figure"),
|
||||
Output("heatmap-fft-solo", "figure"),
|
||||
Output("loading", "children"),
|
||||
],
|
||||
[
|
||||
Input("select-ascan-filter1", "value"),
|
||||
Input("select-ascan-filter2", "value"),
|
||||
Input("select-ascan-filter3", "value"),
|
||||
Input("layer-slider-ascan-solo-x", "value"),
|
||||
Input("layer-slider-ascan-solo-y", "value"),
|
||||
Input("layer-slider-ascan-solo-z", "value"),
|
||||
Input("button-validate-filter", "n_clicks"),
|
||||
Input("input-ascan-solo-fs", "value"),
|
||||
Input("input-ascan-solo-cutoff", "value"),
|
||||
Input("input-ascan-solo-order", "value"),
|
||||
Input("input-ascan-solo-windowsize", "value"),
|
||||
Input("input-ascan-solo-fs-2", "value"),
|
||||
Input("input-ascan-solo-cutoff-2", "value"),
|
||||
Input("input-ascan-solo-order-2", "value"),
|
||||
Input("input-ascan-solo-windowsize-2", "value"),
|
||||
],
|
||||
)
|
||||
def update_heatmap_ascan(
|
||||
selec_transforme_hilbert,
|
||||
select_filtre_1,
|
||||
select_filtre_2,
|
||||
select_ascan_x,
|
||||
select_ascan_y,
|
||||
select_ascan_z,
|
||||
n_clicks,
|
||||
fs_filtre_1,
|
||||
cutoff_filtre_1,
|
||||
order_filtre_1,
|
||||
windowsize_filtre_1,
|
||||
fs_filtre_2,
|
||||
cutoff_filtre_2,
|
||||
order_filtre_2,
|
||||
windowsize_filtre_2,
|
||||
):
|
||||
# TODO: implement the filter
|
||||
print("debut du traitement")
|
||||
data_avec_traitement = volume[
|
||||
int(select_ascan_y) - 1,
|
||||
select_ascan_z[0] : select_ascan_z[1],
|
||||
int(select_ascan_x) - 1,
|
||||
]
|
||||
data_sans_traitement = volume[
|
||||
int(select_ascan_y) - 1,
|
||||
select_ascan_z[0] : select_ascan_z[1],
|
||||
int(select_ascan_x) - 1,
|
||||
]
|
||||
|
||||
data_avec_traitement = switch_case(
|
||||
data_avec_traitement, int(selec_transforme_hilbert)
|
||||
)
|
||||
data_sans_traitement = switch_case(
|
||||
data_sans_traitement, int(selec_transforme_hilbert)
|
||||
)
|
||||
|
||||
data_avec_traitement = switch_case(
|
||||
data_avec_traitement,
|
||||
int(select_filtre_1),
|
||||
float(fs_filtre_1),
|
||||
float(cutoff_filtre_1),
|
||||
int(order_filtre_1),
|
||||
int(windowsize_filtre_1),
|
||||
)
|
||||
data_avec_traitement = switch_case(
|
||||
data_avec_traitement,
|
||||
int(select_filtre_2),
|
||||
float(fs_filtre_2),
|
||||
float(cutoff_filtre_2),
|
||||
int(order_filtre_2),
|
||||
int(windowsize_filtre_2),
|
||||
)
|
||||
print("fin du traitement")
|
||||
bouton = "Valider"
|
||||
if n_clicks != None:
|
||||
data_traits= Cscant(volume,int(selec_transforme_hilbert),int(select_filtre_1),int(select_filtre_2),
|
||||
float(fs_filtre_1),float(cutoff_filtre_1),int(order_filtre_1),int(windowsize_filtre_1),float(fs_filtre_2),float(cutoff_filtre_2),int(order_filtre_2),int(windowsize_filtre_2))
|
||||
bouton = "Valider"
|
||||
fig = px.line(title="A-scan")
|
||||
new_trace = go.Scatter(y=data_avec_traitement, mode="lines", name=" Ascan trait ")
|
||||
fig.add_trace(new_trace)
|
||||
new_trace = go.Scatter(
|
||||
y=data_sans_traitement, mode="lines", name=" Ascan (hilbert) "
|
||||
)
|
||||
fig.add_trace(new_trace)
|
||||
fig.update_layout(xaxis_title="indix", yaxis_title="amplitude")
|
||||
|
||||
|
||||
data_bscan=Bscant(volume[select_ascan_y - 1, select_ascan_z[0] : select_ascan_z[1], :],int(selec_transforme_hilbert),int(select_filtre_1),int(select_filtre_2),float(fs_filtre_1),
|
||||
float(cutoff_filtre_1),int(order_filtre_1),int(windowsize_filtre_1),float(fs_filtre_2),float(cutoff_filtre_2),int(order_filtre_2),int(windowsize_filtre_2),)
|
||||
|
||||
fig2 = px.imshow(
|
||||
data_bscan,
|
||||
color_continuous_scale="Jet",
|
||||
aspect="auto",
|
||||
title="B-scan XZ",
|
||||
)
|
||||
fig2.update_layout(xaxis_title="Z", yaxis_title=" X")
|
||||
data_sans_traitement_fft = np.fft.fft(
|
||||
volume[
|
||||
int(select_ascan_y) - 1,
|
||||
select_ascan_z[0] : select_ascan_z[1],
|
||||
int(select_ascan_x) - 1,
|
||||
]
|
||||
)
|
||||
fig3 = px.line(title="FFT")
|
||||
trace3 = go.Scatter(y=np.abs(data_sans_traitement_fft), mode="lines", name=" FFT ")
|
||||
fig3.add_trace(trace3)
|
||||
fig3.update_layout(
|
||||
xaxis_title="FFT indix", yaxis_title="FFT of signal (Mangnitude)"
|
||||
)
|
||||
return [fig, fig2, fig3, bouton]
|
Reference in New Issue
Block a user