LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
Namespaces | Classes | Enumerations | Functions
lsst::afw::coord Namespace Reference

Namespaces

 utils
 

Classes

class  Coord
 This is the base class for spherical coordinates. More...
 
class  IcrsCoord
 A class to handle Icrs coordinates (inherits from Coord) More...
 
class  Fk5Coord
 A class to handle Fk5 coordinates (inherits from Coord) More...
 
class  GalacticCoord
 A class to handle Galactic coordinates (inherits from Coord) More...
 
class  EclipticCoord
 A class to handle Ecliptic coordinates (inherits from Coord) More...
 
class  TopocentricCoord
 A class to handle topocentric (AltAz) coordinates (inherits from Coord) More...
 
class  Observatory
 Hold the location of an observatory. More...
 
class  Weather
 Basic weather information sufficient for a simple model for air mass or refraction. More...
 

Enumerations

enum  CoordSystem {
  UNKNOWN =-1, FK5, ICRS, GALACTIC,
  ECLIPTIC, TOPOCENTRIC
}
 

Functions

std::ostream & operator<< (std::ostream &os, Observatory const &obs)
 
std::ostream & operator<< (std::ostream &os, Weather const &weath)
 print a Weather to an output stream More...
 
CoordSystem makeCoordEnum (std::string const system)
 A utility function to get the enum value of a coordinate system from a string name. More...
 
boost::shared_ptr< CoordmakeCoord (CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
 Factory function to create a Coord of arbitrary type with decimal RA,Dec. More...
 
boost::shared_ptr< CoordmakeCoord (CoordSystem const system, std::string const ra, std::string const dec, double const epoch)
 Factory function to create a Coord of arbitrary type with string RA [in degrees, not hours!], Dec. More...
 
boost::shared_ptr< CoordmakeCoord (CoordSystem const system, lsst::afw::geom::Point2D const &p2d, lsst::afw::geom::AngleUnit unit, double const epoch)
 Factory function to create a Coord of arbitrary type with Point2D. More...
 
boost::shared_ptr< CoordmakeCoord (CoordSystem const system, lsst::afw::geom::Point3D const &p3d, double const epoch, bool normalize=true, lsst::afw::geom::Angle const defaultLongitude=lsst::afw::geom::Angle(0.))
 Factory function to create a Coord of arbitrary type with a Point3D. More...
 
boost::shared_ptr< CoordmakeCoord (CoordSystem const system)
 Lightweight factory to make an empty coord. More...
 
boost::shared_ptr< CoordmakeCoord (CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec)
 Factory function to create a Coord of arbitrary type with decimal RA,Dec in degrees. More...
 
boost::shared_ptr< CoordmakeCoord (CoordSystem const system, std::string const ra, std::string const dec)
 Factory function to create a Coord of arbitrary type with string RA [in degrees, not hours!], Dec. More...
 
boost::shared_ptr< CoordmakeCoord (CoordSystem const system, lsst::afw::geom::Point2D const &p2d, lsst::afw::geom::AngleUnit unit)
 Factory function to create a Coord of arbitrary type with Point2D. More...
 
boost::shared_ptr< CoordmakeCoord (CoordSystem const system, lsst::afw::geom::Point3D const &p3d, bool normalize=true, lsst::afw::geom::Angle const defaultLongitude=lsst::afw::geom::Angle(0.))
 Factory function to create a Coord of arbitrary type with a Point3D. More...
 
boost::shared_ptr< CoordaverageCoord (std::vector< boost::shared_ptr< Coord const >> const coords, CoordSystem system=UNKNOWN)
 Return average of a list of coordinates. More...
 
lsst::afw::geom::Angle eclipticPoleInclination (double const epoch)
 get the inclination of the ecliptic pole (obliquity) at epoch More...
 
lsst::afw::geom::Angle dmsStringToAngle (std::string const dms)
 Convert a dd:mm:ss string to Angle. More...
 
lsst::afw::geom::Angle hmsStringToAngle (std::string const hms)
 Convert a hh:mm:ss string to Angle. More...
 
std::string angleToDmsString (lsst::afw::geom::Angle const deg)
 a Function to convert a coordinate in decimal degrees to a string with form dd:mm:ss More...
 
std::string angleToHmsString (lsst::afw::geom::Angle const deg)
 a function to convert decimal degrees to a string with form hh:mm:ss.s More...
 
std::ostream & operator<< (std::ostream &os, Coord const &coord)
 

Enumeration Type Documentation

Enumerator
UNKNOWN 
FK5 
ICRS 
GALACTIC 
ECLIPTIC 
TOPOCENTRIC 

Definition at line 54 of file Coord.h.

Function Documentation

std::string lsst::afw::coord::angleToDmsString ( lsst::afw::geom::Angle const  deg)

a Function to convert a coordinate in decimal degrees to a string with form dd:mm:ss

Todo:
allow a user specified format

Definition at line 293 of file Coord.cc.

293  {
294  return angleToXmsString(a, afwGeom::degrees);
295 }
AngleUnit const degrees
Definition: Angle.h:91
std::string lsst::afw::coord::angleToHmsString ( lsst::afw::geom::Angle const  deg)

a function to convert decimal degrees to a string with form hh:mm:ss.s

Definition at line 300 of file Coord.cc.

300  {
301  return angleToXmsString(a, afwGeom::hours);
302 }
AngleUnit const hours
Definition: Angle.h:92
boost::shared_ptr< Coord > lsst::afw::coord::averageCoord ( std::vector< boost::shared_ptr< Coord const >> const  coords,
CoordSystem  system = UNKNOWN 
)

Return average of a list of coordinates.

Parameters
[in]coordslist of coords to average
[in]systemcoordinate system of returned result; if UNKNOWN then all input coordinates must have the same coordinate system, which is used for the result
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif system is UNKNOWN and the coords do not all have the same coordinate system
afwGeom::Angle lsst::afw::coord::dmsStringToAngle ( std::string const  dms)

Convert a dd:mm:ss string to Angle.

Parameters
dmsCoord as a string in dd:mm:ss format

Definition at line 344 of file Coord.cc.

346  {
347  return xmsStringToAngle(dms, afwGeom::degrees);
348 }
AngleUnit const degrees
Definition: Angle.h:91
afwGeom::Angle lsst::afw::coord::eclipticPoleInclination ( double const  epoch)

get the inclination of the ecliptic pole (obliquity) at epoch

Parameters
epochdesired epoch for inclination

Definition at line 354 of file Coord.cc.

356  {
357  double const T = (epoch - 2000.0)/100.0;
358  return (23.0 + 26.0/60.0 + (21.448 - 46.82*T - 0.0006*T*T - 0.0018*T*T*T)/3600.0) * afwGeom::degrees;
359 }
AngleUnit const degrees
Definition: Angle.h:91
afwGeom::Angle lsst::afw::coord::hmsStringToAngle ( std::string const  hms)

Convert a hh:mm:ss string to Angle.

Definition at line 335 of file Coord.cc.

337  {
338  return xmsStringToAngle(hms, afwGeom::hours);
339 }
AngleUnit const hours
Definition: Angle.h:92
boost::shared_ptr< afwCoord::Coord > lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Angle const  ra,
lsst::afw::geom::Angle const  dec,
double const  epoch 
)

Factory function to create a Coord of arbitrary type with decimal RA,Dec.

Note
This factory allows the epoch to be specified but will throw if used with ICRS or Galactic
Most of the other factories (which accept epochs) just call this one indirectly.
Parameters
systemthe system (equ, fk5, galactic ..)
raright ascension
decdeclination
epochepoch of coordinate

Definition at line 1220 of file Coord.cc.

