Class: Ephem::Excerpt
- Inherits:
-
Object
- Object
- Ephem::Excerpt
- Defined in:
- lib/ephem/excerpt.rb
Overview
The Excerpt class creates DAF excerpts (SPK or binary PCK) with reduced time spans and bodies. This is useful for creating smaller files that focus only on the data needed for specific applications.
Defined Under Namespace
Classes: DAFWriter
Constant Summary collapse
- S_PER_DAY =
Constants for time calculations
Core::Constants::Time::SECONDS_PER_DAY
- J2000_EPOCH =
Core::Constants::Time::J2000_EPOCH
- RECORD_SIZE =
1024
Instance Method Summary collapse
-
#extract(output_path:, start_jd:, end_jd:, target_ids: nil, debug: false) ⇒ Ephem::SPK, Ephem::PCK
Creates an excerpt of the SPK file.
-
#initialize(kernel) ⇒ Excerpt
constructor
A new instance of Excerpt.
Constructor Details
#initialize(kernel) ⇒ Excerpt
Returns a new instance of Excerpt.
23 24 25 26 27 |
# File 'lib/ephem/excerpt.rb', line 23 def initialize(kernel) @kernel = kernel @daf = kernel.daf @binary_reader = @daf.binary_reader end |
Instance Method Details
#extract(output_path:, start_jd:, end_jd:, target_ids: nil, debug: false) ⇒ Ephem::SPK, Ephem::PCK
Creates an excerpt of the SPK file
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ephem/excerpt.rb', line 40 def extract(output_path:, start_jd:, end_jd:, target_ids: nil, debug: false) start_seconds = seconds_since_j2000(start_jd) end_seconds = seconds_since_j2000(end_jd) output_file = File.open(output_path, "wb+") copy_file_header(output_file) initialize_summary_section(output_file) writer = create_daf_writer(output_file, debug) process_segments(writer, start_seconds, end_seconds, target_ids, debug) output_file.close reopen(output_path) end |