AIRS Code Collection
spec_qual.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
28int main(
29 int argc,
30 char *argv[]) {
31
32 static airs_rad_gran_t airs_rad_gran;
33
34 FILE *out;
35
36 /* Check arguments... */
37 if (argc != 5)
38 ERRMSG("Give parameters: <airs_l1b_file> <track> <xtrack> <qual.tab>");
39
40 /* Read AIRS data... */
41 printf("Read AIRS Level-1B data file: %s\n", argv[1]);
42 airs_rad_rdr(argv[1], &airs_rad_gran);
43
44 /* Get indices... */
45 const int track = atoi(argv[2]);
46 const int xtrack = atoi(argv[3]);
47
48 /* Check indices... */
49 if (track < 0 || track >= AIRS_RAD_GEOTRACK)
50 ERRMSG("Along-track index out of range!");
51 if (xtrack < 0 || xtrack >= AIRS_RAD_GEOXTRACK)
52 ERRMSG("Across-track index out of range!");
53
54 /* Create file... */
55 printf("Write quality data file: %s\n", argv[4]);
56 if (!(out = fopen(argv[4], "w")))
57 ERRMSG("Cannot create file!");
58
59 /* Write header... */
60 fprintf(out,
61 "# $1 = time (seconds since 01-JAN-2000, 00:00 UTC)\n"
62 "# $2 = satellite longitude [deg]\n"
63 "# $3 = satellite latitude [deg]\n"
64 "# $4 = footprint longitude [deg]\n"
65 "# $5 = footprint latitude [deg]\n"
66 "# $6 = wavenumber [cm^-1]\n"
67 "# $7 = radiance [W/(m^2 sr cm^-1)]\n"
68 "# $8 = channel number\n"
69 "# $9 = state\n"
70 "# $10 = excluded channels\n"
71 "# $11 = calibration channel summary\n"
72 "# $12 = calibration flag\n" "# $13 = combined quality flag\n\n");
73
74 /* Write data... */
75 for (int ichan = 0; ichan < AIRS_RAD_CHANNEL; ichan++) {
76 int flag = (airs_rad_gran.state[track][xtrack] != 0)
77 || (airs_rad_gran.ExcludedChans[ichan] > 2)
78 || (airs_rad_gran.CalChanSummary[ichan] & 8)
79 || (airs_rad_gran.CalChanSummary[ichan] & (32 + 64))
80 || (airs_rad_gran.CalFlag[track][ichan] & 16);
81 fprintf(out, "%.2f %g %g %g %g %g %g %d %d %d %d %d %d\n",
82 airs_rad_gran.Time[track][xtrack] - 220838400,
83 airs_rad_gran.sat_lon[track],
84 airs_rad_gran.sat_lat[track],
85 airs_rad_gran.Longitude[track][xtrack],
86 airs_rad_gran.Latitude[track][xtrack],
87 airs_rad_gran.nominal_freq[ichan],
88 airs_rad_gran.radiances[track][xtrack][ichan] * 1e-3,
89 ichan,
90 airs_rad_gran.state[track][xtrack],
91 airs_rad_gran.ExcludedChans[ichan],
92 airs_rad_gran.CalChanSummary[ichan],
93 airs_rad_gran.CalFlag[track][ichan], flag);
94 }
95
96 /* Close file... */
97 fclose(out);
98
99 return EXIT_SUCCESS;
100}
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:237
AIRS Code Collection library declarations.
int main(int argc, char *argv[])
Definition: spec_qual.c:28