41 {
42
45
46
48
49
50 if (argc < 3)
51 ERRMSG(
"Missing or invalid command-line arguments.\n\n"
52 "Usage: zenith <ctl> <obs> [KEY VALUE ...]\n\n"
53 "Use -h for full help.");
54
55
57 const double t0 =
scan_ctl(argc, argv,
"T0", -1,
"0", NULL);
58 const double t1 =
scan_ctl(argc, argv,
"T1", -1,
"0", NULL);
59 const double dt =
scan_ctl(argc, argv,
"DT", -1,
"1", NULL);
60 const double vpz =
scan_ctl(argc, argv,
"VPZ", -1,
"700", NULL);
61 const double theta0 =
scan_ctl(argc, argv,
"THETA0", -1,
"-90.0", NULL);
62 const double theta1 =
scan_ctl(argc, argv,
"THETA1", -1,
"90.0", NULL);
63 const double dtheta =
scan_ctl(argc, argv,
"DTHETA", -1,
"3.0", NULL);
64 const double obsz =
scan_ctl(argc, argv,
"OBSZ", -1,
"0", NULL);
65
66
67 const double ro =
RE + obsz;
68 const double rv =
RE + vpz;
69
70
71 for (double t = t0; t <= t1; t += dt) {
72 for (double theta = theta0; theta <= theta1 + 1e-12; theta += dtheta) {
73
74
77
78
79 const double th =
DEG2RAD(theta);
80 const double sth = sin(th);
81 const double cth = cos(th);
82
83
84
85
86
87
88
89
90
91
92
93
94 double disc = rv * rv - ro * ro * sth * sth;
95 if (disc < 0.0) {
96 if (disc > -1e-12 * rv * rv)
97 disc = 0.0;
98 else
99 continue;
100 }
101
102
103 if (disc < 0.0)
104 continue;
105
106
107 const double sq = sqrt(disc);
108 const double s1 = -ro * cth - sq;
109 const double s2 = -ro * cth + sq;
110
111
112 double s = DBL_MAX;
113 if (s1 >= 0.0)
114 s = s1;
115 if (s2 >= 0.0 && s2 < s)
116 s = s2;
117
118
119 if (s == DBL_MAX)
120 continue;
121
122
123 const double bx = s * sth;
124 const double bz = ro + s * cth;
125
126
127
128
129
130
131
132 const double beta = atan2(bx, bz);
133
134
137 obs.
vpz[obs.
nr] = vpz;
138
139
141
142
144 }
145 }
146
147
149
150 return EXIT_SUCCESS;
151}
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
void write_obs(const char *dirname, const char *filename, const ctl_t *ctl, const obs_t *obs, int profile)
Write observation data to an output file in ASCII or binary format.
double scan_ctl(int argc, char *argv[], const char *varname, const int arridx, const char *defvalue, char *value)
Scan control file or command-line arguments for a configuration variable.
#define RE
Mean radius of Earth [km].
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define USAGE
Print usage information on -h or --help.
#define DEG2RAD(deg)
Convert degrees to radians.
#define RAD2DEG(rad)
Convert radians to degrees.
#define NR
Maximum number of ray paths.
Observation geometry and radiance data.
double vpz[NR]
View point altitude [km].
double vplat[NR]
View point latitude [deg].
double obsz[NR]
Observer altitude [km].
double time[NR]
Time (seconds since 2000-01-01T00:00Z).
int nr
Number of ray paths.