Class: Astronoby::GreenwichSiderealTime
- Inherits:
-
Object
- Object
- Astronoby::GreenwichSiderealTime
- Defined in:
- lib/astronoby/time/greenwich_sidereal_time.rb
Constant Summary collapse
- JULIAN_CENTURIES_EXPONENTS =
[ BigDecimal("6.697374558"), BigDecimal("2400.051336"), BigDecimal("0.000025862") ].freeze
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.
39 40 41 42 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 39 def initialize(date:, time:) @date = date @time = time end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
11 12 13 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 11 def date @date end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
11 12 13 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 11 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)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 18 def self.from_utc(utc) date = utc.to_date julian_day = utc.to_date.ajd t = (julian_day - Epoch::J2000) / Epoch::DAYS_PER_JULIAN_CENTURY t0 = ( (JULIAN_CENTURIES_EXPONENTS[0] + (JULIAN_CENTURIES_EXPONENTS[1] * t) + (JULIAN_CENTURIES_EXPONENTS[2] * t * t)) % 24 ).abs ut_in_hours = utc.hour + utc.min / 60.0 + (utc.sec + utc.subsec) / 3600.0 gmst = BigDecimal("1.002737909") * ut_in_hours + t0 gmst += 24 if gmst.negative? gmst -= 24 if gmst > 24 new(date: date, time: gmst) end |
Instance Method Details
#to_lst(longitude:) ⇒ Object
69 70 71 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 69 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
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 49 def to_utc date = @date julian_day = @date.ajd t = (julian_day - Epoch::J2000) / Epoch::DAYS_PER_JULIAN_CENTURY t0 = ( (JULIAN_CENTURIES_EXPONENTS[0] + (JULIAN_CENTURIES_EXPONENTS[1] * t) + (JULIAN_CENTURIES_EXPONENTS[2] * t * t)) % 24 ).abs a = @time - t0 a += 24 if a.negative? a -= 24 if a > 24 utc = BigDecimal("0.9972695663") * a decimal_hour_to_time(date, utc) end |