Nantes Université

Skip to content
Extraits de code Groupes Projets
Vérifiée Valider bf16c724 rédigé par Mickael Bonnin's avatar Mickael Bonnin
Parcourir les fichiers

Modified the .gitignore and removed dummy files

parent b71138e8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!1Homogenization of the function description and compliance to PEP8
__pycache__
\ No newline at end of file
__pycache__
.ipynb_checkpoints
\ No newline at end of file
%% Cell type:markdown id:0f96ee4d-3f8a-4a95-b815-4da29fbf1e8e tags:
# Prediction Mode
%% Cell type:markdown id:0bd9e000-a2ee-4e96-a29f-c105ceec4c62 tags:
<div class="alert alert-block alert-info">
<b>This mode is used if the nature/label of the event is not known in advance. </b>
</div>
%% Cell type:markdown id:826842f6-e7ce-4d55-86f3-ce97b39b24b2 tags:
## Download data
%% Cell type:markdown id:c02a24e2-742c-4ac8-b11d-8964284db1c3 tags:
Input data should be in **mseed** format and correspond to raw **60 second 3-component seismograms**.
%% Cell type:markdown id:a245431a-78d6-4fa1-9550-b52412a04c87 tags:
Demo data is available in the "mseed" folder.
%% Cell type:markdown id:eb0b3464-7061-49a8-8eee-da130ad17bae tags:
To apply the algorithm, we need a folder architecture:
* mseed_demo
* 2022004T134407
* FR_CHLF_2022004T134407.mseed
* FR_GARF_2022004T134407.mseed
* FR_GNEF_2022004T134407.mseed
* FR_VERF_2022004T134407.mseed
%% Cell type:markdown id:631cae95-a1bc-46f8-8596-b11f0a6ee1b9 tags:
## Run prediction
%% Cell type:markdown id:263b8345-4e16-47a6-b60f-8cba04e9cb69 tags:
### From a terminal:
%% Cell type:markdown id:36d73373-310d-4557-ba3b-3cc62544c703 tags:
```
python run.py --mode pred --data_dir ./mseed_demo --spectro_dir ./spectro_demo --output_dir ./output_demo
```
%% Cell type:markdown id:f928f030-d567-4cd3-98bc-aba6d0c922ec tags:
### From a notebook:
%% Cell type:code id:93f08547-af04-429d-9dd4-220fd3669d30 tags:
``` python
import sys
sys.path.append('../')
from data_process import spectro_extract_pred
from prediction import pred
```
%% Cell type:code id:1228c624-48f4-401d-9d0f-e76397188218 tags:
``` python
data = spectro_extract_pred(data_dir="./../mseed_demo", spectro_dir="./../spectro_demo")
```
%% Output
Number of events : 9
*****************
EVENT 1 / 9
Number of stream : 14
*****************
EVENT 2 / 9
Number of stream : 10
*****************
EVENT 3 / 9
Number of stream : 8
Stream 5 / 8
%% Cell type:code id:26d663ad-ab6b-4c21-8c04-93f147e48256 tags:
``` python
pred(model_dir="./../model/model_2021354T1554.h5", spectro_dir='./../spectro_demo', output_dir="./../output_demo")
```
%% Output
2022-09-12 17:51:33.630086: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Number of events : 9
*****************
EVENT 1 / 9
Number of station : 15
*****************
EVENT 2 / 9
Number of station : 10
*****************
EVENT 3 / 9
Number of station : 16
*****************
EVENT 4 / 9
Number of station : 8
*****************
EVENT 5 / 9
Number of station : 11
*****************
EVENT 6 / 9
Number of station : 12
*****************
EVENT 7 / 9
Number of station : 7
*****************
EVENT 8 / 9
Number of station : 4
*****************
EVENT 9 / 9
Number of station : 10
Station 10 / 10
%% Cell type:markdown id:a059bc71-912e-4b2b-ab4a-0f7bf5c56b5c tags:
## Read csv file
%% Cell type:code id:29e9f0ed-331c-41be-bad4-b9539a132baa tags:
``` python
import pandas as pd
```
%% Cell type:code id:e9c9f987-e2c7-4273-ad37-67aa2dab0d7b tags:
``` python
pred_net_csv = pd.read_csv("../output_demo/prediction_network_level.csv")
pred_net_csv = pd.DataFrame(pred_net_csv)
pred_net_csv.head()
```
%% Output
event prob_nat prob_ant pred nature
0 2022004T111040 0.006 0.994 1 Anthropogenic
1 2022001T213524 0.961 0.039 0 Natural
2 2022003T080315 0.043 0.957 1 Anthropogenic
3 2022003T084110 0.019 0.981 1 Anthropogenic
4 2022004T134407 0.770 0.230 0 Natural
%% Cell type:code id:b2943f25-c309-488c-8e45-2ef919e6da57 tags:
``` python
pred_sta_csv = pd.read_csv("../output_demo/prediction_station_level.csv")
pred_sta_csv = pd.DataFrame(pred_sta_csv)
pred_sta_csv.head()
```
%% Output
file_name station prob_nat prob_ant pred nature
0 FR_DAUF_2022004T111040 DAUF 0.001 0.999 1 Anthropogenic
1 FR_LEUC_2022004T111040 LEUC 0.002 0.998 1 Anthropogenic
2 FR_CRNF_2022004T111040 CRNF 0.014 0.986 1 Anthropogenic
3 FR_AGO_2022004T111040 AGO 0.001 0.999 1 Anthropogenic
4 FR_ABJF_2022004T111040 ABJF 0.000 1.000 1 Anthropogenic
%% Cell type:code id:8ca9d8ef-2026-4839-abcf-c142c7876eaf tags:
``` python
```
%% Cell type:code id:006f1a8d-f5fc-4783-92ee-f375aea5c03d tags:
``` python
```
%% Cell type:markdown id:0f96ee4d-3f8a-4a95-b815-4da29fbf1e8e tags:
# Validation Mode
%% Cell type:markdown id:0bd9e000-a2ee-4e96-a29f-c105ceec4c62 tags:
<div class="alert alert-block alert-info">
<b>This mode is used if the nature/label of the event is known in advance. </b>
</div>
%% Cell type:markdown id:826842f6-e7ce-4d55-86f3-ce97b39b24b2 tags:
## Download data
%% Cell type:markdown id:c02a24e2-742c-4ac8-b11d-8964284db1c3 tags:
Input data should be in **mseed** format and correspond to raw **60 second 3-component seismograms**.
%% Cell type:markdown id:a245431a-78d6-4fa1-9550-b52412a04c87 tags:
Demo data is available in the "mseed" folder.
%% Cell type:markdown id:eb0b3464-7061-49a8-8eee-da130ad17bae tags:
To apply the algorithm, we need a folder architecture:
* mseed_demo
* 2022004T134407
* FR_CHLF_2022004T134407.mseed
* FR_GARF_2022004T134407.mseed
* FR_GNEF_2022004T134407.mseed
* FR_VERF_2022004T134407.mseed
%% Cell type:markdown id:b61cddaf-cf4d-4d46-afc6-85e99d5c7514 tags:
To apply this mode, a **csv file** import pandas as pd is also required with the associated label for each event.
%% Cell type:code id:9bcac75b-0166-4346-975b-66b226902bb5 tags:
``` python
import pandas as pd
```
%% Cell type:code id:ec2b7b4d-ccb3-4884-97a6-7e7de00010bb tags:
``` python
pred_net_csv = pd.read_csv("../demo_file.csv")
pred_net_csv = pd.DataFrame(pred_net_csv)
pred_net_csv.head()
```
%% Cell type:markdown id:631cae95-a1bc-46f8-8596-b11f0a6ee1b9 tags:
## Run validation
%% Cell type:markdown id:263b8345-4e16-47a6-b60f-8cba04e9cb69 tags:
### From a terminal:
%% Cell type:markdown id:36d73373-310d-4557-ba3b-3cc62544c703 tags:
```
python run.py --mode pred --data_dir ./mseed_demo --spectro_dir ./spectro_demo --output_dir ./output_demo --csv_file ./demo_file.csv
```
%% Cell type:markdown id:f928f030-d567-4cd3-98bc-aba6d0c922ec tags:
### From a notebook:
%% Cell type:code id:93f08547-af04-429d-9dd4-220fd3669d30 tags:
``` python
import sys
sys.path.append('../')
from data_process import spectro_extract_valid
from prediction import valid
import numpy as np
```
%% Cell type:code id:8ee5e6f3-68f5-4a5b-8d1b-246ef60c32a7 tags:
``` python
events = np.genfromtxt(f'./../demo_file.csv', delimiter=',', skip_header = 1, dtype=str)
```
%% Cell type:code id:1228c624-48f4-401d-9d0f-e76397188218 tags:
``` python
data = spectro_extract_valid(data_dir="./../mseed_demo", spectro_dir="./../spectro_demo", events_list=events)
```
%% Cell type:code id:26d663ad-ab6b-4c21-8c04-93f147e48256 tags:
``` python
valid(model_dir="./../model/model_2021354T1554.h5", spectro_dir='./../spectro_demo', output_dir="./../output_demo", event_label=events)
```
%% Cell type:markdown id:a059bc71-912e-4b2b-ab4a-0f7bf5c56b5c tags:
## Read csv file
%% Cell type:code id:29e9f0ed-331c-41be-bad4-b9539a132baa tags:
``` python
import pandas as pd
```
%% Cell type:code id:e9c9f987-e2c7-4273-ad37-67aa2dab0d7b tags:
``` python
pred_net_csv = pd.read_csv("../output_demo/validation_network_level.csv")
pred_net_csv = pd.DataFrame(pred_net_csv)
pred_net_csv.head()
```
%% Cell type:code id:b2943f25-c309-488c-8e45-2ef919e6da57 tags:
``` python
pred_sta_csv = pd.read_csv("../output_demo/validation_station_level.csv")
pred_sta_csv = pd.DataFrame(pred_sta_csv)
pred_sta_csv.head()
```
Ce diff est replié.
Fichier supprimé
event,prob_nat,prob_ant,pred,nature
2022004T111040,0.005,0.995,1,Anthropogenic
2022001T213524,0.961,0.039,0,Natural
2022003T080315,0.043,0.957,1,Anthropogenic
2022003T084110,0.019,0.981,1,Anthropogenic
2022004T134407,0.77,0.23,0,Natural
2022004T105235,0.011,0.989,1,Anthropogenic
2022004T101445,0.015,0.985,1,Anthropogenic
2022004T111745,0.005,0.995,1,Anthropogenic
2022003T041502,0.988,0.012,0,Natural
file_name,station,prob_nat,prob_ant,pred,nature
FR_DAUF_2022004T111040,DAUF,0.001,0.999,1,Anthropogenic
FR_LEUC_2022004T111040,LEUC,0.002,0.998,1,Anthropogenic
FR_CRNF_2022004T111040,CRNF,0.014,0.986,1,Anthropogenic
FR_AGO_2022004T111040,AGO,0.001,0.999,1,Anthropogenic
FR_ABJF_2022004T111040,ABJF,0.0,1.0,1,Anthropogenic
FR_GIZF_2022004T111040,GIZF,0.002,0.998,1,Anthropogenic
FR_CHIF_2022004T111040,CHIF,0.0,1.0,1,Anthropogenic
FR_GARF_2022004T111040,GARF,0.006,0.994,1,Anthropogenic
FR_GNEF_2022004T111040,GNEF,0.013,0.987,1,Anthropogenic
FR_GZNF_2022004T111040,GZNF,0.012,0.988,1,Anthropogenic
FR_VERF_2022004T111040,VERF,0.014,0.986,1,Anthropogenic
FR_SLVF_2022004T111040,SLVF,0.001,0.999,1,Anthropogenic
FR_BRGF_2022004T111040,BRGF,0.005,0.995,1,Anthropogenic
FR_HRSF_2022004T111040,HRSF,0.003,0.997,1,Anthropogenic
FR_MTNF_2022001T213524,MTNF,0.924,0.076,0,Natural
FR_SROF_2022001T213524,SROF,0.961,0.039,0,Natural
FR_PLOF_2022001T213524,PLOF,0.949,0.051,0,Natural
FR_DAUF_2022001T213524,DAUF,0.996,0.004,0,Natural
FR_PLEF_2022001T213524,PLEF,0.989,0.011,0,Natural
FR_RIAF_2022001T213524,RIAF,0.999,0.001,0,Natural
FR_LOCF_2022001T213524,LOCF,0.866,0.134,0,Natural
FR_SOMF_2022001T213524,SOMF,0.944,0.056,0,Natural
FR_LOUF_2022001T213524,LOUF,0.992,0.008,0,Natural
FR_BESN_2022001T213524,BESN,0.991,0.009,0,Natural
FR_CRNF_2022003T080315,CRNF,0.031,0.969,1,Anthropogenic
FR_CHIF_2022003T080315,CHIF,0.047,0.953,1,Anthropogenic
FR_ABJF_2022003T080315,ABJF,0.04,0.96,1,Anthropogenic
FR_GNEF_2022003T080315,GNEF,0.014,0.986,1,Anthropogenic
FR_GARF_2022003T080315,GARF,0.008,0.992,1,Anthropogenic
FR_LGIF_2022003T080315,LGIF,0.014,0.986,1,Anthropogenic
FR_BSCF_2022003T080315,BSCF,0.03,0.97,1,Anthropogenic
FR_BRGF_2022003T080315,BRGF,0.162,0.838,1,Anthropogenic
FR_CHIF_2022003T084110,CHIF,0.006,0.994,1,Anthropogenic
FR_RIAF_2022003T084110,RIAF,0.039,0.961,1,Anthropogenic
FR_CRNF_2022003T084110,CRNF,0.014,0.986,1,Anthropogenic
FR_BOUF_2022003T084110,BOUF,0.054,0.946,1,Anthropogenic
FR_DAUF_2022003T084110,DAUF,0.011,0.989,1,Anthropogenic
FR_GNEF_2022003T084110,GNEF,0.011,0.989,1,Anthropogenic
FR_LGIF_2022003T084110,LGIF,0.012,0.988,1,Anthropogenic
FR_BSCF_2022003T084110,BSCF,0.004,0.996,1,Anthropogenic
FR_ABJF_2022004T134407,ABJF,0.044,0.956,1,Anthropogenic
FR_CHLF_2022004T134407,CHLF,0.962,0.038,0,Natural
FR_LBL_2022004T134407,LBL,0.216,0.784,1,Anthropogenic
FR_GARF_2022004T134407,GARF,0.982,0.018,0,Natural
FR_GNEF_2022004T134407,GNEF,0.914,0.086,0,Natural
FR_VERF_2022004T134407,VERF,0.985,0.015,0,Natural
FR_GZNF_2022004T134407,GZNF,0.985,0.015,0,Natural
FR_COLF_2022004T134407,COLF,0.808,0.192,0,Natural
FR_HRSF_2022004T134407,HRSF,0.989,0.011,0,Natural
FR_BRGF_2022004T134407,BRGF,0.637,0.363,0,Natural
FR_FRNF_2022004T134407,FRNF,0.952,0.048,0,Natural
FR_DAUF_2022004T105235,DAUF,0.003,0.997,1,Anthropogenic
FR_BEGF_2022004T105235,BEGF,0.009,0.991,1,Anthropogenic
FR_BOUF_2022004T105235,BOUF,0.022,0.978,1,Anthropogenic
FR_CRNF_2022004T105235,CRNF,0.026,0.974,1,Anthropogenic
FR_LGIF_2022004T105235,LGIF,0.002,0.998,1,Anthropogenic
FR_GNEF_2022004T105235,GNEF,0.006,0.994,1,Anthropogenic
FR_PLOF_2022004T101445,PLOF,0.017,0.983,1,Anthropogenic
FR_BEGF_2022004T101445,BEGF,0.002,0.998,1,Anthropogenic
FR_RIAF_2022004T101445,RIAF,0.01,0.99,1,Anthropogenic
FR_SROF_2022004T101445,SROF,0.061,0.939,1,Anthropogenic
FR_MTNF_2022004T101445,MTNF,0.006,0.994,1,Anthropogenic
FR_GUEF_2022004T101445,GUEF,0.002,0.998,1,Anthropogenic
FR_OLIV_2022004T101445,OLIV,0.004,0.996,1,Anthropogenic
FR_PLEF_2022004T111745,PLEF,0.011,0.989,1,Anthropogenic
FR_RIAF_2022004T111745,RIAF,0.006,0.994,1,Anthropogenic
FR_BEGF_2022004T111745,BEGF,0.001,0.999,1,Anthropogenic
FR_MTNF_2022004T111745,MTNF,0.001,0.999,1,Anthropogenic
FR_PLDF_2022003T041502,PLDF,0.989,0.011,0,Natural
FR_CHLF_2022003T041502,CHLF,0.985,0.015,0,Natural
FR_AGO_2022003T041502,AGO,0.999,0.001,0,Natural
FR_BRGF_2022003T041502,BRGF,0.988,0.012,0,Natural
FR_FRNF_2022003T041502,FRNF,0.985,0.015,0,Natural
FR_COLF_2022003T041502,COLF,0.986,0.014,0,Natural
FR_HRSF_2022003T041502,HRSF,0.987,0.013,0,Natural
FR_GZNF_2022003T041502,GZNF,0.997,0.003,0,Natural
FR_VERF_2022003T041502,VERF,0.985,0.015,0,Natural
FR_LBL_2022003T041502,LBL,0.977,0.023,0,Natural
Fichier supprimé
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter