LSSTApplications  11.0-24-g0a022a1,14.0+77,15.0,15.0+1
LSSTDataManagementBasePackage
Classes | Functions
lsst.skypix.quadsphere Namespace Reference

Classes

class  QuadSpherePixelization
 

Functions

def _rotX (v, sin, cos)
 
def _rotY (v, sin, cos)
 
def _rotZ (v, sin, cos)
 
def _rotNX (v, sin, cos)
 
def _rotNY (v, sin, cos)
 
def _rotNZ (v, sin, cos)
 
def createQuadSpherePixelization (policy=None)
 
def imageToPolygon (wcs, widthPix, heightPix, padRad=0.0)
 

Function Documentation

◆ _rotNX()

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

Definition at line 47 of file quadsphere.py.

47 def _rotNX(v, sin, cos):
48  return _rotX(v, -sin, cos)
49 
50 
def _rotNX(v, sin, cos)
Definition: quadsphere.py:47
def _rotX(v, sin, cos)
Definition: quadsphere.py:35

◆ _rotNY()

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

Definition at line 51 of file quadsphere.py.

51 def _rotNY(v, sin, cos):
52  return _rotY(v, -sin, cos)
53 
54 
def _rotY(v, sin, cos)
Definition: quadsphere.py:39
def _rotNY(v, sin, cos)
Definition: quadsphere.py:51

◆ _rotNZ()

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

Definition at line 55 of file quadsphere.py.

55 def _rotNZ(v, sin, cos):
56  return _rotZ(v, -sin, cos)
57 
58 
def _rotZ(v, sin, cos)
Definition: quadsphere.py:43
def _rotNZ(v, sin, cos)
Definition: quadsphere.py:55

◆ _rotX()

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

Definition at line 35 of file quadsphere.py.

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

◆ _rotY()

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

Definition at line 39 of file quadsphere.py.

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

◆ _rotZ()

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

Definition at line 43 of file quadsphere.py.

43 def _rotZ(v, sin, cos):
44  return (v[0] * cos - v[1] * sin, v[0] * sin + v[1] * cos, v[2])
45 
46 
def _rotZ(v, sin, cos)
Definition: quadsphere.py:43

◆ createQuadSpherePixelization()

def lsst.skypix.quadsphere.createQuadSpherePixelization (   policy = None)

Definition at line 773 of file quadsphere.py.

773 def createQuadSpherePixelization(policy=None):
774  policyFile = pexPolicy.DefaultPolicyFile(
775  "skypix", "QuadSpherePixelizationDictionary.paf", "policy")
776  defaults = pexPolicy.Policy.createPolicy(
777  policyFile, policyFile.getRepositoryPath())
778  if policy is None:
779  policy = pexPolicy.Policy()
780  policy.mergeDefaults(defaults)
781  # Obtain resolution and padding from policy
782  resolution = policy.get('resolutionPix')
783  padding = math.radians(policy.get('paddingArcsec') / 3600.0)
784  return QuadSpherePixelization(resolution, padding)
785 
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 createQuadSpherePixelization(policy=None)
Definition: quadsphere.py:773

◆ imageToPolygon()

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.

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