/* OK, now put all of the above together to give the observatory coordinates * wrt SSBary in ICRS/AU. */ void earth_ssbary(double jd, int obscode, double *xtopo, double *ytopo, double *ztopo) { double xgeo[3], xobs,yobs,zobs; /* Return zero if we are "observing" from ssbary */ if (obscode==OBSCODE_SSBARY) { *xtopo = *ytopo = *ztopo = 0.; return; } /* Use Horizons to get the coordinates of geocenter */ geocenter_ssbary(jd,xgeo); /* fprintf(stderr,"geocenter ICRS: %g %g %g\n",xgeo[0],xgeo[1],xgeo[2]); */ /* Now get the geocenter->observatory vector */ observatory_geocenter(jd, obscode, &xobs, &yobs, &zobs); /* fprintf(stderr,"observ ICRS: %g %g %g\n", xobs, yobs, zobs); */ /* Add in to give observatory coords in ICRS */ *xtopo = xgeo[0] + xobs; *ytopo = xgeo[1] + yobs; *ztopo = xgeo[2] + zobs; return; }
/* Return the angle btwn zenith (anti-earth) direction and target*/ double zenith_angle(OBSERVATION *obs) { double xobs, yobs, zobs, r; double xec, yec, zec, cosb; /* Get the anti-Earth vector (in ICRS) for this observation */ observatory_geocenter(obs->obstime/DAY+jd0, obs->obscode, &xobs, &yobs, &zobs); r = sqrt(xobs*xobs+yobs*yobs+zobs*zobs); if (r<=0.) { fprintf(stderr,"Non-positive geocentric radius in zenith_angle()\n"); exit(1); } xobs /=r; yobs/=r; zobs/=r; /* Rotate this ICRS vector into ecliptic, then projected coords */ xyz_eq_to_ec(xobs, yobs, zobs, &xec, &yec, &zec,NULL); xyz_ec_to_proj(xec, yec, zec, &xobs, &yobs, &zobs, lat0, lon0, NULL); /* dot the observation direction into the (Earth->bary) vector*/ cosb = obs->thetax*xobs + obs->thetay*yobs + zobs; cosb /= sqrt(1+obs->thetax*obs->thetax+obs->thetay*obs->thetay); return acos(cosb); }