AIRS Code Collection
Functions
spec2tab.c File Reference

Extract radiance spectra. More...

#include "libairs.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Extract radiance spectra.

Definition in file spec2tab.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 28 of file spec2tab.c.

30 {
31
32 static airs_rad_gran_t airs_rad_gran;
33
34 FILE *out;
35
36 int track = -1, xtrack = -1;
37
38 /* Check arguments... */
39 if (argc != 6)
40 ERRMSG("Give parameters: <airs_l1b_file> "
41 "[index <track> <xtrack> | geo <lon> <lat>] <spec.tab>");
42
43 /* Read AIRS data... */
44 printf("Read AIRS Level-1B data file: %s\n", argv[1]);
45 airs_rad_rdr(argv[1], &airs_rad_gran);
46
47 /* Get indices... */
48 if (argv[2][0] == 'i') {
49 track = atoi(argv[3]);
50 xtrack = atoi(argv[4]);
51 }
52
53 /* Find nearest footprint... */
54 else {
55 double dmin = 1e100, x0[3], x1[3];
56 geo2cart(0, atof(argv[3]), atof(argv[4]), x0);
57 for (int track2 = 0; track2 < AIRS_RAD_GEOTRACK; track2++)
58 for (int xtrack2 = 0; xtrack2 < AIRS_RAD_GEOXTRACK; xtrack2++) {
59 geo2cart(0, airs_rad_gran.Longitude[track2][xtrack2],
60 airs_rad_gran.Latitude[track2][xtrack2], x1);
61 if (DIST2(x0, x1) < dmin) {
62 dmin = DIST2(x0, x1);
63 track = track2;
64 xtrack = xtrack2;
65 }
66 }
67 if (dmin > 2500)
68 ERRMSG("Geolocation not covered by granule!");
69 printf("nearest footprint: lon= %g, lat= %g, track= %d, xtrack=%d\n",
70 airs_rad_gran.Longitude[track][xtrack],
71 airs_rad_gran.Latitude[track][xtrack], track, xtrack);
72 }
73
74 /* Check indices... */
75 if (track < 0 || track >= AIRS_RAD_GEOTRACK)
76 ERRMSG("Along-track index out of range!");
77 if (xtrack < 0 || xtrack >= AIRS_RAD_GEOXTRACK)
78 ERRMSG("Across-track index out of range!");
79
80 /* Flag bad observations... */
81 for (int ichan = 0; ichan < AIRS_RAD_CHANNEL; ichan++)
82 if ((airs_rad_gran.state[track][xtrack] != 0)
83 || (airs_rad_gran.ExcludedChans[ichan] > 2)
84 || (airs_rad_gran.CalChanSummary[ichan] & 8)
85 || (airs_rad_gran.CalChanSummary[ichan] & (32 + 64))
86 || (airs_rad_gran.CalFlag[track][ichan] & 16))
87 airs_rad_gran.radiances[track][xtrack][ichan]
88 = (float) sqrt(-1.0);
89
90 /* Create file... */
91 printf("Write spectrum: %s\n", argv[5]);
92 if (!(out = fopen(argv[5], "w")))
93 ERRMSG("Cannot create file!");
94
95 /* Write header... */
96 fprintf(out,
97 "# $1 = time (seconds since 01-JAN-2000, 00:00 UTC)\n"
98 "# $2 = satellite longitude [deg]\n"
99 "# $3 = satellite latitude [deg]\n"
100 "# $4 = footprint longitude [deg]\n"
101 "# $5 = footprint latitude [deg]\n"
102 "# $6 = wavenumber [cm^-1]\n"
103 "# $7 = brightness temperature [K]\n"
104 "# $8 = radiance [W/(m^2 sr cm^-1)]\n\n");
105
106 /* Write data... */
107 for (int ichan = 0; ichan < AIRS_RAD_CHANNEL; ichan++) {
108 if (ichan > 0)
109 if (fabs(airs_rad_gran.nominal_freq[ichan]
110 - airs_rad_gran.nominal_freq[ichan - 1]) > 1.2)
111 fprintf(out, "\n");
112 fprintf(out, "%.2f %g %g %g %g %g %g %g\n",
113 airs_rad_gran.Time[track][xtrack] - 220838400,
114 airs_rad_gran.sat_lon[track],
115 airs_rad_gran.sat_lat[track],
116 airs_rad_gran.Longitude[track][xtrack],
117 airs_rad_gran.Latitude[track][xtrack],
118 airs_rad_gran.nominal_freq[ichan],
119 BRIGHT(airs_rad_gran.radiances[track][xtrack][ichan] * 1e-3,
120 airs_rad_gran.nominal_freq[ichan]),
121 airs_rad_gran.radiances[track][xtrack][ichan] * 1e-3);
122 }
123
124 /* Close file... */
125 fclose(out);
126
127 return EXIT_SUCCESS;
128}
void geo2cart(const double z, const double lon, const double lat, double *x)
Convert geolocation to Cartesian coordinates.
Definition: jurassic.c:3500
#define BRIGHT(rad, nu)
Compute brightness temperature.
Definition: jurassic.h:126
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:237
#define DIST2(a, b)
Compute squared distance between two vectors.
Definition: jurassic.h:137
Here is the call graph for this function: