Commit 9e4f799b authored by Leo Pound Singer's avatar Leo Pound Singer

Move lalinference.{cmap,marker} into new lalinference.plot package

Original: d144bea33abdc468c958e88652ed541ede64a67e
parent 868f4992
......@@ -21,6 +21,7 @@ AC_CONFIG_FILES([ \
python/lalinference/rapid_pe/Makefile \
python/lalinference/imrtgr/Makefile \
python/lalinference/tiger/Makefile \
python/lalinference/plot/Makefile \
python/lalinference/popprior/Makefile \
src/LALInferenceVCSInfo.c \
src/LALInferenceVCSInfo.h \
......
......@@ -10,6 +10,7 @@ SUBDIRS = \
imrtgr \
io \
tiger \
plot \
popprior \
$(END_OF_LIST)
......@@ -25,27 +26,9 @@ pymodule_PYTHON = \
fits.py \
healpix_tree.py \
marker.py \
plot.py \
lalinference_pipe_utils.py \
nest2pos.py \
git_version.py \
$(END_OF_LIST)
endif
dist_pymodule_DATA = \
cylon.csv \
ne_simplified_coastline.json \
$(END_OF_LIST)
EXTRA_DIST += \
cylon.py \
$(END_OF_LIST)
#
# Note: the following script generates a color map RGB data file.
# The output file is distributed to avoid a build dependency on the Python
# `colormath` package (https://pypi.python.org/pypi/colormath).
#
# $(srcdir)/cylon.csv: $(srcdir)/cylon.py
# $(AM_V_GEN)$(PYTHON) $< > $@
#
# Copyright (C) 2014-2016 Leo Singer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""Register some extra Matplotlib color maps"""
__all__ = ()
from matplotlib import cm
from matplotlib import colors
import pkg_resources
import numpy as np
import errno
import os
import warnings
for name in ['cylon']:
# Read in color map RGB data.
try:
with pkg_resources.resource_stream(__name__, name + '.csv') as f:
data = np.loadtxt(f, delimiter=',')
except IOError as e:
warnings.warn('Failed to load "{0}" colormap'.format(name))
continue
# Create color map.
cmap = colors.LinearSegmentedColormap.from_list(name, data)
# Assign in module.
locals().update({name: cmap})
# Register with Matplotlib.
cm.register_cmap(cmap=cmap)
# Generate reversed color map.
name += '_r'
data = data[::-1]
cmap = colors.LinearSegmentedColormap.from_list(name, data)
# Assign in module.
locals().update({name: cmap})
# Register with Matplotlib.
cm.register_cmap(cmap=cmap)
warnings.warn(
'The module `lalinference.cmap` has been deprecated. Please import '
'`lalinference.plot.cmap` instead.')
from .plot.cmap import *
#
# Copyright (C) 2016 Leo Singer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Specialized markers
"""
__all__ = ('earth', 'reticle')
from matplotlib.path import Path
import numpy as np
"""The Earth symbol (circle and cross)."""
earth = Path.unit_circle()
verts = np.concatenate([earth.vertices, [[-1, 0], [1, 0], [0, -1], [0, 1]]])
codes = np.concatenate([earth.codes, [Path.MOVETO, Path.LINETO] * 2])
earth = Path(verts, codes)
del verts, codes
def reticle(inner=0.5, outer=1.0, angle=0.0):
"""
Create a reticle (crosshairs) marker.
Parameters
----------
inner : float
Distance from the origin to the inside of the crosshairs.
outer : float
Distance from the origin to the outside of the crosshairs.
angle : float
Rotation in degrees; 0 for a '+' orientation and 45 'x'.
Returns
-------
path : `matplotlib.path.Path`
The new marker path, suitable for passing to Matplotlib functions
(e.g., `plt.plot(..., marker=reticle())`)
"""
angle = np.deg2rad(angle)
x = np.cos(angle)
y = np.sin(angle)
R = [[x, y], [-y, x]]
codes = [Path.MOVETO, Path.LINETO] * 4
verts = [[0, 1], [1, 0], [0, -1], [-1, 0]]
verts = np.dot(verts, R)
verts = np.swapaxes([inner * verts, outer * verts], 0, 1).reshape(-1, 2)
return Path(verts, codes)
import warnings
warnings.warn(
'The module `lalinference.marker` has been deprecated. Please import '
'`lalinference.plot.marker` instead.')
from .plot.marker import *
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
if HAVE_PYTHON
pymoduledir = $(pkgpythondir)/plot
pymodule_PYTHON = \
__init__.py \
cmap.py \
marker.py \
$(END_OF_LIST)
endif
dist_pymodule_DATA = \
cylon.csv \
ne_simplified_coastline.json \
$(END_OF_LIST)
EXTRA_DIST += \
cylon.py \
$(END_OF_LIST)
#
# Note: the following script generates a color map RGB data file.
# The output file is distributed to avoid a build dependency on the Python
# `colormath` package (https://pypi.python.org/pypi/colormath).
#
# $(srcdir)/cylon.csv: $(srcdir)/cylon.py
# $(AM_V_GEN)$(PYTHON) $< > $@
#
# Copyright (C) 2014-2016 Leo Singer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""Register some extra Matplotlib color maps"""
__all__ = ()
from matplotlib import cm
from matplotlib import colors
import pkg_resources
import numpy as np
import errno
import os
import warnings
for name in ['cylon']:
# Read in color map RGB data.
try:
with pkg_resources.resource_stream(__name__, name + '.csv') as f:
data = np.loadtxt(f, delimiter=',')
except IOError as e:
warnings.warn('Failed to load "{0}" colormap'.format(name))
continue
# Create color map.
cmap = colors.LinearSegmentedColormap.from_list(name, data)
# Assign in module.
locals().update({name: cmap})
# Register with Matplotlib.
cm.register_cmap(cmap=cmap)
# Generate reversed color map.
name += '_r'
data = data[::-1]
cmap = colors.LinearSegmentedColormap.from_list(name, data)
# Assign in module.
locals().update({name: cmap})
# Register with Matplotlib.
cm.register_cmap(cmap=cmap)
#
# Copyright (C) 2016 Leo Singer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Specialized markers
"""
__all__ = ('earth', 'reticle')
from matplotlib.path import Path
import numpy as np
"""The Earth symbol (circle and cross)."""
earth = Path.unit_circle()
verts = np.concatenate([earth.vertices, [[-1, 0], [1, 0], [0, -1], [0, 1]]])
codes = np.concatenate([earth.codes, [Path.MOVETO, Path.LINETO] * 2])
earth = Path(verts, codes)
del verts, codes
def reticle(inner=0.5, outer=1.0, angle=0.0):
"""
Create a reticle (crosshairs) marker.
Parameters
----------
inner : float
Distance from the origin to the inside of the crosshairs.
outer : float
Distance from the origin to the outside of the crosshairs.
angle : float
Rotation in degrees; 0 for a '+' orientation and 45 'x'.
Returns
-------
path : `matplotlib.path.Path`
The new marker path, suitable for passing to Matplotlib functions
(e.g., `plt.plot(..., marker=reticle())`)
"""
angle = np.deg2rad(angle)
x = np.cos(angle)
y = np.sin(angle)
R = [[x, y], [-y, x]]
codes = [Path.MOVETO, Path.LINETO] * 4
verts = [[0, 1], [1, 0], [0, -1], [-1, 0]]
verts = np.dot(verts, R)
verts = np.swapaxes([inner * verts, outer * verts], 0, 1).reshape(-1, 2)
return Path(verts, codes)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment