AIRS Code Collection
ret2tab.c
Go to the documentation of this file.
1/*
2 This file is part of the AIRS Code Collection.
3
4 the AIRS Code Collections is free software: you can redistribute it
5 and/or modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation, either version 3 of
7 the License, or (at your option) any later version.
8
9 The AIRS Code Collection is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with the AIRS Code Collection. If not, see
16 <http://www.gnu.org/licenses/>.
17
18 Copyright (C) 2019-2025 Forschungszentrum Juelich GmbH
19*/
20
26#include "libairs.h"
27
28/* ------------------------------------------------------------
29 Macros...
30 ------------------------------------------------------------ */
31
32/* Replace dummy values by nan. */
33#define CHECK(x) ((x)!=-9999 ? (x) : GSL_NAN)
34
35/* ------------------------------------------------------------
36 Main...
37 ------------------------------------------------------------ */
38
39int main(
40 int argc,
41 char *argv[]) {
42
43 static airs_ret_gran_t airs_ret_gran;
44
45 FILE *out;
46
47 /* Check arguments... */
48 if (argc != 4)
49 ERRMSG("Give parameters: <airs_l2_file> <layer> <airs.tab>");
50
51 /* Get arguments... */
52 const int lay = atoi(argv[2]);
53
54 /* Read AIRS data... */
55 printf("Read AIRS Level-2 data file: %s\n", argv[1]);
56 airs_ret_rdr(argv[1], &airs_ret_gran);
57
58 /* Create output file... */
59 printf("Write ASCII file: %s\n", argv[3]);
60 if (!(out = fopen(argv[3], "w")))
61 ERRMSG("Cannot create file!");
62
63 /* Write header... */
64 fprintf(out,
65 "# $1 = time (seconds since 01-JAN-2000, 00:00 UTC)\n"
66 "# $2 = altitude [km]\n"
67 "# $3 = longitude [deg]\n"
68 "# $4 = latitude [deg]\n"
69 "# $5 = pressure [hPa]\n"
70 "# $6 = temperature [K]\n"
71 "# $7 = H2O mass mixing ratio\n"
72 "# $8 = O3 volume mixing ratio\n"
73 "# $9 = CH4 volume mixing ratio\n"
74 "# $10 = CO volume mixing ratio\n");
75
76 /* Write data to stdout... */
77 for (int track = 0; track < AIRS_RET_GEOTRACK; track++) {
78 fprintf(out, "\n");
79 for (int xtrack = 0; xtrack < AIRS_RET_GEOXTRACK; xtrack++)
80 fprintf(out, "%.2f %g %g %g %g %g %g %g %g %g\n",
81 airs_ret_gran.Time[track][xtrack] - 220838400,
82 CHECK(airs_ret_gran.GP_Height[track][xtrack][lay]) / 1000,
83 CHECK(airs_ret_gran.Longitude[track][xtrack]),
84 CHECK(airs_ret_gran.Latitude[track][xtrack]),
85 CHECK(airs_ret_gran.pressStd[lay]),
86 CHECK(airs_ret_gran.TAirStd[track][xtrack][lay]),
87 CHECK(airs_ret_gran.H2OMMRStd[track][xtrack][lay]),
88 CHECK(airs_ret_gran.O3VMRStd[track][xtrack][lay]),
89 CHECK(airs_ret_gran.COVMRLevStd[track][xtrack][lay]),
90 CHECK(airs_ret_gran.CH4VMRLevStd[track][xtrack][lay]));
91 }
92
93 /* Close file... */
94 fclose(out);
95
96 return EXIT_SUCCESS;
97}
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:237
AIRS Code Collection library declarations.
int main(int argc, char *argv[])
Definition: ret2tab.c:39
#define CHECK(x)
Definition: ret2tab.c:33