AIRS Code Collection
noise_ret.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 ret_t ret;
33
34 wave_t *wave, *wave2;
35
36 FILE *out;
37
38 double mu, mu2, nedt, nedt2;
39
40 /* Check arguments... */
41 if (argc < 4)
42 ERRMSG("Give parameters: <ctl> <airs.nc> <noise.tab>");
43
44 /* Allocate... */
45 ALLOC(wave, wave_t, 1);
46 ALLOC(wave2, wave_t, 1);
47
48 /* Read AIRS data... */
49 read_retr(argv[2], &ret);
50
51 /* Create file... */
52 printf("Write noise data: %s\n", argv[3]);
53 if (!(out = fopen(argv[3], "w")))
54 ERRMSG("Cannot create file!");
55
56 /* Write header... */
57 fprintf(out,
58 "# $1 = altitude [km]\n"
59 "# $2 = longitude [deg]\n"
60 "# $3 = latitude [deg]\n"
61 "# $4 = mean temperature (retrieval) [K]\n"
62 "# $5 = noise estimate (retrieval) [K]\n"
63 "# $6 = mean temperature (a priori) [K]\n"
64 "# $7 = noise estimate (a priori) [K]\n\n");
65
66 /* Loop over altitudes... */
67 for (int ip = 0; ip < ret.np; ip++) {
68
69 /* Convert retrieval data to wave struct... */
70 ret2wave(&ret, wave, 1, ip);
71 ret2wave(&ret, wave2, 2, ip);
72
73 /* Estimate noise... */
74 noise(wave, &mu, &nedt);
75 noise(wave2, &mu2, &nedt2);
76
77 /* Estimate noise... */
78 fprintf(out, "%g %g %g %g %g %g %g\n",
79 wave->z,
80 wave->lon[wave->nx / 2][wave->ny / 2],
81 wave->lat[wave->nx / 2][wave->ny / 2], mu, nedt, mu2, nedt2);
82 }
83
84 /* Close file... */
85 fclose(out);
86
87 /* Free... */
88 free(wave);
89 free(wave2);
90
91 return EXIT_SUCCESS;
92}
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:237
#define ALLOC(ptr, type, n)
Allocate memory.
Definition: jurassic.h:121
void noise(wave_t *wave, double *mu, double *sig)
Estimate noise.
Definition: libairs.c:798
void ret2wave(ret_t *ret, wave_t *wave, int dataset, int ip)
Convert AIRS retrieval results to wave analysis struct.
Definition: libairs.c:1531
void read_retr(char *filename, ret_t *ret)
Read AIRS retrieval data.
Definition: libairs.c:1219
AIRS Code Collection library declarations.
int main(int argc, char *argv[])
Definition: noise_ret.c:28
Retrieval results.
Definition: libairs.h:237
int np
Number of data points.
Definition: libairs.h:243
Wave analysis data.
Definition: libairs.h:287
int nx
Number of across-track values.
Definition: libairs.h:290
int ny
Number of along-track values.
Definition: libairs.h:293
double lon[WX][WY]
Longitude [deg].
Definition: libairs.h:302
double lat[WX][WY]
Latitude [deg].
Definition: libairs.h:305
double z
Altitude [km].
Definition: libairs.h:299