calc_sun 0.1.1 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +15 -0
- data/.gitignore +12 -0
- data/.source_index +0 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +19 -28
- data/Guardfile +41 -0
- data/LICENSE.txt +21 -21
- data/Manifest.txt +20 -4
- data/README.rdoc +45 -37
- data/Rakefile +76 -11
- data/calc_sun.gemspec +10 -15
- data/dev.md +49 -0
- data/example/Almanac.html +1456 -0
- data/example/Makefile +10 -0
- data/example/adt_helper.rb +91 -0
- data/example/askgeo_query.rb +32 -0
- data/example/eq_center.md +15 -0
- data/example/sunriset.c +670 -0
- data/example/sunriset.exe +0 -0
- data/example/sunriset.rb +16 -28
- data/example/test_my_times.rb +134 -0
- data/ext/calc_sun/calc_sun.c +491 -224
- data/ext/side_time/extconf.rb +5 -0
- data/ext/side_time/side_time.c +117 -0
- data/lib/calc_sun.rb +1 -0
- data/lib/calc_sun/version.rb +3 -2
- data/lib/side_time/side_time.so +0 -0
- data/lib/side_time/version.rb +7 -0
- data/lib/sidereal_time.rb +4 -0
- metadata +37 -62
- metadata.gz.sig +0 -0
- data/test/calc_sun_test.rb +0 -230
@@ -0,0 +1,117 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include <math.h>
|
3
|
+
#include <time.h>
|
4
|
+
/* if PI's not defined, define it */
|
5
|
+
#ifndef PI
|
6
|
+
#define PI 3.14159265358979323846
|
7
|
+
#endif
|
8
|
+
#ifndef DBL2NUM
|
9
|
+
# define DBL2NUM(dbl) rb_float_new(dbl)
|
10
|
+
#endif
|
11
|
+
# define R2D 57.295779513082320876798154814105
|
12
|
+
# define D2R 0.017453292519943295769236907684886
|
13
|
+
# define M2PI M_PI * 2.0
|
14
|
+
# define INV24 1.0 / 24.0
|
15
|
+
# define INV360 1.0 / 360.0
|
16
|
+
# define DJ00 2451545.0L
|
17
|
+
# define RND12 1000000000000.0
|
18
|
+
|
19
|
+
/*
|
20
|
+
* call-seq:
|
21
|
+
* initialize()
|
22
|
+
*
|
23
|
+
* Create CalcSun class Ruby object.
|
24
|
+
*
|
25
|
+
*/
|
26
|
+
static VALUE t_init(VALUE self){
|
27
|
+
return self;
|
28
|
+
}
|
29
|
+
/*
|
30
|
+
* call-seq:
|
31
|
+
* date('yyyy-mm-dd')
|
32
|
+
*
|
33
|
+
* convert input string to Date object.
|
34
|
+
*
|
35
|
+
*/
|
36
|
+
static VALUE func_set_datetime(VALUE self, VALUE vdate){
|
37
|
+
VALUE cDate = rb_const_get(rb_cObject, rb_intern("DateTime"));
|
38
|
+
VALUE day = rb_funcall(cDate, rb_intern("parse"), 1, vdate);
|
39
|
+
return day;
|
40
|
+
}
|
41
|
+
/*
|
42
|
+
* call-seq:
|
43
|
+
* jd(date)
|
44
|
+
*
|
45
|
+
* convert Date or DateTime object to JD number.
|
46
|
+
*
|
47
|
+
*/
|
48
|
+
static VALUE func_get_jd(VALUE self, VALUE vdate){
|
49
|
+
double jd = NUM2DBL(rb_funcall(vdate, rb_intern("jd"), 0));
|
50
|
+
return DBL2NUM(jd);
|
51
|
+
}
|
52
|
+
/*
|
53
|
+
* call-seq:
|
54
|
+
* ajd(date)
|
55
|
+
*
|
56
|
+
* convert Date or DateTime object to AJD number.
|
57
|
+
*
|
58
|
+
*/
|
59
|
+
static VALUE func_get_ajd(VALUE self, VALUE vdate){
|
60
|
+
double ajd = NUM2DBL(rb_funcall(vdate, rb_intern("ajd"), 0));
|
61
|
+
return DBL2NUM(ajd);
|
62
|
+
}
|
63
|
+
/*
|
64
|
+
* call-seq:
|
65
|
+
* gmst(date)
|
66
|
+
*
|
67
|
+
* calculate Greenwhich Mean Sidereal Time.
|
68
|
+
*
|
69
|
+
*/
|
70
|
+
static VALUE func_mean_sidetime(VALUE self, VALUE vdate){
|
71
|
+
double ajd = NUM2DBL(func_get_ajd(self, vdate));
|
72
|
+
long double sidereal;
|
73
|
+
long double t;
|
74
|
+
t = (ajd - 2451545.0) / 36525.0;
|
75
|
+
/* calc mean angle */
|
76
|
+
sidereal =
|
77
|
+
280.46061837 +
|
78
|
+
(360.98564736629 * (ajd - 2451545.0)) +
|
79
|
+
(0.000387933 * t * t) -
|
80
|
+
(t * t * t / 38710000.0);
|
81
|
+
sidereal = fmod(sidereal, 360.0);
|
82
|
+
/* change to hours */
|
83
|
+
sidereal *= 24.0 / 360.0;
|
84
|
+
return DBL2NUM(roundf(sidereal * RND12) / RND12);
|
85
|
+
}
|
86
|
+
/*
|
87
|
+
* call-seq:
|
88
|
+
* lmst(date)
|
89
|
+
*
|
90
|
+
* calculate Local Mean Sidereal Time.
|
91
|
+
*
|
92
|
+
*/
|
93
|
+
static VALUE func_local_sidetime(VALUE self, VALUE vdate, VALUE vlon){
|
94
|
+
double sidereal;
|
95
|
+
double ls;
|
96
|
+
double lon = NUM2DBL(vlon);
|
97
|
+
sidereal = NUM2DBL(func_mean_sidetime(self, vdate));
|
98
|
+
sidereal *= 15.0;
|
99
|
+
ls = sidereal + lon;
|
100
|
+
ls *= 24.0 / 360.0;
|
101
|
+
return DBL2NUM(roundf(ls * RND12) / RND12);
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
void Init_side_time(void){
|
106
|
+
VALUE cSideTime = rb_define_class("SideTime", rb_cObject);
|
107
|
+
rb_require("date");
|
108
|
+
rb_define_method(cSideTime, "initialize", t_init, 0);
|
109
|
+
rb_define_attr(cSideTime, "date", 1, 1);
|
110
|
+
rb_define_method(cSideTime, "ajd", func_get_ajd, 1);
|
111
|
+
rb_define_method(cSideTime, "s_datetime", func_set_datetime, 1);
|
112
|
+
rb_define_method(cSideTime, "jd", func_get_jd, 1);
|
113
|
+
//rb_define_method(cSideTime, "jd2000_dif", func_jd_from_2000, 1);
|
114
|
+
//rb_define_method(cSideTime, "jd2000_dif_lon", func_days_from_2000, 2);
|
115
|
+
rb_define_method(cSideTime, "lmst", func_local_sidetime, 2);
|
116
|
+
rb_define_method(cSideTime, "gmst", func_mean_sidetime, 1);
|
117
|
+
}
|
data/lib/calc_sun.rb
CHANGED
data/lib/calc_sun/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calc_sun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Douglas Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
@@ -30,101 +30,76 @@ cert_chain:
|
|
30
30
|
J4L8DCnzZFU8ARwINSdPvhk8WzXpVgErPQezTziVg7gAtBjqdJO5qVlAiOp+z7m2
|
31
31
|
gT57pae1qMGtqvMp
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
34
|
-
dependencies:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rake-compiler
|
37
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - "~>"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: 0.9.3
|
42
|
-
type: :development
|
43
|
-
prerelease: false
|
44
|
-
version_requirements: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 0.9.3
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rdoc
|
51
|
-
requirement: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - "~>"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '4.0'
|
56
|
-
type: :development
|
57
|
-
prerelease: false
|
58
|
-
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - "~>"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '4.0'
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: hoe
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - "~>"
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '3.15'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '3.15'
|
33
|
+
date: 2017-04-06 00:00:00.000000000 Z
|
34
|
+
dependencies: []
|
77
35
|
description: |-
|
78
|
-
|
79
|
-
|
36
|
+
supply the date yyyy-mm-dd, latitude decimal, and
|
37
|
+
longitude decimal in the calls to each method
|
38
|
+
rise(date, lat, lon),
|
39
|
+
noon(date, lat, lon), and
|
40
|
+
set(date, lat, lon)
|
80
41
|
email:
|
81
42
|
- kb9agt@gmail.com
|
82
43
|
executables: []
|
83
44
|
extensions:
|
84
45
|
- ext/calc_sun/extconf.rb
|
85
|
-
extra_rdoc_files:
|
86
|
-
- History.rdoc
|
87
|
-
- LICENSE.txt
|
88
|
-
- Manifest.txt
|
89
|
-
- README.rdoc
|
46
|
+
extra_rdoc_files: []
|
90
47
|
files:
|
48
|
+
- .autotest
|
49
|
+
- .gitignore
|
50
|
+
- .source_index
|
51
|
+
- .travis.yml
|
52
|
+
- CODE_OF_CONDUCT.md
|
91
53
|
- Gemfile
|
54
|
+
- Guardfile
|
92
55
|
- History.rdoc
|
93
56
|
- LICENSE.txt
|
94
57
|
- Manifest.txt
|
95
58
|
- README.rdoc
|
96
59
|
- Rakefile
|
97
60
|
- calc_sun.gemspec
|
61
|
+
- dev.md
|
62
|
+
- example/Almanac.html
|
63
|
+
- example/Makefile
|
64
|
+
- example/adt_helper.rb
|
65
|
+
- example/askgeo_query.rb
|
66
|
+
- example/eq_center.md
|
67
|
+
- example/sunriset.c
|
68
|
+
- example/sunriset.exe
|
98
69
|
- example/sunriset.rb
|
70
|
+
- example/test_my_times.rb
|
99
71
|
- ext/calc_sun/calc_sun.c
|
100
72
|
- ext/calc_sun/extconf.rb
|
73
|
+
- ext/side_time/extconf.rb
|
74
|
+
- ext/side_time/side_time.c
|
101
75
|
- lib/calc_sun.rb
|
76
|
+
- lib/calc_sun/calc_sun.so
|
102
77
|
- lib/calc_sun/version.rb
|
103
|
-
-
|
104
|
-
|
78
|
+
- lib/side_time/side_time.so
|
79
|
+
- lib/side_time/version.rb
|
80
|
+
- lib/sidereal_time.rb
|
81
|
+
homepage: https://github.com/DouglasAllen/calc_sun
|
105
82
|
licenses:
|
106
83
|
- MIT
|
107
84
|
metadata: {}
|
108
85
|
post_install_message:
|
109
|
-
rdoc_options:
|
110
|
-
- "--main"
|
111
|
-
- README.rdoc
|
86
|
+
rdoc_options: []
|
112
87
|
require_paths:
|
113
88
|
- lib
|
114
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
90
|
requirements:
|
116
|
-
- -
|
91
|
+
- - '>='
|
117
92
|
- !ruby/object:Gem::Version
|
118
93
|
version: '0'
|
119
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
95
|
requirements:
|
121
|
-
- -
|
96
|
+
- - '>='
|
122
97
|
- !ruby/object:Gem::Version
|
123
98
|
version: '0'
|
124
99
|
requirements: []
|
125
100
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.6.
|
101
|
+
rubygems_version: 2.6.10
|
127
102
|
signing_key:
|
128
103
|
specification_version: 4
|
129
|
-
summary:
|
104
|
+
summary: Calculates Sun Times ea. rise, noon, set
|
130
105
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|
data/test/calc_sun_test.rb
DELETED
@@ -1,230 +0,0 @@
|
|
1
|
-
|
2
|
-
gem 'minitest'
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require 'test/unit'
|
5
|
-
lib = File.expand_path('../../lib', __FILE__)
|
6
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
7
|
-
require 'calc_sun'
|
8
|
-
#
|
9
|
-
class CalcSunTest < Minitest::Test
|
10
|
-
def test_that_it_has_a_version_number
|
11
|
-
refute_nil ::CalcSun::VERSION
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_it_does_something_useful
|
15
|
-
assert false
|
16
|
-
end
|
17
|
-
end
|
18
|
-
require 'date'
|
19
|
-
#
|
20
|
-
# class TestCalcSun < MiniTest::Test
|
21
|
-
class TestCalcSun100 < Test::Unit::TestCase
|
22
|
-
def setup
|
23
|
-
@t = CalcSun.new
|
24
|
-
@t_ajd = 0.0
|
25
|
-
@t_lat = 0.0
|
26
|
-
@t_lon = 0.0
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_mean_anomaly
|
30
|
-
assert_equal(
|
31
|
-
6.240059966692,
|
32
|
-
@t.mean_anomaly(@t_ajd).round(12)
|
33
|
-
)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_eccentricity
|
37
|
-
assert_equal(
|
38
|
-
0.016709,
|
39
|
-
@t.eccentricity(@t_ajd)
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_equation_of_center
|
44
|
-
assert_equal(
|
45
|
-
-0.001471380867,
|
46
|
-
@t.equation_of_center(@t_ajd).round(12)
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_true_anomaly
|
51
|
-
assert_equal(
|
52
|
-
6.238588585825,
|
53
|
-
@t.true_anomaly(@t_ajd).round(12)
|
54
|
-
)
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_mean_longitude
|
58
|
-
assert_equal(
|
59
|
-
4.895063110817,
|
60
|
-
@t.mean_longitude(@t_ajd).round(12)
|
61
|
-
)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_eccentric_anomaly
|
65
|
-
assert_equal(
|
66
|
-
4.878582250862,
|
67
|
-
@t.eccentric_anomaly(@t_ajd).round(12)
|
68
|
-
)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_obliquity_of_ecliptic
|
72
|
-
assert_equal(
|
73
|
-
0.409092802283,
|
74
|
-
@t.obliquity_of_ecliptic(@t_ajd).round(12)
|
75
|
-
)
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_xv
|
79
|
-
assert_equal(
|
80
|
-
0.148720277673,
|
81
|
-
@t.xv(@t_ajd).round(12)
|
82
|
-
)
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_yv
|
86
|
-
assert_equal(
|
87
|
-
-0.986083974099,
|
88
|
-
@t.yv(@t_ajd).round(12)
|
89
|
-
)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_longitude_of_perihelion
|
93
|
-
assert_equal(
|
94
|
-
4.93824156691,
|
95
|
-
@t.longitude_of_perihelion(@t_ajd).round(12)
|
96
|
-
)
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_true_longitude
|
100
|
-
assert_equal(
|
101
|
-
4.893644845555,
|
102
|
-
@t.true_longitude(@t_ajd).round(12)
|
103
|
-
)
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_rv
|
107
|
-
assert_equal(
|
108
|
-
0.997235842199,
|
109
|
-
@t.rv(@t_ajd).round(12)
|
110
|
-
)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
#
|
115
|
-
class TestCalcSun200 < Test::Unit::TestCase
|
116
|
-
def setup
|
117
|
-
@t = CalcSun.new
|
118
|
-
@t_ajd = 0.0
|
119
|
-
@t_lat = 0.0
|
120
|
-
@t_lon = 0.0
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_ecliptic_x
|
124
|
-
assert_equal(
|
125
|
-
0.17976672602,
|
126
|
-
@t.ecliptic_x(@t_ajd).round(12)
|
127
|
-
)
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_ecliptic_y
|
131
|
-
assert_equal(
|
132
|
-
-0.980899204395,
|
133
|
-
@t.ecliptic_y(@t_ajd).round(12)
|
134
|
-
)
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_right_ascension
|
138
|
-
assert_equal(
|
139
|
-
18.753078192426,
|
140
|
-
@t.right_ascension(@t_ajd).round(12)
|
141
|
-
)
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_declination
|
145
|
-
assert_equal(
|
146
|
-
-0.372949956542,
|
147
|
-
@t.declination(@t_ajd).round(12)
|
148
|
-
)
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_sidereal_time
|
152
|
-
assert_equal(
|
153
|
-
6.697967333333,
|
154
|
-
@t.sidereal_time(@t_ajd).round(12)
|
155
|
-
)
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_local_sidereal_time
|
159
|
-
assert_equal(
|
160
|
-
18.697967333333,
|
161
|
-
@t.local_sidereal_time(@t_ajd, @t_lon).round(12)
|
162
|
-
)
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_dlt
|
166
|
-
assert_equal(
|
167
|
-
12.120732161881,
|
168
|
-
@t.dlt(@t_ajd, @t_lat).round(12)
|
169
|
-
)
|
170
|
-
end
|
171
|
-
|
172
|
-
def test_diurnal_arc
|
173
|
-
assert_equal(
|
174
|
-
6.06036608094,
|
175
|
-
@t.diurnal_arc(@t_ajd, @t_lat).round(12)
|
176
|
-
)
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_t_south
|
180
|
-
assert_equal(
|
181
|
-
12.055110859092,
|
182
|
-
@t.t_south(@t_ajd, @t_lon).round(12)
|
183
|
-
)
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_t_rise
|
187
|
-
assert_equal(
|
188
|
-
5.994744778152,
|
189
|
-
@t.t_rise(@t_ajd, @t_lon, @t_lat).round(12)
|
190
|
-
)
|
191
|
-
end
|
192
|
-
|
193
|
-
def test_t_mid_day
|
194
|
-
assert_equal(
|
195
|
-
12.055110859092,
|
196
|
-
@t.t_mid_day(@t_ajd, @t_lon, @t_lat).round(12)
|
197
|
-
)
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_t_set
|
201
|
-
assert_equal(
|
202
|
-
18.115476940033,
|
203
|
-
@t.t_set(@t_ajd, @t_lon, @t_lat).round(12)
|
204
|
-
)
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_rise_time
|
208
|
-
rise = @t.t_rise(@t_ajd, @t_lon, @t_lat).round(12)
|
209
|
-
assert_equal(
|
210
|
-
"Sun rises \t\t\t : 5:59 UTC",
|
211
|
-
"Sun rises \t\t\t : #{rise.floor}:#{(rise % 1 * 60.0).floor} UTC"
|
212
|
-
)
|
213
|
-
end
|
214
|
-
|
215
|
-
def test_midday_time
|
216
|
-
midday = @t.t_mid_day(@t_ajd, @t_lon, @t_lat).round(12)
|
217
|
-
assert_equal(
|
218
|
-
"Sun mid day \t\t\t : 12:3 UTC",
|
219
|
-
"Sun mid day \t\t\t : #{midday.floor}:#{((midday % 1.0) * 60).floor} UTC"
|
220
|
-
)
|
221
|
-
end
|
222
|
-
|
223
|
-
def test_set_time
|
224
|
-
set = @t.t_set(@t_ajd, @t_lon, @t_lat).round(12)
|
225
|
-
assert_equal(
|
226
|
-
"Sun sets \t\t\t : 18:6 UTC",
|
227
|
-
"Sun sets \t\t\t : #{set.floor}:#{(set % 1 * 60.0).floor} UTC"
|
228
|
-
)
|
229
|
-
end
|
230
|
-
end
|