Class: Orbit::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/orbit/site.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lat, lon, alt) ⇒ Site

Returns a new instance of Site.



7
8
9
10
# File 'lib/orbit/site.rb', line 7

def initialize( lat, lon, alt )
  alt = alt / 1000 #km
  @geo = GeocentricCoordinates.new( OrbitGlobals.deg_to_rad( lat ), OrbitGlobals.deg_to_rad( lon ), alt )
end

Instance Attribute Details

#geoObject

Returns the value of attribute geo.



5
6
7
# File 'lib/orbit/site.rb', line 5

def geo
  @geo
end

Instance Method Details

#altitudeObject



28
29
30
# File 'lib/orbit/site.rb', line 28

def altitude
  @geo.altitude
end

#get_look_angle(eci) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/orbit/site.rb', line 41

def get_look_angle(eci)
       # Calculate the ECI coordinates for this Site object at the time
       # of interest.
       date      = eci.date
       eciSite   = Eci.new(@geo, date)
       vecRgRate = Vector.new(eci.velocity.m_x - eciSite.velocity.m_x,
                                     eci.velocity.m_y - eciSite.velocity.m_y,
                                     eci.velocity.m_z - eciSite.velocity.m_z)

       x = eci.position.m_x - eciSite.position.m_x
       y = eci.position.m_y - eciSite.position.m_y
       z = eci.position.m_z - eciSite.position.m_z
       w = Math.sqrt(OrbitGlobals::sqr(x) + OrbitGlobals::sqr(y) + OrbitGlobals::sqr(z))

       vecRange = Vector.new(x, y, z, w)

       # The site's Local Mean Sidereal Time at the time of interest.
       theta = OrbitGlobals.time_to_lmst( date, longitude_rad)

       sin_lat   = Math.sin(latitude_rad)
       cos_lat   = Math.cos(latitude_rad)
       sin_theta = Math.sin(theta)
       cos_theta = Math.cos(theta)

       top_s = sin_lat * cos_theta * vecRange.m_x +
                      sin_lat * sin_theta * vecRange.m_y -
                      cos_lat * vecRange.m_z
       top_e = -sin_theta * vecRange.m_x +
                       cos_theta * vecRange.m_y
       top_z = cos_lat * cos_theta * vecRange.m_x +
                      cos_lat * sin_theta * vecRange.m_y +
                      sin_lat * vecRange.m_z
       az    = Math.atan(-top_e / top_s)

       if (top_s > 0.0)
          az += OrbitGlobals::PI
        end

       if (az < 0.0)
          az += 2.0 * OrbitGlobals::PI
        end

       el   = Math.asin(top_z / vecRange.m_w)
       rate = (vecRange.m_x * vecRgRate.m_x +
                      vecRange.m_y * vecRgRate.m_y +
                      vecRange.m_z * vecRgRate.m_z) / vecRange.m_w

       topo = TopocentricHorizonCoordinates.new(az,         # azimuth, radians
                                      el,         # elevation, radians
                                      vecRange.m_w, # range, km
                                      rate)      # rate, km / sec
  #if WANT_ATMOSPHERIC_CORRECTION
    # Elevation correction for atmospheric refraction.
    # Reference:  Astronomical Algorithms by Jean Meeus, pp. 101-104
    # Note:  Correction is meaningless when apparent elevation is below horizon
    topo.elevation += OrbitGlobals::deg_to_rad((1.02 /
                                  Math.tan(OrbitGlobals::deg_to_rad(OrbitGlobals::rad_to_deg(el) + 10.3 /
                                  (OrbitGlobals::rad_to_deg(el) + 5.11)))) / 60.0)
    if (topo.elevation < 0.0)
       topo.elevation = el    # Reset to true elevation
     end

    if (topo.elevation > (OrbitGlobals::PI / 2))
       topo.elevation = (OrbitGlobals::PI / 2)
     end
  #endif
       return topo

end

#get_position(date) ⇒ Object



32
33
34
# File 'lib/orbit/site.rb', line 32

def get_position(date)
  return Eci.new(@geo, date)
end

#latitude_degObject



20
21
22
# File 'lib/orbit/site.rb', line 20

def latitude_deg
  OrbitGlobals::rad_to_deg( latitude_rad )
end

#latitude_radObject



12
13
14
# File 'lib/orbit/site.rb', line 12

def latitude_rad
  @geo.latitude_rad
end

#longitude_degObject



24
25
26
# File 'lib/orbit/site.rb', line 24

def longitude_deg
  OrbitGlobals::rad_to_deg( longitude_rad )
end

#longitude_radObject



16
17
18
# File 'lib/orbit/site.rb', line 16

def longitude_rad
  @geo.longitude_rad
end

#view_angle_to_satellite_at_time(sat, time) ⇒ Object



36
37
38
39
# File 'lib/orbit/site.rb', line 36

def view_angle_to_satellite_at_time( sat, time )
  sat_position = sat.eci_position_at_time( time )
  topoLook = get_look_angle( sat_position )
end