Skip to content

Commit 244237e

Browse files
committed
Add tutorial for IDW interpolation
1 parent f6e6d1f commit 244237e

File tree

4 files changed

+295
-3
lines changed

4 files changed

+295
-3
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
[Inverse Distance Weighting]
3+
# This section describes the setting of idw.
4+
5+
# the power parameter
6+
power: 2
7+
8+
9+
[Control points]
10+
# This section describes the RBF control points.
11+
12+
# original control points collects the coordinates of the interpolation control
13+
# points before the deformation.
14+
original control points: -.1 0.0 0.0
15+
0.0 0.0 1.0
16+
0.0 1.0 0.0
17+
1.0 0.0 0.0
18+
0.0 1 1.0
19+
1.0 0.0 1.0
20+
1.0 1.0 0
21+
1.0 1.0 1.0
22+
23+
# deformed control points collects the coordinates of the interpolation control
24+
# points after the deformation.
25+
deformed control points: 0.1 0.2 .3
26+
0.0 0.0 1.0
27+
0.0 1.0 0.0
28+
1.0 0.0 0.0
29+
0.0 .8 1.0
30+
1.0 0.0 1.0
31+
1.0 1.0 0.0
32+
1.2 1.2 1.2

tests/test_utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99

1010

1111
class TestUtils(TestCase):
12+
def cmp(self, f1, f2):
13+
"""
14+
Check if the two files have the same content, skipping comment lines
15+
"""
16+
content1 = [line for line in open(f1) if not line.startswith('#')]
17+
content2 = [line for line in open(f1) if not line.startswith('#')]
18+
return content1 == content2
19+
1220
def test_utils_write_original_box(self):
1321
params = pars.FFDParameters()
1422
params.read_parameters(
@@ -45,7 +53,7 @@ def test_utils_check_vtk_original_box(self):
4553

4654
ut.write_bounding_box(params, outfilename, write_deformed=False)
4755

48-
self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
56+
self.assertTrue(self.cmp(outfilename, outfilename_expected))
4957
os.remove(outfilename)
5058

5159
def test_utils_check_vtk_modified_box(self):
@@ -62,7 +70,7 @@ def test_utils_check_vtk_modified_box(self):
6270

6371
ut.write_bounding_box(params, outfilename)
6472

65-
self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
73+
self.assertTrue(self.cmp(outfilename, outfilename_expected))
6674
os.remove(outfilename)
6775

6876
def test_utils_plot_rbf_control_points(self):

tests/test_vtkhandler.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77

88

99
class TestVtkHandler(TestCase):
10+
def cmp(self, f1, f2):
11+
"""
12+
Check if the two files have the same content, skipping comment lines
13+
"""
14+
content1 = [line for line in open(f1) if not line.startswith('#')]
15+
content2 = [line for line in open(f1) if not line.startswith('#')]
16+
return content1 == content2
17+
1018
def test_vtk_instantiation(self):
1119
vtk_handler = vh.VtkHandler()
1220

@@ -139,7 +147,7 @@ def test_vtk_write_comparison(self):
139147
outfilename_expected = 'tests/test_datasets/test_red_blood_cell_out_true_version6.vtk'
140148

141149
vtk_handler.write(mesh_points, outfilename)
142-
self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
150+
self.assertTrue(self.cmp(outfilename, outfilename_expected))
143151
os.remove(outfilename)
144152

145153
def test_vtk_plot_failing_outfile_type(self):

tutorials/tutorial-5-idw.ipynb

Lines changed: 244 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)