50 char filename[2 *
LEN], losbase[
LEN];
59 ERRMSG(
"Missing or invalid command-line arguments.\n\n"
60 "Usage: raytrace <ctl> <obs> <atm> <raytrace.tab> [KEY VALUE ...]\n\n"
61 "Use -h for full help.");
67 scan_ctl(argc, argv,
"LOSBASE", -1,
"los", losbase);
70 read_obs(NULL, argv[2], &ctl, &obs, 0);
73 read_atm(NULL, argv[3], &ctl, &atm, 0);
76 LOG(1,
"Write raytrace data: %s", argv[4]);
79 if (!(out = fopen(argv[4],
"w")))
80 ERRMSG(
"Cannot create file!");
84 "# $1 = time (seconds since 2000-01-01T00:00Z)\n"
85 "# $2 = observer altitude [km]\n"
86 "# $3 = observer longitude [deg]\n"
87 "# $4 = observer latitude [deg]\n"
88 "# $5 = view point altitude [km]\n"
89 "# $6 = view point longitude [deg]\n"
90 "# $7 = view point latitude [deg]\n"
91 "# $8 = tangent point altitude [km]\n"
92 "# $9 = tangent point longitude [deg]\n"
93 "# $10 = tangent point latitude [deg]\n"
94 "# $11 = ray path index\n" "# $12 = ray path length [km]\n");
95 for (
int ig = 0; ig < ctl.
ng; ig++)
96 fprintf(out,
"# $%d = %s column density [molec/cm^2]\n",
101 for (
int ir = 0; ir < obs.
nr; ir++) {
104 raytrace(&ctl, &atm, &obs, &los, ir);
107 sprintf(filename,
"%s.%d.tab", losbase, ir);
110 LOG(1,
"Write LOS data: %s", filename);
114 if (!(out2 = fopen(filename,
"w")))
115 ERRMSG(
"Cannot create file!");
119 "# $1 = time (seconds since 2000-01-01T00:00Z)\n"
120 "# $2 = altitude [km]\n"
121 "# $3 = longitude [deg]\n"
122 "# $4 = latitude [deg]\n"
123 "# $5 = pressure [hPa]\n" "# $6 = temperature [K]\n");
124 for (
int ig = 0; ig < ctl.
ng; ig++)
125 fprintf(out2,
"# $%d = %s volume mixing ratio [ppv]\n",
127 for (
int iw = 0; iw < ctl.
nw; iw++)
128 fprintf(out2,
"# $%d = extinction (window %d) [km^-1]\n",
129 7 + ctl.
ng + iw, iw);
133 for (
int ip = 0; ip < los.
np; ip++) {
134 fprintf(out2,
"%.2f %g %g %g %g %g", obs.
time[ir], los.
z[ip],
135 los.
lon[ip], los.
lat[ip], los.
p[ip], los.
t[ip]);
136 for (
int ig = 0; ig < ctl.
ng; ig++)
137 fprintf(out2,
" %g", los.
q[ip][ig]);
138 for (
int iw = 0; iw < ctl.
nw; iw++)
139 fprintf(out2,
" %g", los.
k[ip][iw]);
148 for (
int ig = 0; ig < ctl.
ng; ig++)
150 for (
int ip = 0; ip < los.
np; ip++) {
152 for (
int ig = 0; ig < ctl.
ng; ig++)
153 u[ig] += los.
u[ip][ig];
157 fprintf(out,
"%.2f %g %g %g %g %g %g %g %g %g %d %g",
161 for (
int ig = 0; ig < ctl.
ng; ig++)
162 fprintf(out,
" %g", u[ig]);
176 printf(
"\nJURASSIC ray-tracing tool.\n\n");
177 printf(
"Determine atmospheric line-of-sight paths and write a summary\n");
178 printf(
"table plus one LOS profile file per ray.\n\n");
180 printf(
" raytrace <ctl> <obs> <atm> <raytrace.tab> [KEY VALUE ...]\n\n");
181 printf(
"Arguments:\n");
182 printf(
" <ctl> Control file.\n");
183 printf(
" <obs> Observation geometry input file.\n");
184 printf(
" <atm> Atmospheric state input file.\n");
185 printf(
" <raytrace.tab> Output summary table for traced rays.\n");
186 printf(
" [KEY VALUE] Optional control parameters.\n\n");
187 printf(
"Tool-specific control parameters:\n");
188 printf(
" LOSBASE <name> Basename for per-ray LOS output files.\n\n");
189 printf(
"Common control parameters:\n");
190 printf(
" ATMFMT, OBSFMT Input file formats.\n");
191 printf(
" NG, EMITTER[i] Active emitters.\n");
193 (
" ND, NU[i] Spectral channels in observation files.\n");
194 printf(
" NW, WINDOW[i] Extinction-window layout.\n");
195 printf(
" REFRAC, RAYDS, RAYDZ Ray-tracing settings.\n\n");
196 printf(
"Further information:\n");
197 printf(
" Manual: https://slcs-jsc.github.io/jurassic/\n");
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
void raytrace(const ctl_t *ctl, const atm_t *atm, obs_t *obs, los_t *los, const int ir)
Perform line-of-sight (LOS) ray tracing through the atmosphere.
void read_obs(const char *dirname, const char *filename, const ctl_t *ctl, obs_t *obs, int profile)
Read observation data from an input file.
void read_atm(const char *dirname, const char *filename, const ctl_t *ctl, atm_t *atm, int profile)
Read atmospheric input data from a file.
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.
JURASSIC library declarations.
#define LEN
Maximum length of ASCII data lines.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define USAGE
Print usage information on -h or --help.
#define NG
Maximum number of emitters.
#define LOG(level,...)
Print a log message with a specified logging level.
int main(int argc, char *argv[])
Atmospheric profile data.
int nw
Number of spectral windows.
int ng
Number of emitters.
char emitter[NG][LEN]
Name of each emitter.
double z[NLOS]
Altitude [km].
double q[NLOS][NG]
Volume mixing ratio [ppv].
double lon[NLOS]
Longitude [deg].
double ds[NLOS]
Segment length [km].
int np
Number of LOS points.
double u[NLOS][NG]
Column density [molecules/cm^2].
double lat[NLOS]
Latitude [deg].
double k[NLOS][ND]
Extinction [km^-1].
double t[NLOS]
Temperature [K].
double p[NLOS]
Pressure [hPa].
Observation geometry and radiance data.
double tplon[NR]
Tangent point longitude [deg].
double vpz[NR]
View point altitude [km].
double vplat[NR]
View point latitude [deg].
double obslon[NR]
Observer longitude [deg].
double obslat[NR]
Observer latitude [deg].
double obsz[NR]
Observer altitude [km].
double tplat[NR]
Tangent point latitude [deg].
double vplon[NR]
View point longitude [deg].
double time[NR]
Time (seconds since 2000-01-01T00:00Z).
double tpz[NR]
Tangent point altitude [km].
int nr
Number of ray paths.