-
Notifications
You must be signed in to change notification settings - Fork 37
/
rfdop.c
115 lines (95 loc) · 1.97 KB
/
rfdop.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
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <getopt.h>
#include "rfio.h"
#include "rftime.h"
#include "rftrace.h"
void usage(void)
{
printf("rfdop m:t:c:l:d:g:s:o:hi:\n\n");
printf("m date/time (MJD)\n");
printf("t date/time (yyyy-mm-ddThh:mm:ss.sss)\n");
printf("i NORAD number\n");
printf("c TLE catalog file\n");
printf("s site (COSPAR)\n");
printf("d time step [default: 10s]\n");
printf("l trail length [default: 900s]\n");
printf("g enable GRAVES\n");
printf("H skip high orbits (<10 revs/day)\n");
printf("o output file name\n");
printf("h this help\n");
return;
}
int main(int argc, char *argv[])
{
int i, n, satno=0;
double mjd0, *mjd, t;
float length=900.0, dt=10.0;
int site_id;
int graves=0,skiphigh=0;
char *env,tlefile[256],nfd[64],outfname[256]="out.dat";
int arg=0;
// Get defaults
env=getenv("ST_COSPAR");
if (env!=NULL) {
site_id=atoi(env);
}
if (argc>1) {
while ((arg=getopt(argc,argv,"m:t:c:i:l:d:gs:o:hH"))!=-1) {
switch (arg) {
case 't':
strcpy(nfd,optarg);
mjd0=nfd2mjd(nfd);
break;
case 'm':
mjd0=(double) atof(optarg);
break;
case 'c':
strcpy(tlefile,optarg);
break;
case 'i':
satno=atoi(optarg);
break;
case 'l':
length=atof(optarg);
break;
case 'd':
dt=atof(optarg);
break;
case 's':
site_id=atoi(optarg);
break;
case 'g':
graves=1;
break;
case 'H':
skiphigh=1;
break;
case 'o':
strcpy(outfname,optarg);
break;
case 'h':
usage();
return 0;
default:
usage();
return 0;
}
}
} else {
usage();
return 0;
}
// Generate MJDs
n = (int) floor(length/dt);
mjd = (double *) malloc(sizeof(double)*n);
for (i=0;i<n;i++)
mjd[i] = mjd0+(double) i*dt/86400.0;
// Compute Doppler curves
compute_doppler(tlefile,mjd,n,site_id,satno,graves,skiphigh,outfname);
// Free
free(mjd);
return 0;
}