1225  {
1226 
1227  switch (system) {
1228  case FK5:
1229  return std::shared_ptr<Fk5Coord>(new Fk5Coord(ra, dec, epoch));
1230  break;
1231  case ICRS:
1232  throw LSST_EXCEPT(ex::InvalidParameterError,
1233  "ICRS has no epoch, use overloaded makeCoord with args (system, ra, dec).");
1234  break;
1235  case GALACTIC:
1236  throw LSST_EXCEPT(ex::InvalidParameterError,
1237  "Galactic has no epoch, use overloaded makeCoord with (system, ra, dec).");
1238  break;
1239  case ECLIPTIC:
1240  return std::shared_ptr<EclipticCoord>(new EclipticCoord(ra, dec, epoch));
1241  break;
1242  case TOPOCENTRIC:
1243  throw LSST_EXCEPT(ex::InvalidParameterError,
1244  "Cannot make Topocentric with makeCoord() (must also specify Observatory).\n"
1245  "Instantiate TopocentricCoord() directly.");
1246  break;
1247  default:
1248  throw LSST_EXCEPT(ex::InvalidParameterError,
1249  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC, and TOPOCENTRIC allowed.");
1250  break;
1251 
1252  }
1253 
1254 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
boost::shared_ptr< afwCoord::Coord > lsst::afw::coord::makeCoord ( CoordSystem const  system,
std::string const  ra,
std::string const  dec,
double const  epoch 
)

Factory function to create a Coord of arbitrary type with string RA [in degrees, not hours!], Dec.

Note
This factory accepts epoch. There is an overloaded version which uses a default.
Parameters
systemthe system (equ, fk5, galactic ..)
raright ascension
decdeclination
epochepoch of coordinate

Definition at line 1372 of file Coord.cc.

1377  {
1378  return makeCoord(system, dmsStringToAngle(ra), dmsStringToAngle(dec), epoch);
1379 }
boost::shared_ptr< Coord > makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1220
lsst::afw::geom::Angle dmsStringToAngle(std::string const dms)
Convert a dd:mm:ss string to Angle.
Definition: Coord.cc:344
boost::shared_ptr< afwCoord::Coord > lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Point2D const &  p2d,
lsst::afw::geom::AngleUnit  unit,
double const  epoch 
)

Factory function to create a Coord of arbitrary type with Point2D.

Note
This factory accepts epoch. There is an overloaded version which uses a default.
Parameters
systemthe system (equ, fk5, galactic ..)
p2dthe (eg) ra,dec in a Point2D
unitthe units (eg. degrees, radians)
epochepoch of coordinate

Definition at line 1336 of file Coord.cc.

1341  {
1342  if (unit == afwGeom::hours) {
1343  return makeCoord(system, afwGeom::Angle(p2d.getX(), afwGeom::hours), afwGeom::Angle(p2d.getY(), afwGeom::degrees), epoch);
1344  } else {
1345  return makeCoord(system, afwGeom::Angle(p2d.getX(), unit), afwGeom::Angle(p2d.getY(), unit), epoch);
1346  }
1347 }
AngleUnit const hours
Definition: Angle.h:92
AngleUnit const degrees
Definition: Angle.h:91
A class representing an Angle.
Definition: Angle.h:103
boost::shared_ptr< Coord > makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1220
boost::shared_ptr< afwCoord::Coord > lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Point3D const &  p3d,
double const  epoch,
bool  normalize = true,
lsst::afw::geom::Angle const  defaultLongitude = lsst::afw::geom::Angle(0.) 
)

Factory function to create a Coord of arbitrary type with a Point3D.

Note
This factory accepts epoch. There is an overloaded version which uses a default.
Parameters
systemthe system (equ, fk5, galactic ..)
p3dthe coord in Point3D format
epochepoch of coordinate
normalizenormalize the p3d provided
defaultLongitudelongitude to use if x=y=0

Definition at line 1305 of file Coord.cc.

1311  {
1312  Coord c(p3d, 2000.0, normalize, defaultLongitude);
1313  return makeCoord(system, c.getLongitude(), c.getLatitude(), epoch);
1314 }
lsst::afw::coord::Coord Coord
Definition: misc.h:35
boost::shared_ptr< Coord > makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1220
boost::shared_ptr< afwCoord::Coord > lsst::afw::coord::makeCoord ( CoordSystem const  system)

Lightweight factory to make an empty coord.

