40static double DEG_TO_RAD,RAD_TO_DEG;
42typedef struct {
double RA;
46typedef struct {
double A;
50typedef struct {
double Lat;
55static double JDate(
char *datestr);
58static double Sidereal_GW(
double JD);
69void sunPosition(
double latDeg,
double lonDeg,
char *timestamp,
double *azimuth,
double *elevation){
76 Geo.Lat = latDeg * DEG_TO_RAD;
77 Geo.Lon = lonDeg * DEG_TO_RAD;
79 JD = JDate(timestamp);
82 Sd0 = Sidereal_GW(JD)*15.0*DEG_TO_RAD;
85 Equ = Solar_coords(JD);
88 Hor = Solar_pos(Sd0,Geo,Equ);
96int mainOld(
int argc,
char *argv[])
106 char radar[7][4]={
"KOR",
"VAN",
"ANJ",
"IKA",
"KUO",
"UTA",
"LUO"};
108 {1.0518517625,0.43400520732},
109 {1.0629055144,0.47298422728},
110 {1.0780317013,0.40258928078},
111 {1.0969394348,0.47792932682},
112 {1.1303915788,0.45931248147},
113 {1.1716977045,0.46949356877}};
115 DEG_TO_RAD=M_PI/180.0;
116 RAD_TO_DEG=180.0/M_PI;
124 Geo.Lat=atof(argv[2])*DEG_TO_RAD;
125 Geo.Lon=atof(argv[3])*DEG_TO_RAD;
129 JD=JDate(&argv[1][3]);
130 for(r=0;r<7;r++)
if(strncasecmp(argv[1],radar[r],3)==0)
break;
136 for(r=0;r<7;r++)
if(strncasecmp(argv[2],radar[r],3)==0)
break;
140 fprintf(stderr,
"%s : illegal parameter count: %d\n",argv[0],argc);
141 fprintf(stderr,
"usage:\n");
142 fprintf(stderr,
"%s KOR200203011547\n",argv[0]);
143 fprintf(stderr,
"%s 200203011547 KOR\n",argv[0]);
144 fprintf(stderr,
"%s 200203011547 35.0 62.0 \n",argv[0]);
151 Sd0=Sidereal_GW(JD)*15.0*DEG_TO_RAD;
154 Equ=Solar_coords(JD);
157 Hor=Solar_pos(Sd0,Geo,Equ);
160 printf(
"%.1f\t%.1f\n",Hor.A,Hor.h);
165static double Sidereal_GW(
double JD)
167 double JD0,d,T,SDR,SD_0GW,SD_GW;
169 JD0=(double)((
long int)(JD-0.5));
171 T=(JD0+0.5-2415020.0)/36525.0;
176 SDR=0.276919398+100.0021359*T+0.000001075*T*T;
177 SD_0GW=(SDR-(double)((
long int)SDR))*24.0;
181 SD_GW=SD_0GW+d*1.002737908;
187double JDate(
char *datestr)
189 int YY,MM,DD,hh,mm,A,B,y,m;
190 double d,JD=0.0,fy,fm;
192 sscanf(datestr,
"%4d%2d%2d%2d%2d",&YY,&MM,&DD,&hh,&mm);
206 d=(double)DD+(
double)hh/24.0+(double)mm/1440.0;
207 JD=(double)((
long int)(fy*365.25))+(double)((
long int)(30.6001*(fm+1)))
208 +d+1720994.5+(
double)B;
216 double T,TT,L,M,e,OL,C,W,y,x,OA,ep;
219 T=(JD-2415020.0)/36525.0;
223 L=279.69668+36000.76892*T+0.0003025*TT;
226 M=358.47583+35999.04975*T-0.00015*TT-0.0000033*T*TT;
229 e=0.01675104-0.0000418*T-0.000000126*TT;
236 C=(1.919460-0.004789*T-0.000014*TT)*sin(M);
237 C+=(0.020094-0.0001*T)*sin(2*M);
238 C+=0.000293*sin(3*M);
245 W=(259.18-1934.142*T)*DEG_TO_RAD;
248 OA=OL-0.00569-0.00479*sin(W);
254 ep=23.452294-0.0130125*T-0.00000164*TT+0.000000503*T*TT+0.00256*cos(W);
264 Equ.Dec=asin(sin(ep)*sin(OA));
281 H=Sd0+Geo.Lon-Equ.RA;
287 x=cos(H)*sin(Geo.Lat)-tan(Equ.Dec)*cos(Geo.Lat);
290 Hor.A=atan2(y,x)*RAD_TO_DEG+180.0;
292 Hor.h=(asin(sin(Geo.Lat)*sin(Equ.Dec)
293 +cos(Geo.Lat)*cos(Equ.Dec)*cos(H)))*RAD_TO_DEG;
295 if(Hor.A<0.0) Hor.A+=360.0;