Class: Ephem::Excerpt
- Inherits:
-
Object
- Object
- Ephem::Excerpt
- Defined in:
- lib/ephem/excerpt.rb
Overview
The Excerpt class creates SPK file excerpts with reduced time spans and target 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
Creates an excerpt of the SPK file.
-
#initialize(spk) ⇒ Excerpt
constructor
A new instance of Excerpt.
Constructor Details
#initialize(spk) ⇒ Excerpt
Returns a new instance of Excerpt.
23 24 25 26 27 |
# File 'lib/ephem/excerpt.rb', line 23 def initialize(spk) @spk = spk @daf = spk.instance_variable_get(:@daf) @binary_reader = @daf.instance_variable_get(:@binary_reader) end |
Instance Method Details
#extract(output_path:, start_jd:, end_jd:, target_ids: nil, debug: false) ⇒ Ephem::SPK
Creates an excerpt of the SPK file
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ephem/excerpt.rb', line 39 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 SPK.open(output_path) end |