Action #1854

Add GSkyDir::sun() method

Added by Knödlseder Jürgen about 8 years ago. Updated about 5 years ago.

Status:ClosedStart date:09/28/2016
Priority:NormalDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-
Target version:1.7.0
Duration:

Description

A sun(const GTime& time) method should be added to the GSkyDir class that returns the position of the Sun at a given time in sufficient precision for gamma-ray astronomy.

Sun_position_difference.png (234 KB) Knödlseder Jürgen, 11/13/2019 08:43 PM

test_ephem.py Magnifier (3.62 KB) Knödlseder Jürgen, 11/14/2019 12:08 AM

Sun_position_difference

Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen about 8 years ago

Here a Use Case that returns the Sun’s current position:

GTime time;
time.now();
GSkyDir dir;
dir.sun(time);
std::cout << dir << std::endl;

#2 Updated by Knödlseder Jürgen over 5 years ago

  • Target version set to 1.7.0

#3 Updated by Knödlseder Jürgen about 5 years ago

  • Status changed from New to In Progress
  • Assigned To set to Knödlseder Jürgen
  • % Done changed from 0 to 50

I implemented GTime::julian_epoch() methods that return time in units of Julian epochs. This method is needed to precess the Sub position to a given epoch.

For the precession, I implemented a GSkyDir::precess() method.

Finally, I implemented the GSkyDir::sun() method based on the formulae on https://en.wikipedia.org/wiki/Position_of_the_Sun.

I checked the implementation using a public web site. Using GammaLib I got:

>>> import gammalib
>>> time=gammalib.GTime()
>>> sky=gammalib.GSkyDir()
>>> time.now()
>>> sky.sun(time)
>>> print(sky)
(RA,Dec)=(-132.731223266557,-17.6621265786828)

and using https://theskylive.com/sun-info I got
(RA,Dec)=(-132.7375,-17.6625)

A more rigorous comparison should be done for example versus PyEphem (see https://pypi.org/project/pyephem/).

#4 Updated by Knödlseder Jürgen about 5 years ago

Here a comparison for the years 2000 to 2050 between the Right Ascension and Declination computed using GSkyDir.sun() and ephem.Sun() from the PyEphem package. The maximum differences amount to about 0.01 degrees, as stated on https://en.wikipedia.org/wiki/Position_of_the_Sun, which corresponds to 0.6 arcmin or 36 arcsec. This should be sufficient for gamma-ray applications.

#5 Updated by Knödlseder Jürgen about 5 years ago

Here is the script I used for testing: test_ephem.py

#6 Updated by Knödlseder Jürgen about 5 years ago

  • Status changed from Pull request to Closed

Merged into devel.

Also available in: Atom PDF