Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benjamin Jakimow
EO Time Series Viewer
Commits
18ddff76
Commit
18ddff76
authored
Mar 10, 2014
by
Luke Campagnola
Browse files
colormap no longer requires scipy.interpolate
parent
b398ccd0
Changes
1
Show whitespace changes
Inline
Side-by-side
pyqtgraph/colormap.py
View file @
18ddff76
...
...
@@ -63,8 +63,8 @@ class ColorMap(object):
ignored. By default, the mode is entirely RGB.
=============== ==============================================================
"""
self
.
pos
=
pos
self
.
color
=
color
self
.
pos
=
np
.
array
(
pos
)
self
.
color
=
np
.
array
(
color
)
if
mode
is
None
:
mode
=
np
.
ones
(
len
(
pos
))
self
.
mode
=
mode
...
...
@@ -83,11 +83,6 @@ class ColorMap(object):
qcolor Values are returned as an array of QColor objects.
=========== ===============================================================
"""
try
:
import
scipy.interpolate
except
:
raise
Exception
(
"Colormap.map() requires the package scipy.interpolate, but it could not be imported."
)
if
isinstance
(
mode
,
basestring
):
mode
=
self
.
enumMap
[
mode
.
lower
()]
...
...
@@ -96,15 +91,24 @@ class ColorMap(object):
else
:
pos
,
color
=
self
.
getStops
(
mode
)
data
=
np
.
clip
(
data
,
pos
.
min
(),
pos
.
max
())
# don't need this--np.interp takes care of it.
#data = np.clip(data, pos.min(), pos.max())
if
not
isinstance
(
data
,
np
.
ndarray
):
interp
=
scipy
.
interpolate
.
griddata
(
pos
,
color
,
np
.
array
([
data
]))[
0
]
# Interpolate
# TODO: is griddata faster?
# interp = scipy.interpolate.griddata(pos, color, data)
if
np
.
isscalar
(
data
):
interp
=
np
.
empty
((
color
.
shape
[
1
],),
dtype
=
color
.
dtype
)
else
:
interp
=
scipy
.
interpolate
.
griddata
(
pos
,
color
,
data
)
if
not
isinstance
(
data
,
np
.
ndarray
):
data
=
np
.
array
(
data
)
interp
=
np
.
empty
(
data
.
shape
+
(
color
.
shape
[
1
],),
dtype
=
color
.
dtype
)
for
i
in
range
(
color
.
shape
[
1
]):
interp
[...,
i
]
=
np
.
interp
(
data
,
pos
,
color
[:,
i
])
# Convert to QColor if requested
if
mode
==
self
.
QCOLOR
:
if
n
ot
isinstance
(
data
,
np
.
ndarray
):
if
n
p
.
isscalar
(
data
):
return
QtGui
.
QColor
(
*
interp
)
else
:
return
[
QtGui
.
QColor
(
*
x
)
for
x
in
interp
]
...
...
Write
Preview
Supports
Markdown
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