Skip to content

Commit 9a29524

Browse files
authored
Merge pull request #159 from ArnauMiro/158-bugfix_docs
2 parents f09d0e1 + b5ebb1f commit 9a29524

File tree

3 files changed

+124
-7
lines changed

3 files changed

+124
-7
lines changed

Diff for: Examples/example_dataset.py

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/env python
2+
import numpy as np
3+
import pyLOM
4+
5+
6+
## Parameters
7+
OUTFILE = "./example_dataset.h5"
8+
9+
10+
## Synthetic data
11+
#
12+
# This is the data you want to perform ML on, i.e., the cooling function
13+
# or the Cp on the airfoil example
14+
K= np.array([[[1,2,3,4],[5, 6, 7, 8],[9,10,11,12]], [[13, 14, 15, 16],[17,18,19,20],[21,22,23,24]]],np.float32).T
15+
print('K:',K.shape) # (4, 3, 2)
16+
17+
# So the first dimension, 4, are the xyz positions
18+
# then xyz must have length (4,3) or (4,2) in 2D
19+
xyz = np.array([[1,19,12],[1,20,12],[2,5,11],[3,6,11]],np.float32)
20+
print('xyz:',xyz.shape) # (4, 3)
21+
22+
# For the point order array we simply numerate our
23+
# points consecutively
24+
pointO = np.arange(xyz.shape[0])
25+
print('pointO:',pointO.shape) # (4,)
26+
27+
# Now we are missing two variables of size (3,) and (2,)
28+
# for this example we will call them `var1` and `var2`
29+
var1 = np.array([20,30,40],np.float32)
30+
print('var1:',var1.shape) # (3,)
31+
var2 = np.array([200,300],np.float32)
32+
print('var2:',var2.shape) # (2,)
33+
print()
34+
35+
36+
## Create a serial partition table
37+
# The number of points is simply the first dimension
38+
# of K and xyz
39+
npoints = xyz.shape[0]
40+
# Here we create a table with a single partition with the
41+
# same number of points and elements (i.e., a cloud of points)
42+
ptable = pyLOM.PartitionTable.new(1,npoints,npoints)
43+
print(ptable)
44+
45+
46+
## Create a pyLOM dataset
47+
# Now we can arrange the dataset
48+
# In this example, it is indiferent if we treat the data as
49+
# points or cells. For simplicity we will assume the data to
50+
# be points.
51+
d = pyLOM.Dataset(xyz=xyz,ptable=ptable,order=pointO,point=True,
52+
# Add the variables as a dictionary associated with
53+
# their dimensions on the matrix K
54+
vars = {
55+
# We associate var1 to the first dimension of K, i.e.,
56+
# idim = 0 as dimension 0 of K is always the number of
57+
# points
58+
'var1' : {'idim':0,'value':var1},
59+
# We associate var2 to the second dimension of K, i.e.,
60+
# idim = 1
61+
'var2' : {'idim':1,'value':var2},
62+
},
63+
# Now we add the fields, i.e., the actual data to compute
64+
# things. So K has ndim = 2 as there are two extra dimensions
65+
# other than the number of points
66+
K = {'ndim':2,'value':K}
67+
)
68+
print(d)
69+
70+
# Now we store the dataset
71+
# we make sure to activate mode = 'w' to overwrite
72+
# any possible early results
73+
d.save(OUTFILE,mode='w')
74+
75+
76+
pyLOM.cr_info()

Diff for: docs/source/conf.py

+3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828

2929
# Set the default syntax highlighter
3030
highlight_language = 'python'
31+
# Don't run the notebooks
32+
nbsphinx_execute = 'never'
3133

34+
nbsphinx_allow_errors = True
3235
# For nbsphinx
3336
nbsphinx_codecell_lexer = 'ipython3'
3437

Diff for: docs/source/notebook_examples/example_POD_cylinder.ipynb

+45-7
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": null,
14-
"metadata": {},
15-
"outputs": [],
13+
"execution_count": 1,
14+
"metadata": {},
15+
"outputs": [
16+
{
17+
"name": "stderr",
18+
"output_type": "stream",
19+
"text": [
20+
"0 Warning! Import - NVTX not present!\n"
21+
]
22+
}
23+
],
1624
"source": [
1725
"from __future__ import print_function, division\n",
1826
"\n",
@@ -32,9 +40,17 @@
3240
},
3341
{
3442
"cell_type": "code",
35-
"execution_count": null,
36-
"metadata": {},
37-
"outputs": [],
43+
"execution_count": 2,
44+
"metadata": {},
45+
"outputs": [
46+
{
47+
"name": "stderr",
48+
"output_type": "stream",
49+
"text": [
50+
"0 Warning! cupy not available! GPU version deactivated!\n"
51+
]
52+
}
53+
],
3854
"source": [
3955
"pyLOM.gpu_device(gpu_per_node=4)"
4056
]
@@ -50,7 +66,29 @@
5066
"cell_type": "code",
5167
"execution_count": null,
5268
"metadata": {},
53-
"outputs": [],
69+
"outputs": [
70+
{
71+
"ename": "FileNotFoundError",
72+
"evalue": "[Errno 2] Unable to open file (unable to open file: name = '../../../Examples/DATA/CYLINDER.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)",
73+
"output_type": "error",
74+
"traceback": [
75+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
76+
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
77+
"Cell \u001b[0;32mIn [3], line 6\u001b[0m\n\u001b[1;32m 3\u001b[0m VARIABLE \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mVELOC\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m## Data loading\u001b[39;00m\n\u001b[0;32m----> 6\u001b[0m m \u001b[38;5;241m=\u001b[39m \u001b[43mpyLOM\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mMesh\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload\u001b[49m\u001b[43m(\u001b[49m\u001b[43mDATAFILE\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 7\u001b[0m d \u001b[38;5;241m=\u001b[39m pyLOM\u001b[38;5;241m.\u001b[39mDataset\u001b[38;5;241m.\u001b[39mload(DATAFILE,ptable\u001b[38;5;241m=\u001b[39mm\u001b[38;5;241m.\u001b[39mpartition_table)\u001b[38;5;241m.\u001b[39mto_gpu([VARIABLE]) \u001b[38;5;66;03m# Send to GPU if available\u001b[39;00m\n\u001b[1;32m 8\u001b[0m X \u001b[38;5;241m=\u001b[39m d[VARIABLE]\n",
78+
"File \u001b[0;32m~/Documents/repos/pyLowOrder/pyLOM/utils/cr.py:277\u001b[0m, in \u001b[0;36mcr_nvtx.<locals>.decorator.<locals>.wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 274\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[1;32m 275\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs,\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 276\u001b[0m \tcr_start(ch_name,suff)\n\u001b[0;32m--> 277\u001b[0m \tout \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 278\u001b[0m \tcr_stop(ch_name,suff)\n\u001b[1;32m 279\u001b[0m \t\u001b[38;5;28;01mreturn\u001b[39;00m out\n",
79+
"File \u001b[0;32m~/Documents/repos/pyLowOrder/pyLOM/mesh.py:199\u001b[0m, in \u001b[0;36mMesh.load\u001b[0;34m(cls, fname, **kwargs)\u001b[0m\n\u001b[1;32m 197\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m fmt\u001b[38;5;241m.\u001b[39mlower() \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mh5\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[1;32m 198\u001b[0m \t\u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmpio\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;129;01min\u001b[39;00m kwargs\u001b[38;5;241m.\u001b[39mkeys(): kwargs[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmpio\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m--> 199\u001b[0m \tmtype, xyz, conec, eltype, cellO, pointO, ptable \u001b[38;5;241m=\u001b[39m \u001b[43mio\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mh5_load_mesh\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfname\u001b[49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 200\u001b[0m \t\u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mcls\u001b[39m(mtype,xyz,conec,eltype,cellO,pointO,ptable)\n\u001b[1;32m 201\u001b[0m raiseError(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCannot load file <\u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m>!\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m%\u001b[39mfname)\n",
80+
"File \u001b[0;32m~/Documents/repos/pyLowOrder/pyLOM/utils/cr.py:242\u001b[0m, in \u001b[0;36mcr.<locals>.decorator.<locals>.wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 239\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[1;32m 240\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs,\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 241\u001b[0m \tcr_start(ch_name,suff)\n\u001b[0;32m--> 242\u001b[0m \tout \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 243\u001b[0m \tcr_stop(ch_name,suff)\n\u001b[1;32m 244\u001b[0m \t\u001b[38;5;28;01mreturn\u001b[39;00m out\n",
81+
"File \u001b[0;32m~/Documents/repos/pyLowOrder/pyLOM/inp_out/io_h5.py:637\u001b[0m, in \u001b[0;36mh5_load_mesh\u001b[0;34m(fname, mpio)\u001b[0m\n\u001b[1;32m 635\u001b[0m \t\u001b[38;5;28;01mreturn\u001b[39;00m h5_load_mesh_mpio(fname)\n\u001b[1;32m 636\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 637\u001b[0m \t\u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mh5_load_mesh_serial\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfname\u001b[49m\u001b[43m)\u001b[49m\n",
82+
"File \u001b[0;32m~/Documents/repos/pyLowOrder/pyLOM/inp_out/io_h5.py:644\u001b[0m, in \u001b[0;36mh5_load_mesh_serial\u001b[0;34m(fname)\u001b[0m\n\u001b[1;32m 640\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m'''\u001b[39;00m\n\u001b[1;32m 641\u001b[0m \u001b[38;5;124;03mLoad a mesh in HDF5 in serial\u001b[39;00m\n\u001b[1;32m 642\u001b[0m \u001b[38;5;124;03m'''\u001b[39;00m\n\u001b[1;32m 643\u001b[0m \u001b[38;5;66;03m# Open file for writing\u001b[39;00m\n\u001b[0;32m--> 644\u001b[0m file \u001b[38;5;241m=\u001b[39m \u001b[43mh5py\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mFile\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfname\u001b[49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mr\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 645\u001b[0m \u001b[38;5;66;03m# Check the file version\u001b[39;00m\n\u001b[1;32m 646\u001b[0m version \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mtuple\u001b[39m(file\u001b[38;5;241m.\u001b[39mattrs[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mVersion\u001b[39m\u001b[38;5;124m'\u001b[39m])\n",
83+
"File \u001b[0;32m~/.local/lib/python3.9/site-packages/h5py/_hl/files.py:562\u001b[0m, in \u001b[0;36mFile.__init__\u001b[0;34m(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, fs_strategy, fs_persist, fs_threshold, fs_page_size, page_buf_size, min_meta_keep, min_raw_keep, locking, alignment_threshold, alignment_interval, meta_block_size, **kwds)\u001b[0m\n\u001b[1;32m 553\u001b[0m fapl \u001b[38;5;241m=\u001b[39m make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0,\n\u001b[1;32m 554\u001b[0m locking, page_buf_size, min_meta_keep, min_raw_keep,\n\u001b[1;32m 555\u001b[0m alignment_threshold\u001b[38;5;241m=\u001b[39malignment_threshold,\n\u001b[1;32m 556\u001b[0m alignment_interval\u001b[38;5;241m=\u001b[39malignment_interval,\n\u001b[1;32m 557\u001b[0m meta_block_size\u001b[38;5;241m=\u001b[39mmeta_block_size,\n\u001b[1;32m 558\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwds)\n\u001b[1;32m 559\u001b[0m fcpl \u001b[38;5;241m=\u001b[39m make_fcpl(track_order\u001b[38;5;241m=\u001b[39mtrack_order, fs_strategy\u001b[38;5;241m=\u001b[39mfs_strategy,\n\u001b[1;32m 560\u001b[0m fs_persist\u001b[38;5;241m=\u001b[39mfs_persist, fs_threshold\u001b[38;5;241m=\u001b[39mfs_threshold,\n\u001b[1;32m 561\u001b[0m fs_page_size\u001b[38;5;241m=\u001b[39mfs_page_size)\n\u001b[0;32m--> 562\u001b[0m fid \u001b[38;5;241m=\u001b[39m \u001b[43mmake_fid\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muserblock_size\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfapl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfcpl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mswmr\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mswmr\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 564\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(libver, \u001b[38;5;28mtuple\u001b[39m):\n\u001b[1;32m 565\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_libver \u001b[38;5;241m=\u001b[39m libver\n",
84+
"File \u001b[0;32m~/.local/lib/python3.9/site-packages/h5py/_hl/files.py:235\u001b[0m, in \u001b[0;36mmake_fid\u001b[0;34m(name, mode, userblock_size, fapl, fcpl, swmr)\u001b[0m\n\u001b[1;32m 233\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m swmr \u001b[38;5;129;01mand\u001b[39;00m swmr_support:\n\u001b[1;32m 234\u001b[0m flags \u001b[38;5;241m|\u001b[39m\u001b[38;5;241m=\u001b[39m h5f\u001b[38;5;241m.\u001b[39mACC_SWMR_READ\n\u001b[0;32m--> 235\u001b[0m fid \u001b[38;5;241m=\u001b[39m \u001b[43mh5f\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mopen\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mflags\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfapl\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfapl\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 236\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m mode \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mr+\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[1;32m 237\u001b[0m fid \u001b[38;5;241m=\u001b[39m h5f\u001b[38;5;241m.\u001b[39mopen(name, h5f\u001b[38;5;241m.\u001b[39mACC_RDWR, fapl\u001b[38;5;241m=\u001b[39mfapl)\n",
85+
"File \u001b[0;32mh5py/_objects.pyx:54\u001b[0m, in \u001b[0;36mh5py._objects.with_phil.wrapper\u001b[0;34m()\u001b[0m\n",
86+
"File \u001b[0;32mh5py/_objects.pyx:55\u001b[0m, in \u001b[0;36mh5py._objects.with_phil.wrapper\u001b[0;34m()\u001b[0m\n",
87+
"File \u001b[0;32mh5py/h5f.pyx:102\u001b[0m, in \u001b[0;36mh5py.h5f.open\u001b[0;34m()\u001b[0m\n",
88+
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] Unable to open file (unable to open file: name = '../../../Examples/DATA/CYLINDER.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)"
89+
]
90+
}
91+
],
5492
"source": [
5593
"## Parameters\n",
5694
"DATAFILE = '../../../Testsuite/DATA/CYLINDER.h5'\n",

0 commit comments

Comments
 (0)