ephem 0.5.2 → 0.6.0

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +185 -0
  3. data/README.md +171 -15
  4. data/bin/ruby-ephem +1 -2
  5. data/lib/ephem/cli.rb +174 -100
  6. data/lib/ephem/computation/chebyshev_polynomial.rb +82 -110
  7. data/lib/ephem/core/calendar_calculations.rb +17 -26
  8. data/lib/ephem/core/constants/bodies.rb +2 -0
  9. data/lib/ephem/core/constants/time.rb +1 -1
  10. data/lib/ephem/core/orientation.rb +23 -7
  11. data/lib/ephem/core/state.rb +48 -13
  12. data/lib/ephem/core/vector.rb +92 -24
  13. data/lib/ephem/download.rb +77 -14
  14. data/lib/ephem/error.rb +3 -3
  15. data/lib/ephem/excerpt.rb +126 -105
  16. data/lib/ephem/io/binary_reader.rb +29 -8
  17. data/lib/ephem/io/daf.rb +1 -4
  18. data/lib/ephem/io/endianness_manager.rb +5 -18
  19. data/lib/ephem/io/record_data.rb +2 -20
  20. data/lib/ephem/io/record_parser.rb +1 -1
  21. data/lib/ephem/io/summary_manager.rb +24 -15
  22. data/lib/ephem/pck.rb +24 -7
  23. data/lib/ephem/segments/base_segment.rb +38 -20
  24. data/lib/ephem/segments/chebyshev_type2.rb +105 -58
  25. data/lib/ephem/segments/coverage.rb +66 -0
  26. data/lib/ephem/segments/orientation_segment.rb +17 -15
  27. data/lib/ephem/segments/orientation_source.rb +4 -2
  28. data/lib/ephem/segments/position_chain.rb +124 -0
  29. data/lib/ephem/segments/position_group.rb +24 -0
  30. data/lib/ephem/segments/segment.rb +87 -18
  31. data/lib/ephem/segments/segment_group.rb +19 -5
  32. data/lib/ephem/spk.rb +134 -11
  33. data/lib/ephem/version.rb +1 -1
  34. data/lib/ephem.rb +5 -3
  35. metadata +4 -10
  36. data/.rspec +0 -3
  37. data/.standard.yml +0 -3
  38. data/.tool-versions +0 -1
  39. data/CODE_OF_CONDUCT.md +0 -132
  40. data/Rakefile +0 -12
  41. data/benchmarks/run.rb +0 -431
  42. data/bin/console +0 -11
  43. data/bin/setup +0 -8
  44. data/lib/tasks/validate_accuracy.rake +0 -47
