JURASSIC
raytrace.c
Go to the documentation of this file.
1/*
2 This file is part of JURASSIC.
3
4 JURASSIC is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 JURASSIC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with JURASSIC. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright (C) 2003-2021 Forschungszentrum Juelich GmbH
18*/
19
25#include "jurassic.h"
26
27int main(
28 int argc,
29 char *argv[]) {
30
31 static atm_t atm, atm2;
32 static ctl_t ctl;
33 static los_t los;
34 static obs_t obs;
35
36 FILE *out;
37
38 char filename[LEN], losbase[LEN];
39
40 double u[NG];
41
42 /* Check arguments... */
43 if (argc < 4)
44 ERRMSG("Give parameters: <ctl> <obs> <atm>");
45
46 /* Read control parameters... */
47 read_ctl(argc, argv, &ctl);
48
49 /* Get basenames... */
50 scan_ctl(argc, argv, "LOSBASE", -1, "los", losbase);
51
52 /* Read observation geometry... */
53 read_obs(NULL, argv[2], &ctl, &obs);
54
55 /* Read atmospheric data... */
56 read_atm(NULL, argv[3], &ctl, &atm);
57
58 /* Write info... */
59 LOG(1, "Write raytrace data: raytrace.tab");
60
61 /* Create file... */
62 if (!(out = fopen("raytrace.tab", "w")))
63 ERRMSG("Cannot create file!");
64
65 /* Write header... */
66 fprintf(out,
67 "# $1 = time (seconds since 2000-01-01T00:00Z)\n"
68 "# $2 = observer altitude [km]\n"
69 "# $3 = observer longitude [deg]\n"
70 "# $4 = observer latitude [deg]\n"
71 "# $5 = view point altitude [km]\n"
72 "# $6 = view point longitude [deg]\n"
73 "# $7 = view point latitude [deg]\n"
74 "# $8 = tangent point altitude [km]\n"
75 "# $9 = tangent point longitude [deg]\n"
76 "# $10 = tangent point latitude [deg]\n"
77 "# $11 = ray path index\n" "# $12 = ray path length [km]\n");
78 for (int ig = 0; ig < ctl.ng; ig++)
79 fprintf(out, "# $%d = %s column density [molec/cm^2]\n",
80 13 + ig, ctl.emitter[ig]);
81 fprintf(out, "\n");
82
83 /* Loop over rays... */
84 for (int ir = 0; ir < obs.nr; ir++) {
85
86 /* Raytracing... */
87 raytrace(&ctl, &atm, &obs, &los, ir);
88
89 /* Copy data... */
90 atm2.np = los.np;
91 for (int ip = 0; ip < los.np; ip++) {
92 atm2.time[ip] = obs.time[ir];
93 atm2.z[ip] = los.z[ip];
94 atm2.lon[ip] = los.lon[ip];
95 atm2.lat[ip] = los.lat[ip];
96 atm2.p[ip] = los.p[ip];
97 atm2.t[ip] = los.t[ip];
98 for (int ig = 0; ig < ctl.ng; ig++)
99 atm2.q[ig][ip] = los.q[ip][ig];
100 for (int iw = 0; iw < ctl.nw; iw++)
101 atm2.k[iw][ip] = NAN;
102 }
103
104 /* Save data... */
105 sprintf(filename, "los.%d", ir);
106 write_atm(NULL, filename, &ctl, &atm2);
107
108 /* Get column densities... */
109 double s = 0;
110 for (int ig = 0; ig < ctl.ng; ig++)
111 u[ig] = 0;
112 for (int ip = 0; ip < los.np; ip++) {
113 s += los.ds[ip];
114 for (int ig = 0; ig < ctl.ng; ig++)
115 u[ig] += los.u[ip][ig];
116 }
117
118 /* Write summary data... */
119 fprintf(out, "%.2f %g %g %g %g %g %g %g %g %g %d %g",
120 obs.time[ir], obs.obsz[ir], obs.obslon[ir], obs.obslat[ir],
121 obs.vpz[ir], obs.vplon[ir], obs.vplat[ir],
122 obs.tpz[ir], obs.tplon[ir], obs.tplat[ir], ir, s);
123 for (int ig = 0; ig < ctl.ng; ig++)
124 fprintf(out, " %g", u[ig]);
125 fprintf(out, "\n");
126 }
127
128 /* Close file... */
129 fclose(out);
130
131 return EXIT_SUCCESS;
132}
void write_atm(const char *dirname, const char *filename, const ctl_t *ctl, const atm_t *atm)
Write atmospheric data.
Definition: jurassic.c:5339
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read forward model control parameters.
Definition: jurassic.c:4550
void raytrace(const ctl_t *ctl, const atm_t *atm, obs_t *obs, los_t *los, const int ir)
Do ray-tracing to determine LOS.
Definition: jurassic.c:4205
void read_atm(const char *dirname, const char *filename, const ctl_t *ctl, atm_t *atm)
Read atmospheric data.
Definition: jurassic.c:4445
void read_obs(const char *dirname, const char *filename, const ctl_t *ctl, obs_t *obs)
Read observation data.
Definition: jurassic.c:4700
double scan_ctl(int argc, char *argv[], const char *varname, int arridx, const char *defvalue, char *value)
Search control parameter file for variable entry.
Definition: jurassic.c:5117
JURASSIC library declarations.
#define LEN
Maximum length of ASCII data lines.
Definition: jurassic.h:383
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:237
#define NG
Maximum number of emitters.
Definition: jurassic.h:358
#define LOG(level,...)
Print log message.
Definition: jurassic.h:221
int main(int argc, char *argv[])
Definition: raytrace.c:27
Atmospheric data.
Definition: jurassic.h:488
double time[NP]
Time (seconds since 2000-01-01T00:00Z).
Definition: jurassic.h:494
double k[NW][NP]
Extinction [km^-1].
Definition: jurassic.h:515
double lat[NP]
Latitude [deg].
Definition: jurassic.h:503
double lon[NP]
Longitude [deg].
Definition: jurassic.h:500
double t[NP]
Temperature [K].
Definition: jurassic.h:509
int np
Number of data points.
Definition: jurassic.h:491
double z[NP]
Altitude [km].
Definition: jurassic.h:497
double q[NG][NP]
Volume mixing ratio [ppv].
Definition: jurassic.h:512
double p[NP]
Pressure [hPa].
Definition: jurassic.h:506
Forward model control parameters.
Definition: jurassic.h:541
int nw
Number of spectral windows.
Definition: jurassic.h:556
int ng
Number of emitters.
Definition: jurassic.h:544
char emitter[NG][LEN]
Name of each emitter.
Definition: jurassic.h:547
Line-of-sight data.
Definition: jurassic.h:678
double z[NLOS]
Altitude [km].
Definition: jurassic.h:684
double q[NLOS][NG]
Volume mixing ratio [ppv].
Definition: jurassic.h:699
double lon[NLOS]
Longitude [deg].
Definition: jurassic.h:687
double ds[NLOS]
Segment length [km].
Definition: jurassic.h:711
int np
Number of LOS points.
Definition: jurassic.h:681
double u[NLOS][NG]
Column density [molecules/cm^2].
Definition: jurassic.h:714
double lat[NLOS]
Latitude [deg].
Definition: jurassic.h:690
double t[NLOS]
Temperature [K].
Definition: jurassic.h:696
double p[NLOS]
Pressure [hPa].
Definition: jurassic.h:693
Observation geometry and radiance data.
Definition: jurassic.h:734
double tplon[NR]
Tangent point longitude [deg].
Definition: jurassic.h:764
double vpz[NR]
View point altitude [km].
Definition: jurassic.h:752
double vplat[NR]
View point latitude [deg].
Definition: jurassic.h:758
double obslon[NR]
Observer longitude [deg].
Definition: jurassic.h:746
double obslat[NR]
Observer latitude [deg].
Definition: jurassic.h:749
double obsz[NR]
Observer altitude [km].
Definition: jurassic.h:743
double tplat[NR]
Tangent point latitude [deg].
Definition: jurassic.h:767
double vplon[NR]
View point longitude [deg].
Definition: jurassic.h:755
double time[NR]
Time (seconds since 2000-01-01T00:00Z).
Definition: jurassic.h:740
double tpz[NR]
Tangent point altitude [km].
Definition: jurassic.h:761
int nr
Number of ray paths.
Definition: jurassic.h:737