Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ttk
spam
Commits
0c358ba3
Commit
0c358ba3
authored
Apr 13, 2021
by
Olga Stamati
Browse files
tests for LQC
parent
70bf6e0e
Pipeline
#64625
passed with stages
in 12 minutes and 46 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
tools/tests/test_DIC.py
View file @
0c358ba3
...
...
@@ -143,6 +143,7 @@ class TestFunctionDVC(unittest.TestCase):
os
.
remove
(
"spam-corrected-N12.tsv"
)
os
.
remove
(
"spamPhiFieldCF.tsv"
)
def
test_applyPhiField
(
self
):
a
=
numpy
.
random
.
rand
(
10
,
10
,
10
)
Phi
=
spam
.
deformation
.
computePhi
({
't'
:
[
0.0
,
3.0
,
3.0
]})
...
...
@@ -415,8 +416,6 @@ class TestFunctionDVC(unittest.TestCase):
nodePositions
,
nodesDim2D
=
spam
.
DIC
.
grid
.
makeGrid
((
1
,
50
,
50
),
10
)
self
.
assertEqual
((
1
,
4
,
4
),
nodesDim2D
)
def
test_grid
(
self
):
im
=
spam
.
datasets
.
loadSnow
()
imageSize
=
im
.
shape
...
...
@@ -432,5 +431,30 @@ class TestFunctionDVC(unittest.TestCase):
grid3
=
spam
.
DIC
.
makeGrid
(
imageSize
,
[
10
,
10
,
10
,
10
])
self
.
assertTrue
(
grid3
is
None
)
def
test_kinematics
(
self
):
# local quadratic coherency
points
,
_
=
spam
.
DIC
.
grid
.
makeGrid
((
10
,
10
,
10
),
2
)
disp
=
numpy
.
ones_like
(
points
,
dtype
=
'<f4'
)
*
5
# all points should be coherent
LQC1
=
spam
.
DIC
.
estimateLocalQuadraticCoherency
(
points
,
disp
,
neighbourRadius
=
20
)
self
.
assertEqual
(
len
(
numpy
.
where
(
LQC1
>
0.1
)[
0
]),
0
)
# set some bad points
dispMod
=
disp
.
copy
()
dispMod
[:
4
]
=
numpy
.
random
.
randint
(
-
20
,
high
=-
2
,
size
=
[
4
,
3
])
dispMod
[
20
:
25
]
=
numpy
.
random
.
randint
(
-
20
,
high
=-
2
,
size
=
[
5
,
3
])
dispMod
[
-
4
:]
=
numpy
.
random
.
randint
(
-
20
,
high
=-
2
,
size
=
[
4
,
3
])
# try with radius
LQC2
=
spam
.
DIC
.
estimateLocalQuadraticCoherency
(
points
,
dispMod
,
neighbourRadius
=
20
)
self
.
assertTrue
(
len
(
numpy
.
where
(
LQC2
>
0.1
)[
0
]),
13
)
# try with number of neighbours
LQC3
=
spam
.
DIC
.
estimateLocalQuadraticCoherency
(
points
,
dispMod
,
nNeighbours
=
35
)
self
.
assertTrue
(
len
(
numpy
.
where
(
LQC3
>
0.1
)[
0
]),
13
)
# correct disp
dispModFit
=
spam
.
DIC
.
estimateDisplacementFromQuadraticFit
(
points
,
dispMod
,
LQC2
,
neighbourRadius
=
20
)
self
.
assertTrue
(
numpy
.
allclose
(
dispModFit
,
disp
))
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment