Class: Astronoby::Observer
- Inherits:
-
Object
- Object
- Astronoby::Observer
- Defined in:
- lib/astronoby/observer.rb
Constant Summary collapse
- DEFAULT_ELEVATION =
Distance.zero
- DEFAULT_TEMPERATURE =
283.15- PRESSURE_AT_SEA_LEVEL =
1013.25- PASCAL_PER_MILLIBAR =
0.01- EARTH_GRAVITATIONAL_ACCELERATION =
9.80665- MOLAR_MASS_OF_AIR =
0.0289644- UNIVERSAL_GAS_CONSTANT =
8.31432
Instance Attribute Summary collapse
-
#elevation ⇒ Astronoby::Distance
readonly
Geographic elevation above sea level.
-
#latitude ⇒ Astronoby::Angle
readonly
Geographic latitude.
-
#longitude ⇒ Astronoby::Angle
readonly
Geographic longitude.
-
#pressure ⇒ Numeric
readonly
Atmospheric pressure in millibars.
-
#temperature ⇒ Numeric
readonly
Temperature in kelvins.
-
#utc_offset ⇒ Numeric, String
readonly
Offset from Coordinated Universal Time.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
True if all attributes are equal.
-
#earth_fixed_rotation_matrix_for(instant) ⇒ Matrix
Computes the Earth-fixed rotation matrix R₃(GAST) * W (polar motion) for a given instant.
-
#geocentric_position ⇒ Astronoby::Vector<Astronoby::Distance>
Returns the observer’s ECEF position vector (WGS-84 geodetic to ECEF).
-
#geocentric_velocity ⇒ Astronoby::Vector<Astronoby::Velocity>
Returns the observer’s ECEF velocity vector due to Earth rotation.
-
#hash ⇒ Integer
Hash value.
-
#initialize(latitude:, longitude:, elevation: DEFAULT_ELEVATION, utc_offset: 0, temperature: DEFAULT_TEMPERATURE, pressure: nil) ⇒ Observer
constructor
A new instance of Observer.
Constructor Details
#initialize(latitude:, longitude:, elevation: DEFAULT_ELEVATION, utc_offset: 0, temperature: DEFAULT_TEMPERATURE, pressure: nil) ⇒ Observer
Returns a new instance of Observer.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/astronoby/observer.rb', line 40 def initialize( latitude:, longitude:, elevation: DEFAULT_ELEVATION, utc_offset: 0, temperature: DEFAULT_TEMPERATURE, pressure: nil ) @latitude = latitude @longitude = longitude @elevation = elevation @utc_offset = utc_offset @temperature = temperature @pressure = pressure || compute_pressure end |
Instance Attribute Details
#elevation ⇒ Astronoby::Distance (readonly)
Returns geographic elevation above sea level.
20 21 22 |
# File 'lib/astronoby/observer.rb', line 20 def elevation @elevation end |
#latitude ⇒ Astronoby::Angle (readonly)
Returns geographic latitude.
14 15 16 |
# File 'lib/astronoby/observer.rb', line 14 def latitude @latitude end |
#longitude ⇒ Astronoby::Angle (readonly)
Returns geographic longitude.
17 18 19 |
# File 'lib/astronoby/observer.rb', line 17 def longitude @longitude end |
#pressure ⇒ Numeric (readonly)
Returns atmospheric pressure in millibars.
29 30 31 |
# File 'lib/astronoby/observer.rb', line 29 def pressure @pressure end |
#temperature ⇒ Numeric (readonly)
Returns temperature in kelvins.
26 27 28 |
# File 'lib/astronoby/observer.rb', line 26 def temperature @temperature end |
#utc_offset ⇒ Numeric, String (readonly)
Returns offset from Coordinated Universal Time.
23 24 25 |
# File 'lib/astronoby/observer.rb', line 23 def utc_offset @utc_offset end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Returns true if all attributes are equal.
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/astronoby/observer.rb', line 94 def ==(other) return false unless other.is_a?(self.class) @latitude == other.latitude && @longitude == other.longitude && @elevation == other.elevation && @utc_offset == other.utc_offset && @temperature == other.temperature && @pressure == other.pressure end |
#earth_fixed_rotation_matrix_for(instant) ⇒ Matrix
Computes the Earth-fixed rotation matrix R₃(GAST) * W (polar motion) for a given instant.
88 89 90 |
# File 'lib/astronoby/observer.rb', line 88 def earth_fixed_rotation_matrix_for(instant) EarthRotation.matrix_for(instant) * polar_motion_matrix_for(instant) end |
#geocentric_position ⇒ Astronoby::Vector<Astronoby::Distance>
Returns the observer’s ECEF position vector (WGS-84 geodetic to ECEF).
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/astronoby/observer.rb', line 59 def geocentric_position @geocentric_position ||= begin n = earth_prime_vertical_radius_of_curvature x = (n + @elevation.m) * @latitude.cos * @longitude.cos y = (n + @elevation.m) * @latitude.cos * @longitude.sin z = (n * (1 - Constants::WGS84_ECCENTICITY_SQUARED) + @elevation.m) * @latitude.sin Distance.vector_from_meters([x, y, z]) end end |
#geocentric_velocity ⇒ Astronoby::Vector<Astronoby::Velocity>
Returns the observer’s ECEF velocity vector due to Earth rotation.
73 74 75 76 77 78 79 80 81 |
# File 'lib/astronoby/observer.rb', line 73 def geocentric_velocity @geocentric_velocity ||= begin r = projected_radius vx = -Constants::EARTH_ANGULAR_VELOCITY_RAD_PER_S * r * @longitude.sin vy = Constants::EARTH_ANGULAR_VELOCITY_RAD_PER_S * r * @longitude.cos vz = 0.0 Velocity.vector_from_mps([vx, vy, vz]) end end |
#hash ⇒ Integer
Returns hash value.
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/astronoby/observer.rb', line 107 def hash [ self.class, @latitude, @longitude, @elevation, @utc_offset, @temperature, @pressure ].hash end |