Parameters
systemthe system (FK5, ICRS, etc)

Definition at line 1398 of file Coord.cc.

1400  {
1401  switch (system) {
1402  case FK5:
1403  return std::shared_ptr<Fk5Coord>(new Fk5Coord());
1404  break;
1405  case ICRS:
1406  return std::shared_ptr<IcrsCoord>(new IcrsCoord());
1407  break;
1408  case GALACTIC:
1409  return std::shared_ptr<GalacticCoord>(new GalacticCoord());
1410  break;
1411  case ECLIPTIC:
1412  return std::shared_ptr<EclipticCoord>(new EclipticCoord());
1413  break;
1414  case TOPOCENTRIC:
1415  throw LSST_EXCEPT(ex::InvalidParameterError,
1416  "Cannot make Topocentric with makeCoord() (must also specify Observatory).\n"
1417  "Instantiate TopocentricCoord() directly.");
1418  break;
1419  default:
1420  throw LSST_EXCEPT(ex::InvalidParameterError,
1421  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC, allowed.");
1422  break;
1423 
1424  }
1425 }
lsst::afw::coord::IcrsCoord IcrsCoord
Definition: misc.h:37
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
boost::shared_ptr< afwCoord::Coord > lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Angle const  ra,
lsst::afw::geom::Angle const  dec 
)

Factory function to create a Coord of arbitrary type with decimal RA,Dec in degrees.

