Skip to content

Commit

Permalink
post review cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
parejkoj committed Dec 18, 2018
1 parent 4060c64 commit 2ca9271
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 118 deletions.
1 change: 0 additions & 1 deletion doc/lsst.skymap/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Python API reference
:no-main-docstr:
:no-inheritance-diagram:
.. automodapi:: lsst.skymap.detail
.. automodapi:: lsst.skymap.baseSkyMap
.. automodapi:: lsst.skymap.cachingSkyMap
.. automodapi:: lsst.skymap.healpixSkyMap
.. automodapi:: lsst.skymap.ringsSkyMap
30 changes: 13 additions & 17 deletions python/lsst/skymap/baseSkyMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
rather than the scale at the center.
"""

__all__ = ["BaseSkyMapConfig", "BaseSkyMap"]

import hashlib
import struct

import lsst.pex.config as pexConfig
from lsst.geom import SpherePoint, Angle, arcseconds, degrees
from . import detail

__all__ = ["BaseSkyMapConfig", "BaseSkyMap"]


class BaseSkyMapConfig(pexConfig.Config):
patchInnerDimensions = pexConfig.ListField(
Expand Down Expand Up @@ -76,6 +76,11 @@ class BaseSkyMap:
See TractInfo for more information.
Parameters
----------
config : `BaseSkyMapConfig` or None
The configuration for this SkyMap; if None use the default config.
Notes
-----
BaseSkyMap is an abstract base class. Subclasses must do the following:
Expand All @@ -95,13 +100,6 @@ class BaseSkyMap:
ConfigClass = BaseSkyMapConfig

def __init__(self, config=None):
"""Construct a BaseSkyMap
Parameters
----------
config : `BaseSkyMapConfig` or None
The configuration for this SkyMap; if None use the default config.
"""
if config is None:
config = self.ConfigClass()
config.freeze() # just to be sure, e.g. for pickling
Expand All @@ -120,7 +118,7 @@ def findTract(self, coord):
Parameters
----------
coord : `lsst.afw.geom.SpherePoint`
ICRS sky coordinate
ICRS sky coordinate to search for.
Returns
-------
Expand All @@ -129,8 +127,6 @@ def findTract(self, coord):
Notes
-----
- This routine will be more efficient if coord is ICRS.
- If coord is equidistant between multiple sky tract centers then one
is arbitrarily chosen.
Expand All @@ -155,7 +151,7 @@ def findTractPatchList(self, coordList):
Parameters
----------
coordList : `lsst.afw.geom.SpherePoint`
list of ICRS sky coordinates
List of ICRS sky coordinates to search for.
Returns
-------
Expand Down Expand Up @@ -183,7 +179,7 @@ def findClosestTractPatchList(self, coordList):
Parameters
----------
coordList : `lsst.afw.geom.SpherePoint`
list of ICRS sky coordinates
List of ICRS sky coordinates to search for.
Returns
-------
Expand Down Expand Up @@ -289,7 +285,7 @@ def register(self, name, registry):
registry.addDimensionEntry(
"Patch",
{"skymap": name, "tract": tractInfo.getId(),
"patch": tractInfo.getSequentialPatchIndex(patchInfo),
"cell_x": cellX, "cell_y": cellY,
"region": patchInfo.getOuterSkyPolygon(tractInfo.getWcs())}
"patch": tractInfo.getSequentialPatchIndex(patchInfo),
"cell_x": cellX, "cell_y": cellY,
"region": patchInfo.getOuterSkyPolygon(tractInfo.getWcs())}
)
18 changes: 15 additions & 3 deletions python/lsst/skymap/cachingSkyMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,26 @@
# see <http://www.lsstcorp.org/LegalNotices/>.
#

from .baseSkyMap import BaseSkyMap
__all__ = ["CachingSkyMap"]

__all__ = ["CachingSkyMap", ]
from .baseSkyMap import BaseSkyMap


class CachingSkyMap(BaseSkyMap):
"""A SkyMap that generates its tracts on request and caches them
"""A SkyMap that generates its tracts on request and caches them.
Parameters
----------
numTracts : `int`
Number of tracts to create.
config : `lsst.skymap.baseSkyMap.ConfigClass`
The configuration, or None to use the default.
version : `int` or `tuple` of `int` (optional)
Software version of this class, to retain compatibility with old
instances.
Notes
-----
A subclass should define
* __init__ to calculate the required number of tracts (and pass it up)
* generateTract to generate a tract
Expand Down
28 changes: 16 additions & 12 deletions python/lsst/skymap/detail/dodecahedron.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#!/usr/bin/env python

__all__ = ['Dodecahedron']

import math
import numpy

__all__ = ('Dodecahedron', )


class Dodecahedron:
"""A dodecahedron
"""A dodecahedron with positions of faces and associated vertices.
Parameters
----------
withFacesOnPoles : `bool`
If True center a face on each pole, else put a vertex on each pole.
"""

def __init__(self, withFacesOnPoles=False):
self._withFacesOnPoles = bool(withFacesOnPoles)

Expand Down Expand Up @@ -43,9 +47,8 @@ def getFaceCtrList(self):
Returns
-------
results : `list`
A list of face centers (in index order); each a unit vector
(numpy array).
results : `list` of `numpy.ndarray`
A list of face centers (in index order); each a unit vector.
"""
return self.faceVecList[:]

Expand All @@ -60,7 +63,7 @@ def getFaceCtr(self, ind):
Returns
-------
results : `np.ndarray`
Face center as a unit vector (numpy array).
Face center as a unit vector.
"""
return self.faceVecList[ind][:]

