LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
pipe_tasks
11.0-2-g818369d
python
lsst
pipe
tasks
mocks
visualization.py
Go to the documentation of this file.
1
#
2
# LSST Data Management System
3
# Copyright 2008, 2009, 2010, 2011, 2012 LSST Corporation.
4
#
5
# This product includes software developed by the
6
# LSST Project (http://www.lsst.org/).
7
#
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the LSST License Statement and
19
# the GNU General Public License along with this program. If not,
20
# see <http://www.lsstcorp.org/LegalNotices/>.
21
#
22
23
from
matplotlib
import
pyplot
24
25
import
lsst.afw.geom
26
27
def
plotObservations
(catalog, wcs):
28
"""Plot the bounding boxes of an observation catalog (see MockCoaddTask.buildObservationCatalog)
29
using matplotlib, in the coordinates defined by the given Wcs (usually a skymap Wcs).
30
"""
31
for
record
in
catalog:
32
box =
lsst.afw.geom.Box2D
(record.getBBox())
33
x = []
34
y = []
35
iWcs = record.getWcs()
36
for
xi, yi
in
box.getCorners():
37
try
:
38
coord = iWcs.pixelToSky(xi, yi)
39
xo, yo = wcs.skyToPixel(coord)
40
x.append(xo)
41
y.append(yo)
42
except
:
43
print
"WARNING: point %d, %d failed"
% (xi, yi)
44
pyplot.fill(x, y, facecolor=
'
r', alpha=0.1, edgecolor=None)
45
46
def
plotPatches
(tractInfo):
47
"""Plot the patches in a skymap tract using matplotlib.
48
"""
49
nPatchX, nPatchY = tractInfo.getNumPatches()
50
for
iPatchX
in
range(nPatchX):
51
for
iPatchY
in
range(nPatchY):
52
patchInfo = tractInfo.getPatchInfo((iPatchX, iPatchY))
53
xp1, yp1 = zip(*patchInfo.getOuterBBox().getCorners())
54
xp2, yp2 = zip(*patchInfo.getInnerBBox().getCorners())
55
pyplot.fill(xp1, yp1, fill=
False
, edgecolor=
'g'
, linestyle=
'dashed'
)
56
pyplot.fill(xp2, yp2, fill=
False
, edgecolor=
'g'
)
57
58
def
plotTruth
(catalog, wcs):
59
"""Plot the objects in a truth catalog as dots using matplotlib, in the coordinate
60
system defined by the given Wcs.
61
"""
62
xp = []
63
yp = []
64
for
record
in
catalog:
65
x, y = wcs.skyToPixel(record.getCoord())
66
xp.append(x)
67
yp.append(y)
68
pyplot.plot(xp, yp,
'k+'
)
69
70
def
displayImages
(root):
71
"""Display coadd images with DS9 in different frames, with the bounding boxes of the
72
observations that went into them overlayed.
73
"""
74
import
lsst.afw.display.ds9
75
import
lsst.afw.display.utils
76
butler =
lsst.daf.persistence.Butler
(root=root)
77
skyMap = butler.get(
"deepCoadd_skyMap"
)
78
tractInfo = skyMap[0]
79
task = lsst.pipe.tasks.mocks.MockCoaddTask()
80
coadds = [patchRef.get(
"deepCoadd"
, immediate=
True
)
81
for
patchRef
in
task.iterPatchRefs(butler, tractInfo)]
82
for
n, coadd
in
enumerate(coadds):
83
lsst.afw.display.ds9.mtv
(coadd, frame=n+1)
84
for
n, coadd
in
enumerate(coadds):
85
lsst.afw.display.utils.drawCoaddInputs
(coadd, frame=n+1)
86
return
butler
87
88
def
makePlots
(root):
89
"""Convenience function to make all matplotlib plots.
90
"""
91
import
lsst.pipe.tasks.mocks
92
import
lsst.daf.persistence
93
butler =
lsst.daf.persistence.Butler
(root=root)
94
skyMap = butler.get(
"deepCoadd_skyMap"
)
95
observations = butler.get(
"observations"
, tract=0)
96
truth = butler.get(
"truth"
, tract=0)
97
tractInfo = skyMap[0]
98
plotPatches
(tractInfo)
99
plotObservations
(observations, tractInfo.getWcs())
100
plotTruth
(truth, tractInfo.getWcs())
101
pyplot.axis(
"scaled"
)
102
pyplot.show()
103
return
butler
lsst::afw.display.ds9
Definition:
ds9.py:1
lsst::daf::persistence
Definition:
Utils.h:44
lsst.pipe.tasks.mocks.visualization.plotObservations
def plotObservations
Definition:
visualization.py:27
lsst::daf::persistence.butler.Butler
Definition:
butler.py:38
lsst::afw.display.ds9.mtv
def mtv
Definition:
ds9.py:79
lsst::afw.display.utils.drawCoaddInputs
def drawCoaddInputs
Definition:
utils.py:351
lsst.pipe.tasks.mocks
Definition:
__init__.py:1
lsst.pipe.tasks.mocks.visualization.plotTruth
def plotTruth
Definition:
visualization.py:58
lsst::afw.display.utils
Definition:
utils.py:1
lsst.pipe.tasks.mocks.visualization.plotPatches
def plotPatches
Definition:
visualization.py:46
lsst.pipe.tasks.mocks.visualization.displayImages
def displayImages
Definition:
visualization.py:70
lsst::afw::geom
Definition:
AffineTransform.h:38
lsst::afw::geom::Box2D
A floating-point coordinate rectangle geometry.
Definition:
Box.h:271
lsst.pipe.tasks.mocks.visualization.makePlots
def makePlots
Definition:
visualization.py:88
Generated on Thu Sep 24 2015 02:29:24 for LSSTApplications by
1.8.5