Class: Astronoby::Observer

Inherits:
Object
  • Object
show all
Defined in:
lib/astronoby/observer.rb

Constant Summary collapse

DEFAULT_ELEVATION =
0
DEFAULT_TEMPERATURE =
BigDecimal("283.15")
PRESSURE_AT_SEA_LEVEL =
BigDecimal("1013.25")
PASCAL_PER_MILLIBAR =
BigDecimal("0.01")
EARTH_GRAVITATIONAL_ACCELERATION =
BigDecimal("9.80665")
MOLAR_MASS_OF_AIR =
BigDecimal("0.0289644")
UNIVERSAL_GAS_CONSTANT =
BigDecimal("8.31432")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(latitude:, longitude:, elevation: DEFAULT_ELEVATION, temperature: DEFAULT_TEMPERATURE, pressure: nil) ⇒ Observer

Returns a new instance of Observer.

Parameters:

  • latitude (Angle)

    geographic latitude of the observer

  • longitude (Angle)

    geographic longitude of the observer

  • elevation (Numeric) (defaults to: DEFAULT_ELEVATION)

    geographic elevation (or altitude) of the observer above sea level in meters

  • temperature (Numeric) (defaults to: DEFAULT_TEMPERATURE)

    temperature at the observer’s location in kelvins

  • pressure (Numeric) (defaults to: nil)

    atmospheric pressure at the observer’s location in millibars



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/astronoby/observer.rb', line 23

def initialize(
  latitude:,
  longitude:,
  elevation: DEFAULT_ELEVATION,
  temperature: DEFAULT_TEMPERATURE,
  pressure: nil
)
  @latitude = latitude
  @longitude = longitude
  @elevation = elevation
  @temperature = temperature
  @pressure = pressure
end

Instance Attribute Details

#elevationObject (readonly)

Returns the value of attribute elevation.



13
14
15
# File 'lib/astronoby/observer.rb', line 13

def elevation
  @elevation
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



13
14
15
# File 'lib/astronoby/observer.rb', line 13

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



13
14
15
# File 'lib/astronoby/observer.rb', line 13

def longitude
  @longitude
end

#temperatureObject (readonly)

Returns the value of attribute temperature.



13
14
15
# File 'lib/astronoby/observer.rb', line 13

def temperature
  @temperature
end

Instance Method Details

#pressureBigDecimal

Compute an estimation of the atmospheric pressure based on the elevation and temperature

Returns:

  • (BigDecimal)

    the atmospheric pressure in millibars.



41
42
43
# File 'lib/astronoby/observer.rb', line 41

def pressure
  @pressure ||= PRESSURE_AT_SEA_LEVEL * pressure_ratio
end