Expand All @@ -75,7 +78,7 @@ def getVertices(self, ind):
Returns
-------
sortedVertexList : `list` of `numpy.ndarray`
A list of vertices, each a unit vector (numpy array).
A list of vertices, each a unit vector.
"""
faceVec = self.getFaceCtr(ind)
vertexList, indList = _findCloseList(self.vertexVecList, faceVec)
Expand Down Expand Up @@ -197,7 +200,8 @@ def _computeFullVecList(basisSet):
"""Given a collection of basis vectors, compute all permutations with both
signs of all nonzero values.
For example:
For example::
[(0, 1, 2)] -> [(0, 1, 2), (0, -1, 2), (0, 1, -2), (0, -1, -2)]
"""
fullSet = []
Expand Down Expand Up @@ -247,7 +251,7 @@ def _findCloseList(vecList, vec):
----------
vecList : `list`
List of cartesian vectors.
vec : `int`
vec : `iterable` of `float`
Vector to be near.
Returns
Expand All @@ -270,7 +274,7 @@ def _findClosePair(vecList, ind=0):
Parameters
----------
vecList : `list`
vecList : `list` of `numpy.ndarray`
List of cartesian vectors.
ind : `int`
Index of first vector.
Expand Down
16 changes: 9 additions & 7 deletions python/lsst/skymap/detail/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#

__all__ = ["coordFromVec"]

import numpy

import lsst.sphgeom
import lsst.afw.geom as afwGeom

__all__ = ["coordFromVec"]

_TinyFloat = numpy.finfo(float).tiny

Expand All @@ -34,16 +36,16 @@ def coordFromVec(vec, defRA=None):
Parameters
----------
vec :
an ICRS catesian vector as a sequence of three floats
defRA :
the RA to use if the vector is too near a pole (an afwGeom Angle);
ignored if not near a pole
vec : `list` of `float`
An ICRS catesian vector.
defRA : `lsst.geom.Angle` or None
The RA to use if the vector is too near a pole;
ignored if not near a pole.
Raises
------
RuntimeError
if vec too near a pole and defRA is None
If vec too near a pole and defRA is None.
"""
if abs(vec[0]) < _TinyFloat and abs(vec[1]) < _TinyFloat:
if defRA is None:
Expand Down
47 changes: 24 additions & 23 deletions python/lsst/skymap/detail/wcsFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,50 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
import lsst.afw.geom as afwGeom

__all__ = ('WcsFactory', )
__all__ = ['WcsFactory']

import lsst.afw.geom as afwGeom


class WcsFactory:
"""A factory for creating Wcs objects for the sky tiles.
Parameters
----------
pixelScale : `lsst.geom.Angle`
Desired scale, as sky/pixel.
projection : `str`
FITS-standard 3-letter name of projection, e.g.: TAN (tangent),
STG (stereographic), MOL (Mollweide's), AIT (Hammer-Aitoff)
see Representations of celestial coordinates in FITS
(Calabretta and Greisen, 2002).
rotation : `lsst.geom.Angle`
Rotation relative to cardinal.
flipX : `bool`
Flip the X axis?
"""

def __init__(self, pixelScale, projection, rotation=0*afwGeom.radians, flipX=False):
"""Make a WcsFactory
Parameters
----------
pixelScale :
desired scale, as sky/pixel, an afwGeom.Angle
projection :
FITS-standard 3-letter name of projection, e.g.:
TAN (tangent), STG (stereographic), MOL (Mollweide's), AIT (Hammer-Aitoff)
see Representations of celestial coordinates in FITS (Calabretta and Greisen, 2002)
rotation :
Rotation relative to cardinal, as an lsst.afw.geom.Angle
flipX :
Flip the X axis?
"""
if len(projection) != 3:
raise RuntimeError("projection=%r; must have length 3" % (projection,))
self._projection = projection
self._cdMatrix = afwGeom.makeCdMatrix(scale=pixelScale, orientation=rotation, flipX=flipX)

def makeWcs(self, crPixPos, crValCoord):
"""Make a Wcs
"""Make a Wcs.
Parameters
----------
crPixPos :
crPix for WCS, using the LSST standard; an afwGeom.Point2D or pair of floats
crValCoord :
ICRS crVal for WCS (lsst.afw.geom.SpherePoint)
crPixPos : `lsst.geom.Point2D`
crPix for WCS, using the LSST standard.
crValCoord : `lsst.geom.SpherePoint`
ICRS crVal for WCS.
Returns
-------
results : `afwGeom.makeSkyWcs`
results : `lsst.afw.geom.SkyWcs`
The new SkyWcs object.
"""
return afwGeom.makeSkyWcs(crpix=crPixPos, crval=crValCoord,
cdMatrix=self._cdMatrix, projection=self._projection)
10 changes: 5 additions & 5 deletions python/lsst/skymap/discreteSkyMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
# see <http://www.lsstcorp.org/LegalNotices/>.
#

__all__ = ["DiscreteSkyMap"]

import struct

from lsst.pex.config import ListField
import lsst.afw.geom as afwGeom
from .cachingSkyMap import CachingSkyMap
from .tractInfo import ExplicitTractInfo

__all__ = ["DiscreteSkyMap", ]


class DiscreteSkyMapConfig(CachingSkyMap.ConfigClass):
"""Configuration for the DiscreteSkyMap"""
Expand All @@ -54,9 +54,9 @@ class DiscreteSkyMap(CachingSkyMap):
Parameters
----------
config : `lsst.skyMap.CachingSkyMap.ConfigClass`
If None the default config is used.
version :
config : `lsst.skyMap.baseSkyMap.ConfigClass`
The configuration, or None to use the default.
version : `int` or `tuple` of `int` (optional)
Software version of this class, to retain compatibility with old
instances.
"""
Expand Down

0 comments on commit 2ca9271

Please sign in to comment.