JURASSIC
obs2spec.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 <omp.h>
26#include "jurassic.h"
27
28/* ------------------------------------------------------------
29 Main...
30 ------------------------------------------------------------ */
31
32int main(
33 int argc,
34 char *argv[]) {
35
36 static ctl_t ctl;
37
38 obs_t *obs;
39
40 FILE *out;
41
42 /* Check arguments... */
43 if (argc < 4)
44 ERRMSG("Give parameters: <ctl> <obs> <spec.tab>");
45
46 /* Allocate... */
47 ALLOC(obs, obs_t, 1);
48
49 /* Read control parameters... */
50 read_ctl(argc, argv, &ctl);
51
52 /* Read observation geometry... */
53 read_obs(".", argv[2], &ctl, obs);
54
55 /* Write info... */
56 LOG(1, "Write spectra: %s", argv[3]);
57
58 /* Create file... */
59 if (!(out = fopen(argv[3], "w")))
60 ERRMSG("Cannot create file!");
61
62 /* Write header... */
63 fprintf(out,
64 "# $1 = time (seconds since 2000-01-01T00:00Z)\n"
65 "# $2 = observer altitude [km]\n"
66 "# $3 = observer longitude [deg]\n"
67 "# $4 = observer latitude [deg]\n"
68 "# $5 = view point altitude [km]\n"
69 "# $6 = view point longitude [deg]\n"
70 "# $7 = view point latitude [deg]\n"
71 "# $8 = tangent point altitude [km]\n"
72 "# $9 = tangent point longitude [deg]\n"
73 "# $10 = tangent point latitude [deg]\n"
74 "# $11 = channel frequency [cm^-1]\n"
75 "# $12 = channel radiance [W/(m^2 sr cm^-1)]\n"
76 "# $13 = channel transmittance [1]\n");
77
78 /* Write data... */
79 for (int ir = 0; ir < obs->nr; ir++) {
80 fprintf(out, "\n");
81 for (int id = 0; id < ctl.nd; id++)
82 fprintf(out, "%.2f %g %g %g %g %g %g %g %g %g %.4f %g %g\n",
83 obs->time[ir], obs->obsz[ir], obs->obslon[ir], obs->obslat[ir],
84 obs->vpz[ir], obs->vplon[ir], obs->vplat[ir], obs->tpz[ir],
85 obs->tplon[ir], obs->tplat[ir], ctl.nu[id], obs->rad[id][ir],
86 obs->tau[id][ir]);
87 }
88
89 /* Close file... */
90 fclose(out);
91
92 /* Free... */
93 free(obs);
94
95 return EXIT_SUCCESS;
96}
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read forward model control parameters.
Definition: jurassic.c:4550
void read_obs(const char *dirname, const char *filename, const ctl_t *ctl, obs_t *obs)
Read observation data.
Definition: jurassic.c:4700
JURASSIC library declarations.
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:237
#define ALLOC(ptr, type, n)
Allocate memory.
Definition: jurassic.h:121
#define LOG(level,...)
Print log message.
Definition: jurassic.h:221
int main(int argc, char *argv[])
Definition: obs2spec.c:32
Forward model control parameters.
Definition: jurassic.h:541
double nu[ND]
Centroid wavenumber of each channel [cm^-1].
Definition: jurassic.h:553
int nd
Number of radiance channels.
Definition: jurassic.h:550
Observation geometry and radiance data.
Definition: jurassic.h:734
double tau[ND][NR]
Transmittance of ray path.
Definition: jurassic.h:770
double rad[ND][NR]
Radiance [W/(m^2 sr cm^-1)].
Definition: jurassic.h:773
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