LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
LSSTDataManagementBasePackage
Classes | Functions
lsst.skypix.quadsphere Namespace Reference

Classes

class  QuadSpherePixelization
 

Functions

def _rotX
 
def _rotY
 
def _rotZ
 
def _rotNX
 
def _rotNY
 
def _rotNZ
 
def createQuadSpherePixelization
 
def imageToPolygon
 

Function Documentation

def lsst.skypix.quadsphere._rotNX (   v,
  sin,
  cos 
)
private

Definition at line 47 of file quadsphere.py.

47 
48 def _rotNX(v, sin, cos):
49  return _rotX(v, -sin, cos)
50 
def lsst.skypix.quadsphere._rotNY (   v,
  sin,
  cos 
)
private

Definition at line 51 of file quadsphere.py.

51 
52 def _rotNY(v, sin, cos):
53  return _rotY(v, -sin, cos)
54 
def lsst.skypix.quadsphere._rotNZ (   v,
  sin,
  cos 
)
private

Definition at line 55 of file quadsphere.py.

55 
56 def _rotNZ(v, sin, cos):
57  return _rotZ(v, -sin, cos)
58 
def lsst.skypix.quadsphere._rotX (   v,
  sin,
  cos 
)
private

Definition at line 35 of file quadsphere.py.

35 
36 def _rotX(v, sin, cos):
37  return (v[0], v[1] * cos - v[2] * sin, v[1] * sin + v[2] * cos)
38 
def lsst.skypix.quadsphere._rotY (   v,
  sin,
  cos 
)
private

Definition at line 39 of file quadsphere.py.

39 
40 def _rotY(v, sin, cos):
41  return (v[0] * cos + v[2] * sin, v[1], -v[0] * sin + v[2] * cos)
42 
def lsst.skypix.quadsphere._rotZ (   v,
  sin,
  cos 
)
private

Definition at line 43 of file quadsphere.py.

43 
44 def _rotZ(v, sin, cos):
45  return (v[0] * cos - v[1] * sin, v[0] * sin + v[1] * cos, v[2])
46 
def lsst.skypix.quadsphere.createQuadSpherePixelization (   policy = None)

Definition at line 773 of file quadsphere.py.

774 def createQuadSpherePixelization(policy=None):
775  policyFile = pexPolicy.DefaultPolicyFile(
776  "skypix", "QuadSpherePixelizationDictionary.paf", "policy")
777  defaults = pexPolicy.Policy.createPolicy(
778  policyFile, policyFile.getRepositoryPath())
779  if policy is None:
780  policy = pexPolicy.Policy()
781  policy.mergeDefaults(defaults)
782  # Obtain resolution and padding from policy
783  resolution = policy.get('resolutionPix')
784  padding = math.radians(policy.get('paddingArcsec') / 3600.0)
785  return QuadSpherePixelization(resolution, padding)
786 
a container for holding hierarchical configuration data in memory.
Definition: Policy.h:169
a representation of a default Policy file that is stored as a file in the installation directory of a...
def lsst.skypix.quadsphere.imageToPolygon (   wcs,
  widthPix,
  heightPix,
  padRad = 0.0 
)
Computes and returns a spherical convex polygon approximation to the
region of the unit sphere covered by an image specified with a WCS and
a width/height (pixels). The polygon is computed by connecting the 
world coordinates of the 4 image corners with great circles, and can
optionally be padded by padRad radians.

Definition at line 787 of file quadsphere.py.

788 def imageToPolygon(wcs, widthPix, heightPix, padRad=0.0):
789  """Computes and returns a spherical convex polygon approximation to the
790  region of the unit sphere covered by an image specified with a WCS and
791  a width/height (pixels). The polygon is computed by connecting the
792  world coordinates of the 4 image corners with great circles, and can
793  optionally be padded by padRad radians.
794  """
795  # Compute image corners
796  cd = wcs.getCDMatrix()
797  xpad = math.degrees(padRad) / math.sqrt(cd[0, 0]**2 + cd[0, 1]**2)
798  ypad = math.degrees(padRad) / math.sqrt(cd[1, 0]**2 + cd[1, 1]**2)
799  xmin, ymin = -0.5 - xpad, -0.5 - ypad
800  xmax, ymax = widthPix + xpad - 0.5, heightPix + ypad - 0.5
801  # Produce a lsst.afw.coord.coordLib.Coord object for each vertex
802  coords = [wcs.pixelToSky(xmin, ymin), wcs.pixelToSky(xmax, ymin),
803  wcs.pixelToSky(xmax, ymax), wcs.pixelToSky(xmin, ymax)]
804  # Map these to python tuples containing cartesian unit vectors
805  verts = []
806  for c in coords:
807  verts.append(tuple(c.getVector()))
808  # and turn them into a spherical convex polygon
809  convex, cc = geom.convex(verts)
810  if not convex:
811  raise RuntimeError('Image corners do not form a convex polygon: ' + cc)
812  elif not cc:
813  verts.reverse()
814  return geom.SphericalConvexPolygon(verts)