1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
/*****************************************************************************/
/* easpec.c */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Calculates Earth-specific quantities (inclination of the rotation axis, */
/* sideral time, geocentric position of an observer, ...) */
/* This part of the library is not standalone (depends on earth and cmath). */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* (c) 2003, 2006; Pal, A. (apal@szofi.elte.hu). */
/*****************************************************************************/
#include <stdio.h>
#include <math.h>
#include <astro/astro.h>
#include <astro/earth.h>
#include <astro/easpec.h>
/*****************************************************************************/
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795028841968
#endif
/*****************************************************************************/
double get_earth_axis_angle(double jdate)
{
double jc;
static double cjdate=0.0,ce=0.0;
if ( cjdate==jdate ) return(ce);
jc=(jdate-2451545.0)/36525.0;
ce=23.439291+(-0.0130042+(-0.00000016+0.000000504*jc)*jc)*jc;
cjdate=jdate;
return(ce);
}
double get_sideral_time(double jdate)
{
double jc,jday;
static double cjdate=0.0,csid=0.0;
if ( cjdate==jdate ) return(csid);
jday=(double)((long)(jdate-0.5))+0.5;
jc=(jday-2415020.0)/36525.0;
csid=0.276919398+(100.0021359+0.000001075*jc)*jc;
csid+=1.002737908*(jdate-jday);
if ( csid<0 ) csid+=(double)((long)(-csid))+10.0;
csid=csid-(double)((long)csid);
csid=csid*360.0;
cjdate=jdate;
return(csid);
}
void get_observer_coords(double jdate,double lon,double lat,double *x,double *y,double *z)
{
double wx,wy,n,d,lst;
lst=get_sideral_time(jdate)+lon;
wx=r_earth_equ*cosa(lat);
wy=r_earth_pol*sina(lat);
n=sqrt(wx*wx+wy*wy);
d =r_earth_equ*wx/n;
*z=r_earth_pol*wy/n;
*x=d*cosa(lst);
*y=d*sina(lst);
}
double get_heliocentric_julian_date_diff(double jd,double ra,double dec)
{
double rx,ry,rz;
double nx,ny,nz;
double eps,dis,hjd_diff;
get_earth_coords(jd,&rx,&ry,&rz);
eps=get_earth_axis_angle(jd);
nx=cosa(dec)*cosa(ra);
ny=cosa(dec)*sina(ra);
nz=sina(dec);
rotate(&ny,&nz,-eps);
/* jd0=get_julian_date(2000,1,1); */
/* rotate(&nx,&ny,(jd-jd0)/(365.25*25800.0)*360.0); */
dis=nx*rx+ny*ry+nz*rz;
hjd_diff=dis * 0.0057755178;
return(hjd_diff);
}
double get_heliocentric_julian_date(double jd,double ra,double dec)
{
double hjd;
hjd=jd + get_heliocentric_julian_date_diff(jd,ra,dec);
return(hjd);
}
double get_heliocentric_julian_date_epoch(double jd,double ra,double dec,double y0)
{
double rx,ry,rz;
double nx,ny,nz;
double eps,dis,hjd,jd0;
get_earth_coords(jd,&rx,&ry,&rz);
eps=get_earth_axis_angle(jd);
nx=cosa(dec)*cosa(ra);
ny=cosa(dec)*sina(ra);
nz=sina(dec);
rotate(&ny,&nz,-eps);
jd0=2451545.0+(y0-2000.0)*365.25;
rotate(&nx,&ny,(jd-jd0)/(365.25*25800.0)*360.0);
dis=nx*rx+ny*ry+nz*rz;
hjd=jd + dis * 0.0057755178;
return(hjd);
}
double get_barycentric_julian_date_diff(double jd,double ra,double dec)
{
double rx,ry,rz;
double nx,ny,nz;
double bx,by,bz,tmass;
double jupx,jupy,jupz,
satx,saty,satz,
urax,uray,uraz,
nepx,nepy,nepz;
double eps,dis,bjd_diff;
get_planet_coords(jd,5,&jupx,&jupy,&jupz);
get_planet_coords(jd,6,&satx,&saty,&satz);
get_planet_coords(jd,7,&urax,&uray,&uraz);
get_planet_coords(jd,8,&nepx,&nepy,&nepz);
tmass=1+m_jupiter+m_saturn+m_uranus+m_neptune;
bx=(jupx*m_jupiter+satx*m_saturn+urax*m_uranus+nepx*m_neptune)/tmass;
by=(jupy*m_jupiter+saty*m_saturn+uray*m_uranus+nepy*m_neptune)/tmass;
bz=(jupz*m_jupiter+satz*m_saturn+uraz*m_uranus+nepz*m_neptune)/tmass;
get_earth_coords(jd,&rx,&ry,&rz);
rx-=bx;
ry-=by;
rz-=bz;
eps=get_earth_axis_angle(jd);
nx=cosa(dec)*cosa(ra);
ny=cosa(dec)*sina(ra);
nz=sina(dec);
rotate(&ny,&nz,-eps);
/* jd0=get_julian_date(2000,1,1); */
/* rotate(&nx,&ny,(jd-jd0)/(365.25*25800.0)*360.0); */
dis=nx*rx+ny*ry+nz*rz;
bjd_diff=dis * 0.0057755178;
return(bjd_diff);
}
double get_barycentric_julian_date(double jd,double ra,double dec)
{
double bjd;
bjd=jd + get_barycentric_julian_date_diff(jd,ra,dec);
return(bjd);
}
int get_annular_parallax_correction(double jd,double ra,double dec,double dis,double *rra,double *rdec)
{
double x0,y0,z0,dx,dy,dz,eps;
x0=dis*cosa(dec)*cosa(ra);
y0=dis*cosa(dec)*sina(ra);
z0=dis*sina(dec);
get_earth_coords(jd,&dx,&dy,&dz);
eps=get_earth_axis_angle(jd);
rotate(&dy,&dz,+eps);
x0+=dx*M_PI/(180.0*3600.0);
y0+=dy*M_PI/(180.0*3600.0);
z0+=dz*M_PI/(180.0*3600.0);
*rra=getpcoords(x0,y0);
dis=sqrt(x0*x0+y0*y0+z0*z0);
*rdec=asina(z0/dis);
return(0);
}
/*****************************************************************************/
|