Skip to content

Commit f337dce

Browse files
committed
revision changes
1 parent 10e3c04 commit f337dce

36 files changed

Lines changed: 116 additions & 128 deletions

scripts/JGR/06_compare_depths_optimized.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ def cleanup_variables(*vars_to_delete):
6464
# plotting the below events
6565
ids = [
6666
'BS_manning003/E01267N3753E01646N3535-BS-M809_E01502N3737_D010_S112D70R270_A006995_S075',
67-
'BS_manning003/E01267N3753E01646N3535-BS-M809_E01502N3737_D144_S022D70R270_A006995_S075',
68-
'BS_manning003/E01267N3753E01646N3535-BS-M809_E01547N3670_D010_S337D70R270_A006995_S075',
69-
'BS_manning003/E01267N3753E01646N3535-BS-M809_E01495N3692_D010_S022D50R270_A006995_S075',
70-
'BS_4-8_manning003/E01267N3753E01646N3535-BS-M809_E01502N3737_D010_S067D90R090_A006995_S075',
71-
'BS_manning003/E01267N3753E01646N3535-BS-M809_E01523N3692_D010_S292D50R270_A006995_S075',
72-
'BS_4-8_manning003/E01267N3753E01646N3535-BS-M809_E01551N3692_D010_S112D90R090_A006995_S075',
73-
'PS_manning003/E02020N3739E02658N3366-PS-Str_PYes_Var-M895_E02351N3465_S003',
74-
'PS_manning003/E02020N3739E02658N3366-PS-Str_PYes_Var-M902_E02417N3454_S001',
67+
# 'BS_manning003/E01267N3753E01646N3535-BS-M809_E01502N3737_D144_S022D70R270_A006995_S075',
68+
# 'BS_manning003/E01267N3753E01646N3535-BS-M809_E01547N3670_D010_S337D70R270_A006995_S075',
69+
# 'BS_manning003/E01267N3753E01646N3535-BS-M809_E01495N3692_D010_S022D50R270_A006995_S075',
70+
# 'BS_4-8_manning003/E01267N3753E01646N3535-BS-M809_E01502N3737_D010_S067D90R090_A006995_S075',
71+
# 'BS_manning003/E01267N3753E01646N3535-BS-M809_E01523N3692_D010_S292D50R270_A006995_S075',
72+
# 'BS_4-8_manning003/E01267N3753E01646N3535-BS-M809_E01551N3692_D010_S112D90R090_A006995_S075',
73+
# 'PS_manning003/E02020N3739E02658N3366-PS-Str_PYes_Var-M895_E02351N3465_S003',
74+
# 'PS_manning003/E02020N3739E02658N3366-PS-Str_PYes_Var-M902_E02417N3454_S001',
7575
]
7676

7777
#dimensions and gauge numbers
@@ -151,7 +151,8 @@ def cleanup_variables(*vars_to_delete):
151151
print(f"Starting to process {total_events} events from index {start}")
152152
print_memory_usage(0)
153153

154-
for id in events_to_process:
154+
# for id in events_to_process:
155+
for id in ids:
155156
eve = np.where(eve_id==id)[0][0]
156157
processed_events += 1
157158

