Example #1
0
 /**
  * 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);
 }
Example #2
0
 /**
  * Calculates the offset of this time zone for a given Julian date. Accounts
  * for daylight savings time if relevant and based on the date.
  *
  * @param  float $jd Julian date to check for
  * @return float     Offset in hours including DST (if relevant)
  */
 public function offset($jd)
 {
     // Is DST observed for this timezone? If no, return offset as is
     if ($this->dst == false) {
         return $this->offset;
     }
     // Get YMD for provided JD and day of year number (with fractional day)
     IAU::Jd2cal($jd, 0, $y, $m, $d, $fd);
     $dayN = static::dayOfYear($y, $m, $d) + $fd;
     // DST begins at 2:00 a.m. on the second Sunday of March and...
     IAU::Cal2jd($y, 3, 1, $djm0, $djm);
     $dayB = static::dayOfYear($y, 2, 1) + 14 - static::weekDayNum($djm0 + $djm) + 2 / 24;
     // ...ends at 2:00 a.m. on the first Sunday of November
     IAU::Cal2jd($y, 11, 1, $djm0, $djm);
     $dayE = static::dayOfYear($y, 11, 1) + 14 - static::weekDayNum($djm0 + $djm) + 2 / 24;
     // Check if the given JD falls with in the DST range for that year
     if ($dayN >= $dayB && $dayN < $dayE) {
         return $this->offset + 1;
     } else {
         return $this->offset;
     }
 }
Example #3
0
 /**
  * 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;
     }
 }
Example #4
0
 /**
  * Gets a component of this date
  *
  * @param  string    $e Component name, e.g. year, month, etc...
  * @return int|float
  */
 protected function getComponent($e)
 {
     // JD -> Date
     $ihmsf = [];
     IAU::D2dtf($this->timescale, $this->prec - 2, $this->jd, $this->dayFrac, $iy, $im, $id, $ihmsf);
     switch ($e) {
         case 'year':
             return $iy;
         case 'month':
             return $im;
         case 'day':
             return $id;
         case 'hour':
             return $ihmsf[0];
         case 'min':
             return $ihmsf[1];
         case 'sec':
             return $ihmsf[2];
         case 'micro':
             return $ihmsf[3];
     }
 }