Skip to content

Commit

Permalink
Checked (and updated) example notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnende committed Mar 22, 2024
1 parent 4a136b0 commit a76fa79
Show file tree
Hide file tree
Showing 11 changed files with 191,064 additions and 35,863 deletions.
34 changes: 23 additions & 11 deletions examples/notebooks/3D_mesh_builder.ipynb

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions examples/notebooks/CNS_spring-block.ipynb

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions examples/notebooks/RSF_spring-block.ipynb

Large diffs are not rendered by default.

35 changes: 22 additions & 13 deletions examples/notebooks/compute_events.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@
"This notebook shows the workflow to compute the seismic events of a simulation using the python function `extract_events`. For usage details of this function, check the source code in `qdyn/utils/postprocessing/extract_events`"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "7f4eb619",
"metadata": {},
"outputs": [],
"source": [
"%matplotlib widget\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"import os\n",
"import sys\n",
"import pickle\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Import QDYN wrapper\n",
"from qdyn import qdyn\n",
"from qdyn.utils import post_processing"
]
},
{
"cell_type": "code",
"execution_count": 11,
Expand All @@ -25,19 +46,7 @@
}
],
"source": [
"# reload modules automatically\n",
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"\"\"\"\n",
"INITIAL PARAMETERS\n",
"\"\"\"\n",
"import numpy as np\n",
"import pandas as pd\n",
"import os\n",
"import sys\n",
"import pickle\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Add QDYN source directory to PATH\n",
"# Go up in the directory tree\n",
Expand Down Expand Up @@ -683,7 +692,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
191,107 changes: 161,923 additions & 29,184 deletions examples/notebooks/double_asperity.ipynb

Large diffs are not rendered by default.

55 changes: 29 additions & 26 deletions examples/notebooks/intersecting_faults.ipynb

Large diffs are not rendered by default.

38 changes: 17 additions & 21 deletions examples/notebooks/restart_simulation.ipynb

Large diffs are not rendered by default.

35,537 changes: 28,997 additions & 6,540 deletions examples/notebooks/single_asperity.ipynb

Large diffs are not rendered by default.

51 changes: 19 additions & 32 deletions examples/notebooks/single_asperity_3D.ipynb

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions qdyn/pyqdyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def read_output(self, mirror=False, path_output=None, read_ot=True, filename_ot=

df = read_csv(
filename_iot, header=None, skiprows=nheaders_ot,
names=quants_ot, delim_whitespace=True
names=quants_ot, sep="\s+"
)

# Sanitise output (check for near-infinite numbers, etc.)
Expand All @@ -807,7 +807,7 @@ def read_output(self, mirror=False, path_output=None, read_ot=True, filename_ot=

self.ot_vmax = read_csv(
filename_vmax, header=None, skiprows=nheaders_vmax,
names=quants_vmax, delim_whitespace=True
names=quants_vmax, sep="\s+"
)
# Discard duplicate rows from duplicate time-steps
self.ot_vmax = self.ot_vmax.drop_duplicates(subset=["step"], keep="first")
Expand All @@ -825,7 +825,7 @@ def read_output(self, mirror=False, path_output=None, read_ot=True, filename_ot=
if path_output!= None:
filename_ox= path_output + filename_ox

data_ox = read_csv(filename_ox, header=None, names=quants_ox, delim_whitespace=True, comment="#")
data_ox = read_csv(filename_ox, header=None, names=quants_ox, sep="\s+", comment="#")

# Store snapshot data in self.ox
self.ox = data_ox
Expand All @@ -852,7 +852,7 @@ def read_output(self, mirror=False, path_output=None, read_ot=True, filename_ot=
if path_output!= None:
filename_ox_last = path_output + filename_ox_last

data_ox_last = read_csv(filename_ox_last, header=None, names=quants_ox, delim_whitespace=True, comment="#")
data_ox_last = read_csv(filename_ox_last, header=None, names=quants_ox, sep="\s+", comment="#")

# Store snapshot data in self.ox
self.ox_last = data_ox_last
Expand Down Expand Up @@ -892,7 +892,7 @@ def read_output(self, mirror=False, path_output=None, read_ot=True, filename_ot=
# Read pre-rupture file
data_ox_dyn_pre[i] = read_csv(
ox_dyn_files_pre[i], header=None, names=quants_ox,
delim_whitespace=True, comment="#"
sep="\s+", comment="#"
)
# Sanitise output (check for near-infinite numbers, etc.)
data_ox_dyn_pre[i] = data_ox_dyn_pre[i].apply(pd.to_numeric, errors="coerce")
Expand All @@ -903,7 +903,7 @@ def read_output(self, mirror=False, path_output=None, read_ot=True, filename_ot=
# Read pre-rupture file
data_ox_dyn_post[i] = read_csv(
ox_dyn_files_post[i], header=None, names=quants_ox,
delim_whitespace=True, comment="#"
sep="\s+", comment="#"
)
# Sanitise output (check for near-infinite numbers, etc.)
data_ox_dyn_post[i] = data_ox_dyn_post[i].apply(pd.to_numeric, errors="coerce")
Expand All @@ -914,7 +914,7 @@ def read_output(self, mirror=False, path_output=None, read_ot=True, filename_ot=
# Rupture stats file
data_ox_dyn_rup[i] = read_csv(
ox_dyn_files_rup[i], header=None, names=quants_rup,
delim_whitespace=True, comment="#"
sep="\s+", comment="#"
)
# Sanitise output (check for near-infinite numbers, etc.)
data_ox_dyn_rup[i] = data_ox_dyn_rup[i].apply(pd.to_numeric, errors="coerce")
Expand Down Expand Up @@ -957,7 +957,7 @@ def read_output(self, mirror=False, path_output=None, read_ot=True, filename_ot=
# Read output file
self.fault[n] = read_csv(
filename_fault, header=None, skiprows=nheaders_fault, usecols=col_list,
names=quants_fault, delim_whitespace=True
names=quants_fault, sep="\s+"
)

# Discard duplicate rows from duplicate time-steps
Expand Down
2 changes: 0 additions & 2 deletions qdyn/utils/post_processing/plot_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ def slip_profile(ox, warm_up=0, orientation="horizontal"):

ind_warmup = np.where(t_vals >= warm_up)[0][0]

print(ind_warmup)

Nx = len(x_unique)
Nt = len(t_vals) - 1

Expand Down

0 comments on commit a76fa79

Please sign in to comment.