Class: Astronoby::GreenwichMeanSiderealTime
- Inherits:
-
GreenwichSiderealTime
- Object
- SiderealTime
- GreenwichSiderealTime
- Astronoby::GreenwichMeanSiderealTime
- Defined in:
- lib/astronoby/time/greenwich_mean_sidereal_time.rb
Overview
Greenwich Mean Sidereal Time (GMST). Computed from UTC using the IERS Conventions 2010 ERA-based expression, with a polynomial fallback for dates outside the IERS EOP data range.
Constant Summary collapse
- JULIAN_CENTURIES_EXPONENTS =
[ 6.697374558, 2400.051336, 0.000025862 ].freeze
- SIDEREAL_MINUTE_IN_UT_MINUTE =
0.9972695663- UT_TO_SIDEREAL_RATIO =
1.002737909
Constants inherited from SiderealTime
Instance Attribute Summary
Attributes inherited from SiderealTime
Class Method Summary collapse
-
.from_utc(utc) ⇒ Astronoby::GreenwichMeanSiderealTime
Creates GMST from UTC using the IERS Conventions 2010 ERA-based expression.
-
.from_utc_polynomial(utc) ⇒ Numeric
Polynomial fallback for dates outside the IERS EOP data range.
Instance Method Summary collapse
-
#initialize(date:, time:) ⇒ GreenwichMeanSiderealTime
constructor
A new instance of GreenwichMeanSiderealTime.
-
#to_utc ⇒ Time
Converts GMST back to UTC.
Methods inherited from GreenwichSiderealTime
apparent_from_utc, mean_from_utc, #to_lst
Methods inherited from SiderealTime
#apparent?, #mean?, normalize_time, #normalize_time, validate_type!
Constructor Details
#initialize(date:, time:) ⇒ GreenwichMeanSiderealTime
Returns a new instance of GreenwichMeanSiderealTime.
70 71 72 |
# File 'lib/astronoby/time/greenwich_mean_sidereal_time.rb', line 70 def initialize(date:, time:) super(date: date, time: time, type: MEAN) end |
Class Method Details
.from_utc(utc) ⇒ Astronoby::GreenwichMeanSiderealTime
Creates GMST from UTC using the IERS Conventions 2010 ERA-based expression.
Source:
Title: IERS Conventions (2010)
Chapter: 5.5.7 - ERA based expressions for Greenwich Sidereal Time
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/astronoby/time/greenwich_mean_sidereal_time.rb', line 29 def self.from_utc(utc) date = utc.to_date gmst_hours = begin gmst_radians = IERS::GMST.at(utc) gmst_radians * 12.0 / Math::PI rescue IERS::OutOfRangeError from_utc_polynomial(utc) end gmst_hours = normalize_time(gmst_hours) new(date: date, time: gmst_hours) end |
.from_utc_polynomial(utc) ⇒ Numeric
Polynomial fallback for dates outside the IERS EOP data range.
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)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/astronoby/time/greenwich_mean_sidereal_time.rb', line 52 def self.from_utc_polynomial(utc) julian_day = utc.to_date.ajd t = (julian_day - JulianDate::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 UT_TO_SIDEREAL_RATIO * ut_in_hours + t0 end |
Instance Method Details
#to_utc ⇒ Time
Converts GMST back to UTC.
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
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/astronoby/time/greenwich_mean_sidereal_time.rb', line 83 def to_utc date = @date julian_day = @date.ajd t = (julian_day - JulianDate::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 = normalize_time(@time - t0) utc = SIDEREAL_MINUTE_IN_UT_MINUTE * a Util::Time.decimal_hour_to_time(date, 0, utc) end |