29 {
30
33
34
35 if (argc < 3)
36 ERRMSG(
"Give parameters: <ctl> <obs>");
37
38
40 const double t0 =
scan_ctl(argc, argv,
"T0", -1,
"0", NULL);
41 const double t1 =
scan_ctl(argc, argv,
"T1", -1,
"0", NULL);
42 const double dt =
scan_ctl(argc, argv,
"DT", -1,
"1", NULL);
43 const double vpz =
scan_ctl(argc, argv,
"VPZ", -1,
"700", NULL);
44 const double theta0 =
scan_ctl(argc, argv,
"THETA0", -1,
"-90.0", NULL);
45 const double theta1 =
scan_ctl(argc, argv,
"THETA1", -1,
"90.0", NULL);
46 const double dtheta =
scan_ctl(argc, argv,
"DTHETA", -1,
"3.0", NULL);
47 const double obsz =
scan_ctl(argc, argv,
"OBSZ", -1,
"0", NULL);
48
49
50 const double ro =
RE + obsz;
51 const double rv =
RE + vpz;
52
53
54 for (double t = t0; t <= t1; t += dt) {
55 for (double theta = theta0; theta <= theta1 + 1e-12; theta += dtheta) {
56
57
60
61
62 const double th =
DEG2RAD(theta);
63 const double sth = sin(th);
64 const double cth = cos(th);
65
66
67
68
69
70
71
72
73
74
75
76
77 double disc = rv * rv - ro * ro * sth * sth;
78 if (disc < 0.0) {
79 if (disc > -1e-12 * rv * rv)
80 disc = 0.0;
81 else
82 continue;
83 }
84
85
86 if (disc < 0.0)
87 continue;
88
89
90 const double sq = sqrt(disc);
91 const double s1 = -ro * cth - sq;
92 const double s2 = -ro * cth + sq;
93
94
95 double s = DBL_MAX;
96 if (s1 >= 0.0)
97 s = s1;
98 if (s2 >= 0.0 && s2 < s)
99 s = s2;
100
101
102 if (s == DBL_MAX)
103 continue;
104
105
106 const double bx = s * sth;
107 const double bz = ro + s * cth;
108
109
110
111
112
113
114
115 const double beta = atan2(bx, bz);
116
117
120 obs.
vpz[obs.
nr] = vpz;
121
122
124
125
127 }
128 }
129
130
132
133 return EXIT_SUCCESS;
134}
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)
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 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.