/** * Finds the mean obliquity of the ecliptic (ε0) for a given date by using the * coefficients provided by Laskar. * * By using this method the accuracy is estimated to be at 0".01 after 1000 * years and a few arc seconds after 10,000 years on either side of the * epoch J2000. Also, this method is only valid over a period of 10,000 years * on either side of J2000 and will throe an exception if attempted on out * of range dates * * @param AstroDate $date Date to find ε0 for * @return Angle Mean obliquity (ε0) * @throws Exception Occurs with an out of range date, |year| > 10,000 * * @see Meeus, Jean. Astronomical Algorithms. Richmond, Virg.: Willmann-Bell, * 2009. 147. Print. */ public static function meanObliquityLaskar(AstroDate $date) { // Time factor $t = ($date->copy()->toUTC()->jd - 2451545.0) / 36525; // Check for out of range date if (abs($t) >= 1) { $msg = "The Laskar method is not valid for the year {$date->year}."; throw new Exception($msg); } $ε0TermsLaskar = [Angle::dms(23, 26, 21.448)->rad, Angle::dms(0, 0, -4680.93)->rad, Angle::dms(0, 0, -1.55)->rad, Angle::dms(0, 0, 1999.25)->rad, Angle::dms(0, 0, -51.38)->rad, Angle::dms(0, 0, -249.67)->rad, Angle::dms(0, 0, -39.05)->rad, Angle::dms(0, 0, 7.12)->rad, Angle::dms(0, 0, 27.87)->rad, Angle::dms(0, 0, 5.79)->rad, Angle::dms(0, 0, 2.45)->rad]; $ε0 = static::Horner($t, $ε0TermsLaskar); return Angle::rad($ε0); }
/** * Creates a new geographic location from values expressed as radians * * @param float $lat Latitude, radians * @param float $lon Longitude, radians West negative * * @return static */ public static function rad($lat, $lon) { return new static(Angle::rad($lat), Angle::rad($lon)); }
/** * Converts this instance to an equatorial coordinate * * @return Equat */ public function toEquat() { // Cartesian -> spherical IAU::C2s([$this->x->au, $this->y->au, $this->z->au], $theta, $phi); // Create RA and Declination components from radians $ra = Angle::rad($theta)->norm()->toTime(); $dec = Angle::rad($phi); // Return new equatorial instance using same frame and epoch return new Equat($this->frame, $this->epoch, $ra, $dec, $this->r); }
/** * Performs a [IRCS -> observed] coordinate transformation for the parameters * of this instance * @param string $type Coordintate type, 'e' for equat 'h' for horiz * @return static|Horiz */ protected function ICRStoObserved($type = 'e', Pressure $pressure = null, Temperature $temp = null, $humidity = null) { // Instance initial properties $rc = $this->ra->toAngle()->rad; $dc = $this->dec->rad; $date1 = $this->epoch->toDate()->toTDB()->toJD(); $pr = 0; $pd = 0; $rv = 0; $px = $this->dist->au > 0 ? 8.794 / 3600 / $this->dist->au : 0; $utc1 = $this->epoch->toDate()->toUTC()->toJD(); $dut1 = IERS::jd($utc1)->dut1(); $elong = $this->topo ? $this->topo->lon->rad : 0; $phi = $this->topo ? $this->topo->lat->rad : 0; $hm = 0; //$this->obsrv->height->m; $xp = IERS::jd($utc1)->x() / 3600 * pi() / 180; $yp = IERS::jd($utc1)->y() / 3600 * pi() / 180; $phpa = $pressure ? $pressure->mbar : 0; $tc = $temp ? $temp->c : 0; $rh = $humidity ? $humidity : 0; $wl = 0.55; // ICRS -> CIRS (geocentric observer) IAU::Atci13($rc, $dc, $pr, $pd, $px, $rv, $date1, 0, $ri, $di, $eo); // CIRS -> ICRS (astrometric) //IAU::Atic13($ri, $di, $date1, 0, $rca, $dca, $eo); // ICRS (astrometric) -> CIRS (geocentric observer) //IAU::Atci13($rca, $dca, $pr, $pd, $px, $rv, $date1, 0, $ri, $di, $eo); // Apparent place ? //$ri = $ri - $eo; //$di = $di; // // CIRS -> topocentric IAU::Atio13($ri, $di, $utc1, 0, $dut1, $elong, $phi, $hm, $xp, $yp, $phpa, $tc, $rh, $wl, $aob, $zob, $hob, $dob, $rob); if ($type == 'e') { // Copy this instance, and override the apparent RA and Decl $topocentric = $this->copy(); $topocentric->ra = Angle::rad($rob)->toTime(); $topocentric->dec = Angle::rad($dob); $topocentric->apparent = true; // Return apparent coordinates return $topocentric; } else { // Prepare new horizontal instance $horiz = new Horiz(Angle::rad(deg2rad(90) - $zob), Angle::rad($aob), $this->dist); return $horiz; } }
/** * Finds the sidereal time of this intsance * * @param type $mode Type of sidereal time... (a = apparent, m = mean) * @param Angle $lon If a longitude is supplied, finds local sidereal time, * otherwise returns sidereal time at Greenwich */ public function sidereal($mode = 'a', Angle $lon = null) { // Get UT1 time $ut = $this->copy()->toUT1(); $uta = $ut->jd; $utb = $ut->dayFrac; $ut = null; // Get TT time $tt = $this->copy()->toTT(); $tta = $tt->jd; $ttb = $tt->dayFrac; $tt = null; // Compute either GMST or GAST $st; if ($mode == 'a') { $strad = IAU::Gst06a($uta, $utb, $tta, $ttb); } else { $strad = IAU::Gmst06($uta, $utb, $tta, $ttb); } // Add longitude if relevant if ($lon) { $st = Angle::rad($strad)->add($lon)->norm()->toTime(); } else { $st = Angle::rad($strad)->toTime(); } // Return as hours return $st->setUnit('hours'); }
public function testSign() { $this->assertEquals('-', Angle::deg(-10)->sign); $this->assertEquals('-', Angle::rad(-10)->sign); $this->assertEquals('-', Angle::asec(-10)->sign); $this->assertEquals('-', Angle::amin(-10)->sign); $this->assertEquals('-', Angle::mas(-10)->sign); $this->assertEquals('-', Angle::dms(-10, 0, 0, 0)->sign); $this->assertEquals('-', Angle::dms(0, -10, 0, 0)->sign); $this->assertEquals('-', Angle::dms(0, 0, -10, 0)->sign); $this->assertEquals('-', Angle::dms(0, 0, 0, -10)->sign); $this->assertEquals('+', Angle::dms(10, 0, 0, 0)->sign); $this->assertEquals('+', Angle::dms(1, -10, 0, 0)->sign); $this->assertEquals('+', Angle::dms(1, 0, -10, 0)->sign); $this->assertEquals('+', Angle::dms(1, 0, 0, -10)->sign); $this->assertEquals('+', Angle::deg(10)->sign); $this->assertEquals('+', Angle::rad(10)->sign); $this->assertEquals('+', Angle::asec(10)->sign); $this->assertEquals('+', Angle::amin(10)->sign); $this->assertEquals('+', Angle::mas(10)->sign); }