forked from cbassa/sattools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pass.c
754 lines (627 loc) · 16 KB
/
pass.c
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <getopt.h>
#include <time.h>
#include "sgdp4h.h"
#define LIM 128
#define D2R M_PI/180.0
#define R2D 180.0/M_PI
#define XKMPER 6378.135 // Earth radius in km
#define XKMPAU 149597879.691 // AU in km
#define FLAT (1.0/298.257)
#define STDMAG 6.0
#define PASSMAX 1000
long Isat=0;
long Isatsel=0;
extern double SGDP4_jd0;
int ipass=0,npass;
struct map {
long satno;
double lat,lng;
double mjd;
float alt,timezone;
float saltmin,altmin,altmax;
int length,all;
char nfd[LIM],tlefile[LIM],observer[32];
char datadir[LIM],tledir[LIM];
int site_id,plot;
} m;
struct point {
double mjd;
char nfd[LIM];
xyz_t obspos,satpos,sunpos;
double sra,sde,salt,sazi,azi,alt;
} *pt;
struct pass {
int satno;
double mjdrise,mjdmax,mjdset;
char line[80],skymap[LIM],radio[80];
float length,altmax;
} p[PASSMAX];
double nfd2mjd(char *date);
double date2mjd(int year,int month,double day);
void mjd2date(double mjd,char *date,int length);
void usage();
void initialize_setup(void);
void get_site(int site_id);
void nfd_now(char *s);
void print_header(void);
void obspos_xyz(double,xyz_t *,xyz_t *);
void sunpos_xyz(double,xyz_t *,double *,double *);
double gmst(double);
double dgmst(double);
double modulo(double,double);
void equatorial2horizontal(double,double,double,double *,double *);
void horizontal2equatorial(double,double,double,double *,double *);
void compute_observer_and_solar_positions(void);
void compute_track(orbit_t orb)
{
int i,flag=0;
double jd;
xyz_t satpos,satvel;
double dx,dy,dz,rsun,rearth;
double h,psun,pearth,psat;
char state[10]="",state1[10]="";
double r,ra,de,phase,azi,alt,alt1;
float mag;
double mjdrise,mjdmax,mjdset,mjdentry,mjdexit;
int irise=-1,imax=-1,iset=-1,ientry=-1,iexit=-1;
int i1=-1,i2=-1,i3=-1;
int sunlit,sundown;
for (i=0;i<m.length;i++) {
// Sun altitude
if (pt[i].salt<m.saltmin)
sundown=1;
else
sundown=0;
// Compute satellite position
jd=pt[i].mjd+2400000.5;
satpos_xyz(jd,&satpos,&satvel);
// Sun position from satellite
dx=-satpos.x+pt[i].sunpos.x;
dy=-satpos.y+pt[i].sunpos.y;
dz=-satpos.z+pt[i].sunpos.z;
// Distances
rsun=sqrt(dx*dx+dy*dy+dz*dz);
rearth=sqrt(satpos.x*satpos.x+satpos.y*satpos.y+satpos.z*satpos.z);
h=rearth-XKMPER;
// Angles
psun=asin(696.0e3/rsun)*R2D;
pearth=asin(6378.135/rearth)*R2D;
psat=acos((-dx*satpos.x-dy*satpos.y-dz*satpos.z)/(rsun*rearth))*R2D;
// Visibility state
if (psat-pearth<-psun)
strcpy(state,"eclipsed");
else if (psat-pearth>-psun && psat-pearth<psun)
strcpy(state,"umbra");
else if (psat-pearth>psun)
strcpy(state,"sunlit");
if (strcmp(state,"eclipsed")!=0)
sunlit=1;
else
sunlit=0;
// Position differences
dx=satpos.x-pt[i].obspos.x;
dy=satpos.y-pt[i].obspos.y;
dz=satpos.z-pt[i].obspos.z;
// Celestial position
r=sqrt(dx*dx+dy*dy+dz*dz);
ra=modulo(atan2(dy,dx)*R2D,360.0);
de=asin(dz/r)*R2D;
// Phase
phase=acos(((pt[i].obspos.x-satpos.x)*(pt[i].sunpos.x-satpos.x)+(pt[i].obspos.y-satpos.y)*(pt[i].sunpos.y-satpos.y)+(pt[i].obspos.z-satpos.z)*(pt[i].sunpos.z-satpos.z))/(rsun*r))*R2D;
// Magnitude
if (strcmp(state,"sunlit")==0)
mag=STDMAG-15.0+5*log10(r)-2.5*log10(sin(phase*D2R)+(M_PI-phase*D2R)*cos(phase*D2R));
else
mag=15;
// Horizontal position
equatorial2horizontal(pt[i].mjd,ra,de,&azi,&alt);
if (alt>0.0)
pt[i].alt=alt;
else
pt[i].alt=0.0;
pt[i].azi=modulo(azi+180.0,360.0);
// Find all passes
if (m.all==1) {
if (i==0) {
if (alt>=m.altmin && flag==0) {
irise=i;
flag=1;
}
if (imax==-1 && flag==1) {
imax=i;
flag=2;
}
} else if (i==m.length-1) {
if (alt>=m.altmin && flag==0) {
irise=i;
flag=1;
}
if (imax==-1 && flag==1) {
imax=i;
flag=2;
}
if (alt>=m.altmin && flag==2) {
iset=i;
flag=3;
}
} else if (i>0) {
if (alt1<m.altmin && alt>=m.altmin && flag==0) {
irise=i;
flag=1;
} else if (alt1>m.altmin && alt<=m.altmin && flag==2) {
iset=i;
flag=3;
} else if (flag==1 && alt<alt1) {
imax=i-1;
flag=2;
}
}
} else {
if (flag==0 && alt>=m.altmin && sundown==1 && sunlit==1) {
irise=i;
flag=1;
} else if (flag==1 && (alt<alt1 || !(sundown==1 && sunlit==1))) {
imax=i-1;
flag=2;
} else if (flag==2 && !(alt>=m.altmin && sundown==1 && sunlit==1)) {
iset=i;
flag=3;
}
/*
if (sundown==1 && sunlit==1) {
if (alt>=m.altmin && flag==0) {
irise=i;
flag=1;
} else if (alt<=m.altmin && flag==2) {
iset=i;
flag=3;
} else if (flag==1 && alt<alt1) {
imax=i-1;
flag=2;
}
}
*/
}
if (flag==3) {
i1=irise;
i2=imax;
i3=iset;
p[ipass].satno=orb.satno;
p[ipass].mjdrise=pt[i1].mjd;
p[ipass].mjdmax=pt[i2].mjd;
p[ipass].mjdset=pt[i3].mjd;
p[ipass].length=86400.0*(pt[i3].mjd-pt[i1].mjd);
p[ipass].altmax=pt[i2].alt;
sprintf(p[ipass].line,"%05d | %s %3.0f/%2.0f | %.8s %3.0f/%2.0f | %.8s %3.0f/%2.0f | \n",orb.satno,
pt[i1].nfd,pt[i1].azi,pt[i1].alt,
pt[i2].nfd+11,pt[i2].azi,pt[i2].alt,
pt[i3].nfd+11,pt[i3].azi,pt[i3].alt);
sprintf(p[ipass].radio,"%05d %s %s %s %4.0f %5.1f\n",orb.satno,pt[i1].nfd,pt[i2].nfd,pt[i3].nfd,p[ipass].length,pt[i2].alt);
sprintf(p[ipass].skymap,"skymap -c %s -i %d -s %d -t %s -l %.0f",m.tlefile,orb.satno,m.site_id,pt[i1].nfd,p[ipass].length);
flag=0;
irise=-1;
imax=-1;
iset=-1;
ientry=-1;
iexit=-1;
ipass++;
npass++;
}
alt1=alt;
strcpy(state1,state);
}
return;
}
int qsort_compare_mjdrise(const void *a,const void *b)
{
struct pass *pa=(struct pass *) a;
struct pass *pb=(struct pass *) b;
if (pa->mjdrise<pb->mjdrise)
return -1;
else if (pa->mjdrise>pb->mjdrise)
return 1;
else
return 0;
}
int main(int argc,char *argv[])
{
int arg=0,radio=0;
FILE *file;
orbit_t orb;
int imode,quiet=0;
// Initialize setup
initialize_setup();
// Decode options
while ((arg=getopt(argc,argv,"t:c:i:s:l:hS:A:aPqm:RM:"))!=-1) {
switch (arg) {
case 'R':
radio=1;
break;
case 't':
strcpy(m.nfd,optarg);
m.mjd=nfd2mjd(m.nfd);
break;
case 'm':
m.mjd=atof(optarg);
mjd2date(m.mjd,m.nfd,0);
break;
case 'c':
strcpy(m.tlefile,optarg);
break;
case 's':
get_site(atoi(optarg));
break;
case 'i':
m.satno=atoi(optarg);
break;
case 'l':
m.length=atoi(optarg);
if (strchr(optarg,'h')!=NULL)
m.length*=3600;
else if (strchr(optarg,'m')!=NULL)
m.length*=60;
else if (strchr(optarg,'d')!=NULL)
m.length*=86400;
break;
case 'S':
m.saltmin=atof(optarg);
break;
case 'A':
m.altmin=atof(optarg);
break;
case 'M':
m.altmax=atof(optarg);
break;
case 'a':
m.all=1;
break;
case 'h':
usage();
return 0;
break;
case 'P':
m.plot=1;
break;
case 'q':
quiet=1;
break;
default:
usage();
return 0;
}
}
// Allocate
pt=(struct point *) malloc(sizeof(struct point)*m.length);
// Compute observer positions
compute_observer_and_solar_positions();
// Reloop stderr
freopen("/tmp/stderr.txt","w",stderr);
// Open TLE file
file=fopen(m.tlefile,"r");
if (file==NULL)
fatal_error("File open failed for reading %s\n",m.tlefile);
// Loop over objects
while (read_twoline(file,m.satno,&orb)==0) {
Isat=orb.satno;
imode=init_sgdp4(&orb);
if (imode==SGDP4_ERROR)
continue;
// Skip non LEO objects
if (orb.rev>=10.0 || m.satno!=0)
compute_track(orb);
}
npass=ipass;
// Close
fclose(file);
fclose(stderr);
// Sort passes
qsort(p,npass,sizeof(struct pass),qsort_compare_mjdrise);
// Output header
if (quiet==0)
print_header();
// Print passes
for (ipass=0;ipass<npass;ipass++) {
if (radio==0)
printf("%s",p[ipass].line);
else if (radio==1 && p[ipass].altmax>m.altmax)
printf("%s",p[ipass].radio);
if (m.plot==1)
system(p[ipass].skymap);
}
// Free
free(pt);
return 0;
}
// nfd2mjd
double nfd2mjd(char *date)
{
int year,month,day,hour,min,sec;
double mjd,dday;
sscanf(date,"%04d-%02d-%02dT%02d:%02d:%02d",&year,&month,&day,&hour,&min,&sec);
dday=day+hour/24.0+min/1440.0+sec/86400.0;
mjd=date2mjd(year,month,dday);
return mjd;
}
void usage()
{
printf("pass t:c:i:s:l:hS:A:aPqm:R\n\n");
printf("t date/time (yyyy-mm-ddThh:mm:ss.sss) [default: now]\n");
printf("c TLE catalog file [default: classfd.tle]\n");
printf("i satellite ID (NORAD) [default: all]\n");
printf("s site (COSPAR\n");
printf("l length [default: %d s]\n",m.length);
printf("A minimum satellite altitude [default: %.1f deg]\n",m.altmin);
printf("S maximum solar altitude [default: %.1f deg]\n",m.saltmin);
printf("a compute all passes [toggle; default: off]\n");
printf("P plot passes [toggle; default: off]\n");
printf("m MJD date/time\n");
printf("q no header [toggle; default: off]\n");
printf("R format output for radio passes [toggle; default: off]\n");
printf("h this help\n");
return;
}
// Compute Date from Julian Day
void mjd2date(double mjd,char *date,int length)
{
double f,jd,dday;
int z,alpha,a,b,c,d,e;
int year,month,day,hour,min;
float sec,x;
jd=mjd+2400000.5;
jd+=0.5;
z=floor(jd);
f=fmod(jd,1.);
if (z<2299161)
a=z;
else {
alpha=floor((z-1867216.25)/36524.25);
a=z+1+alpha-floor(alpha/4.);
}
b=a+1524;
c=floor((b-122.1)/365.25);
d=floor(365.25*c);
e=floor((b-d)/30.6001);
dday=b-d-floor(30.6001*e)+f;
if (e<14)
month=e-1;
else
month=e-13;
if (month>2)
year=c-4716;
else
year=c-4715;
day=(int) floor(dday);
x=24.0*(dday-day);
x=3600.*fabs(x)+0.0001;
sec=fmod(x,60.);
x=(x-sec)/60.;
min=fmod(x,60.);
x=(x-min)/60.;
hour=x;
sec=floor(1000.0*sec)/1000.0;
if (length==3)
sprintf(date,"%04d-%02d-%02dT%02d:%02d:%06.3f",year,month,day,hour,min,sec);
else if (length==0)
sprintf(date,"%04d-%02d-%02dT%02d:%02d:%02.0f",year,month,day,hour,min,sec);
return;
}
// Compute Julian Day from Date
double date2mjd(int year,int month,double day)
{
int a,b;
double jd;
if (month<3) {
year--;
month+=12;
}
a=floor(year/100.);
b=2.-a+floor(a/4.);
if (year<1582) b=0;
if (year==1582 && month<10) b=0;
if (year==1582 && month==10 && day<=4) b=0;
jd=floor(365.25*(year+4716))+floor(30.6001*(month+1))+day+b-1524.5;
return jd-2400000.5;
}
// Initialize setup
void initialize_setup(void)
{
char *env;
// Default parameters
m.satno=0;
m.timezone=0.0;
m.length=3600;
nfd_now(m.nfd);
m.mjd=nfd2mjd(m.nfd);
m.saltmin=-6.0;
m.altmin=10.0;
m.altmax=10.0;
m.all=0;
m.plot=0;
// Default settings
strcpy(m.observer,"Unknown");
m.site_id=0;
// Get environment variables
env=getenv("ST_DATADIR");
if (env!=NULL) {
strcpy(m.datadir,env);
} else {
printf("ST_DATADIR environment variable not found.\n");
}
env=getenv("ST_COSPAR");
if (env!=NULL) {
get_site(atoi(env));
} else {
printf("ST_COSPAR environment variable not found.\n");
}
env=getenv("ST_TLEDIR");
if (env!=NULL) {
strcpy(m.tledir,env);
} else {
printf("ST_TLEDIR environment variable not found.\n");
}
sprintf(m.tlefile,"%s/classfd.tle",m.tledir);
return;
}
// Get observing site
void get_site(int site_id)
{
int i=0;
char line[LIM];
FILE *file;
int id;
double lat,lng;
float alt;
char abbrev[3],observer[64],filename[LIM];
sprintf(filename,"%s/data/sites.txt",m.datadir);
file=fopen(filename,"r");
if (file==NULL) {
printf("File with site information not found!\n");
return;
}
while (fgets(line,LIM,file)!=NULL) {
// Skip
if (strstr(line,"#")!=NULL)
continue;
// Strip newline
line[strlen(line)-1]='\0';
// Read data
sscanf(line,"%4d %2s %lf %lf %f",
&id,abbrev,&lat,&lng,&alt);
strcpy(observer,line+38);
// Change to km
alt/=1000.0;
if (id==site_id) {
m.lat=lat;
m.lng=lng;
m.alt=alt;
m.site_id=id;
strcpy(m.observer,observer);
}
}
fclose(file);
return;
}
// Present nfd
void nfd_now(char *s)
{
time_t rawtime;
struct tm *ptm;
// Get UTC time
time(&rawtime);
ptm=gmtime(&rawtime);
sprintf(s,"%04d-%02d-%02dT%02d:%02d:%02d",ptm->tm_year+1900,ptm->tm_mon+1,ptm->tm_mday,ptm->tm_hour,ptm->tm_min,ptm->tm_sec);
return;
}
// Print header
void print_header(void)
{
printf("Observer: %s (%04d) [%+.4f, %+.4f, %.0fm]\n",m.observer,m.site_id,m.lat,m.lng,m.alt*1000.0);
printf("Elements: %s\n",m.tlefile);
printf("UT Date/Time: %s for %g h \n",m.nfd,m.length/3600.0);
return;
}
// Observer position
void obspos_xyz(double mjd,xyz_t *pos,xyz_t *vel)
{
double ff,gc,gs,theta,s,dtheta;
s=sin(m.lat*D2R);
ff=sqrt(1.0-FLAT*(2.0-FLAT)*s*s);
gc=1.0/ff+m.alt/XKMPER;
gs=(1.0-FLAT)*(1.0-FLAT)/ff+m.alt/XKMPER;
theta=gmst(mjd)+m.lng;
dtheta=dgmst(mjd)*D2R/86400;
pos->x=gc*cos(m.lat*D2R)*cos(theta*D2R)*XKMPER;
pos->y=gc*cos(m.lat*D2R)*sin(theta*D2R)*XKMPER;
pos->z=gs*sin(m.lat*D2R)*XKMPER;
vel->x=-gc*cos(m.lat*D2R)*sin(theta*D2R)*XKMPER*dtheta;
vel->y=gc*cos(m.lat*D2R)*cos(theta*D2R)*XKMPER*dtheta;
vel->z=0.0;
return;
}
// Solar position
void sunpos_xyz(double mjd,xyz_t *pos,double *ra,double *de)
{
double jd,t,l0,m,e,c,r;
double n,s,ecl;
jd=mjd+2400000.5;
t=(jd-2451545.0)/36525.0;
l0=modulo(280.46646+t*(36000.76983+t*0.0003032),360.0)*D2R;
m=modulo(357.52911+t*(35999.05029-t*0.0001537),360.0)*D2R;
e=0.016708634+t*(-0.000042037-t*0.0000001267);
c=(1.914602+t*(-0.004817-t*0.000014))*sin(m)*D2R;
c+=(0.019993-0.000101*t)*sin(2.0*m)*D2R;
c+=0.000289*sin(3.0*m)*D2R;
r=1.000001018*(1.0-e*e)/(1.0+e*cos(m+c));
n=modulo(125.04-1934.136*t,360.0)*D2R;
s=l0+c+(-0.00569-0.00478*sin(n))*D2R;
ecl=(23.43929111+(-46.8150*t-0.00059*t*t+0.001813*t*t*t)/3600.0+0.00256*cos(n))*D2R;
*ra=atan2(cos(ecl)*sin(s),cos(s))*R2D;
*de=asin(sin(ecl)*sin(s))*R2D;
pos->x=r*cos(*de*D2R)*cos(*ra*D2R)*XKMPAU;
pos->y=r*cos(*de*D2R)*sin(*ra*D2R)*XKMPAU;
pos->z=r*sin(*de*D2R)*XKMPAU;
return;
}
// Greenwich Mean Sidereal Time
double gmst(double mjd)
{
double t,gmst;
t=(mjd-51544.5)/36525.0;
gmst=modulo(280.46061837+360.98564736629*(mjd-51544.5)+t*t*(0.000387933-t/38710000),360.0);
return gmst;
}
// Greenwich Mean Sidereal Time
double dgmst(double mjd)
{
double t,dgmst;
t=(mjd-51544.5)/36525.0;
dgmst=360.98564736629+t*(0.000387933-t/38710000);
return dgmst;
}
// Return x modulo y [0,y)
double modulo(double x,double y)
{
x=fmod(x,y);
if (x<0.0) x+=y;
return x;
}
// Convert equatorial into horizontal coordinates
void equatorial2horizontal(double mjd,double ra,double de,double *azi,double *alt)
{
double h;
h=gmst(mjd)+m.lng-ra;
*azi=modulo(atan2(sin(h*D2R),cos(h*D2R)*sin(m.lat*D2R)-tan(de*D2R)*cos(m.lat*D2R))*R2D,360.0);
*alt=asin(sin(m.lat*D2R)*sin(de*D2R)+cos(m.lat*D2R)*cos(de*D2R)*cos(h*D2R))*R2D;
return;
}
// Convert horizontal into equatorial coordinates
void horizontal2equatorial(double mjd,double azi,double alt,double *ra,double *de)
{
double h;
h=atan2(sin(azi*D2R),cos(azi*D2R)*sin(m.lat*D2R)+tan(alt*D2R)*cos(m.lat*D2R))*R2D;
*ra=modulo(gmst(mjd)+m.lng-h,360.0);
*de=asin(sin(m.lat*D2R)*sin(alt*D2R)-cos(m.lat*D2R)*cos(alt*D2R)*cos(azi*D2R))*R2D;
if (*ra<0.0)
*ra+=360.0;
return;
}
void compute_observer_and_solar_positions(void)
{
int i;
xyz_t obsvel;
for (i=0;i<m.length;i++) {
// Compute MJDs
pt[i].mjd=m.mjd+(double) i/86400.0;
mjd2date(pt[i].mjd,pt[i].nfd,0);
// Observer position
obspos_xyz(pt[i].mjd,&pt[i].obspos,&obsvel);
// Solar position
sunpos_xyz(pt[i].mjd,&pt[i].sunpos,&pt[i].sra,&pt[i].sde);
equatorial2horizontal(pt[i].mjd,pt[i].sra,pt[i].sde,&pt[i].sazi,&pt[i].salt);
}
return;
}