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-2026 Forschungszentrum Juelich GmbH
18*/
19
25#include <omp.h>
26#include "jurassic.h"
27
28/* ------------------------------------------------------------
29 Functions...
30 ------------------------------------------------------------ */
31
33static void usage(
34 void);
35
36/* ------------------------------------------------------------
37 Main...
38 ------------------------------------------------------------ */
39
40int main(
41 int argc,
42 char *argv[]) {
43
44 static ctl_t ctl;
45
46 obs_t *obs;
47
48 FILE *out;
49
50 /* Print usage information... */
51 USAGE;
52
53 /* Check arguments... */
54 if (argc < 4)
55 ERRMSG("Missing or invalid command-line arguments.\n\n"
56 "Usage: obs2spec <ctl> <obs> <spec.tab> [KEY VALUE ...]\n\n"
57 "Use -h for full help.");
58
59 /* Allocate... */
60 ALLOC(obs, obs_t, 1);
61
62 /* Read control parameters... */
63 read_ctl(argc, argv, &ctl);
64
65 /* Read observation geometry... */
66 read_obs(NULL, argv[2], &ctl, obs, 0);
67
68 /* Write info... */
69 LOG(1, "Write spectra: %s", argv[3]);
70
71 /* Create file... */
72 if (!(out = fopen(argv[3], "w")))
73 ERRMSG("Cannot create file!");
74
75 /* Write header... */
76 fprintf(out,
77 "# $1 = time (seconds since 2000-01-01T00:00Z)\n"
78 "# $2 = observer altitude [km]\n"
79 "# $3 = observer longitude [deg]\n"
80 "# $4 = observer latitude [deg]\n"
81 "# $5 = view point altitude [km]\n"
82 "# $6 = view point longitude [deg]\n"
83 "# $7 = view point latitude [deg]\n"
84 "# $8 = tangent point altitude [km]\n"
85 "# $9 = tangent point longitude [deg]\n"
86 "# $10 = tangent point latitude [deg]\n"
87 "# $11 = channel frequency [cm^-1]\n"
88 "# $12 = channel radiance [W/(m^2 sr cm^-1)]\n"
89 "# $13 = channel transmittance [1]\n");
90
91 /* Write data... */
92 for (int ir = 0; ir < obs->nr; ir++) {
93 fprintf(out, "\n");
94 for (int id = 0; id < ctl.nd; id++)
95 fprintf(out, "%.2f %g %g %g %g %g %g %g %g %g %.4f %g %g\n",
96 obs->time[ir], obs->obsz[ir], obs->obslon[ir], obs->obslat[ir],
97 obs->vpz[ir], obs->vplon[ir], obs->vplat[ir], obs->tpz[ir],
98 obs->tplon[ir], obs->tplat[ir], ctl.nu[id], obs->rad[id][ir],
99 obs->tau[id][ir]);
100 }
101
102 /* Close file... */
103 fclose(out);
104
105 /* Free... */
106 free(obs);
107
108 return EXIT_SUCCESS;
109}
110
111/*****************************************************************************/
112
113static void usage(
114 void) {
115 printf("\nJURASSIC spectrum writer.\n\n");
116 printf("Write radiances and transmittances from an observation file to\n");
117 printf("a per-channel spectrum table.\n\n");
118 printf("Usage:\n");
119 printf(" obs2spec <ctl> <obs> <spec.tab> [KEY VALUE ...]\n\n");
120 printf("Arguments:\n");
121 printf(" <ctl> Control file.\n");
122 printf(" <obs> Observation input file.\n");
123 printf(" <spec.tab> Output spectrum table.\n");
124 printf(" [KEY VALUE] Optional control parameters.\n\n");
125 printf("Common control parameters:\n");
126 printf
127 (" OBSFMT Observation file format from the control file.\n");
128 printf
129 (" ND, NU[i] Spectral channels in observation files.\n");
130 printf(" WRITE_BBT Brightness-temperature output flag.\n\n");
131 printf("Further information:\n");
132 printf(" Manual: https://slcs-jsc.github.io/jurassic/\n");
133}
void usage(void)
Print command-line help.
Definition: formod.c:163
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
Definition: jurassic.c:5516
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.
Definition: jurassic.c:5810
JURASSIC library declarations.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: jurassic.h:1325
#define USAGE
Print usage information on -h or --help.
Definition: jurassic.h:1206
#define ALLOC(ptr, type, n)
Allocate memory for an array.
Definition: jurassic.h:418
#define LOG(level,...)
Print a log message with a specified logging level.
Definition: jurassic.h:1255
int main(int argc, char *argv[])
Definition: obs2spec.c:40
Control parameters.
Definition: jurassic.h:1428
double nu[ND]
Centroid wavenumber of each channel [cm^-1].
Definition: jurassic.h:1452
int nd
Number of radiance channels.
Definition: jurassic.h:1449
Observation geometry and radiance data.
Definition: jurassic.h:1657
double tau[ND][NR]
Transmittance of ray path.
Definition: jurassic.h:1693
double rad[ND][NR]
Radiance [W/(m^2 sr cm^-1)].
Definition: jurassic.h:1696
double tplon[NR]
Tangent point longitude [deg].
Definition: jurassic.h:1687
double vpz[NR]
View point altitude [km].
Definition: jurassic.h:1675
double vplat[NR]
View point latitude [deg].
Definition: jurassic.h:1681
double obslon[NR]
Observer longitude [deg].
Definition: jurassic.h:1669
double obslat[NR]
Observer latitude [deg].
Definition: jurassic.h:1672
double obsz[NR]
Observer altitude [km].
Definition: jurassic.h:1666
double tplat[NR]
Tangent point latitude [deg].
Definition: jurassic.h:1690
double vplon[NR]
View point longitude [deg].
Definition: jurassic.h:1678
double time[NR]
Time (seconds since 2000-01-01T00:00Z).
Definition: jurassic.h:1663
double tpz[NR]
Tangent point altitude [km].
Definition: jurassic.h:1684
int nr
Number of ray paths.
Definition: jurassic.h:1660