Class: Daylight::Transit

Inherits:
Object
  • Object
show all
Defined in:
lib/trigger_switch_d/daylight.rb

Overview

Calculates new transit, by calling step a number of times to improve the approximation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(west, north, date) ⇒ Transit

Returns a new instance of Transit.



102
103
104
105
106
107
108
109
# File 'lib/trigger_switch_d/daylight.rb', line 102

def initialize(west,north,date)
  @north = north
  # @what_time = what_time
  @julian_date = JulianDateApproximation.new(west,date)
  @approximation = transit_approximation(@julian_date.to_f)
  @mean_anomaly, @lamda, @julian_date_transit_approximation_as_float = @approximation
  run
end

Instance Attribute Details

#lamdaObject (readonly)

:nodoc:all



101
102
103
# File 'lib/trigger_switch_d/daylight.rb', line 101

def lamda
  @lamda
end

Instance Method Details

#to_utc(what_time) ⇒ Object



111
112
113
114
115
116
# File 'lib/trigger_switch_d/daylight.rb', line 111

def to_utc(what_time)
  @julian_date.hour_angle = FOR[what_time]*Float(HourAngleForObserver.new(@north.to_rad, self))
  raw = Float(@julian_date) + (C8 * Math.sin(@mean_anomaly)) - (C9 * Math.sin(2*@lamda.to_rad))
  dt = Date.jd(raw+0.5)
  Time.httpdate(dt.strftime("%a, %d %b %Y %H:%M:%S GMT"))
end