Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gridcorner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Keitel
gridcorner
Commits
78457b59
Commit
78457b59
authored
7 years ago
by
Gregory Ashton
Browse files
Options
Downloads
Patches
Plain Diff
Adds slice_max method and update example
parent
0a0105b7
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
example.png
+0
-0
0 additions, 0 deletions
example.png
example.py
+7
-3
7 additions, 3 deletions
example.py
projection_matrix/__init__.py
+1
-1
1 addition, 1 deletion
projection_matrix/__init__.py
projection_matrix/projection_matrix.py
+16
-2
16 additions, 2 deletions
projection_matrix/projection_matrix.py
with
24 additions
and
6 deletions
example.png
+
0
−
0
View replaced file @
0a0105b7
View file @
78457b59
65.1 KiB
|
W:
|
H:
70.7 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
example.py
+
7
−
3
View file @
78457b59
import
numpy
as
np
import
numpy
as
np
import
projection_matrix
.projection_matrix
as
pmp
import
projection_matrix
as
pmp
# Generate example data
# Generate example data
x
=
np
.
linspace
(
0
,
1
,
50
)
x
=
np
.
linspace
(
0
,
1
,
50
)
...
@@ -11,10 +11,14 @@ sigmax = 0.1
...
@@ -11,10 +11,14 @@ sigmax = 0.1
sigmay
=
1
sigmay
=
1
sigmaz
=
0.2
sigmaz
=
0.2
D
=
(
np
.
exp
(
-
(
X
-
x0
)
**
2
/
sigmax
**
2
)
D
=
(
np
.
exp
(
-
(
X
-
x0
)
**
2
/
sigmax
**
2
)
+
0.5
*
np
.
exp
(
-
(
X
-
0.1
)
**
2
/
sigmax
**
2
)
+
np
.
exp
(
-
(
Y
-
y0
)
**
2
/
sigmay
**
2
)
+
np
.
exp
(
-
(
Y
-
y0
)
**
2
/
sigmay
**
2
)
+
np
.
exp
(
-
(
Z
-
z0
)
**
2
/
sigmaz
**
2
))
+
np
.
exp
(
-
(
Z
-
z0
)
**
2
/
sigmaz
**
2
))
fig
,
axes
=
pmp
(
fig
,
axes
=
pmp
.
projection_matrix
(
D
,
xyz
=
[
x
,
y
,
z
],
labels
=
[
'
x
'
,
'
y
'
,
'
z
'
,
'
D
'
],
projection
=
np
.
max
)
D
,
xyz
=
[
x
,
y
,
z
],
labels
=
[
'
x
'
,
'
y
'
,
'
z
'
,
'
D
'
],
projection
=
pmp
.
slice_max
,
#projection=np.max
)
fig
.
savefig
(
'
example
'
)
fig
.
savefig
(
'
example
'
)
This diff is collapsed.
Click to expand it.
projection_matrix/__init__.py
+
1
−
1
View file @
78457b59
from
.projection_matrix
import
projection_matrix
from
.projection_matrix
import
projection_matrix
,
slice_max
This diff is collapsed.
Click to expand it.
projection_matrix/projection_matrix.py
+
16
−
2
View file @
78457b59
...
@@ -3,7 +3,17 @@ import matplotlib.pyplot as plt
...
@@ -3,7 +3,17 @@ import matplotlib.pyplot as plt
from
matplotlib.ticker
import
MaxNLocator
from
matplotlib.ticker
import
MaxNLocator
def
projection_matrix
(
D
,
xyz
,
labels
=
None
,
projection
=
np
.
max
,
max_n_ticks
=
4
,
def
slice_max
(
D
,
axis
):
"""
Return the slice along the given axis
"""
idxs
=
[
range
(
D
.
shape
[
j
])
for
j
in
range
(
D
.
ndim
)]
max_idx
=
list
(
np
.
unravel_index
(
D
.
argmax
(),
D
.
shape
))
for
k
in
np
.
atleast_1d
(
axis
):
idxs
[
k
]
=
[
max_idx
[
k
]]
res
=
np
.
squeeze
(
D
[
np
.
ix_
(
*
tuple
(
idxs
))])
return
res
def
projection_matrix
(
D
,
xyz
,
labels
=
None
,
projection
=
slice_max
,
max_n_ticks
=
4
,
factor
=
3
):
factor
=
3
):
"""
Generate a projection matrix plot
"""
Generate a projection matrix plot
...
@@ -20,7 +30,8 @@ def projection_matrix(D, xyz, labels=None, projection=np.max, max_n_ticks=4,
...
@@ -20,7 +30,8 @@ def projection_matrix(D, xyz, labels=None, projection=np.max, max_n_ticks=4,
labels, the final label is for the dependent variable.
labels, the final label is for the dependent variable.
projection: func
projection: func
Function to use for projection, must take an `axis` argument. Default
Function to use for projection, must take an `axis` argument. Default
is `np.max()`, to project out a slice along the maximum.
is `projection_matrix.slice_max()`, to project out a slice along the
maximum.
max_n_ticks: int
max_n_ticks: int
Number of ticks for x and y axis of the `pcolormesh` plots
Number of ticks for x and y axis of the `pcolormesh` plots
factor: float
factor: float
...
@@ -100,3 +111,6 @@ def projection_1D(ax, x, D, xidx, projection):
...
@@ -100,3 +111,6 @@ def projection_1D(ax, x, D, xidx, projection):
ax
.
yaxis
.
tick_right
()
ax
.
yaxis
.
tick_right
()
ax
.
yaxis
.
set_label_position
(
"
right
"
)
ax
.
yaxis
.
set_label_position
(
"
right
"
)
return
ax
return
ax
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment