コード例 #1
0
ファイル: subet.c プロジェクト: chopley/controlCode
void slaSubet ( double rc, double dc, double eq, double *rm, double *dm )
/*
**  - - - - - - - - -
**   s l a S u b e t
**  - - - - - - - - -
**
**  Remove the e-terms (elliptic component of annual aberration)
**  from a pre IAU 1976 catalogue RA,Dec to give a mean place.
**
**  (double precision)
**
**  Given:
**     rc,dc     double     RA,Dec (radians) with e-terms included
**     eq        double     Besselian epoch of mean equator and equinox
**
**  Returned:
**     *rm,*dm   double     RA,Dec (radians) without e-terms
**
**  Called:
**     slaEtrms, slaDcs2c, sla,dvdv, slaDcc2s, slaDranrm
**
**  Explanation:
**     Most star positions from pre-1984 optical catalogues (or
**     derived from astrometry using such stars) embody the
**     e-terms.  This routine converts such a position to a
**     formal mean place (allowing, for example, comparison with a
**     pulsar timing position).
**
**  Reference:
**     Explanatory Supplement to the Astronomical Ephemeris,
**     section 2D, page 48.
**
**  Last revision:   31 October 1993
**
**  Copyright P.T.Wallace.  All rights reserved.
*/
{
   double a[3], v[3], f;

   int i;

/* E-terms */
   slaEtrms ( eq, a );

/* Spherical to Cartesian */
   slaDcs2c ( rc, dc, v );

/* Include the e-terms */
   f = 1.0 + slaDvdv (v, a);
   for ( i = 0; i < 3; i++ ) {
      v[i] = f * v[i] - a[i];
   }

/* Cartesian to spherical */
   slaDcc2s ( v, rm, dm );

/* Bring RA into conventional range */
   *rm = slaDranrm ( *rm );
}
コード例 #2
0
ファイル: eqecl.c プロジェクト: chopley/controlCode
void slaEqecl ( double dr, double dd, double date,
                double *dl, double *db )
/*
**  - - - - - - - - -
**   s l a E q e c l
**  - - - - - - - - -
**
**  Transformation from J2000.0 equatorial coordinates to
**  ecliptic coordinates.
**
**  (double precision)
**
**  Given:
**     dr,dd       double      J2000.0 mean RA,Dec (radians)
**     date        double      TDB (loosely ET) as Modified Julian Date
**                                              (JD-2400000.5)
**  Returned:
**     *dl,*db     double      ecliptic longitude and latitude
**                             (mean of date, IAU 1980 theory, radians)
**
**
**  Called:
**     slaDcs2c, slaPrec, slaEpj, slaDmxv, slaEcmat, slaDcc2s,
**     slaDranrm, slaDrange
**
**
**  Last revision:   31 October 1993
**
**  Copyright P.T.Wallace.  All rights reserved.
*/
{
   double rmat[3][3], v1[3], v2[3];

/* Spherical to Cartesian */
   slaDcs2c ( dr, dd, v1 );

/* Mean J2000 to mean of date */
   slaPrec ( 2000.0, slaEpj ( date ), rmat );
   slaDmxv ( rmat, v1, v2 );

/* Equatorial to ecliptic */
   slaEcmat ( date, rmat );
   slaDmxv ( rmat, v2, v1 );

/* Cartesian to spherical */
   slaDcc2s ( v1, dl, db );

/* Express in conventional ranges */
   *dl = slaDranrm ( *dl );
   *db = slaDrange ( *db );
}
コード例 #3
0
ファイル: ampqk.c プロジェクト: snfraser/astrolib
void slaAmpqk ( double ra, double da, double amprms[21],
                double *rm, double *dm )
/*
**  - - - - - - - - -
**   s l a A m p q k
**  - - - - - - - - -
**
**  Convert star RA,Dec from geocentric apparent to mean place.
**
**  The mean coordinate system is the post IAU 1976 system,
**  loosely called FK5.
**
**  Use of this routine is appropriate when efficiency is important
**  and where many star positions are all to be transformed for
**  one epoch and equinox.  The star-independent parameters can be
**  obtained by calling the slaMappa routine.
**
**  Given:
**     ra       double      apparent RA (radians)
**     da       double      apparent Dec (radians)
**
**     amprms   double[21]  star-independent mean-to-apparent parameters:
**
**       (0)      time interval for proper motion (Julian years)
**       (1-3)    barycentric position of the Earth (AU)
**       (4-6)    heliocentric direction of the Earth (unit vector)
**       (7)      (grav rad Sun)*2/(Sun-Earth distance)
**       (8-10)   abv: barycentric Earth velocity in units of c
**       (11)     sqrt(1-v*v) where v=modulus(abv)
**       (12-20)  precession/nutation (3,3) matrix
**
**  Returned:
**     *rm      double      mean RA (radians)
**     *dm      double      mean Dec (radians)
**
**  References:
**     1984 Astronomical Almanac, pp B39-B41.
**     (also Lederle & Schwan, Astron. Astrophys. 134, 1-6, 1984)
**
**  Note:
**
**     Iterative techniques are used for the aberration and
**     light deflection corrections so that the routines
**     slaAmp (or slaAmpqk) and slaMap (or slaMapqk) are
**     accurate inverses;  even at the edge of the Sun's disc
**     the discrepancy is only about 1 nanoarcsecond.
**
**  Called:  slaDcs2c, slaDimxv, slaDvdv, slaDvn, slaDcc2s,
**           slaDranrm
**
**  Last revision:   7 May 2000
**
**  Copyright P.T.Wallace.  All rights reserved.
*/
{
   double gr2e;    /* (grav rad Sun)*2/(Sun-Earth distance) */
   double ab1;     /* sqrt(1-v*v) where v=modulus of Earth vel */
   double ehn[3];  /* Earth position wrt Sun (unit vector, FK5) */
   double abv[3];  /* Earth velocity wrt SSB (c, FK5) */
   double p[3], p1[3], p2[3], p3[3];  /* work vectors */
   double ab1p1, p1dv, p1dvp1, w, pde, pdep1;
   int i, j;

/* Unpack some of the parameters */
   gr2e = amprms[7];
   ab1  = amprms[11];
   for ( i = 0; i < 3; i++ ) {
      ehn[i] = amprms[i + 4];
      abv[i] = amprms[i + 8];
   }

/* Apparent RA,Dec to Cartesian */
   slaDcs2c ( ra, da, p3 );

/* Precession and nutation */
   slaDimxv ( (double(*)[3]) &amprms[12], p3, p2 );

/* Aberration */
   ab1p1 = ab1 + 1.0;
   for ( i = 0; i < 3; i++ ) {
      p1[i] = p2[i];
   }
   for ( j = 0; j < 2; j++ ) {
      p1dv = slaDvdv ( p1, abv );
      p1dvp1 = 1.0 + p1dv;
      w = 1.0 + p1dv / ab1p1;
      for ( i = 0; i < 3; i++ ) {
         p1[i] = ( p1dvp1 * p2[i] - w * abv[i] ) / ab1;
      }
      slaDvn ( p1, p3, &w );
      for ( i = 0; i < 3; i++ ) {
         p1[i] = p3[i];
      }
   }

/* Light deflection */
   for ( i = 0; i < 3; i++ ) {
      p[i] = p1[i];
   }
   for ( j = 0; j < 5; j++ ) {
      pde = slaDvdv ( p, ehn );
      pdep1 = 1.0 + pde;
      w = pdep1 - gr2e * pde;
      for ( i = 0; i < 3; i++ ) {
         p[i] = ( pdep1 * p1[i] - gr2e * ehn[i] ) / w;
      }
      slaDvn ( p, p2, &w );
      for ( i = 0; i < 3; i++ ) {
         p[i] = p2[i];
      }
   }

/* Mean RA,Dec */
   slaDcc2s ( p, rm, dm );
   *rm = slaDranrm ( *rm );
}
コード例 #4
0
void projCircle(double racen, double deccen, double radius, double val) {
  int i, j, ip, in, sign, pixval;
  float mx[NCIRC], my[NCIRC];
  double t, axialvec[3], cenvec[3], angvec[3], rotvec[3], rmat[3][3];
  double ra[NCIRC], rap[NCIRC], ran[NCIRC];
  double dec[NCIRC], decp[NCIRC], decn[NCIRC];
  double x, y;

  // make Cartesian representation of the vector pointing to center
  slaDcs2c(racen, deccen, cenvec);

  // make Cartesian representation of a vector pointing radius away
  if(deccen>0.0)
    slaDcs2c(racen, deccen-radius, angvec);
  else
    slaDcs2c(racen, deccen+radius, angvec);

  t = 0;
  for(i=0; i<NCIRC; i++) {
    // length of axial vector is angle of rotation
    for(j=0;j<3;j++) axialvec[j] = cenvec[j]*t;
    // get rotation matrix
    slaDav2m(axialvec, rmat);
    // apply rotation to angled vector
    slaDmxv(rmat, angvec, rotvec);
    // get new ra, dec
    slaDcc2s(rotvec, &(ra[i]), &(dec[i]));
    //    if(ra[i] < 0 && racen > 0.0) ra[i] += 2*M_PI;
    //    if(ra[i] > 0 && racen < 0.0) ra[i] -= 2*M_PI;
    // update rotation angle
    t += 2.0*M_PI/(double) (NCIRC-1);
  }

  pixval = rint((__minind*(__maxval-val) + __maxind*(val-__minval))/
               (__maxval-__minval));

  // saturate properly
  pixval = MIN(__maxind, pixval);
  pixval = MAX(__minind, pixval);

  cpgsci(pixval);

  // determine if the polygon wraps around
  sign = 0;
  for(i=0; i<NCIRC-1; i++) {
    if(dec[i]>deccen && ra[i+1]*ra[i] < 0 && ra[i+1]<ra[i]) sign = 1;
  }

  // if so, draw two polygons separately
  if(sign) {
    in = 0;
    ip = 0;
    for(i=0; i<NCIRC; i++) {
      if(ra[i]<0.0) {
        ran[in] = ra[i]; decn[in] = dec[i]; in++;
      }
      else {
        ran[in] = -0.99999*M_PI; decn[in] = dec[i]; in++;
      }
      if(ra[i]>0.0) {
        rap[ip] = ra[i]; decp[ip] = dec[i]; ip++;
      }
      else {
        rap[ip] = 0.99999*M_PI; decp[ip] = dec[i]; ip++;
      }
    }
    
    for(i=0; i<ip; i++) {
      // Hammer-Aitoff projection
      project(rap[i], decp[i], &x, &y);
      mx[i] = x; my[i] = y;
    }
    cpgpoly(ip,mx,my);
    
    for(i=0; i<in; i++) {
      // Hammer-Aitoff projection
      project(ran[i], decn[i], &x, &y);
      mx[i] = x; my[i] = y;
    }
    cpgpoly(in,mx,my);
  }
  // otherwise draw only one
  else {
    for(i=0; i<NCIRC; i++) {
      // Hammer-Aitoff projection
      project(ra[i], dec[i], &x, &y);
      mx[i] = x; my[i] = y;
    }
    cpgpoly(NCIRC,mx,my);
  }

  cpgsci(1);
}