LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
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
lsst::afw::geom::Angle Angle
Definition: misc.h:37
table::Key< table::Array< double > > cd
Definition: Wcs.cc:1087
void setMotion(double muRa, double muDecl, lsst::afw::geom::Angle parallax, double vRadial, bool trueAngle, bool parallaxCor)
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:112
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
void setTimeRange(double epoch1, double epoch2)
double max
Definition: attributes.cc:218
Include files required for standard LSST Exception handling.
int _flags
Bit-wise OR of Flags.
Eigen::Vector3d _v
(dx/dt, dy/dt, dz/dt)
lsst::afw::coord::IcrsCoord IcrsCoord
Definition: misc.h:36
AngleUnit const radians
constant with units of radians
Definition: Angle.h:91
double maxAlpha(double const theta, double const centerDec)
Definition: SpatialUtil.cc:279
lsst::afw::geom::Point3D getVector() const
Return our contents in a position vector.
Definition: Coord.cc:490
Eigen::Vector3d _p
(x, y, z) at _epoch
double asRadians() const
Definition: Angle.h:122
#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
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
virtual double getMinCoord1() const
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:119
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:156
virtual double getMinCoord0() const
lsst::afw::geom::Angle const clampPhi(lsst::afw::geom::Angle const a)
Definition: SpatialUtils.h:45