Class: Astronoby::GreenwichSiderealTime
- Inherits:
-
Object
- Object
- Astronoby::GreenwichSiderealTime
- Defined in:
- lib/astronoby/time/greenwich_sidereal_time.rb
Constant Summary collapse
- JULIAN_CENTURIES_EXPONENTS =
[ 6.697374558, 2400.051336, 0.000025862 ].freeze
- SIDEREAL_MINUTE_IN_UT_MINUTE =
0.9972695663
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Class Method Summary collapse
-
.from_utc(utc) ⇒ Object
Source: Title: Practical Astronomy with your Calculator or Spreadsheet Authors: Peter Duffett-Smith and Jonathan Zwart Edition: Cambridge University Press Chapter: 12 - Conversion of UT to Greenwich sidereal time (GST).
Instance Method Summary collapse
-
#initialize(date:, time:) ⇒ GreenwichSiderealTime
constructor
A new instance of GreenwichSiderealTime.
- #to_lst(longitude:) ⇒ Object
-
#to_utc ⇒ Object
Source: Title: Practical Astronomy with your Calculator or Spreadsheet Authors: Peter Duffett-Smith and Jonathan Zwart Edition: Cambridge University Press Chapter: 13 - Conversion of GST to UT.
Constructor Details
#initialize(date:, time:) ⇒ GreenwichSiderealTime
Returns a new instance of GreenwichSiderealTime.
41 42 43 44 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 41 def initialize(date:, time:) @date = date @time = time end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
13 14 15 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 13 def date @date end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
13 14 15 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 13 def time @time end |
Class Method Details
.from_utc(utc) ⇒ Object
Source:
Title: Practical Astronomy with your Calculator or Spreadsheet
Authors: Peter Duffett-Smith and Jonathan Zwart
Edition: Cambridge University Press
Chapter: 12 - Conversion of UT to Greenwich sidereal time (GST)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 20 def self.from_utc(utc) date = utc.to_date julian_day = utc.to_date.ajd t = (julian_day - Epoch::J2000) / Constants::DAYS_PER_JULIAN_CENTURY t0 = ( (JULIAN_CENTURIES_EXPONENTS[0] + (JULIAN_CENTURIES_EXPONENTS[1] * t) + (JULIAN_CENTURIES_EXPONENTS[2] * t * t)) % Constants::HOURS_PER_DAY ).abs ut_in_hours = utc.hour + utc.min / Constants::MINUTES_PER_HOUR + (utc.sec + utc.subsec) / Constants::SECONDS_PER_HOUR gmst = 1.002737909 * ut_in_hours + t0 gmst += Constants::HOURS_PER_DAY if gmst.negative? gmst -= Constants::HOURS_PER_DAY if gmst > Constants::HOURS_PER_DAY new(date: date, time: gmst) end |
Instance Method Details
#to_lst(longitude:) ⇒ Object
71 72 73 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 71 def to_lst(longitude:) LocalSiderealTime.from_gst(gst: self, longitude: longitude) end |
#to_utc ⇒ Object
Source:
Title: Practical Astronomy with your Calculator or Spreadsheet
Authors: Peter Duffett-Smith and Jonathan Zwart
Edition: Cambridge University Press
Chapter: 13 - Conversion of GST to UT
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 51 def to_utc date = @date julian_day = @date.ajd t = (julian_day - Epoch::J2000) / Constants::DAYS_PER_JULIAN_CENTURY t0 = ( (JULIAN_CENTURIES_EXPONENTS[0] + (JULIAN_CENTURIES_EXPONENTS[1] * t) + (JULIAN_CENTURIES_EXPONENTS[2] * t * t)) % Constants::HOURS_PER_DAY ).abs a = @time - t0 a += Constants::HOURS_PER_DAY if a.negative? a -= Constants::HOURS_PER_DAY if a > Constants::HOURS_PER_DAY utc = SIDEREAL_MINUTE_IN_UT_MINUTE * a Util::Time.decimal_hour_to_time(date, utc) end |