@@ -219,7 +220,7 @@ def cleanup_variables(*vars_to_delete):
219220
# Local Deformation
220221
DZ = axs[0].scatter(x_list,y_list, c=dz_smooth, s=0.0005, cmap=cmap_dz,
221222
vmin=-5, vmax=5,alpha=1)
222-
axs[0].text(xpos,ypos, f'max: {np.nanmax(dz_smooth):.3f},\\nmin: {np.nanmin(dz_smooth):.3f}',
223+
axs[0].text(xpos,ypos, f'max: {np.nanmax(dz_smooth):.3f},\nmin: {np.nanmin(dz_smooth):.3f}',
223224
horizontalalignment='center', verticalalignment='center',transform=axs[0].transAxes, fontsize=12)
224225
axs[0].set_title('Local Deformation')
225226

@@ -233,14 +234,14 @@ def cleanup_variables(*vars_to_delete):
233234
# Pred_mean
234235
PR_pretrain = axs[2].scatter(idx[:, 1], idx[:, 0], c=pred_mean, s=0.0005, cmap=cmap_depth,
235236
vmin=0, vmax=10,alpha=1)
236-
axs[2].text(xpos,ypos, f'max: {np.nanmax(pred_mean):.3f}\\nr^2: {eve_perf_mean["r2"].iloc[eve]:.3f}\\ng: {eve_perf_mean["g"].iloc[eve]:.3f}',
237+
axs[2].text(xpos,ypos, f'max: {np.nanmax(pred_mean):.3f}\nr^2: {eve_perf_mean["r2"].iloc[eve]:.3f}\ng: {eve_perf_mean["g"].iloc[eve]:.3f}',
237238
horizontalalignment='center', verticalalignment='center',transform=axs[2].transAxes, fontsize=12)
238239
axs[2].set_title('Mean')
239240

240241
# Error
241242
ER_pretrain = axs[3].scatter(idx[:, 1], idx[:, 0], c=error_mean, s=0.0005, cmap=cmap_error,
242243
vmin=-5,vmax=5,alpha=1)
243-
axs[3].text(xpos,ypos, f'max: {np.nanmax(error_mean):.3f},\\nmin: {np.nanmin(error_mean):.3f}',
244+
axs[3].text(xpos,ypos, f'max: {np.nanmax(error_mean):.3f},\nmin: {np.nanmin(error_mean):.3f}',
244245
horizontalalignment='center', verticalalignment='center',transform=axs[3].transAxes, fontsize=12)
245246
axs[3].set_title('Error Mean')
246247

@@ -254,7 +255,7 @@ def cleanup_variables(*vars_to_delete):
254255
# Error
255256
ER_direct = axs[5].scatter(idx[:, 1], idx[:, 0], c=error_sigmaminus, s=0.0005, cmap=cmap_error,
256257
vmin=-5,vmax=5,alpha=1)
257-
axs[5].text(xpos,ypos, f'max: {np.nanmax(error_sigmaminus):.3f},\\nmin: {np.nanmin(error_sigmaminus):.3f}',
258+
axs[5].text(xpos,ypos, f'max: {np.nanmax(error_sigmaminus):.3f},\nmin: {np.nanmin(error_sigmaminus):.3f}',
258259
horizontalalignment='center', verticalalignment='center',transform=axs[5].transAxes, fontsize=12)
259260
axs[5].set_title('Error Mean-2Sigma')
260261

@@ -268,7 +269,7 @@ def cleanup_variables(*vars_to_delete):
268269
#Error
269270
ER_pretrain = axs[7].scatter(idx[:, 1], idx[:, 0], c=error_sigmaplus, s=0.0005, cmap=cmap_error,
270271
vmin=-5,vmax=5,alpha=1)
271-
axs[7].text(xpos,ypos, f'max: {np.nanmax(error_sigmaplus):.3f},\\nmin: {np.nanmin(error_sigmaplus):.3f}',
272+
axs[7].text(xpos,ypos, f'max: {np.nanmax(error_sigmaplus):.3f},\nmin: {np.nanmin(error_sigmaplus):.3f}',
272273
horizontalalignment='center', verticalalignment='center',transform=axs[7].transAxes, fontsize=12)
273274
axs[7].set_title('Error Mean+2Sigma')
274275

@@ -299,7 +300,7 @@ def cleanup_variables(*vars_to_delete):
299300
plt.tight_layout()
300301

301302
# Save with lower DPI for large datasets to save space and time
302-
dpi_value = 50 if total_events > 1000 else 150
303+
dpi_value = 100 if total_events > 1000 else 150
303304
plt.savefig(output_file, dpi=dpi_value, bbox_inches='tight', pad_inches=0.1)
304305

305306
#close figure and clear memory
@@ -340,12 +341,12 @@ def cleanup_variables(*vars_to_delete):
340341
continue
341342

342343
# Final summary
343-
print(f"\\nProcessing complete!")
344+
print(f"\nProcessing complete!")
344345
print(f"Successfully processed: {processed_events - len(failed_events)}/{total_events}")
345346
print(f"Failed events: {len(failed_events)}")
346347

347348
if failed_events:
348-
print("\\nFailed events:")
349+
print("\nFailed events:")
349350
for event_id, error_msg in failed_events:
350351
print(f" {event_id}: {error_msg}")
351352

@@ -360,7 +361,7 @@ def cleanup_variables(*vars_to_delete):
360361
for id in ids:
361362
try:
362363
eve = np.where(eve_id==id)[0][0]
363-
print(id,'\\n',eve)
364+
print(id,'\n',eve)
364365
#cm to m
365366
pred_mean=pred_depths_mean[eve]/100
366367
pred_sigmaminus=pred_depths_sigmaminus[eve]/100

scripts/JGR/plots/03_plotPygmt_gridPTHA_hazCurves.ipynb

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 3,
12+
"execution_count": 1,
1313
"metadata": {},
1414
"outputs": [
1515
{
@@ -255,33 +255,9 @@
255255
},
256256
{
257257
"cell_type": "code",
258-
"execution_count": 19,
258+
"execution_count": null,
259259
"metadata": {},
260-
"outputs": [
261-
{
262-
"name": "stderr",
263-
"output_type": "stream",
264-
"text": [
265-
"/tmp/ipykernel_651152/611917742.py:134: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
266-
" ex_rate = np.reshape(ex_rate, (grid_CT.dims['y'], grid_CT.dims['x']))\n",
267-
"xyz2grd [WARNING]: (x_max-x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.\n",
268-
"xyz2grd [WARNING]: (y_max-y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.\n",
269-
"xyz2grd (gmtapi_init_grdheader): Please select compatible -R and -I values\n",
270-
"xyz2grd [WARNING]: Encountered first invalid binary data record near/at line # 7220\n",
271-
"xyz2grd [WARNING]: Likely causes:\n",
272-
"xyz2grd [WARNING]: (1) Invalid x and/or y values, i.e. NaNs.\n"
273-
]
274-
},
275-
{
276-
"name": "stdout",
277-
"output_type": "stream",
278-
"text": [
279-
"Exact depth 1000 cm not found. Interpolating between 894.9999999999999 and 1074.0 cm.\n",
280-
"non zero size 666743 647194\n",
281-
"final non zero size 666743\n"
282-
]
283-
}
284-
],
260+
"outputs": [],
285261
"source": [
286262
"import pandas as pd\n",
287263
"import numpy as np\n",
@@ -446,7 +422,7 @@
446422
},
447423
{
448424
"cell_type": "code",
449-
"execution_count": 26,
425+
"execution_count": 6,
450426
"metadata": {},
451427
"outputs": [
452428
{
@@ -465,7 +441,7 @@
465441
"xyz2grd [WARNING]: Encountered first invalid binary data record near/at line # 198127\n",
466442
"xyz2grd [WARNING]: Likely causes:\n",
467443
"xyz2grd [WARNING]: (1) Invalid x and/or y values, i.e. NaNs.\n",
468-
"/tmp/ipykernel_651152/3219471298.py:129: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
444+
"/tmp/ipykernel_3809418/3219471298.py:129: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
469445
" ex_rate = np.reshape(ex_rate, (grid_SR.dims['y'], grid_SR.dims['x']))\n",
470446
"xyz2grd [WARNING]: (x_max-x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.\n",
471447
"xyz2grd [WARNING]: (y_max-y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.\n",
@@ -498,7 +474,7 @@
498474
"xyz2grd [WARNING]: Encountered first invalid binary data record near/at line # 165127\n",
499475
"xyz2grd [WARNING]: Likely causes:\n",
500476
"xyz2grd [WARNING]: (1) Invalid x and/or y values, i.e. NaNs.\n",
501-
"/tmp/ipykernel_651152/3219471298.py:129: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
477+
"/tmp/ipykernel_3809418/3219471298.py:129: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
502478
" ex_rate = np.reshape(ex_rate, (grid_SR.dims['y'], grid_SR.dims['x']))\n",
503479
"xyz2grd [WARNING]: (x_max-x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.\n",
504480
"xyz2grd [WARNING]: (y_max-y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.\n",
@@ -531,7 +507,7 @@
531507
"xyz2grd [WARNING]: Encountered first invalid binary data record near/at line # 95070\n",
532508
"xyz2grd [WARNING]: Likely causes:\n",
533509
"xyz2grd [WARNING]: (1) Invalid x and/or y values, i.e. NaNs.\n",
534-
"/tmp/ipykernel_651152/3219471298.py:129: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
510+
"/tmp/ipykernel_3809418/3219471298.py:129: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
535511
" ex_rate = np.reshape(ex_rate, (grid_SR.dims['y'], grid_SR.dims['x']))\n",
536512
"xyz2grd [WARNING]: (x_max-x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.\n",
537513
"xyz2grd [WARNING]: (y_max-y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.\n",
@@ -564,7 +540,7 @@
564540
"xyz2grd [WARNING]: Encountered first invalid binary data record near/at line # 59089\n",
565541
"xyz2grd [WARNING]: Likely causes:\n",
566542
"xyz2grd [WARNING]: (1) Invalid x and/or y values, i.e. NaNs.\n",
567-
"/tmp/ipykernel_651152/3219471298.py:129: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
543+
"/tmp/ipykernel_3809418/3219471298.py:129: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
568544
" ex_rate = np.reshape(ex_rate, (grid_SR.dims['y'], grid_SR.dims['x']))\n",
569545
"xyz2grd [WARNING]: (x_max-x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.\n",
570546
"xyz2grd [WARNING]: (y_max-y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.\n",
@@ -599,7 +575,7 @@
599575
"xyz2grd [WARNING]: Encountered first invalid binary data record near/at line # 8127\n",
600576
"xyz2grd [WARNING]: Likely causes:\n",
601577
"xyz2grd [WARNING]: (1) Invalid x and/or y values, i.e. NaNs.\n",
602-
"/tmp/ipykernel_651152/3219471298.py:129: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
578+
"/tmp/ipykernel_3809418/3219471298.py:129: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.\n",
603579
" ex_rate = np.reshape(ex_rate, (grid_SR.dims['y'], grid_SR.dims['x']))\n",
604580
"xyz2grd [WARNING]: (x_max-x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.\n",
605581
"xyz2grd [WARNING]: (y_max-y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.\n",

scripts/JGR/plots/07_plotFig_modelPerformance_misFit_modelArch.ipynb

Lines changed: 80 additions & 73 deletions
Large diffs are not rendered by default.

scripts/JGR/plots/08_plotFig_bias_variance_size.ipynb

Lines changed: 4 additions & 3 deletions
Large diffs are not rendered by default.
-64.8 KB
Loading
-69.3 KB
Loading
-59 KB
Loading
-66.5 KB
Loading
-59.1 KB
Loading
-404 Bytes
Loading

0 commit comments

Comments
 (0)