Skip to content

Instantly share code, notes, and snippets.

@komasaru
Last active April 19, 2018 06:29
Show Gist options
  • Save komasaru/86b9f3be5e8d567d52db523745c26027 to your computer and use it in GitHub Desktop.
Save komasaru/86b9f3be5e8d567d52db523745c26027 to your computer and use it in GitHub Desktop.
Ruby script to apply Bias-Precession-Nutation to a rectanglar coordinate.
#! /usr/local/bin/ruby
# coding: utf-8
#---------------------------------------------------------------------------------
#= バイアス・歳差・章動適用
#
# date name version
# 2016.08.27 mk-mode.com 1.00 新規作成
#
# Copyright(C) 2016 mk-mode.com All Rights Reserved.
#---------------------------------------------------------------------------------
#++
require 'eph_bpn'
class BpnRotation
# ある日のある天体の GCRS 座標(単位: AU)
COORD = [-1.0020195, 0.0660430, 0.0286337]
def initialize
@e = EphBpn.new("20160919")
end
def exec
pos_b = @e.apply_bias(COORD) # Apply Bias
pos_p = @e.apply_prec(pos_b) # Apply Precession
pos_n = @e.apply_nut(pos_p) # Apply Nutation
pos_bp = @e.apply_bias_prec(COORD) # Apply Bias & Precession
puts "TDB: #{@e.tdb}"
puts " JD: #{@e.jd}"
puts " JC: #{@e.jc}"
puts "EPS: #{@e.eps}"
puts " 元の GCRS 座標: #{COORD}"
puts " バイアス適用後: #{pos_b}"
puts " 歳差適用後: #{pos_p}"
puts " 章動適用後: #{pos_n}"
puts "* 元の GCRS 座標にバイアス&歳差同時適用後:"
puts " #{pos_bp})"
rescue => e
msg = "[#{e.class}] #{e.message}\n"
msg << e.backtrace.each { |tr| "\t#{tr}"}.join("\n")
$stderr.puts msg
exit 1
end
end
BpnRotation.new.exec if __FILE__ == $0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment