Class: Astronoby::GreenwichSiderealTime

Inherits:
SiderealTime show all
Defined in:
lib/astronoby/time/greenwich_sidereal_time.rb

Overview

Greenwich Sidereal Time base class. Dispatches to mean or apparent subclasses.

Constant Summary

Constants inherited from SiderealTime

SiderealTime::TYPES

Instance Attribute Summary

Attributes inherited from SiderealTime

#date, #time, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SiderealTime

#apparent?, #initialize, #mean?, normalize_time, #normalize_time, validate_type!

Constructor Details

This class inherits a constructor from Astronoby::SiderealTime

Class Method Details

.apparent_from_utc(utc) ⇒ Astronoby::GreenwichApparentSiderealTime

Parameters:

  • utc (Time)

    the UTC time

Returns:



31
32
33
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 31

def self.apparent_from_utc(utc)
  GreenwichApparentSiderealTime.from_utc(utc)
end

.from_utc(utc, type: MEAN) ⇒ Astronoby::GreenwichMeanSiderealTime, Astronoby::GreenwichApparentSiderealTime

Creates a Greenwich Sidereal Time from UTC.

Parameters:

  • utc (Time)

    the UTC time

  • type (Symbol) (defaults to: MEAN)

    :mean or :apparent

Returns:



13
14
15
16
17
18
19
20
21
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 13

def self.from_utc(utc, type: MEAN)
  validate_type!(type)
  case type
  when MEAN
    GreenwichMeanSiderealTime.from_utc(utc)
  when APPARENT
    GreenwichApparentSiderealTime.from_utc(utc)
  end
end

.mean_from_utc(utc) ⇒ Astronoby::GreenwichMeanSiderealTime

Parameters:

  • utc (Time)

    the UTC time

Returns:



25
26
27
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 25

def self.mean_from_utc(utc)
  GreenwichMeanSiderealTime.from_utc(utc)
end

Instance Method Details

#to_lst(longitude:) ⇒ Astronoby::LocalMeanSiderealTime, Astronoby::LocalApparentSiderealTime

Converts to Local Sidereal Time for a given longitude.

Parameters:

Returns:



54
55
56
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 54

def to_lst(longitude:)
  LocalSiderealTime.from_gst(gst: self, longitude: longitude)
end

#to_utcTime

Converts to UTC.

Returns:

  • (Time)

    the UTC time

Raises:

  • (NotImplementedError)

    if this is apparent sidereal time



39
40
41
42
43
44
45
46
47
# File 'lib/astronoby/time/greenwich_sidereal_time.rb', line 39

def to_utc
  unless mean?
    raise NotImplementedError,
      "UTC conversion only supported for mean sidereal time"
  end

  gmst = GreenwichMeanSiderealTime.new(date: @date, time: @time)
  gmst.to_utc
end