data/CODE_OF_CONDUCT.md DELETED
@@ -1,132 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, visible or invisible disability, ethnicity, sex characteristics, gender
8
- identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, caste, color, religion, or sexual
10
- identity and orientation.
11
-
12
- We pledge to act and interact in ways that contribute to an open, welcoming,
13
- diverse, inclusive, and healthy community.
14
-
15
- ## Our Standards
16
-
17
- Examples of behavior that contributes to a positive environment for our
18
- community include:
19
-
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
24
- and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the overall
26
- community
27
-
28
- Examples of unacceptable behavior include:
29
-
30
- * The use of sexualized language or imagery, and sexual attention or advances of
31
- any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email address,
35
- without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
37
- professional setting
38
-
39
- ## Enforcement Responsibilities
40
-
41
- Community leaders are responsible for clarifying and enforcing our standards of
42
- acceptable behavior and will take appropriate and fair corrective action in
43
- response to any behavior that they deem inappropriate, threatening, offensive,
44
- or harmful.
45
-
46
- Community leaders have the right and responsibility to remove, edit, or reject
47
- comments, commits, code, wiki edits, issues, and other contributions that are
48
- not aligned to this Code of Conduct, and will communicate reasons for moderation
49
- decisions when appropriate.
50
-
51
- ## Scope
52
-
53
- This Code of Conduct applies within all community spaces, and also applies when
54
- an individual is officially representing the community in public spaces.
55
- Examples of representing our community include using an official email address,
56
- posting via an official social media account, or acting as an appointed
57
- representative at an online or offline event.
58
-
59
- ## Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported to the community leaders responsible for enforcement at
63
- [INSERT CONTACT METHOD].
64
- All complaints will be reviewed and investigated promptly and fairly.
65
-
66
- All community leaders are obligated to respect the privacy and security of the
67
- reporter of any incident.
68
-
69
- ## Enforcement Guidelines
70
-
71
- Community leaders will follow these Community Impact Guidelines in determining
72
- the consequences for any action they deem in violation of this Code of Conduct:
73
-
74
- ### 1. Correction
75
-
76
- **Community Impact**: Use of inappropriate language or other behavior deemed
77
- unprofessional or unwelcome in the community.
78
-
79
- **Consequence**: A private, written warning from community leaders, providing
80
- clarity around the nature of the violation and an explanation of why the
81
- behavior was inappropriate. A public apology may be requested.
82
-
83
- ### 2. Warning
84
-
85
- **Community Impact**: A violation through a single incident or series of
86
- actions.
87
-
88
- **Consequence**: A warning with consequences for continued behavior. No
89
- interaction with the people involved, including unsolicited interaction with
90
- those enforcing the Code of Conduct, for a specified period of time. This
91
- includes avoiding interactions in community spaces as well as external channels
92
- like social media. Violating these terms may lead to a temporary or permanent
93
- ban.
94
-
95
- ### 3. Temporary Ban
96
-
97
- **Community Impact**: A serious violation of community standards, including
98
- sustained inappropriate behavior.
99
-
100
- **Consequence**: A temporary ban from any sort of interaction or public
101
- communication with the community for a specified period of time. No public or
102
- private interaction with the people involved, including unsolicited interaction
103
- with those enforcing the Code of Conduct, is allowed during this period.
104
- Violating these terms may lead to a permanent ban.
105
-
106
- ### 4. Permanent Ban
107
-
108
- **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
110
- individual, or aggression toward or disparagement of classes of individuals.
111
-
112
- **Consequence**: A permanent ban from any sort of public interaction within the
113
- community.
114
-
115
- ## Attribution
116
-
117
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
- version 2.1, available at
119
- [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
-
121
- Community Impact Guidelines were inspired by
122
- [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
-
124
- For answers to common questions about this code of conduct, see the FAQ at
125
- [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
- [https://www.contributor-covenant.org/translations][translations].
127
-
128
- [homepage]: https://www.contributor-covenant.org
129
- [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
- [Mozilla CoC]: https://github.com/mozilla/diversity
131
- [FAQ]: https://www.contributor-covenant.org/faq
132
- [translations]: https://www.contributor-covenant.org/translations
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- Dir.glob("lib/tasks/**/*.rake").each { |r| load r }
7
-
8
- RSpec::Core::RakeTask.new(:spec)
9
-
10
- require "standard/rake"
11
-
12
- task default: %i[spec standard]
data/benchmarks/run.rb DELETED
@@ -1,431 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "benchmark/ips"
4
- require "objspace"
5
- require_relative "../lib/ephem"
6
-
7
- # ---------------------------------------------------------------------------
8
- # Configuration
9
- # ---------------------------------------------------------------------------
10
-
11
- ROOT = File.expand_path("..", __dir__)
12
- SPK_FULL = File.join(ROOT, "spec", "support", "data", "de432s.bsp")
13
- SPK_EXCERPT = File
14
- .join(ROOT, "spec", "support", "data", "de421_2000_excerpt.bsp")
15
- PCK_EXCERPT = File
16
- .join(ROOT, "spec", "support", "data", "moon_pa_de440_excerpt.bpc")
17
-
18
- JD_J2000 = Ephem::Core::Constants::Time::J2000_EPOCH # 2451545.0
19
- JD_TEST = 2459000.0 # 2020-09-30, well within de432s range
20
-
21
- SEQUENTIAL_STEPS = 1000
22
-
23
- # Body pairs available in DE432s: [center, target]
24
- BODY_PAIRS = {
25
- "Sun" => [0, 10],
26
- "Earth-Moon Bary" => [0, 3],
27
- "Mars Bary" => [0, 4],
28
- "Jupiter Bary" => [0, 5],
29
- "Saturn Bary" => [0, 6]
30
- }.freeze
31
-
32
- # ---------------------------------------------------------------------------
33
- # Helpers
34
- # ---------------------------------------------------------------------------
35
-
36
- def separator(title)
37
- puts
38
- puts "=" * 70
39
- puts " #{title}"
40
- puts "=" * 70
41
- puts
42
- end
43
-
44
- def ensure_file!(path)
45
- return if File.exist?(path)
46
- abort "SPK file not found: #{path}\n" \
47
- "Run specs first or place the file manually."
48
- end
49
-
50
- # ---------------------------------------------------------------------------
51
- # Preflight
52
- # ---------------------------------------------------------------------------
53
-
54
- ensure_file!(SPK_FULL)
55
- ensure_file!(SPK_EXCERPT)
56
-
57
- puts "Ephem Benchmark Suite"
58
- puts "-" * 70
59
- puts "Ruby: #{RUBY_VERSION} (#{RUBY_PLATFORM})"
60
- puts "Ephem: #{Ephem::VERSION}"
61
- puts "SPK: #{File.basename(SPK_FULL)} (#{(File.size(SPK_FULL) / 1024.0 / 1024).round(2)} MB)"
62
- puts "Excerpt: #{File.basename(SPK_EXCERPT)} (#{(File.size(SPK_EXCERPT) / 1024.0).round(1)} KB)"
63
- puts "J2000: #{JD_J2000}"
64
- puts "Test JD: #{JD_TEST}"
65
- puts "-" * 70
66
-
67
- # Pre-open the main SPK file and warm up data for hot-path benchmarks
68
- spk = Ephem::SPK.open(SPK_FULL)
69
- segment_emb = spk[0, 3] # Earth-Moon Barycenter
70
- segment_sun = spk[0, 10] # Sun
71
-
72
- # Trigger lazy data loading so hot-path benchmarks don't include I/O
73
- segment_emb.compute(JD_TEST)
74
- segment_sun.compute(JD_TEST)
75
-
76
- # Pre-compute time arrays for sequential/random benchmarks
77
- sequential_times = Array.new(SEQUENTIAL_STEPS) { |i| JD_TEST + i }
78
- random_times = sequential_times.shuffle
79
-
80
- # =========================================================================
81
- # 1. SPK FILE OPENING
82
- # =========================================================================
83
-
84
- separator "1. SPK File Opening"
85
-
86
- GC.start
87
- Benchmark.ips do |x|
88
- x.report("SPK.open (full 10MB)") do
89
- s = Ephem::SPK.open(SPK_FULL)
90
- s.close
91
- end
92
-
93
- x.report("SPK.open (excerpt 54KB)") do
94
- s = Ephem::SPK.open(SPK_EXCERPT)
95
- s.close
96
- end
97
-
98
- x.compare!
99
- end
100
-
101
- # =========================================================================
102
- # 2. FIRST DATA LOAD (COLD START)
103
- # =========================================================================
104
-
105
- separator "2. First Data Load (Cold Start)"
106
-
107
- puts "Measures the cost of the first compute() call on a segment,"
108
- puts "which triggers lazy loading of coefficient data from disk."
109
- puts
110
-
111
- GC.start
112
- Benchmark.ips do |x|
113
- x.report("cold compute (load + eval)") do
114
- segment_emb.clear_data
115
- segment_emb.compute(JD_TEST)
116
- end
117
-
118
- x.report("warm compute (cached)") do
119
- segment_emb.compute(JD_TEST)
120
- end
121
-
122
- x.compare!
123
- end
124
-
125
- # Ensure data is loaded again for subsequent benchmarks
126
- segment_emb.compute(JD_TEST)
127
-
128
- # =========================================================================
129
- # 3. SINGLE POSITION COMPUTATION (HOT PATH)
130
- # =========================================================================
131
-
132
- separator "3. Single Position Computation (Hot Path)"
133
-
134
- puts "segment.compute(time) — Chebyshev eval + Vector creation"
135
- puts
136
-
137
- GC.start
138
- Benchmark.ips do |x|
139
- x.report("compute (position)") { segment_emb.compute(JD_TEST) }
140
- end
141
-
142
- # =========================================================================
143
- # 4. SINGLE STATE COMPUTATION
144
- # =========================================================================
145
-
146
- separator "4. Single State Computation"
147
-
148
- puts "segment.compute_and_differentiate(time) — position + velocity"
149
- puts
150
-
151
- GC.start
152
- Benchmark.ips do |x|
153
- x.report("compute_and_differentiate (state)") do
154
- segment_emb.compute_and_differentiate(JD_TEST)
155
- end
156
- end
157
-
158
- # =========================================================================
159
- # 5. POSITION vs STATE (COMPARISON)
160
- # =========================================================================
161
-
162
- separator "5. Position vs State (Direct Comparison)"
163
-
164
- GC.start
165
- Benchmark.ips do |x|
166
- x.report("compute (position only)") { segment_emb.compute(JD_TEST) }
167
- x.report("compute_and_differentiate") do
168
- segment_emb.compute_and_differentiate(JD_TEST)
169
- end
170
-
171
- x.compare!
172
- end
173
-
174
- # =========================================================================
175
- # 6. SEQUENTIAL TIME ACCESS
176
- # =========================================================================
177
-
178
- separator "6. Sequential Time Access (#{SEQUENTIAL_STEPS} days)"
179
-
180
- puts "Tests interval-finding binary search with temporal locality."
181
- puts "The @last_interval cache should accelerate sequential access."
182
- puts
183
-
184
- GC.start
185
- Benchmark.ips do |x|
186
- x.report("sequential (#{SEQUENTIAL_STEPS} days)") do
187
- sequential_times.each { |t| segment_emb.compute(t) }
188
- end
189
- end
190
-
191
- # =========================================================================
192
- # 7. RANDOM TIME ACCESS
193
- # =========================================================================
194
-
195
- separator "7. Random Time Access (#{SEQUENTIAL_STEPS} days, shuffled)"
196
-
197
- puts "Same times as above but shuffled — measures interval cache miss impact."
198
- puts
199
-
200
- GC.start
201
- Benchmark.ips do |x|
202
- x.report("sequential access") do
203
- sequential_times.each { |t| segment_emb.compute(t) }
204
- end
205
-
206
- x.report("random access") do
207
- random_times.each { |t| segment_emb.compute(t) }
208
- end
209
-
210
- x.compare!
211
- end
212
-
213
- # =========================================================================
214
- # 8. BATCH COMPUTATION
215
- # =========================================================================
216
-
217
- separator "8. Batch vs Loop Computation"
218
-
219
- batch_sizes = [10, 100, 1000]
220
-
221
- batch_sizes.each do |n|
222
- times = sequential_times.first(n)
223
-
224
- puts "--- Batch size: #{n} ---"
225
- GC.start
226
- Benchmark.ips do |x|
227
- x.report("loop (#{n} times)") do
228
- times.each { |t| segment_emb.compute_and_differentiate(t) }
229
- end
230
-
231
- x.report("batch (#{n} times)") do
232
- segment_emb.compute_and_differentiate(times)
233
- end
234
-
235
- x.compare!
236
- end
237
- puts
238
- end
239
-
240
- # =========================================================================
241
- # 9. MULTIPLE BODIES
242
- # =========================================================================
243
-
244
- separator "9. Multiple Bodies (Computation Speed by Target)"
245
-
246
- # Pre-load all segments
247
- body_segments = {}
248
- BODY_PAIRS.each do |name, (center, target)|
249
- seg = spk[center, target]
250
- seg.compute(JD_TEST) # warm up
251
- body_segments[name] = seg
252
- end
253
-
254
- GC.start
255
- Benchmark.ips do |x|
256
- body_segments.each do |name, seg|
257
- x.report(name) { seg.compute(JD_TEST) }
258
- end
259
-
260
- x.compare!
261
- end
262
-
263
- # =========================================================================
264
- # 10. CHEBYSHEV POLYNOMIAL (MICRO-BENCHMARK)
265
- # =========================================================================
266
-
267
- separator "10. Chebyshev Polynomial Evaluation (Micro)"
268
-
269
- puts "Direct ChebyshevPolynomial.evaluate / evaluate_derivative calls"
270
- puts "with real coefficients extracted from a loaded segment."
271
- puts
272
-
273
- # Extract real coefficient data from the loaded segment
274
- coefficients = segment_emb.instance_variable_get(:@coefficients)
275
- radii = segment_emb.instance_variable_get(:@radii)
276
-
277
- # Pick the first interval's coefficients
278
- test_coeffs = coefficients[0]
279
- test_radius = radii[0]
280
- test_t = 0.0 # midpoint of the interval (normalized)
281
-
282
- puts "Polynomial degree: #{test_coeffs.size} terms"
283
- puts "Components per term: #{test_coeffs.first.size}"
284
- puts
285
-
286
- GC.start
287
- Benchmark.ips do |x|
288
- x.report("evaluate (position)") do
289
- Ephem::Computation::ChebyshevPolynomial.evaluate(test_coeffs, test_t)
290
- end
291
-
292
- x.report("evaluate_derivative (velocity)") do
293
- Ephem::Computation::ChebyshevPolynomial.evaluate_derivative(
294
- test_coeffs, test_t, test_radius
295
- )
296
- end
297
-
298
- x.report("evaluate_with_derivative (pos+vel, 1 pass)") do
299
- Ephem::Computation::ChebyshevPolynomial.evaluate_with_derivative(
300
- test_coeffs, test_t, test_radius
301
- )
302
- end
303
-
304
- x.compare!
305
- end
306
-
307
- # =========================================================================
308
- # 11. VECTOR OPERATIONS
309
- # =========================================================================
310
-
311
- separator "11. Vector Operations"
312
-
313
- v1 = Ephem::Core::Vector.new(1.0, 2.0, 3.0)
314
- v2 = Ephem::Core::Vector.new(4.0, 5.0, 6.0)
315
-
316
- GC.start
317
- Benchmark.ips do |x|
318
- x.report("Vector.new") { Ephem::Core::Vector.new(1.0, 2.0, 3.0) }
319
- x.report("Vector + Vector") { v1 + v2 }
320
- x.report("Vector - Vector") { v1 - v2 }
321
- x.report("Vector.dot") { v1.dot(v2) }
322
- x.report("Vector.cross") { v1.cross(v2) }
323
- x.report("Vector.magnitude") { v1.magnitude }
324
- x.report("Vector.to_a") { v1.to_a }
325
-
326
- x.compare!
327
- end
328
-
329
- # =========================================================================
330
- # 12. MEMORY PROFILING
331
- # =========================================================================
332
-
333
- separator "12. Memory Profiling"
334
-
335
- # --- 12a. Object allocations per compute call ---
336
- puts "--- Object allocations per call ---"
337
- puts
338
-
339
- # Warm up
340
- segment_emb.compute(JD_TEST)
341
- segment_emb.compute_and_differentiate(JD_TEST)
342
-
343
- # Measure compute
344
- GC.start
345
- GC.disable
346
- before = GC.stat[:total_allocated_objects]
347
- segment_emb.compute(JD_TEST)
348
- after = GC.stat[:total_allocated_objects]
349
- GC.enable
350
- puts " compute (position): #{after - before} objects allocated"
351
-
352
- # Measure compute_and_differentiate
353
- GC.start
354
- GC.disable
355
- before = GC.stat[:total_allocated_objects]
356
- segment_emb.compute_and_differentiate(JD_TEST)
357
- after = GC.stat[:total_allocated_objects]
358
- GC.enable
359
- puts " compute_and_differentiate: #{after - before} objects allocated"
360
-
361
- # Measure batch of 100
362
- times_100 = sequential_times.first(100)
363
- GC.start
364
- GC.disable
365
- before = GC.stat[:total_allocated_objects]
366
- segment_emb.compute_and_differentiate(times_100)
367
- after = GC.stat[:total_allocated_objects]
368
- GC.enable
369
- alloc_100 = after - before
370
- puts " batch compute_and_diff (100): #{alloc_100} objects (#{(alloc_100 / 100.0).round(1)}/call)"
371
-
372
- puts
373
-
374
- # --- 12b. Segment data memory footprint ---
375
- puts "--- Segment data memory footprint ---"
376
- puts
377
-
378
- # Force a fresh load and measure
379
- segment_fresh = spk[0, 3]
380
- segment_fresh.clear_data
381
-
382
- GC.start
383
- before_mem = ObjectSpace.memsize_of_all
384
- segment_fresh.compute(JD_TEST) # triggers load
385
- GC.start
386
- after_mem = ObjectSpace.memsize_of_all
387
-
388
- delta_kb = (after_mem - before_mem) / 1024.0
389
- puts " Segment [0,3] data load: ~#{delta_kb.round(1)} KB"
390
-
391
- # Report coefficient array size
392
- coeffs = segment_fresh.instance_variable_get(:@coefficients)
393
- if coeffs
394
- puts " Coefficient records: #{coeffs.size}"
395
- puts " Terms per record: #{coeffs.first&.size}"
396
- puts " Components per term: #{coeffs.first&.first&.size}"
397
- end
398
-
399
- # =========================================================================
400
- # 13. PCK ORIENTATION (BINARY PCK)
401
- # =========================================================================
402
-
403
- separator "13. PCK Orientation (Binary PCK)"
404
-
405
- puts "angles_at (Euler angles) vs orientation_at (angles + rates)"
406
- puts
407
-
408
- pck = Ephem::PCK.open(PCK_EXCERPT)
409
- moon = pck[31008] # MOON_PA_DE440 frame
410
- moon.angles_at(JD_J2000) # warm up
411
-
412
- orientation_times = Array.new(SEQUENTIAL_STEPS) { |index| JD_J2000 + index }
413
-
414
- GC.start
415
- Benchmark.ips do |x|
416
- x.report("angles_at (scalar)") { moon.angles_at(JD_J2000) }
417
- x.report("orientation_at (scalar)") { moon.orientation_at(JD_J2000) }
418
- x.report("angles_at (batch 1000)") { moon.angles_at(orientation_times) }
419
-
420
- x.compare!
421
- end
422
-
423
- pck.close
424
-
425
- # =========================================================================
426
- # Cleanup
427
- # =========================================================================
428
-
429
- spk.close
430
-
431
- separator "Benchmark Complete"
data/bin/console DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "ephem"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- require "irb"
11
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
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
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "parallel"
4
-
5
- require_relative "../ephem/tasks/validate_accuracy"
6
-
7
- desc "
8
- Validate accuracy of library by comparing with python-jplephem.
9
- Usage: rake validate_accuracy date=1900 kernel=de440 target=1
10
- "
11
- task :validate_accuracy do
12
- date = ENV["date"]
13
- kernel = ENV["kernel"]
14
- target = ENV["target"]
15
-
16
- unless date && kernel && target
17
- puts "Error: All parameters are required"
18
- puts "Usage: rake validate_accuracy date=2000 kernel=de440s target=1"
19
- exit 1
20
- end
21
-
22
- unless Ephem::Tasks::ValidateAccuracy
23
- .run(date: date, kernel: kernel, target: target)
24
- exit 1
25
- end
26
- end
27
-
28
- namespace :validate_accuracy do
29
- task :all do
30
- kernels = Ephem::Tasks::ValidateAccuracy::KERNELS.keys
31
- targets = (1..10).to_a.map(&:to_s)
32
-
33
- parameter_sets = kernels.product(targets).map do |kernel, target|
34
- {date: "2000", kernel: kernel, target: target}
35
- end
36
-
37
- results = Parallel.map(parameter_sets, in_processes: 10) do |params|
38
- Ephem::Tasks::ValidateAccuracy.run(
39
- date: params[:date],
40
- kernel: params[:kernel],
41
- target: params[:target]
42
- )
43
- end
44
-
45
- exit 1 if results.any?(FalseClass)
46
- end
47
- end