Note
This factory assumes a default epoch
Most of the other factories (which don't accept epoch) call this one.
Parameters
systemthe system (equ, fk5, galactic ..)
raright ascension
decdeclination

Definition at line 1264 of file Coord.cc.

1268  {
1269 
1270  switch (system) {
1271  case FK5:
1272  return std::shared_ptr<Fk5Coord>(new Fk5Coord(ra, dec, 2000.0));
1273  break;
1274  case ICRS:
1275  return std::shared_ptr<IcrsCoord>(new IcrsCoord(ra, dec));
1276  break;
1277  case GALACTIC:
1278  return std::shared_ptr<GalacticCoord>(new GalacticCoord(ra, dec));
1279  break;
1280  case ECLIPTIC:
1281  return std::shared_ptr<EclipticCoord>(new EclipticCoord(ra, dec, 2000.0));
1282  break;
1283  case TOPOCENTRIC:
1284  throw LSST_EXCEPT(ex::InvalidParameterError,
1285  "Cannot make Topocentric with makeCoord() (must also specify Observatory).\n"
1286  "Instantiate TopocentricCoord() directly.");
1287  break;
1288  default:
1289  throw LSST_EXCEPT(ex::InvalidParameterError,
1290  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC, and TOPOCENTRIC allowed.");
1291  break;
1292 
1293  }
1294 
1295 }
lsst::afw::coord::IcrsCoord IcrsCoord
Definition: misc.h:37
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
boost::shared_ptr< afwCoord::Coord > lsst::afw::coord::makeCoord ( CoordSystem const  system,
std::string const  ra,
std::string const  dec 
)

Factory function to create a Coord of arbitrary type with string RA [in degrees, not hours!], Dec.

Note
This factory uses a default epoch. There is an overloaded version which accepts an epoch.
Parameters
systemthe system (equ, fk5, galactic ..)
raright ascension
decdeclination

Definition at line 1385 of file Coord.cc.

1389  {
1390  return makeCoord(system, dmsStringToAngle(ra), dmsStringToAngle(dec));
1391 }
boost::shared_ptr< Coord > makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1220
lsst::afw::geom::Angle dmsStringToAngle(std::string const dms)
Convert a dd:mm:ss string to Angle.
Definition: Coord.cc:344
boost::shared_ptr< afwCoord::Coord > lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Point2D const &  p2d,
lsst::afw::geom::AngleUnit  unit 
)

Factory function to create a Coord of arbitrary type with Point2D.

Note
This factory uses a default epoch. There is an overloaded version which accepts an epoch.
Parameters
systemthe system (equ, fk5, galactic ..)
p2dthe (eg) ra,dec in a Point2D
unitthe units (eg. degrees, radians)

Definition at line 1355 of file Coord.cc.

1359  {
1360  if (unit == afwGeom::hours) {
1361  return makeCoord(system, afwGeom::Angle(p2d.getX(), afwGeom::hours), afwGeom::Angle(p2d.getY(), afwGeom::degrees));
1362  } else {
1363  return makeCoord(system, afwGeom::Angle(p2d.getX(), unit), afwGeom::Angle(p2d.getY(), unit));
1364  }
1365 }
AngleUnit const hours
Definition: Angle.h:92
AngleUnit const degrees
Definition: Angle.h:91
A class representing an Angle.
Definition: Angle.h:103
boost::shared_ptr< Coord > makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1220
boost::shared_ptr< afwCoord::Coord > lsst::afw::coord::makeCoord ( CoordSystem const  system,
lsst::afw::geom::Point3D const &  p3d,
bool  normalize = true,
lsst::afw::geom::Angle const  defaultLongitude = lsst::afw::geom::Angle(0.) 
)

Factory function to create a Coord of arbitrary type with a Point3D.

Note
This factory uses a default epoch. There is an overloaded version which accepts an epoch.
Parameters
systemthe system (equ, fk5, galactic ..)
p3dthe coord in Point3D format
normalizenormalize the p3d provided
defaultLongitudelongitude to use if x=y=0

Definition at line 1321 of file Coord.cc.

1326  {
1327  Coord c(p3d, 2000.0, normalize, defaultLongitude);
1328  return makeCoord(system, c.getLongitude(), c.getLatitude());
1329 }
lsst::afw::coord::Coord Coord
Definition: misc.h:35
boost::shared_ptr< Coord > makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:1220
afwCoord::CoordSystem lsst::afw::coord::makeCoordEnum ( std::string const  system)

A utility function to get the enum value of a coordinate system from a string name.

Definition at line 117 of file Coord.cc.

117  {
118  static CoordSystemMap idmap = getCoordSystemMap();
119  if (idmap.find(system) != idmap.end()) {
120  return idmap[system];
121  } else {
122  throw LSST_EXCEPT(ex::InvalidParameterError, "System " + system + " not defined.");
123  }
124 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
std::ostream & lsst::afw::coord::operator<< ( std::ostream &  os,
Weather const &  weath 
)

print a Weather to an output stream

Definition at line 54 of file Weather.cc.

54  {
55  return os << "Weather("
56  << weath.getAirTemperature() << ", "
57  << weath.getAirPressure() << ", "
58  << weath.getHumidity() << ")";
59 }
std::ostream & lsst::afw::coord::operator<< ( std::ostream &  os,
Observatory const &  obs 
)

Definition at line 86 of file Observatory.cc.

86  {
87  return os << (boost::format("%gW, %gN %g")
88  % obs.getLatitude().asDegrees()
89  % obs.getLongitude().asDegrees()
90  % obs.getElevation()).str();
91 }
std::ostream & lsst::afw::coord::operator<< ( std::ostream &  os,
afwCoord::Coord const &  coord 
)

Definition at line 1427 of file Coord.cc.

1427  {
1428  auto const className = coord.getClassName();
1429  auto const coordSystem = coord.getCoordSystem();
1430  os << (boost::format("%s(%.7f, %.7f")
1431  % className
1432  % coord[0].asDegrees()
1433  % coord[1].asDegrees()).str();
1434  if (coordSystem == TOPOCENTRIC) {
1435  os << (boost::format(", %.12f, (%s)")
1436  % coord.getEpoch()
1437  % dynamic_cast<afwCoord::TopocentricCoord const &>(coord).getObservatory()).str();
1438  } else if (coordSystem != ICRS && coordSystem != GALACTIC) {
1439  os << (boost::format(", %.2f") % coord.getEpoch()).str();
1440  }
1441  os << ")";
1442  return os;
1443 }
A class to handle topocentric (AltAz) coordinates (inherits from Coord)
Definition: Coord.h:329