/** * Creates a new JPL DE ephemeris reader * * @param DE $de JPL DE version to load * @param float $jde Optional initial JDE in TDB */ public function __construct(DE $de = null, $jde = 2451545.5) { // Set DE version if provided otherwise load default $this->de = $de ? $de : DE::parse(static::DE_DEFAULT); // Get the DE storage path $this->path = $this->getStoragePath(); // Parse DE header file $this->header = new Header($this->selectHeaderFile()); // Set initial JDE of instance $this->jde($jde); }
public function testpo() { // Define number of tests to run $testLimit = 250; // Create reader, and obtain testpo file reference $reader = new Reader(DE::DE421()); $testpo = Reader::testpo(DE::DE421()); // Seek initial test line $testpo->seek(8); // Iterate through each line in the testpo file for ($i = 0; $i < $testLimit; $i++) { // Read and split next line to array $testpo->next(); $line = $testpo->splitCurrent(' '); // Check if array has the tests if (count($line) != 7) { continue; } // Parse out test values $jde = $line[2]; $target = $line[3]; $center = $line[4]; $elem = $line[5]; $valExp = (double) $line[6]; // Only test Planets if ($target > 9 || $center > 9) { continue; } // Get SSObj instance for target & center $target = $target == 3 ? SSObj::Earth() : new SSObj($target); $center = $center == 3 ? SSObj::Earth() : new SSObj($center); // Interpolate position/velocity & grab test coordinate element $posvel = $reader->jde($jde)->position($target, $center); $valAct = $posvel[$elem - 1]; /* $e = sprintf('%+11.13E', $valExp); $a = sprintf('%+11.13E', $valAct); echo "\n{$center} -> {$target}\n--- $e\n+++ $a\n"; * */ $this->assertEquals($valExp, $valAct, $jde, 1.0E-13); } echo "\n"; }