Add files via upload

This commit is contained in:
yalmansour1998
2024-05-31 10:45:58 +02:00
committed by GitHub
parent 6a7113016a
commit 29c0474bd8

View File

@ -10,20 +10,18 @@ from filtrage import *
from selection_filtre import *
dash.register_page(
__name__, path="/ascan", title="A-Scan filters", name="A-Scan filters"
)
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)
"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
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]
@ -66,14 +64,8 @@ layout = html.Div(
{"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",
},
{"label": "filtre à réponse impulsionnelle infinie", "value": "6"},
{"label": "filtre à réponse impulsionnelle finie", "value": "7"},
],
value=2,
style={"margin-bottom": "15px"},
@ -90,18 +82,13 @@ layout = html.Div(
{"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",
},
{"label": "filtre à réponse impulsionnelle infinie", "value": "6"},
{"label": "filtre à réponse impulsionnelle finie", "value": "7"},
],
value=2,
style={"margin-bottom": "15px"},
),
],
width=3,
),
@ -110,17 +97,138 @@ layout = html.Div(
dbc.Label("applique les filtres selections sur tous les data"),
dbc.Button(
id="button-validate-filter",
children=dbc.Spinner(
html.Div(id="loading"), show_initially=False
),
children=dbc.Spinner(html.Div(id="loading"), show_initially=False),
color="primary",
style={"marginBottom": "15px"},
),
],
width=3,
),
]
),
dbc.Row(
[
dbc.Label(" paramètre du 1er filtre ", html_for="Fs "),
dbc.Col(
[
dbc.Label("Fs ", html_for="Fs "),
dbc.Input(
id="input-ascan-solo-fs",
type="number",
placeholder="Fs",
value=1,
step=0.1,
style={"marginTop": "15px"},
),
],
width=3,
),
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,
style={"marginTop": "15px"},
),
],
width=3,
),
dbc.Col(
[
dbc.Label("order ", html_for="order"),
dbc.Input(
id="input-ascan-solo-order",
type="number",
placeholder="order",
value=1,
step=1,
style={"marginTop": "15px"},
),
],
width=3,
),
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,
style={"marginTop": "15px"},
),
],
width=3,
),]),
dbc.Row(
[
dbc.Label("paramètre de 2eme filtre ", html_for="Fs "),
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,
style={"marginTop": "15px"},
),
],
width=3,
),
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,
style={"marginTop": "15px"},
),
],
width=3,
),
dbc.Col(
[
dbc.Label("order ", html_for="order"),
dbc.Input(
id="input-ascan-solo-order-2",
type="number",
placeholder="order",
value=1,
step=1,
style={"marginTop": "15px"},
),
],
width=3,
),
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,
style={"marginTop": "15px"},
),
],
width=3,
),
]),
dbc.Row(
[
dbc.Col(
@ -129,6 +237,14 @@ layout = html.Div(
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(
@ -149,7 +265,7 @@ layout = html.Div(
value=1,
step=1,
marks={
str(i): str(i) for i in range(1, dim_z + 1, max(1, int(dim_z / 20)))
str(i): str(i) for i in range(1, dim_z+1,max(1, int(dim_z / 20)))
},
),
dbc.Label("y"),
@ -159,146 +275,26 @@ layout = html.Div(
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)))},
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],
value=[dim_y/dim_y,dim_y],
step=1,
marks={
str(i): str(i) for i in range(0, dim_y + 1, max(1, int(dim_y / 20)))
},
),
dbc.Row(
[
dbc.Label(" paramètre du 1er filtre ", html_for="Fs "),
dbc.Col(
[
dbc.Label("Fs ", html_for="Fs "),
dbc.Input(
id="input-ascan-solo-fs",
type="number",
placeholder="Fs",
value=1,
step=0.1,
style={"marginTop": "15px"},
),
],
width=3,
),
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,
style={"marginTop": "15px"},
),
],
width=3,
),
dbc.Col(
[
dbc.Label("order ", html_for="order"),
dbc.Input(
id="input-ascan-solo-order",
type="number",
placeholder="order",
value=1,
step=1,
style={"marginTop": "15px"},
),
],
width=3,
),
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,
style={"marginTop": "15px"},
),
],
width=3,
),
]
),
dbc.Row(
[
dbc.Label("paramètre de 2eme filtre ", html_for="Fs "),
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,
style={"marginTop": "15px"},
),
],
width=3,
),
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,
style={"marginTop": "15px"},
),
],
width=3,
),
dbc.Col(
[
dbc.Label("order ", html_for="order"),
dbc.Input(
id="input-ascan-solo-order-2",
type="number",
placeholder="order",
value=1,
step=1,
style={"marginTop": "15px"},
),
],
width=3,
),
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,
style={"marginTop": "15px"},
),
],
width=3,
),
]
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(
[
@ -317,45 +313,24 @@ layout = html.Div(
],
)
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,
]
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("loading", "children"),
],
[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"),
@ -374,110 +349,38 @@ def update_filter_values(select_filtre_1, select_filtre_2):
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,
):
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), # type: ignore
float(cutoff_filtre_1), # type: ignore
int(order_filtre_1),
int(windowsize_filtre_1),
)
data_avec_traitement = switch_case(
data_avec_traitement,
int(select_filtre_2),
float(fs_filtre_2), # type: ignore
float(cutoff_filtre_2), # type: ignore
int(order_filtre_2),
int(windowsize_filtre_2),
)
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")
if n_clicks != None:
data_traits = switch_case(volume, int(selec_transforme_hilbert))
data_traits = switch_case(
data_traits,
int(select_filtre_1),
float(fs_filtre_1), # type: ignore
float(cutoff_filtre_1), # type: ignore
int(order_filtre_1),
int(windowsize_filtre_1),
)
data_traits = switch_case(
data_traits,
int(select_filtre_2),
float(fs_filtre_2), # type: ignore
float(cutoff_filtre_2), # type: ignore
int(order_filtre_2),
int(windowsize_filtre_2),
)
fig = px.line(title="A-scan")
new_trace = go.Scatter(y=data_avec_traitement, mode="lines", name=" Ascan trait ")
if(n_clicks!=None):
data_traits=switch_case(data_traits,int(selec_transforme_hilbert))
data_traits=switch_case(data_traits,int(select_filtre_1),float(fs_filtre_1),float(cutoff_filtre_1),int(order_filtre_1),int(windowsize_filtre_1))
data_traits=switch_case(data_traits,int(select_filtre_2),float(fs_filtre_2),float(cutoff_filtre_2),int(order_filtre_2),int(windowsize_filtre_2))
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) "
)
new_trace = go.Scatter(y=data_sans_traitement, mode='lines', name=' Ascan (hilbert) ')
fig.add_trace(new_trace)
data_bscan = switch_case(
volume[select_ascan_y - 1, select_ascan_z[0] : select_ascan_z[1], :],
int(selec_transforme_hilbert),
)
data_bscan = switch_case(
data_bscan,
int(select_filtre_1),
float(fs_filtre_1), # type: ignore
float(cutoff_filtre_1), # type: ignore
int(order_filtre_1),
int(windowsize_filtre_1),
)
data_bscan = switch_case(
data_bscan,
int(select_filtre_2),
float(fs_filtre_2), # type: ignore
float(cutoff_filtre_2), # type: ignore
int(order_filtre_2),
int(windowsize_filtre_2),
)
fig2 = px.imshow(
data_bscan,
color_continuous_scale="Jet",
aspect="auto",
title="B-scan ZX",
)
return [fig, fig2, "Valider"]
fig.update_layout(xaxis_title="indix",yaxis_title="amplitude")
data_bscan=switch_case(volume[select_ascan_y - 1, select_ascan_z[0]:select_ascan_z[1], :],int(selec_transforme_hilbert))
data_bscan=switch_case(data_bscan,int(select_filtre_1),float(fs_filtre_1),float(cutoff_filtre_1),int(order_filtre_1),int(windowsize_filtre_1))
data_bscan=switch_case(data_bscan,int(select_filtre_2),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 ZX",)
fig2.update_layout(xaxis_title="X",yaxis_title="Z ")
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,"Valider"]