eph_bpn 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5412aa463168c6638923b0dc1607d2d54a42badc
4
+ data.tar.gz: 85bdb0d301b177416267d78f0cf24877ad72815e
5
+ SHA512:
6
+ metadata.gz: 1a4f1f49d48659aa413cc53a72fb4e3920dfe7dc52d2f72323c91eb9c2170e86e1e76f12e74585fc4dd327aada6d4089e1188cee0fa2123e39d33888a0a0d5a5
7
+ data.tar.gz: 9bdbde0decfe32e3f6b1dd46fcbfe6f4dcd0b8b6999bebfe93bfd9125eede215968648598325d4c80826cec32bc7375b89bff49882501b3c51ae0cd3b60189b5
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in eph_bpn.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "guard"
8
+ gem "guard-rspec", "~> 4.7.0"
9
+ end
10
+
data/Guardfile ADDED
@@ -0,0 +1,42 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Masaru Koizumi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # EphBpn
2
+
3
+ ## Introduction
4
+
5
+ This is the gem library which calculates ephemeris(Bias, Precession Nutation).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'eph_bpn'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install eph_bpn
22
+
23
+ ## Usage
24
+
25
+ ### Instantiation
26
+
27
+ e = EphBpn.new("20160723")
28
+ e = EphBpn.new("20160723123456")
29
+ e = EphBpn.new
30
+
31
+ * You can set TDB formatted "YYYYMMDD" or "YYYYMMDDHHMMSS" as an argument.
32
+ * If you don't set an argument, this class considers the system time to have been set as an argument.
33
+
34
+ ### Calculation
35
+
36
+ r_i = [-0.50787065, 0.80728228, 0.34996714] # ICRS Coordinate
37
+ r_b = e.apply_bias(r_i) # Apply Bias
38
+ r_p = e.apply_prec(r_b) # Apply Precession
39
+ r_n = e.apply_nut(r_p) # Apply Nutation
40
+ puts "TDB: #{e.tdb}" #=> TDB: 2016-07-23 00:00:00 +0000
41
+ puts " JD: #{e.jd}" #=> JD: 2457592.5
42
+ puts " JC: #{e.jc}" #=> JC: 0.16557152635181382
43
+ puts "EPS: #{e.eps}" #=> EPS: 0.40905500411767176
44
+ p r_i #=> [-0.50787065, 0.80728228, 0.34996714]
45
+ p r_b #=> [-0.5078706789483137, 0.8072822556207571, 0.34996715422685276]
46
+ p r_p #=> [-0.5114184398597698, 0.8053953379861463, 0.3491472536549302]
47
+ p r_n #=> [-0.5114184385245731, 0.8053953403876852, 0.3491472500709293]
48
+
49
+ ## Development
50
+
51
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
+
53
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/komasaru/eph_bpn.
58
+
59
+
60
+ ## License
61
+
62
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
63
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "eph_bpn"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/eph_bpn.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'eph_bpn/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "eph_bpn"
8
+ spec.version = EphBpn::VERSION
9
+ spec.authors = ["komasaru"]
10
+ spec.email = ["masaru@mk-mode.com"]
11
+
12
+ spec.summary = %q{Ephemeris(Bias, Precession, Nutation) calculation tool.}
13
+ spec.description = %q{EphBpn is a ephemeris(Bias, Precession, Nutation) calculation tool.}
14
+ spec.homepage = "https://github.com/komasaru/eph_bpn"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ #if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ #else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ #end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ end
data/exe/eph_bpn ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "eph_bpn"
4
+
5
+ e = EphBpn.new(ARGV[0])
6
+ r_i = [-0.50787065, 0.80728228, 0.34996714] # ICRS Coordinate
7
+ r_b = e.apply_bias(r_i) # Apply Bias
8
+ r_p = e.apply_prec(r_b) # Apply Precession
9
+ r_n = e.apply_nut(r_p) # Apply Nutation
10
+ puts "TDB: #{e.tdb}" #=> TDB: 2016-07-23 00:00:00 +0000
11
+ puts " JD: #{e.jd}" #=> JD: 2457592.5
12
+ puts " JC: #{e.jc}" #=> JC: 0.16557152635181382
13
+ puts "EPS: #{e.eps}" #=> EPS: 0.40905500411767176
14
+ p r_i #=> [-0.50787065, 0.80728228, 0.34996714]
15
+ p r_b #=> [-0.5078706789483137, 0.8072822556207571, 0.34996715422685276]
16
+ p r_p #=> [-0.5114184398597698, 0.8053953379861463, 0.3491472536549302]
17
+ p r_n #=> [-0.5114184385245731, 0.8053953403876852, 0.3491472500709293]
18
+
@@ -0,0 +1,24 @@
1
+ module EphBpn
2
+ class Argument
3
+ def initialize(arg)
4
+ @arg = arg
5
+ end
6
+
7
+ #=========================================================================
8
+ # 引数取得
9
+ #
10
+ # * コマンドライン引数を取得して日時の妥当性チェックを行う
11
+ # * コマンドライン引数無指定なら、現在日時とする。
12
+ #
13
+ # @return: tdb (Time Object)
14
+ #=========================================================================
15
+ def get_tdb
16
+ (puts Const::MSG_ERR_1; return) unless @arg =~ /^\d{8}$|^\d{14}$/
17
+ year, month, day = @arg[ 0, 4].to_i, @arg[ 4, 2].to_i, @arg[ 6, 2].to_i
18
+ hour, min, sec = @arg[ 8, 2].to_i, @arg[10, 2].to_i, @arg[12, 2].to_i
19
+ (puts Const::MSG_ERR_2; return) unless Date.valid_date?(year, month, day)
20
+ (puts Const::MSG_ERR_2; return) if hour > 23 || min > 59 || sec > 59
21
+ return Time.new(year, month, day, hour, min, sec, "+00:00")
22
+ end
23
+ end
24
+ end