CppEphem
CESkyCoord.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * CESkyCoord.cpp: CppEphem *
3  * ----------------------------------------------------------------------- *
4  * Copyright © 2019 JCardenzana *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 
34 #include "CESkyCoord.h"
35 
36 /**********************************************************************/
40 {
41  init_members();
42 }
43 
44 
45 /**********************************************************************/
52 CESkyCoord::CESkyCoord(const CEAngle& xcoord,
53  const CEAngle& ycoord,
54  const CESkyCoordType& coord_type)
55 {
56  init_members();
57 
58  // Setup the coordinates
59  xcoord_ = xcoord;
60  ycoord_ = ycoord;
61  coord_type_ = coord_type;
62 }
63 
64 
65 /**********************************************************************/
69 {
70  // Set coordinates
71  xcoord_ = other.XCoord();
72  ycoord_ = other.YCoord();
74 }
75 
76 
77 /**********************************************************************/
81 {
82  free_members();
83  init_members();
84  copy_members(other);
85 }
86 
87 
88 /**********************************************************************/
92 {
93  free_members();
94 }
95 
96 
97 /**********************************************************************/
101 {
102  if (this != &other) {
103  free_members();
104  init_members();
105  copy_members(other);
106  }
107  return *this;
108 }
109 
110 
111 /**********************************************************************/
121 {
122  return AngularSeparation(*this, coords);
123 }
124 
125 
126 /**********************************************************************/
142  const CESkyCoord& coords2)
143 {
144  // Make sure the coordinates are in the same frame
145  if (coords1.GetCoordSystem() != coords2.GetCoordSystem()) {
146  throw CEException::invalid_value("CESkyCoord::AngularSeparation(CESkyCoord&, CESkyCoord&)",
147  "Supplied coordinates are in different frames");
148  }
149 
150  // Get the appropriate Y-Coordinates
151  double y1 = coords1.YCoord().Rad();
152  double y2 = coords2.YCoord().Rad();
153  if (coords1.GetCoordSystem() == CESkyCoordType::OBSERVED) {
154  y1 = M_PI_2 - y1;
155  y2 = M_PI_2 - y2;
156  }
157 
158  // Convert the second coordinates to be the same type as the first set of coordinates
159  return AngularSeparation(coords1.XCoord(), y1,
160  coords2.XCoord(), y2);
161 }
162 
163 
164 /**********************************************************************/
184 CEAngle CESkyCoord::AngularSeparation(const CEAngle& xcoord_first,
185  const CEAngle& ycoord_first,
186  const CEAngle& xcoord_second,
187  const CEAngle& ycoord_second)
188 {
189  // Call the 'iauSeps' SOFA algorithm
190  return CEAngle::Rad(iauSeps(xcoord_first, ycoord_first,
191  xcoord_second, ycoord_second));
192 }
193 
194 
195 /**********************************************************************/
202 void CESkyCoord::CIRS2ICRS(const CESkyCoord& in_cirs,
203  CESkyCoord* out_icrs,
204  const CEDate& date)
205 {
206  double eo; // Equation of the origins
207 
208  // Compute the TDB date
209  double tdb1(0.0);
210  double tdb2(0.0);
211  CEDate::UTC2TDB(date.MJD(), &tdb1, &tdb2);
212 
213  // Use the SOFA library to compute the new date
214  double return_ra(0.0);
215  double return_dec(0.0);
216  iauAtic13(in_cirs.XCoord(), in_cirs.YCoord(),
217  tdb1, tdb2,
218  &return_ra, &return_dec, &eo);
219 
220  // Subtract the eo from RA if J2000 coordinates are desired
221  //*return_ra -= eo;
222 
223  out_icrs->SetCoordinates(CEAngle(return_ra), CEAngle(return_dec),
225  return;
226 }
227 
228 
229 /**********************************************************************/
236 void CESkyCoord::CIRS2Galactic(const CESkyCoord& in_cirs,
237  CESkyCoord* out_galactic,
238  const CEDate& date)
239 {
240  // In order to do this with the sofa package, we must first
241  // convert from CIRS -> ICRS
242  CIRS2ICRS(in_cirs, out_galactic, date);
243 
244  // Now we can convert to galactic
245  ICRS2Galactic(*out_galactic, out_galactic);
246 }
247 
248 
249 /**********************************************************************/
259 void CESkyCoord::CIRS2Observed(const CESkyCoord& in_cirs,
260  CESkyCoord* out_observed,
261  const CEDate& date,
262  const CEObserver& observer,
263  CESkyCoord* observed_cirs,
264  CEAngle* hour_angle)
265 {
266  // Setup the observed RA, Dec and hour_angle variables
267  double temp_ra(0.0);
268  double temp_dec(0.0);
269  double temp_hour_angle(0.0);
270 
271  // Call the necessary sofa method
272  double az(0.0);
273  double zen(0.0);
274  int err_code = iauAtio13(in_cirs.XCoord(),
275  in_cirs.YCoord(),
276  CEDate::GetMJD2JDFactor(), date.MJD(),
277  date.dut1(),
278  observer.Longitude_Rad(),
279  observer.Latitude_Rad(),
280  observer.Elevation_m(),
281  date.xpolar(), date.ypolar(),
282  observer.Pressure_hPa(),
283  observer.Temperature_C(),
284  observer.RelativeHumidity(),
285  observer.Wavelength_um(),
286  &az, &zen,
287  &temp_hour_angle,
288  &temp_ra, &temp_dec);
289 
290  // Handle the error code
291  if (err_code == -1) {
292  throw CEException::sofa_error("CESkyCoord::CIRS2Observed",
293  "iauAtio13", -1,
294  "SOFA method was passed an unacceptable date");
295  }
296 
297  // Set the output coordinates
298  out_observed->SetCoordinates(CEAngle::Rad(az), CEAngle::Rad(zen),
300 
301  // If passed, set the observed CIRS coordinates
302  if (observed_cirs != nullptr) {
303  observed_cirs->SetCoordinates(CEAngle::Rad(temp_ra), CEAngle::Rad(temp_dec),
305  }
306 
307  // Set the hour angle
308  if (hour_angle != nullptr) {
309  hour_angle->SetAngle(temp_hour_angle, CEAngleType::RADIANS);
310  }
311 
312  return;
313 }
314 
315 
316 /**********************************************************************/
323 void CESkyCoord::CIRS2Ecliptic(const CESkyCoord& in_cirs,
324  CESkyCoord* out_ecliptic,
325  const CEDate& date)
326 {
327  // CIRS -> ICRS
328  CESkyCoord tmp_icrs;
329  CIRS2ICRS(in_cirs, &tmp_icrs, date);
330 
331  // ICRS -> ECLIPTIC
332  ICRS2Ecliptic(tmp_icrs, out_ecliptic, date);
333 }
334 
335 
336 /**********************************************************************/
343 void CESkyCoord::ICRS2CIRS(const CESkyCoord& in_icrs,
344  CESkyCoord* out_cirs,
345  const CEDate& date)
346 {
347  // Store the equation of the origins
348  double eo; // Equation of the origins
349 
350  // Use the sofa library to convert these coordinates
351  double tdb1(0.0);
352  double tdb2(0.0);
353  CEDate::UTC2TDB(date.MJD(), &tdb1, &tdb2);
354  double return_ra(0.0);
355  double return_dec(0.0);
356  iauAtci13(in_icrs.XCoord().Rad(),
357  in_icrs.YCoord().Rad(),
358  0.0, 0.0, 0.0, 0.0,
359  tdb1, tdb2,
360  &return_ra, &return_dec, &eo);
361 
362  // Subtract the equation of the origins if J2000 coordinates are desired
363  //*return_ra -= eo;
364 
365  // Set the output cirs coordinates
366  out_cirs->SetCoordinates(CEAngle::Rad(return_ra),
367  CEAngle::Rad(return_dec),
369 
370  return;
371 }
372 
373 
374 /**********************************************************************/
380 void CESkyCoord::ICRS2Galactic(const CESkyCoord& in_icrs,
381  CESkyCoord* out_galactic)
382 {
383  // Use the sofa method to convert the coordinates
384  double glon(0.0);
385  double glat(0.0);
386  iauIcrs2g(in_icrs.XCoord().Rad(), in_icrs.YCoord().Rad(), &glon, &glat);
387  out_galactic->SetCoordinates(CEAngle::Rad(glon),
388  CEAngle::Rad(glat),
390 
391  return;
392 }
393 
394 
395 /**********************************************************************/
408 void CESkyCoord::ICRS2Observed(const CESkyCoord& in_icrs,
409  CESkyCoord* out_observed,
410  const CEDate& date,
411  const CEObserver& observer,
412  CESkyCoord* observed_icrs,
413  CEAngle* hour_angle)
414 {
415  // First convert the ICRS coordinates to CIRS coordinates
416  CESkyCoord tmp_cirs;
417  ICRS2CIRS(in_icrs, &tmp_cirs, date);
418 
419  // Now convert CIRS to Observed
420  CESkyCoord obs_cirs;
421  CIRS2Observed(tmp_cirs, out_observed,
422  date, observer,
423  &obs_cirs, hour_angle);
424 
425  // Convert the apparent CIRS RA,Dec to ICRS RA,Dec
426  if (observed_icrs != nullptr) {
427  CIRS2ICRS(obs_cirs, observed_icrs, date);
428  }
429 
430  return;
431 }
432 
433 
434 /**********************************************************************/
441 void CESkyCoord::ICRS2Ecliptic(const CESkyCoord& in_icrs,
442  CESkyCoord* out_ecliptic,
443  const CEDate& date)
444 {
445  // Use the sofa method to convert the coordinates
446  double elon(0.0);
447  double elat(0.0);
448 
449  // Get the time in TT
450  double tt1(0.0);
451  double tt2(0.0);
452  CEDate::UTC2TT(date.MJD(), &tt1, &tt2);
453 
454  // Convert ICRS -> ECLIPTIC
455  iauEqec06(tt1, tt2, in_icrs.XCoord().Rad(), in_icrs.YCoord().Rad(),
456  &elon, &elat);
457  out_ecliptic->SetCoordinates(CEAngle::Rad(elon),
458  CEAngle::Rad(elat),
460 
461  return;
462 }
463 
464 
465 /**********************************************************************/
472 void CESkyCoord::Galactic2CIRS(const CESkyCoord& in_galactic,
473  CESkyCoord* out_cirs,
474  const CEDate& date)
475 {
476  // Do the Galactic -> ICRS converstion
477  CESkyCoord tmp_icrs;
478  Galactic2ICRS(in_galactic, &tmp_icrs);
479 
480  // Now convert ICRS -> CIRS
481  ICRS2CIRS(tmp_icrs, out_cirs, date);
482 
483  return;
484 }
485 
486 
487 /**********************************************************************/
493 void CESkyCoord::Galactic2ICRS(const CESkyCoord& in_galactic,
494  CESkyCoord* out_icrs)
495 {
496  // Do the Galactic -> ICRS converstion
497  double ra(0.0);
498  double dec(0.0);
499  iauG2icrs(in_galactic.XCoord().Rad(),
500  in_galactic.YCoord().Rad(),
501  &ra, &dec);
502  out_icrs->SetCoordinates(ra, dec, CESkyCoordType::ICRS);
503 
504  return;
505 }
506 
507 
508 /**********************************************************************/
521 void CESkyCoord::Galactic2Observed(const CESkyCoord& in_galactic,
522  CESkyCoord* out_observed,
523  const CEDate& date,
524  const CEObserver& observer,
525  CESkyCoord* observed_galactic,
526  CEAngle* hour_angle)
527 {
528  // Galactic -> CIRS
529  CESkyCoord tmp_cirs;
530  Galactic2CIRS(in_galactic, &tmp_cirs, date);
531 
532  // CIRS -> OBSERVED
533  CESkyCoord obs_cirs;
534  CIRS2Observed(tmp_cirs, out_observed, date,
535  observer, &obs_cirs, hour_angle);
536 
537  // Observed CIRS -> observed Galactic
538  if (observed_galactic != nullptr) {
539  CIRS2Galactic(obs_cirs, observed_galactic, date);
540  }
541 
542  return;
543 }
544 
545 
546 /**********************************************************************/
553 void CESkyCoord::Galactic2Ecliptic(const CESkyCoord& in_galactic,
554  CESkyCoord* out_ecliptic,
555  const CEDate& date)
556 {
557  // Galactic -> ICRS
558  CESkyCoord tmp_icrs;
559  Galactic2ICRS(in_galactic, &tmp_icrs);
560 
561  // ICRS -> ECLIPTIC
562  ICRS2Ecliptic(tmp_icrs, out_ecliptic, date);
563 }
564 
565 
566 /**********************************************************************/
574 void CESkyCoord::Observed2CIRS(const CESkyCoord& in_observed,
575  CESkyCoord* out_cirs,
576  const CEDate& date,
577  const CEObserver& observer)
578 {
579  // Preliminary coordinates
580  double ra(0.0);
581  double dec(0.0);
582 
583  // Run the SOFA method
584  int err_code = iauAtoi13("A",
585  in_observed.XCoord().Rad(),
586  in_observed.YCoord().Rad(),
587  CEDate::GetMJD2JDFactor(), date.MJD(),
588  date.dut1(),
589  observer.Longitude_Rad(),
590  observer.Latitude_Rad(),
591  observer.Elevation_m(),
592  date.xpolar(), date.ypolar(),
593  observer.Pressure_hPa(),
594  observer.Temperature_C(),
595  observer.RelativeHumidity(),
596  observer.Wavelength_um(),
597  &ra, &dec);
598 
599  // Handle unacceptable date
600  if (err_code == -1) {
601  throw CEException::sofa_error("CESkyCoord::CIRS2Observed",
602  "iauAtio13", -1,
603  "SOFA method was passed an unacceptable date");
604  }
605 
606  // Set ICRS coordinates
607  out_cirs->SetCoordinates(CEAngle::Rad(ra), CEAngle::Rad(dec),
609 
610  return;
611 }
612 
613 
614 /**********************************************************************/
622 void CESkyCoord::Observed2ICRS(const CESkyCoord& in_observed,
623  CESkyCoord* out_icrs,
624  const CEDate& date,
625  const CEObserver& observer)
626 {
627  // Convert from Observed -> CIRS
628  CESkyCoord tmp_cirs;
629  Observed2CIRS(in_observed, &tmp_cirs, date, observer);
630 
631  // Convert from CIRS -> ICRS
632  CIRS2ICRS(tmp_cirs, out_icrs, date);
633 }
634 
635 
636 /**********************************************************************/
644 void CESkyCoord::Observed2Galactic(const CESkyCoord& in_observed,
645  CESkyCoord* out_galactic,
646  const CEDate& date,
647  const CEObserver& observer)
648 {
649  // Convert from Observed -> ICRS
650  CESkyCoord tmp_icrs;
651  Observed2ICRS(in_observed, &tmp_icrs, date, observer);
652 
653  // Convert from ICRS -> Galactic
654  ICRS2Galactic(tmp_icrs, out_galactic);
655 }
656 
657 
658 /**********************************************************************/
666 void CESkyCoord::Observed2Ecliptic(const CESkyCoord& in_observed,
667  CESkyCoord* out_ecliptic,
668  const CEDate& date,
669  const CEObserver& observer)
670 {
671  // Convert from Observed -> ICRS
672  CESkyCoord tmp_icrs;
673  Observed2ICRS(in_observed, &tmp_icrs, date, observer);
674 
675  // Convert from ICRS -> ECLIPTIC
676  ICRS2Ecliptic(tmp_icrs, out_ecliptic, date);
677 }
678 
679 
680 /**********************************************************************/
687 void CESkyCoord::Ecliptic2CIRS(const CESkyCoord& in_ecliptic,
688  CESkyCoord* out_cirs,
689  const CEDate& date)
690 {
691  // ECLIPTIC -> ICRS
692  CESkyCoord tmp_icrs;
693  Ecliptic2ICRS(in_ecliptic, &tmp_icrs, date);
694 
695  // ICRS -> CIRS
696  ICRS2CIRS(tmp_icrs, out_cirs, date);
697 }
698 
699 
700 /**********************************************************************/
707 void CESkyCoord::Ecliptic2ICRS(const CESkyCoord& in_ecliptic,
708  CESkyCoord* out_icrs,
709  const CEDate& date)
710 {
711  // Create the variables used for returning ICRS
712  double ra(0.0);
713  double dec(0.0);
714 
715  // Get current time in TT
716  double tt1(0.0);
717  double tt2(0.0);
718  CEDate::UTC2TT(date.MJD(), &tt1, &tt2);
719 
720  // Convert ECLIPTIC to ICRS
721  iauEceq06(tt1, tt2,
722  in_ecliptic.XCoord().Rad(), in_ecliptic.YCoord().Rad(),
723  &ra, &dec);
724 
725  // Set the output ICRS
726  out_icrs->SetCoordinates(CEAngle::Rad(ra), CEAngle::Rad(dec),
728 }
729 
730 
731 /**********************************************************************/
738 void CESkyCoord::Ecliptic2Galactic(const CESkyCoord& in_ecliptic,
739  CESkyCoord* out_galactic,
740  const CEDate& date)
741 {
742  // ECLIPTIC -> ICRS
743  CESkyCoord tmp_icrs;
744  Ecliptic2ICRS(in_ecliptic, &tmp_icrs, date);
745 
746  // ICRS -> GALACTIC
747  ICRS2Galactic(tmp_icrs, out_galactic);
748 }
749 
750 
751 /**********************************************************************/
759 void CESkyCoord::Ecliptic2Observed(const CESkyCoord& in_ecliptic,
760  CESkyCoord* out_observed,
761  const CEDate& date,
762  const CEObserver& observer)
763 {
764  // ECLIPTIC -> CIRS
765  CESkyCoord tmp_cirs;
766  Ecliptic2CIRS(in_ecliptic, &tmp_cirs, date);
767 
768  // CIRS -> OBSERVED
769  CIRS2Observed(tmp_cirs, out_observed, date, observer);
770 }
771 
772 
773 /**********************************************************************/
787 CESkyCoord CESkyCoord::ConvertTo(const CESkyCoordType& output_coord_type,
788  const CEDate& date,
789  const CEObserver& observer)
790 {
791  // Do conversion to CIRS
792  CESkyCoord coord;
793  if (output_coord_type == CESkyCoordType::CIRS) {
794  coord = ConvertToCIRS(date, observer);
795  } else if (output_coord_type == CESkyCoordType::ICRS) {
796  coord = ConvertToICRS(date, observer);
797  } else if (output_coord_type == CESkyCoordType::GALACTIC) {
798  coord = ConvertToGalactic(date, observer);
799  } else if (output_coord_type == CESkyCoordType::OBSERVED) {
800  coord = ConvertToObserved(date, observer);
801  } else if (output_coord_type == CESkyCoordType::ECLIPTIC) {
802  coord = ConvertToEcliptic(date, observer);
803  }
804 
805  return coord;
806 }
807 
808 
809 /**********************************************************************/
819  const CEObserver& observer)
820 {
821  // Create the coordinate to be returned
822  CESkyCoord cirs;
823 
824  // Convert
826  // CIRS -> CIRS
827  cirs.SetCoordinates(*this);
828  } else if (coord_type_ == CESkyCoordType::ICRS) {
829  // ICRS -> CIRS
830  ICRS2CIRS(*this, &cirs, date);
831  } else if (coord_type_ == CESkyCoordType::GALACTIC) {
832  // Galactic -> CIRS
833  Galactic2CIRS(*this, &cirs, date);
834  } else if (coord_type_ == CESkyCoordType::OBSERVED) {
835  // Observed -> CIRS
836  Observed2CIRS(*this, &cirs, date, observer);
837  } else if (coord_type_ == CESkyCoordType::ECLIPTIC) {
838  // ECLIPTIC -> CIRS
839  Ecliptic2CIRS(*this, &cirs, date);
840  }
841 
842  return cirs;
843 }
844 
845 
846 /**********************************************************************/
856  const CEObserver& observer)
857 {
858  // Create return coordinate
859  CESkyCoord icrs;
860 
861  // Convert
863  // CIRS -> ICRS
864  CIRS2ICRS(*this, &icrs, date);
865  } else if (coord_type_ == CESkyCoordType::ICRS) {
866  // ICRS -> ICRS
867  icrs.SetCoordinates(*this);
868  } else if (coord_type_ == CESkyCoordType::GALACTIC) {
869  // GALACTIC -> ICRS
870  Galactic2ICRS(*this, &icrs);
871  } else if (coord_type_ == CESkyCoordType::OBSERVED) {
872  // OBSERVED -> ICRS
873  Observed2ICRS(*this, &icrs, date, observer);
874  } else if (coord_type_ == CESkyCoordType::ECLIPTIC) {
875  // ECLIPTIC -> ICRS
876  Ecliptic2ICRS(*this, &icrs, date);
877  }
878 
879  return icrs;
880 }
881 
882 
883 /**********************************************************************/
893  const CEObserver& observer)
894 {
895  // Create return coordiantes
896  CESkyCoord galactic;
897 
898  // Convert
900  // CIRS -> GALACTIC
901  CIRS2Galactic(*this, &galactic, date);
902  } else if (coord_type_ == CESkyCoordType::ICRS) {
903  // ICRS -> GALACTIC
904  ICRS2Galactic(*this, &galactic);
905  } else if (coord_type_ == CESkyCoordType::GALACTIC) {
906  // GALACTIC -> GALACTIC
907  galactic.SetCoordinates(*this);
908  } else if (coord_type_ == CESkyCoordType::OBSERVED) {
909  // OBSERVED -> GALACTIC
910  Observed2Galactic(*this, &galactic, date, observer);
911  } else if (coord_type_ == CESkyCoordType::ECLIPTIC) {
912  // ECLIPTIC -> GALACTIC
913  Ecliptic2Galactic(*this, &galactic, date);
914  }
915 
916  return galactic;
917 }
918 
919 
920 /**********************************************************************/
930  const CEObserver& observer)
931 {
932  // Create return coordinates
933  CESkyCoord observed;
934 
935  // Convert
937  // CIRS -> OBSERVED
938  CIRS2Observed(*this, &observed, date, observer);
939  } else if (coord_type_ == CESkyCoordType::ICRS) {
940  // ICRS -> OBSERVED
941  ICRS2Observed(*this, &observed, date, observer);
942  } else if (coord_type_ == CESkyCoordType::GALACTIC) {
943  // GALACTIC -> OBSERVED
944  Galactic2Observed(*this, &observed, date, observer);
945  } else if (coord_type_ == CESkyCoordType::OBSERVED) {
946  // OBSERVED -> OBSERVED
947  observed.SetCoordinates(*this);
948  } else if (coord_type_ == CESkyCoordType::ECLIPTIC) {
949  // ECLIPTIC -> OBSERVED
950  Ecliptic2Observed(*this, &observed, date, observer);
951  }
952 
953  return observed;
954 }
955 
956 
957 /**********************************************************************/
967  const CEObserver& observer)
968 {
969  // Create return coordinates
970  CESkyCoord ecliptic;
971 
972  // Convert
974  // CIRS -> ECLIPTIC
975  CIRS2Ecliptic(*this, &ecliptic, date);
976  } else if (coord_type_ == CESkyCoordType::ICRS) {
977  // ICRS -> ECLIPTIC
978  ICRS2Ecliptic(*this, &ecliptic, date);
979  } else if (coord_type_ == CESkyCoordType::GALACTIC) {
980  // GALACTIC -> ECLIPTIC
981  Galactic2Ecliptic(*this, &ecliptic, date);
982  } else if (coord_type_ == CESkyCoordType::OBSERVED) {
983  // OBSERVED -> ECLIPTIC
984  Observed2Ecliptic(*this, &ecliptic, date, observer);
985  } else if (coord_type_ == CESkyCoordType::ECLIPTIC) {
986  // ECLIPTIC -> ECLIPTIC
987  ecliptic.SetCoordinates(*this);
988  }
989 
990  return ecliptic;
991 }
992 
993 
994 /**********************************************************************/
1001 void CESkyCoord::SetCoordinates(const CEAngle& xcoord,
1002  const CEAngle& ycoord,
1003  const CESkyCoordType& coord_type) const
1004 {
1005  xcoord_ = xcoord;
1006  ycoord_ = ycoord;
1007  coord_type_ = coord_type;
1008 }
1009 
1010 
1011 /**********************************************************************/
1016 void CESkyCoord::SetCoordinates(const CESkyCoord& coords)
1017 {
1018  copy_members(coords);
1019 }
1020 
1021 
1022 /**********************************************************************/
1027 std::string CESkyCoord::print(void) const
1028 {
1029  std::string msg = "Coordinates:\n";
1030  msg += " - System : " + std::to_string(int(coord_type_)) + "\n";
1031  msg += " - X-coord: " + std::to_string(xcoord_.Deg()) + " deg\n";
1032  msg += " - Y-coord: " + std::to_string(ycoord_.Deg()) + " deg\n";
1033  return msg;
1034 }
1035 
1036 
1037 /**********************************************************************/
1042 void CESkyCoord::copy_members(const CESkyCoord& other)
1043 {
1044  coord_type_ = other.coord_type_;
1045  xcoord_ = other.xcoord_;
1046  ycoord_ = other.ycoord_;
1047 }
1048 
1049 
1050 /**********************************************************************/
1053 void CESkyCoord::free_members(void)
1054 {
1055  // Nothing to do here
1056 }
1057 
1058 
1059 /**********************************************************************/
1062 void CESkyCoord::init_members(void)
1063 {
1065  xcoord_ = 0.0;
1066  ycoord_ = 0.0;
1067 }
1068 
1069 
1070 /**********************************************************************/
1075 bool operator==(const CESkyCoord& lhs, const CESkyCoord& rhs)
1076 {
1077  bool are_equal = true;
1078 
1079  // Check the coordinate systems are equivalent
1080  if (lhs.GetCoordSystem() != rhs.GetCoordSystem()) {
1081  are_equal = false;
1082  }
1083  // Check that the x-coordinate and the y-coordinate are the same
1084  else {
1085  // Check how far appart the coordinates are from each other
1086  CEAngle angsep = CESkyCoord::AngularSeparation(lhs, rhs);
1087  // Currently require separation < 0.03 arcsec
1088  double marcsec_rad = 4.848e-6;
1089  if (angsep > 3.0*marcsec_rad) {
1090  are_equal = false;
1091  }
1092  }
1093 
1094  return are_equal;
1095 }
1096 
1097 
1098 /**********************************************************************/
1103 bool operator!=(const CESkyCoord& lhs, const CESkyCoord& rhs)
1104 {
1105  return !(lhs == rhs);
1106 }
CEObserver::Elevation_m
double Elevation_m() const
Return altitude in meters above sea level.
Definition: CEObserver.h:166
CESkyCoord::ConvertToEcliptic
CESkyCoord ConvertToEcliptic(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to ECLIPTIC coordinates.
Definition: CESkyCoord.cpp:965
CESkyCoordType::ICRS
RA, Dec (referenced at the barycenter of the solarsystem)
CESkyCoord::Galactic2ICRS
static void Galactic2ICRS(const CESkyCoord &in_galactic, CESkyCoord *out_icrs)
GALACTIC -> ICRS coordinate conversion.
Definition: CESkyCoord.cpp:492
CESkyCoord::ConvertToCIRS
CESkyCoord ConvertToCIRS(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to CIRS coordinates.
Definition: CESkyCoord.cpp:817
CESkyCoord::Galactic2Ecliptic
static void Galactic2Ecliptic(const CESkyCoord &in_galactic, CESkyCoord *out_ecliptic, const CEDate &date=CEDate())
GALACTIC -> ECLIPTIC coordinate conversion.
Definition: CESkyCoord.cpp:552
CESkyCoordType
CESkyCoordType
The following enum specifies what coordinates this object represents.
Definition: CESkyCoord.h:39
CESkyCoord::Ecliptic2ICRS
static void Ecliptic2ICRS(const CESkyCoord &in_ecliptic, CESkyCoord *out_icrs, const CEDate &date=CEDate())
ECLIPTIC -> ICRS coordinate conversion.
Definition: CESkyCoord.cpp:706
CESkyCoordType::CIRS
RA, Dec (referenced at the center of the Earth)
CEDate
Definition: CEDate.h:43
CEObserver::Temperature_C
double Temperature_C() const
Return temperature in degrees Celsius.
Definition: CEObserver.h:186
CESkyCoord::xcoord_
CEAngle xcoord_
Definition: CESkyCoord.h:208
CESkyCoord::Galactic2Observed
static void Galactic2Observed(const CESkyCoord &in_galactic, CESkyCoord *out_observed, const CEDate &date, const CEObserver &observer, CESkyCoord *observed_galactic=nullptr, CEAngle *hour_angle=nullptr)
GALACTIC -> OBSERVED coordinate conversion.
Definition: CESkyCoord.cpp:520
CESkyCoord
Definition: CESkyCoord.h:49
CESkyCoord::CIRS2ICRS
static void CIRS2ICRS(const CESkyCoord &in_cirs, CESkyCoord *out_icrs, const CEDate &date=CEDate())
Convert CIRS to ICRS coordinates.
Definition: CESkyCoord.cpp:201
CECoordinates::YCoord
virtual CEAngle YCoord(const double &jd=CppEphem::julian_date_J2000()) const
Return y coordinate at given Julian date.
Definition: CECoordinates.h:424
CESkyCoord::AngularSeparation
virtual CEAngle AngularSeparation(const CESkyCoord &coords) const
Get the angular separation between the coordinates represented by this object and another coordinate ...
Definition: CESkyCoord.cpp:119
CESkyCoord::ICRS2Galactic
static void ICRS2Galactic(const CESkyCoord &in_icrs, CESkyCoord *out_galactic)
ICRS -> GALACTIC coordinate conversion.
Definition: CESkyCoord.cpp:379
CEObserver::RelativeHumidity
double RelativeHumidity() const
Return relative humidity.
Definition: CEObserver.h:216
CESkyCoord::CIRS2Galactic
static void CIRS2Galactic(const CESkyCoord &in_cirs, CESkyCoord *out_galactic, const CEDate &date=CEDate())
Convert CIRS to Galactic coordinates.
Definition: CESkyCoord.cpp:235
CESkyCoordType::GALACTIC
Galacitc longitude, latitude.
CESkyCoord::CIRS2Observed
static void CIRS2Observed(const CESkyCoord &in_cirs, CESkyCoord *out_observed, const CEDate &date, const CEObserver &observer, CESkyCoord *observed_cirs=nullptr, CEAngle *hour_angle=nullptr)
CIRS -> Observed (or observer specific) coordinate conversion.
Definition: CESkyCoord.cpp:258
CEObserver::Longitude_Rad
double Longitude_Rad() const
Return observer geographic longitude in radians.
Definition: CEObserver.h:126
CEException::sofa_error
Definition: CEException.h:102
CESkyCoord::ICRS2Ecliptic
static void ICRS2Ecliptic(const CESkyCoord &in_icrs, CESkyCoord *out_ecliptic, const CEDate &date=CEDate())
ICRS -> ECLIPTIC coordinate conversion.
Definition: CESkyCoord.cpp:440
CEDate::UTC2TDB
static void UTC2TDB(const double &mjd, double *tdb1, double *tdb2)
Convert the UTC MJD to TDB JD (useful for planet computations)
Definition: CEDate.cpp:429
CESkyCoord::operator=
CESkyCoord & operator=(const CESkyCoord &other)
Overloaded '=' (assignment) operator.
Definition: CESkyCoord.cpp:99
CESkyCoord::ICRS2CIRS
static void ICRS2CIRS(const CESkyCoord &in_icrs, CESkyCoord *out_cirs, const CEDate &date=CEDate())
ICRS -> CIRS coordinate conversion.
Definition: CESkyCoord.cpp:342
CEAngle
Definition: CEAngle.h:38
CEDate::ypolar
static double ypolar(const double &date, const CEDateType &date_type=CEDateType::JD)
Polar motion (xy for a given date.
Definition: CEDate.cpp:520
CEAngle::Rad
double Rad(void) const
Return angle in radians as a double.
Definition: CEAngle.cpp:351
CESkyCoord::Ecliptic2CIRS
static void Ecliptic2CIRS(const CESkyCoord &in_ecliptic, CESkyCoord *out_cirs, const CEDate &date=CEDate())
ECLIPTIC -> CIRS coordinate conversion.
Definition: CESkyCoord.cpp:686
CEAngle::SetAngle
void SetAngle(const double &angle, const CEAngleType &angle_type=CEAngleType::RADIANS)
Set the angle from a double.
Definition: CEAngle.cpp:369
CEObserver::Pressure_hPa
double Pressure_hPa() const
Return atmospheric pressure in units of hPa.
Definition: CEObserver.h:176
CEObserver::Wavelength_um
double Wavelength_um() const
Return the wavelength in units of micrometers.
Definition: CEObserver.h:226
CECoordinates::GetCoordSystem
CECoordinateType GetCoordSystem(void) const
Return coordinate system.
Definition: CECoordinates.h:486
CEAngle::Rad
static CEAngle Rad(const double &angle)
Return angle constructed from a radians angle.
Definition: CEAngle.cpp:340
CESkyCoord::GetCoordSystem
CESkyCoordType GetCoordSystem(void) const
Return coordinate system.
Definition: CESkyCoord.h:251
CESkyCoord::free_members
void free_members(void)
Cleanup data members that need to be freed or cleared.
Definition: CESkyCoord.cpp:1052
CESkyCoord::init_members
void init_members(void)
Set initial values and allocate memory for data members.
Definition: CESkyCoord.cpp:1061
CESkyCoord::Ecliptic2Galactic
static void Ecliptic2Galactic(const CESkyCoord &in_ecliptic, CESkyCoord *out_galactic, const CEDate &date=CEDate())
ECLIPTIC -> GALACTIC coordinate conversion.
Definition: CESkyCoord.cpp:737
CESkyCoord::ConvertToObserved
CESkyCoord ConvertToObserved(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to OBSERVED coordinates.
Definition: CESkyCoord.cpp:928
CEDate::GetMJD2JDFactor
static double GetMJD2JDFactor()
Gets the stored SOFA Julian date to Mod Julian date factor 'DJM0'.
Definition: CEDate.h:236
CESkyCoord::ICRS2Observed
static void ICRS2Observed(const CESkyCoord &in_icrs, CESkyCoord *out_observed, const CEDate &date, const CEObserver &observer, CESkyCoord *observed_cirs=nullptr, CEAngle *hour_angle=nullptr)
ICRS -> OBSERVED coordinate conversion.
Definition: CESkyCoord.cpp:407
CESkyCoord::Observed2CIRS
static void Observed2CIRS(const CESkyCoord &in_observed, CESkyCoord *out_cirs, const CEDate &date, const CEObserver &observer)
OBSERVED -> CIRS coordinate conversion.
Definition: CESkyCoord.cpp:573
operator!=
bool operator!=(const CESkyCoord &lhs, const CESkyCoord &rhs)
Compare two coordinate objects.
Definition: CESkyCoord.cpp:1102
CESkyCoord::CIRS2Ecliptic
static void CIRS2Ecliptic(const CESkyCoord &in_cirs, CESkyCoord *out_ecliptic, const CEDate &date=CEDate())
Convert CIRS to ECLIPTIC coordinates.
Definition: CESkyCoord.cpp:322
CESkyCoord::print
std::string print(void) const
Generate a message string that specifies the information about this coordinate.
Definition: CESkyCoord.cpp:1026
CECoordinates
Definition: CECoordinates.h:48
CESkyCoord::ConvertToGalactic
CESkyCoord ConvertToGalactic(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to GALACTIC coordinates.
Definition: CESkyCoord.cpp:891
CESkyCoord::~CESkyCoord
virtual ~CESkyCoord()
Destructor.
Definition: CESkyCoord.cpp:90
CESkyCoord::CESkyCoord
CESkyCoord()
Default constructor.
Definition: CESkyCoord.cpp:38
CEAngleType::RADIANS
CEObserver
Definition: CEObserver.h:28
CEException::invalid_value
Definition: CEException.h:73
CECoordinates::XCoord
virtual CEAngle XCoord(const double &jd=CppEphem::julian_date_J2000()) const
Return x coordinate at given Julian date.
Definition: CECoordinates.h:411
CESkyCoord::ycoord_
CEAngle ycoord_
Definition: CESkyCoord.h:209
CEDate::MJD
virtual double MJD() const
Get the Modified Julian date represented by this object.
Definition: CEDate.h:160
CESkyCoord::copy_members
void copy_members(const CESkyCoord &other)
Copy data members from another CESkyCoord object.
Definition: CESkyCoord.cpp:1041
CEDate::xpolar
static double xpolar(const double &date, const CEDateType &date_type=CEDateType::JD)
Polar motion (x) for a given date.
Definition: CEDate.cpp:494
CESkyCoord::Observed2Galactic
static void Observed2Galactic(const CESkyCoord &in_observed, CESkyCoord *out_galactic, const CEDate &date, const CEObserver &observer)
OBSERVED -> GALACTIC coordinate conversion.
Definition: CESkyCoord.cpp:643
CESkyCoord::Ecliptic2Observed
static void Ecliptic2Observed(const CESkyCoord &in_ecliptic, CESkyCoord *out_observed, const CEDate &date, const CEObserver &observer)
ECLIPTIC -> OBSERVED coordinate conversion.
Definition: CESkyCoord.cpp:758
CESkyCoord::SetCoordinates
virtual void SetCoordinates(const CEAngle &xcoord, const CEAngle &ycoord, const CESkyCoordType &coord_type=CESkyCoordType::ICRS) const
Set the coordinates of this object.
Definition: CESkyCoord.cpp:1000
operator==
bool operator==(const CESkyCoord &lhs, const CESkyCoord &rhs)
Compare two coordinate objects.
Definition: CESkyCoord.cpp:1074
CESkyCoord.h
CESkyCoord::Observed2ICRS
static void Observed2ICRS(const CESkyCoord &in_observed, CESkyCoord *out_icrs, const CEDate &date, const CEObserver &observer)
OBSERVED -> ICRS coordinate conversion.
Definition: CESkyCoord.cpp:621
CEDate::UTC2TT
static void UTC2TT(const double &mjd, double *tt1, double *tt2)
Convert the UTC MJD to TT JD.
Definition: CEDate.cpp:405
CEObserver::Latitude_Rad
double Latitude_Rad() const
Return geographic latitude in radians.
Definition: CEObserver.h:146
CESkyCoord::Observed2Ecliptic
static void Observed2Ecliptic(const CESkyCoord &in_observed, CESkyCoord *out_ecliptic, const CEDate &date, const CEObserver &observer)
OBSERVED -> ECLIPTIC coordinate conversion.
Definition: CESkyCoord.cpp:665
CESkyCoordType::ECLIPTIC
Ecliptic longitude, latitude.
CESkyCoord::Galactic2CIRS
static void Galactic2CIRS(const CESkyCoord &in_galactic, CESkyCoord *out_cirs, const CEDate &date=CEDate())
GALACTIC -> CIRS coordinate conversion.
Definition: CESkyCoord.cpp:471
CEAngle::Deg
static CEAngle Deg(const double &angle)
Return angle (radians) constructed from a degree angle.
Definition: CEAngle.cpp:317
CEDate::dut1
static double dut1(const double &date, const CEDateType &date_type=CEDateType::JD)
Return dut1 based on a given modified date.
Definition: CEDate.cpp:447
CESkyCoord::ConvertToICRS
CESkyCoord ConvertToICRS(const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert this coordinate to ICRS coordinates.
Definition: CESkyCoord.cpp:854
CESkyCoord::coord_type_
CESkyCoordType coord_type_
Definition: CESkyCoord.h:210
CESkyCoord::ConvertTo
CESkyCoord ConvertTo(const CESkyCoordType &output_coord_type, const CEDate &date=CEDate(), const CEObserver &observer=CEObserver())
Convert these coordinates to another coordinate system NOTE: If this object is not OBSERVED coordinat...
Definition: CESkyCoord.cpp:786
CESkyCoord::XCoord
virtual CEAngle XCoord(const CEDate &jd=CppEphem::julian_date_J2000()) const
Return x coordinate at given Julian date.
Definition: CESkyCoord.h:227
CESkyCoordType::OBSERVED
Azimuth, Zenith (requires additional observer information)
CESkyCoord::YCoord
virtual CEAngle YCoord(const CEDate &jd=CppEphem::julian_date_J2000()) const
Return y coordinate at given Julian date.
Definition: CESkyCoord.h:240