LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
ReferencePosition.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
29 
30 #include <algorithm>
31 #include <cmath>
32 
33 #include "lsst/pex/exceptions.h"
34 
35 namespace pexExcept = lsst::pex::exceptions;
36 
40 
45 
46 
47 namespace lsst { namespace ap { namespace match {
48 
49 double const ReferencePosition::MIN_PARALLAX = 1e-11; // rad
50 
51 
55  _p = _sc.getVector().asEigen();
56  _v = Eigen::Vector3d::Zero();
57  _parallax = 0.0 * radians;
62  _flags = 0;
63 }
64 
68  double muRa,
69  double muDecl,
71  Angle parallax,
72  double vRadial,
73  bool trueAngle,
74  bool parallaxCor
76 ) {
77  double sr = std::sin(_sc.getLongitude().asRadians());
78  double cr = std::cos(_sc.getLongitude().asRadians());
79  double sd = std::sin(_sc.getLatitude().asRadians());
80  double cd = std::cos(_sc.getLatitude().asRadians());
81  if (trueAngle) {
82  muRa = (cd == 0.0) ? 0.0 : muRa/cd;
83  }
84  // if parallax is tiny, treat this as a position on the celestial sphere
85  if (parallax < MIN_PARALLAX) {
86  _p.x() = cd*cr;
87  _p.y() = cd*sr;
88  _p.z() = sd;
89  double t = sd*muDecl;
90  _v.x() = -_p.y()*muRa - cr*t;
91  _v.y() = _p.x()*muRa - sr*t;
92  _v.z() = cd*muDecl;
93  _flags = MOVING;
94  return;
95  }
96  double r = 1.0 / parallax.asRadians();
97  double s = r*cd;
98  double t = r*sd*muDecl;
99  double u = cd*vRadial;
100  _p.x() = s*cr;
101  _p.y() = s*sr;
102  _p.z() = r*sd;
103  _v.x() = cr*u - _p.y()*muRa - cr*t;
104  _v.y() = sr*u + _p.x()*muRa - sr*t;
105  _v.z() = sd*vRadial + s*muDecl;
106  if (_v.squaredNorm() > 0.25*C_AU_PER_DAY*C_AU_PER_DAY) {
107  throw LSST_EXCEPT(pexExcept::RuntimeError,
108  "star velocity vector magnitude exceeds half "
109  "the speed of light");
110  }
111  _parallax = parallax;
112  _flags = MOVING | PARALLAX | (parallaxCor ? PARALLAX_COR : 0);
113 }
114 
122 void ReferencePosition::setTimeRange(double epoch1, double epoch2) {
123  if ((_flags & MOVING) != 0) {
124  Eigen::Vector3d p1 = _p + _v*(epoch1 - _epoch);
125  Eigen::Vector3d p2 = _p + _v*(epoch2 - _epoch);
126  Eigen::Vector3d m = p1 + p2;
127  Angle r = std::max(angularSeparation(m, p1),
128  angularSeparation(m, p2));
129  if ((_flags & PARALLAX_COR) != 0) {
130  r += 2.0*_parallax;
131  }
132  IcrsCoord sc = cartesianToIcrs(m);
133  Angle alpha = maxAlpha(r, sc.getLatitude());
134  _minDecl = clampPhi(sc.getLatitude() - r);
135  _maxDecl = clampPhi(sc.getLatitude() + r);
136  _minRa = sc.getLongitude() - alpha;
137  _maxRa = sc.getLongitude() + alpha;
138  }
139 }
140 
141 
143  return static_cast<double>(_minRa);
144 }
145 
147  return static_cast<double>(_maxRa);
148 }
149 
151  return static_cast<double>(_minDecl);
152 }
153 
155  return static_cast<double>(_maxDecl);
156 }
157 
158 }}} // namespace lsst::ap::match
159 
virtual double getMaxCoord1() const
Class for simulated reference catalog positions.
lsst::afw::coord::IcrsCoord _sc
(ra, decl) at _epoch, ICRS rad
lsst::afw::geom::Angle const angularSeparation(Eigen::Vector3d const &v1, Eigen::Vector3d const &v2)
Definition: SpatialUtils.h:83
table::Key< table::Array< double > > cd
Definition: Wcs.cc:1043
AngleUnit const radians
constant with units of radians
Definition: Angle.h:91
void setMotion(double muRa, double muDecl, lsst::afw::geom::Angle parallax, double vRadial, bool trueAngle, bool parallaxCor)
lsst::afw::coord::IcrsCoord const cartesianToIcrs(Eigen::Vector3d const &v)
Definition: SpatialUtils.h:74
lsst::afw::geom::Angle _parallax
parallax, rad
double _epoch
epoch of reference position, MJD
lsst::afw::coord::IcrsCoord IcrsCoord
Definition: misc.h:41
void setTimeRange(double epoch1, double epoch2)
double asRadians() const
Definition: Angle.h:122
double max
Definition: attributes.cc:218
int _flags
Bit-wise OR of Flags.
Eigen::Vector3d _v
(dx/dt, dy/dt, dz/dt)
double maxAlpha(double const theta, double const centerDec)
Definition: SpatialUtil.cc:279
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
Eigen::Vector3d _p
(x, y, z) at _epoch
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
double alpha(double const theta, double const centerDec, double const dec)
Definition: SpatialUtil.cc:248
virtual double getMaxCoord0() const
lsst::afw::geom::Angle Angle
Definition: misc.h:42
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:111
virtual double getMinCoord1() const
lsst::afw::geom::Point3D getVector() const
Return our contents in a position vector.
Definition: Coord.cc:490
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:118
Angle const maxAlpha(Angle radius, Angle centerPhi)
Definition: SpatialUtils.cc:79
Set if the reference position has proper motion.
A class to handle Icrs coordinates (inherits from Coord)
Definition: Coord.h:155
Include files required for standard LSST Exception handling.
virtual double getMinCoord0() const
lsst::afw::geom::Angle const clampPhi(lsst::afw::geom::Angle const a)
Definition: SpatialUtils.h:45