Class: EphJpl::Ephemeris
- Inherits:
-
Object
- Object
- EphJpl::Ephemeris
- Defined in:
- lib/eph_jpl/ephemeris.rb
Instance Attribute Summary collapse
-
#bin ⇒ Object
readonly
Returns the value of attribute bin.
-
#center ⇒ Object
readonly
Returns the value of attribute center.
-
#center_name ⇒ Object
readonly
Returns the value of attribute center_name.
-
#jd ⇒ Object
readonly
Returns the value of attribute jd.
-
#km ⇒ Object
readonly
Returns the value of attribute km.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#target_name ⇒ Object
readonly
Returns the value of attribute target_name.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
Instance Method Summary collapse
- #calc ⇒ Object
-
#initialize(target, center, jd, bin, km = false) ⇒ Ephemeris
constructor
A new instance of Ephemeris.
Constructor Details
#initialize(target, center, jd, bin, km = false) ⇒ Ephemeris
Returns a new instance of Ephemeris.
6 7 8 9 10 11 12 13 |
# File 'lib/eph_jpl/ephemeris.rb', line 6 def initialize(target, center, jd, bin, km = false) @target, @center, @jd, @km = target, center, jd, km @target_name = Const::ASTRS[@target - 1] @center_name = Const::ASTRS[@center - 1] @unit = @target > 13 ? "rad, rad/day" : @km ? "km, km/sec" : "AU, AU/day" @bin = bin @list = get_list end |
Instance Attribute Details
#bin ⇒ Object (readonly)
Returns the value of attribute bin.
3 4 5 |
# File 'lib/eph_jpl/ephemeris.rb', line 3 def bin @bin end |
#center ⇒ Object (readonly)
Returns the value of attribute center.
3 4 5 |
# File 'lib/eph_jpl/ephemeris.rb', line 3 def center @center end |
#center_name ⇒ Object (readonly)
Returns the value of attribute center_name.
3 4 5 |
# File 'lib/eph_jpl/ephemeris.rb', line 3 def center_name @center_name end |
#jd ⇒ Object (readonly)
Returns the value of attribute jd.
3 4 5 |
# File 'lib/eph_jpl/ephemeris.rb', line 3 def jd @jd end |
#km ⇒ Object (readonly)
Returns the value of attribute km.
3 4 5 |
# File 'lib/eph_jpl/ephemeris.rb', line 3 def km @km end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
3 4 5 |
# File 'lib/eph_jpl/ephemeris.rb', line 3 def target @target end |
#target_name ⇒ Object (readonly)
Returns the value of attribute target_name.
3 4 5 |
# File 'lib/eph_jpl/ephemeris.rb', line 3 def target_name @target_name end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
3 4 5 |
# File 'lib/eph_jpl/ephemeris.rb', line 3 def unit @unit end |
Instance Method Details
#calc ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 |
# File 'lib/eph_jpl/ephemeris.rb', line 15 def calc pvs = Array.new(11).map { |a| Array.new(6, 0.0) } # for position, velocity pvs_tmp = Array.new(13) # Temporary array for position, velocity of target and center rrds = Array.new(6, 0.0) # for calculated data (difference between target and center) begin # Interpolate (11:Sun) pv_sun = interpolate(11) # Interpolate (1:Mercury - 10:Moon) 0.upto(9) do |i| next if @list[i] == 0 pvs[i] = interpolate(i + 1) next if i > 8 next if Const::BARY pvs[i] = pvs[i].map.with_index do |pv, j| pv - pv_sun[j] end end # Interpolate (14:Nutation) if @list[10] > 0 && @bin[:ipts][11][1] > 0 p_nut = interpolate(14) end # Interpolate (15:Libration) if @list[11] > 0 && @bin[:ipts][12][1] > 0 pvs[10] = interpolate(15) end # Difference between target and center case when @target == 14 rrds = p_nut if @bin[:ipts][11][1] > 0 when @target == 15 rrds = pvs[10] if @bin[:ipts][12][1] > 0 else 0.upto(9) { |i| pvs_tmp[i] = pvs[i] } pvs_tmp[10] = pv_sun if [@target, @center].include?(11) pvs_tmp[11] = Array.new(6, 0.0) if [@target, @center].include?(12) pvs_tmp[12] = pvs[2] if [@target, @center].include?(13) if @target * @center == 30 || @target + @center == 13 pvs_tmp[2] = Array.new(6, 0.0) else pvs_tmp[2] = pvs[2].map.with_index do |pv, i| pv - pvs[9][i] / (1.0 + @bin[:emrat]) end unless @list[2] == 0 pvs_tmp[9] = pvs_tmp[2].map.with_index do |pv, i| pv + pvs[9][i] end unless @list[9] == 0 end 0.upto(5) do |i| rrds[i] = pvs_tmp[@target - 1][i] - pvs_tmp[@center - 1][i] end end return rrds rescue => e raise end end |