Skip to content

Commit e6894e6

Browse files
committed
simple notebook to strip unnecessary datasets and groups in the hdf5 outputs
1 parent bf5f82a commit e6894e6

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "62c2ebe8-0b46-4a9a-811d-87a08f3d76d8",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import numpy as np\n",
11+
"import h5py"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": 5,
17+
"id": "4a695f8f-893b-4dc3-829b-eed6d5a8ded3",
18+
"metadata": {},
19+
"outputs": [],
20+
"source": [
21+
"pydir = '../output_mark_wave/'\n",
22+
"\n",
23+
"Nts = [1,2,4,8,10,12,14,16]\n",
24+
"Nxs = [151,301]\n",
25+
"Nys = [60,120]\n",
26+
"\n",
27+
"datasetname = ['Y',\n",
28+
" 'buoy',\n",
29+
" 'dT',\n",
30+
" 'dY',\n",
31+
" 'drhoY',\n",
32+
" 'p2_nodes_half',\n",
33+
" 'rhoX_half',\n",
34+
" 'rhoY_half',\n",
35+
" 'rho_half',\n",
36+
" 'rhou_half',\n",
37+
" 'rhov_half',\n",
38+
" 'rhow_half',\n",
39+
" 'rhs',\n",
40+
" 'vortz'\n",
41+
" ]\n",
42+
"\n",
43+
"for Nx, Ny in zip(Nxs,Nys): \n",
44+
" for Nt in Nts:\n",
45+
" fn = pydir + 'output_mark_wave_ensemble=1_%i_%i_36.000000_bottom_forcing_S%i' %(Nx,Ny,Nt)\n",
46+
" \n",
47+
" odir = '%i_%i_LW/' %(Nx, Ny)\n",
48+
" fn_d = pydir + odir + 'output_%i_%i_36.0_%s_S%i' %(Nx, Ny, 'lw', Nt)\n",
49+
"\n",
50+
" fs = h5py.File(fn + '.h5', 'r')\n",
51+
" fd = h5py.File(fn_d + '.h5', 'w')\n",
52+
"\n",
53+
" for a in fs.attrs:\n",
54+
" fd.attrs[a] = fs.attrs[a]\n",
55+
" for d in fs:\n",
56+
" if not d in datasetname:\n",
57+
" fs.copy(d, fd)\n",
58+
"\n",
59+
"fs.close()\n",
60+
"fd.close()"
61+
]
62+
},
63+
{
64+
"cell_type": "code",
65+
"execution_count": null,
66+
"id": "858bfecf-40d9-403b-b25e-a8cae8f22a42",
67+
"metadata": {},
68+
"outputs": [],
69+
"source": []
70+
}
71+
],
72+
"metadata": {
73+
"kernelspec": {
74+
"display_name": "Python 3 (ipykernel)",
75+
"language": "python",
76+
"name": "python3"
77+
},
78+
"language_info": {
79+
"codemirror_mode": {
80+
"name": "ipython",
81+
"version": 3
82+
},
83+
"file_extension": ".py",
84+
"mimetype": "text/x-python",
85+
"name": "python",
86+
"nbconvert_exporter": "python",
87+
"pygments_lexer": "ipython3",
88+
"version": "3.9.15"
89+
}
90+
},
91+
"nbformat": 4,
92+
"nbformat_minor": 5
93+
}

0 commit comments

Comments
 (0)