IASI Code Collection
noise.c
Go to the documentation of this file.
1/*
2 This file is part of the IASI Code Collection.
3
4 the IASI 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 IASI 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 IASI Code Collection. If not, see
16 <http://www.gnu.org/licenses/>.
17
18 Copyright (C) 2019-2026 Forschungszentrum Juelich GmbH
19*/
20
26#include "libiasi.h"
27
28int main(
29 int argc,
30 char *argv[]) {
31
32 static iasi_rad_t *iasi_rad;
33
34 static wave_t wave;
35
36 static FILE *out;
37
38 static double mu, nesr, sigma;
39
40 static int ichan, itrack, ix, iy, format;
41
42 /* Check arguments... */
43 if (argc < 4)
44 ERRMSG("Give parameters: <ctl> <iasi_l1_file> <noise.tab>");
45
46 /* Read control parameters... */
47 format = (int) scan_ctl(argc, argv, "FORMAT", -1, "1", NULL);
48
49 /* Allocate... */
50 ALLOC(iasi_rad, iasi_rad_t, 1);
51
52 /* Read IASI data... */
53 printf("Read IASI data: %s\n", argv[2]);
54 iasi_read(format, argv[2], iasi_rad);
55
56 /* Create file... */
57 printf("Write noise data: %s\n", argv[3]);
58 if (!(out = fopen(argv[3], "w")))
59 ERRMSG("Cannot create file!");
60
61 /* Write header... */
62 fprintf(out,
63 "# $1 = track index\n"
64 "# $2 = channel index\n"
65 "# $3 = wavenumber [1/cm]\n"
66 "# $4 = mean BT [K]\n"
67 "# $5 = NEDT [K]\n" "# $6 = NESR [W/(m^2 sr cm^-1)]\n");
68
69 /* Analyze blocks of data... */
70 for (itrack = 0; itrack < iasi_rad->ntrack; itrack += 60) {
71
72 /* Write empty line... */
73 fprintf(out, "\n");
74
75 /* Loop over channels... */
76 for (ichan = 0; ichan < IASI_L1_NCHAN; ichan++) {
77
78 /* Set wave struct... */
79 wave.nx = L1_NXTRACK;
80 wave.ny = 0;
81 for (iy = itrack; iy < GSL_MIN(itrack + 60, iasi_rad->ntrack); iy++) {
82 for (ix = 0; ix < wave.nx; ix++)
83 wave.temp[ix][wave.ny] = BRIGHT(iasi_rad->Rad[iy][ix][ichan],
84 iasi_rad->freq[ichan]);
85 wave.ny++;
86 }
87
88 /* Check number of data points... */
89 if (wave.ny >= 55) {
90
91 /* Get noise... */
92 noise(&wave, &mu, &sigma);
93
94 /* Get NESR... */
95 nesr = PLANCK(mu + sigma, iasi_rad->freq[ichan])
96 - PLANCK(mu, iasi_rad->freq[ichan]);
97
98 /* Write output... */
99 if (gsl_finite(sigma))
100 fprintf(out, "%d %d %.4f %g %g %g\n", itrack, ichan,
101 iasi_rad->freq[ichan], mu, sigma, nesr);
102 }
103 }
104 }
105
106 /* Close file... */
107 fclose(out);
108
109 /* Free... */
110 free(iasi_rad);
111
112 return EXIT_SUCCESS;
113}
void iasi_read(int format, char *filename, iasi_rad_t *iasi_rad)
Read IASI Level-1 data.
Definition: libiasi.c:297
void noise(wave_t *wave, double *mu, double *sig)
Estimate noise.
Definition: libiasi.c:808
IASI Code Collection library declarations.
#define L1_NXTRACK
Across-track size of IASI radiance granule (don't change).
Definition: libiasi.h:102
#define IASI_L1_NCHAN
Number of channels of IASI radiance granule.
Definition: libiasi.h:114
int main(int argc, char *argv[])
Definition: noise.c:28
IASI converted Level-1 radiation data.
Definition: libiasi.h:288
double freq[IASI_L1_NCHAN]
channel wavenumber [cm^-1]
Definition: libiasi.h:294
int ntrack
Number of along-track samples.
Definition: libiasi.h:291
float Rad[L1_NTRACK][L1_NXTRACK][IASI_L1_NCHAN]
Radiance [W/(m^2 sr cm^-1)].
Definition: libiasi.h:306
Wave analysis data.
Definition: libiasi.h:320
int nx
Number of across-track values.
Definition: libiasi.h:323
int ny
Number of along-track values.
Definition: libiasi.h:326
double temp[WX][WY]
Temperature [K].
Definition: libiasi.h:347