def testTopocentric(self): """Verify Altitude/Azimuth coordinate transforms""" # try converting the RA,Dec of Sedna (on the specified date) to Alt/Az # sedna (from jpl) for 2010-03-03 00:00 UT ra, dec = "03:26:42.61", "+06:32:07.1" az, alt = 231.5947, 44.3375 obs = afwCoord.Observatory(-74.659 * afwGeom.degrees, 40.384 * afwGeom.degrees, 100.0) # peyton obsDate = dafBase.DateTime(2010, 3, 3, 0, 0, 0, dafBase.DateTime.TAI) epoch = obsDate.get(dafBase.DateTime.EPOCH) sedna = afwCoord.Fk5Coord(ra, dec, epoch) altaz = sedna.toTopocentric(obs, obsDate) print("Topocentric (Sedna): ", altaz.getAltitude().asDegrees(), altaz.getAzimuth().asDegrees(), alt, az) self.assertEqual(altaz.getCoordSystem(), afwCoord.TOPOCENTRIC) # precision is low as we don't account for as much as jpl (abberation, nutation, etc) self.assertAlmostEqual(altaz.getAltitude().asDegrees(), alt, 1) self.assertAlmostEqual(altaz.getAzimuth().asDegrees(), az, 1) # convert back to RA,Dec to check the roundtrip sedna2 = altaz.toFk5(epoch) ra2, dec2 = sedna2.getRa().asDegrees(), sedna2.getDec().asDegrees() print("Topocentric roundtrip (Sedna): ", sedna.getRa().asDegrees(), ra2, sedna.getDec().asDegrees(), dec2) self.assertAlmostEqual(sedna.getRa().asDegrees(), ra2) self.assertAlmostEqual(sedna.getDec().asDegrees(), dec2)
def testNames(self): """Test the names of the Coords (Useful with Point2D form)""" # verify that each coordinate type can tell you what its components are called. radec1, known1 = afwCoord.Coord( self.ra, self.dec).getCoordNames(), ["RA", "Dec"] radec3, known3 = afwCoord.Fk5Coord( self.ra, self.dec).getCoordNames(), ["RA", "Dec"] radec4, known4 = afwCoord.IcrsCoord( self.ra, self.dec).getCoordNames(), ["RA", "Dec"] lb, known5 = afwCoord.GalacticCoord( self.ra, self.dec).getCoordNames(), ["L", "B"] lambet, known6 = afwCoord.EclipticCoord( self.ra, self.dec).getCoordNames(), ["Lambda", "Beta"] observatory = afwCoord.Observatory(0 * afwGeom.degrees, 0 * afwGeom.degrees, 0) altaz = afwCoord.TopocentricCoord(self.ra, self.dec, 2000.0, observatory).getCoordNames() known7 = ["Az", "Alt"] pairs = [ [radec1, known1], [radec3, known3], [radec4, known4], [lb, known5], [lambet, known6], [altaz, known7], ] for pair, known in (pairs): self.assertEqual(pair[0], known[0]) self.assertEqual(pair[1], known[1])
def coordIter(self, includeCoord=True): """Return a collection of coords, one per class @param[in] includeCoord if True then include lsst.afw.coord.Coord (the base class) in the list of classes instantiated """ if includeCoord: yield afwCoord.Coord(self.l * afwGeom.degrees, self.b * afwGeom.degrees) for coordClass, enum, cast, stringName in self.coordList: yield coordClass(self.l * afwGeom.degrees, self.b * afwGeom.degrees) obs = afwCoord.Observatory(-74.659 * afwGeom.degrees, 40.384 * afwGeom.degrees, 100.0) # peyton obsDate = dafBase.DateTime(2010, 3, 3, 0, 0, 0, dafBase.DateTime.TAI) epoch = obsDate.get(dafBase.DateTime.EPOCH) yield afwCoord.TopocentricCoord( 23.4 * afwGeom.degrees, 45.6 * afwGeom.degrees, epoch, obs, )