41 #define G_POSANG "GSkyDir::posang(GSkyDir&, std::string&)"
202 #if defined(G_SINCOS_CACHE)
229 #if defined(G_SINCOS_CACHE)
256 #if defined(G_SINCOS_CACHE)
283 #if defined(G_SINCOS_CACHE)
318 #if defined(G_SINCOS_CACHE)
353 #if defined(G_SINCOS_CACHE)
393 GMatrix rot = (ry * rz).transpose();
400 GVector native(-cos_phi*sin_theta, sin_phi*sin_theta, cos_theta);
431 rotate(phi_rad, theta_rad);
457 if (from_epoch != to_epoch) {
460 double t0 = (from_epoch - 2000.0) / 100.0;
461 double t = (to_epoch - from_epoch) / 100.0;
467 double a = ((2306.2181 + 1.39656 * t0 - 0.000139 * t02) * t +
468 (0.30188 - 0.000344 * t0) * t2 + 0.017998 * t3) * arcsec;
469 double b = ((2306.2181 + 1.39656 * t0 - 0.000139 * t02) * t +
470 (1.09468 + 0.000066 * t0) * t2 + 0.018203 * t3) * arcsec;
471 double c = ((2004.3109 - 0.85330 * t0 - 0.000217 * t02) * t +
472 (-0.42665 - 0.000217 * t0) * t2 - 0.041833 * t3) * arcsec;
483 double xx = cosa*cosc*cosb - sina*sinb;
484 double yx = -sina*cosc*cosb - cosa*sinb;
485 double zx = -sinc*cosb;
486 double xy = cosa*cosc*sinb + sina*cosb;
487 double yy = -sina*cosc*sinb + cosa*cosb;
488 double zy = -sinc*sinb;
489 double xz = cosa*sinc;
490 double yz = -sina*sinc;
497 double x2 = xx*vector[0] + yx*vector[1] + zx*vector[2];
498 double y2 = xy*vector[0] + yy*vector[1] + zy*vector[2];
499 double z2 = xz*vector[0] + yz*vector[1] + zz*vector[2];
502 GVector rotated_vector(x2, y2, z2);
532 double n = time.
jd() - 2451545.0;
539 double mean_longitude = 280.460 + 0.9856474 * n;
540 while (mean_longitude < 0.0) {
541 mean_longitude += 360.0;
543 while (mean_longitude >= 360.0) {
544 mean_longitude -= 360.0;
551 double ecliptic_longitude = mean_longitude +
557 double sin_ecliptic_longitude =
std::sin(ecliptic_longitude_rad);
558 double cos_ecliptic_longitude =
std::cos(ecliptic_longitude_rad);
604 const int d_lng[] = { 0, 2, 2, 0, 0, 0, 2, 2, 2, 2,
605 0, 1, 0, 2, 0, 0, 4, 0, 4, 2,
606 2, 1, 1, 2, 2, 4, 2, 0, 2, 2,
607 1, 2, 0, 0, 2, 2, 2, 4, 0, 3,
608 2, 4, 0, 2, 2, 2, 4, 0, 4, 1,
609 2, 0, 1, 3, 4, 2, 0, 1, 2, 2};
610 const int m_lng[] = { 0, 0, 0, 0, 1, 0, 0,-1, 0,-1,
611 1, 0, 1, 0, 0, 0, 0, 0, 0, 1,
612 1, 0, 1,-1, 0, 0, 0, 1, 0,-1,
613 0,-2, 1, 2,-2, 0, 0,-1, 0, 0,
614 1,-1, 2, 2, 1,-1, 0, 0,-1, 0,
615 1, 0, 1, 0, 0,-1, 2, 1, 0,0};
616 const int mp_lng[] = { 1,-1, 0, 2, 0, 0,-2,-1, 1, 0,
617 -1, 0, 1, 0, 1, 1,-1, 3,-2,-1,
618 0,-1, 0, 1, 2, 0,-3,-2,-1,-2,
619 1, 0, 2, 0,-1, 1, 0,-1, 2,-1,
620 1,-2,-1,-1,-2, 0, 1, 4, 0,-2,
621 0, 2, 1,-2,-3, 2, 1,-1, 3,-1};
622 const int f_lng[] = { 0, 0, 0, 0, 0, 2, 0, 0, 0, 0,
623 0, 0, 0,-2, 2,-2, 0, 0, 0, 0,
624 0, 0, 0, 0, 0, 0, 0, 0, 2, 0,
625 0, 0, 0, 0, 0,-2, 2, 0, 2, 0,
626 0, 0, 0, 0, 0,-2, 0, 0, 0, 0,
627 -2,-2, 0, 0, 0, 0, 0, 0, 0,-2};
628 const int sin_lng[] = { 6288774, 1274027, 658314, 213618,-185116,
629 -114332, 58793, 57066, 53322, 45758,
630 -40923, -34720, -30383, 15327, -12528,
631 10980, 10675, 10034, 8548, -7888,
632 -6766, -5163, 4987, 4036, 3994,
633 3861, 3665, -2689, -2602, 2390,
634 -2348, 2236, -2120, -2069, 2048,
635 -1773, -1595, 1215, -1110, -892,
636 -810, 759, -713, -700, 691,
637 596, 549, 537, 520, -487,
638 -399, -381, 351, -340, 330,
639 327, -323, 299, 294, 0};
656 const int d_lat[] = { 0, 0, 0, 2, 2, 2, 2, 0, 2, 0,
657 2, 2, 2, 2, 2, 2, 2, 0, 4, 0,
658 0, 0, 1, 0, 0, 0, 1, 0, 4, 4,
659 0, 4, 2, 2, 2, 2, 0, 2, 2, 2,
660 2, 4, 2, 2, 0, 2, 1, 1, 0, 2,
661 1, 2, 0, 4, 4, 1, 4, 1, 4, 2};
662 const int m_lat[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
663 -1, 0, 0, 1,-1,-1,-1, 1, 0, 1,
664 0, 1, 0, 1, 1, 1, 0, 0, 0, 0,
665 0, 0, 0, 0,-1, 0, 0, 0, 0, 1,
666 1, 0,-1,-2, 0, 1, 1, 1, 1, 1,
667 0,-1, 1, 0,-1, 0, 0, 0,-1,-2};
668 const int mp_lat[] = { 0, 1, 1, 0,-1,-1, 0, 2, 1, 2,
669 0,-2, 1, 0,-1, 0,-1,-1,-1, 0,
670 0,-1, 0, 1, 1, 0, 0, 3, 0,-1,
671 1,-2, 0, 2, 1,-2, 3, 2,-3,-1,
672 0, 0, 1, 0, 1, 1, 0, 0,-2,-1,
673 1,-2, 2,-2,-1, 1, 1,-1, 0, 0};
674 const int f_lat[] = { 1, 1,-1,-1, 1,-1, 1, 1,-1,-1,
675 -1,-1, 1,-1, 1, 1,-1,-1,-1, 1,
676 3, 1, 1, 1,-1,-1,-1, 1,-1, 1,
677 -3, 1,-3,-1,-1, 1,-1, 1,-1, 1,
678 1, 1, 1,-1, 3,-1,-1, 1,-1,-1,
679 1,-1, 1,-1,-1,-1,-1,-1,-1, 1};
680 const int sin_lat[] = {5128122, 280602, 277693, 173237, 55413,
681 46271, 32573, 17198, 9266, 8822,
682 8216, 4324, 4200, -3359, 2463,
683 2211, 2065, -1870, 1828, -1794,
684 -1749, -1565, -1491, -1475, -1410,
685 -1344, -1335, 1107, 1021, 833,
686 777, 671, 607, 596, 491,
687 -451, 439, 422, 421, -366,
688 -351, 331, 315, 302, -283,
689 -229, 223, 223, -220, -220,
690 -185, 181, -177, 176, 166,
691 -164, 132, -119, 115, 107};
698 const int nutate_d_lng[] = { 0,-2, 0, 0, 0, 0,-2, 0, 0,-2,
699 -2,-2, 0, 2, 0, 2, 0, 0,-2, 0,
700 2, 0, 0,-2, 0,-2, 0, 0, 2,-2,
701 0,-2, 0, 0, 2, 2, 0,-2, 0, 2,
702 2,-2,-2, 2, 2, 0,-2,-2, 0,-2,
703 -2, 0,-1,-2, 1, 0, 0,-1, 0, 0,
705 const int nutate_m_lng[] = { 0, 0, 0, 0, 1, 0, 1, 0, 0,-1,
706 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
707 0, 0, 0, 0, 0, 0, 0, 2, 0, 2,
708 1, 0,-1, 0, 0, 0, 1, 1,-1, 0,
709 0, 0, 0, 0, 0,-1,-1, 0, 0, 0,
710 1, 0, 0, 1, 0, 0, 0,-1, 1,-1,
712 const int nutate_mp_lng[] = { 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,
713 1, 0,-1, 0, 1,-1,-1, 1, 2,-2,
714 0, 2, 2, 1, 0, 0,-1, 0,-1, 0,
715 0, 1, 0, 2,-1, 1, 0, 1, 0, 0,
716 1, 2, 1,-2, 0, 1, 0, 0, 2, 2,
717 0, 1, 1, 0, 0, 1,-2, 1, 1, 1,
719 const int nutate_f_lng[] = { 0, 2, 2, 0, 0, 0, 2, 2, 2, 2,
720 0, 2, 2, 0, 0, 2, 0, 2, 0, 2,
721 2, 2, 0, 2, 2, 2, 2, 0, 0, 2,
722 0, 0, 0,-2, 2, 2, 2, 0, 2, 2,
723 0, 2, 2, 0, 0, 0, 2, 0, 2, 0,
724 2,-2, 0, 0, 0, 2, 2, 0, 0, 2,
726 const int nutate_om_lng[] = { 1, 2, 2, 2, 0, 0, 2, 1, 2, 2,
727 0, 1, 2, 0, 1, 2, 1, 1, 0, 1,
728 2, 2, 0, 2, 0, 0, 1, 0, 1, 2,
729 1, 1, 1, 0, 1, 2, 2, 0, 2, 1,
730 0, 2, 1, 1, 1, 0, 1, 1, 1, 1,
731 1, 0, 0, 0, 0, 0, 2, 0, 0, 2,
733 const int nutate_sin_lng[] = {-171996, -13187, -2274, 2062, 1426,
734 712, -517, -386, -301, 217,
735 -158, 129, 123, 63, 63,
736 -59, -58, -51, 48, 46,
737 -38, -31, 29, 29, 26,
738 -22, 21, 17, 16, -16,
739 -15, -13, -12, 11, -10,
746 const int nutate_cos_lng[] = { 92025, 5736, 977, -895, 54,
747 -7, 224, 200, 129, -95,
759 const double nutate_sdelt[] = {-174.2, -1.6, -0.2, 0.2, -3.4,
760 0.1, 1.2, -0.4, 0.0, -0.5,
761 0.0, 0.1, 0.0, 0.0, 0.1,
762 0.0, -0.1, 0.0, 0.0, 0.0,
763 0.0, 0.0, 0.0, 0.0, 0.0,
764 0.0, 0.0, -0.1, 0.0, 0.1,
765 0.0, 0.0, 0.0, 0.0, 0.0,
766 0.0, 0.0, 0.0, 0.0, 0.0,
767 0.0, 0.0, 0.0, 0.0, 0.0,
768 0.0, 0.0, 0.0, 0.0, 0.0,
769 0.0, 0.0, 0.0, 0.0, 0.0,
770 0.0, 0.0, 0.0, 0.0, 0.0,
772 const double nutate_cdelt[] = {8.9, -3.1, -0.5, 0.5, -0.1,
773 0.0, -0.6, 0.0, -0.1, 0.3,
774 0.0, 0.0, 0.0, 0.0, 0.0,
775 0.0, 0.0, 0.0, 0.0, 0.0,
776 0.0, 0.0, 0.0, 0.0, 0.0,
777 0.0, 0.0, 0.0, 0.0, 0.0,
778 0.0, 0.0, 0.0, 0.0, 0.0,
779 0.0, 0.0, 0.0, 0.0, 0.0,
780 0.0, 0.0, 0.0, 0.0, 0.0,
781 0.0, 0.0, 0.0, 0.0, 0.0,
782 0.0, 0.0, 0.0, 0.0, 0.0,
783 0.0, 0.0, 0.0, 0.0, 0.0,
787 double t = (time.
jd() - 2451545.0) / 36525.0;
791 double Lprimed = 218.3164477 +
794 (1.0/538841.0 - 1.0/65194000.0 * t) * t) * t) * t;
798 double D = (297.8501921 +
801 (1.0/545868.0 - 1.0/113065000.0 * t) * t) * t) * t) *
805 double M = (357.5291092 +
807 (-0.0001536 + 1.0/24490000.0 * t) * t) * t) *
811 double Mprime = (134.9633964 +
814 (1.0/69699.0 - 1.0/14712000.0 * t) * t) * t) * t) *
818 double F = (93.2720950 +
821 (-1.0/35260000 + 1.0/863310000 * t) * t) * t) * t) *
826 double Omega = (125.04452 +
828 (0.0020708 + 1.0/4.5e5 * t) * t) * t) *
832 double A1 = (119.75 + 131.849 * t) * gammalib::deg2rad;
833 double A2 = ( 53.09 + 479264.290 * t) * gammalib::deg2rad;
834 double A3 = (313.45 + 481266.484 * t) * gammalib::deg2rad;
840 double Ab = -2235.0 *
std::sin(Lprime) +
848 double E = 1.0 - (0.002516 + 7.4e-6 * t) * t;
855 for (
int i = 0; i < 60; ++i) {
858 double sinlng = sin_lng[i];
860 double sinlat = sin_lat[i];
877 double s_l = d_lng[i] * D + m_lng[i] * M + mp_lng[i] * Mprime +
879 double s_b = d_lat[i] * D + m_lat[i] * M + mp_lat[i] * Mprime +
890 double geolong = Lprimed + 1.0e-6 * sum_l;
891 double geolat = 1.0e-6 * sum_b;
897 double nut_long = 0.0;
898 double nut_obliq = 0.0;
899 for (
int i = 0; i < 63; ++i) {
900 double arg = nutate_d_lng[i] * D + nutate_m_lng[i] * M +
901 nutate_mp_lng[i] * Mprime + nutate_f_lng[i] * F +
902 nutate_om_lng[i] * Omega;
903 nut_long += (nutate_sdelt[i] * t + nutate_sin_lng[i]) *
std::sin(arg);
904 nut_obliq += (nutate_cdelt[i] * t + nutate_cos_lng[i]) *
std::cos(arg);
910 geolong += nut_long / 3600.0;
920 double y = t / 100.0;
921 double epsilon = (84381.448 +
930 (5.79 + 2.45 * y)*y)*y)*y)*y)*y)*y)*y)*y)*y)/3600.0;
967 #if defined(G_SINCOS_CACHE)
977 GVector vector(cosdec*cosra, cosdec*sinra, sindec);
1000 #if defined(G_SINCOS_CACHE)
1010 GVector vector(cosb*cosl, cosb*sinl, sinb);
1035 #if defined(G_SINCOS_CACHE)
1043 #if defined(G_SINCOS_CACHE)
1059 #if defined(G_SINCOS_CACHE)
1071 #if defined(G_SINCOS_CACHE)
1079 #if defined(G_SINCOS_CACHE)
1095 #if defined(G_SINCOS_CACHE)
1158 if (coordsys ==
"CEL") {
1161 #if defined(G_SINCOS_CACHE)
1171 #if defined(G_SINCOS_CACHE)
1182 else if (coordsys ==
"GAL") {
1185 #if defined(G_SINCOS_CACHE)
1195 #if defined(G_SINCOS_CACHE)
1207 std::string msg =
"Invalid coordinate system \""+coordsys+
"\" "
1208 "specified. Please specify either \"CEL\" or "
1245 result =
"(RA,Dec)=(not initialised)";
1275 #if defined(G_SINCOS_CACHE)
1305 #if defined(G_SINCOS_CACHE)
1337 double*
l = (
double*)&
m_l;
1338 double*
b = (
double*)&
m_b;
1359 double*
ra = (
double*)&
m_ra;
1383 double* xout,
double *yout)
const
1386 const double psi[] = {0.57477043300, 4.9368292465};
1387 const double stheta[] = {0.88998808748, -0.88998808748};
1388 const double ctheta[] = {0.45598377618, 0.45598377618};
1389 const double phi[] = {4.9368292465, 0.57477043300};
1392 double a = xin - phi[type];
1400 b = -stheta[type] * cbsa + ctheta[type] * sb;
1451 equal = (a.
m_b == b.
m_b);
1461 equal = (a.
m_b == b.
b());
1464 equal = (a.
m_b == b.
b() && a.
m_l == b.
l());
1477 equal = (b.
dec() == a.
dec());
1480 equal = (b.
dec() == a.
dec() && b.
ra() == a.
ra());
GSkyDir & operator=(const GSkyDir &dir)
Assignment operator.
Sky direction class interface definition.
GVector abs(const GVector &vector)
Computes absolute of vector elements.
void lb(const double &l, const double &b)
Set galactic sky direction (radians)
void moon(const GTime &time, const double &epoch=2000.0)
Set sky direction to direction of Moon.
const double & b(void) const
Return galactic latitude in radians.
GVector cos(const GVector &vector)
Computes cosine of vector elements.
Generic matrix class definition.
void gal2equ(void) const
Convert galactic to equatorial coordinates.
double m_dec
Declination in radians.
double modulo(const double &v1, const double &v2)
Returns the remainder of the division.
GSkyDir * clone(void) const
Clone sky direction.
std::string print(const GChatter &chatter=NORMAL) const
Print sky direction information.
void eulery(const double &angle)
Set Euler rotation matrix around y axis.
const double & ra(void) const
Return Right Ascension in radians.
double jd(void) const
Return time in Julian Days (TT)
virtual ~GSkyDir(void)
Destructor.
double m_b
Galactic latitude in radians.
void radec(const double &ra, const double &dec)
Set equatorial sky direction (radians)
void copy_members(const GSkyDir &dir)
Copy class members.
void sun(const GTime &time, const double &epoch=2000.0)
Set sky direction to direction of Sun.
GVector tan(const GVector &vector)
Computes tangens of vector elements.
void rotate_deg(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
void eulerz(const double &angle)
Set Euler rotation matrix around z axis.
void init_members(void)
Initialise class members.
void rotate(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
bool m_has_lb
Has galactic coordinates.
const double & l(void) const
Return galactic longitude in radians.
const double & dec(void) const
Return Declination in radians.
GSkyDir(void)
Constructor.
void free_members(void)
Delete class members.
Vector class interface definition.
void radec_deg(const double &ra, const double &dec)
Set equatorial sky direction (degrees)
GVector asin(const GVector &vector)
Computes arcsin of vector elements.
double posang(const GSkyDir &dir, const std::string &coordsys="CEL") const
Compute position angle between sky directions in radians.
double cos_dist(const GSkyDir &dir) const
Compute cosine of angular distance between sky directions.
GVector celvector(void) const
Return sky direction as 3D vector in celestial coordinates.
void clear(void)
Clear sky direction.
void euler(const int &type, const double &xin, const double &yin, double *xout, double *yout) const
General coordinate transformation routine for J2000.
void lb_deg(const double &l, const double &b)
Set galactic sky direction (degrees)
double m_l
Galactic longitude in radians.
GVector sin(const GVector &vector)
Computes sine of vector elements.
Exception handler interface definition.
double atan2(const double &y, const double &x)
Compute arc tangens in radians.
bool m_has_radec
Has equatorial coordinates.
Generic matrix class definition.
bool operator==(const GEnergy &a, const GEnergy &b)
Energy equality operator friend.
double m_ra
Right Ascension in radians.
GVector galvector(void) const
Return sky direction as 3D vector in galactic coordinates.
double julian_epoch(void) const
Return Julian epoch in native reference (TT)
Time class interface definition.
void precess(const double &from_epoch, const double &to_epoch)
Precess sky direction.
bool operator!=(const GEbounds &a, const GEbounds &b)
Energy boundaries inequality operator friend.
void equ2gal(void) const
Convert equatorial to galactic coordinates.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.