64 {
66
67
69
70
71 if (argc < 6)
72 ERRMSG(
"Missing or invalid command-line arguments.\n\n"
73 "Usage: tblrdc <ctl> <tblbase_in> <tblfmt_in> <tblbase_out> <tblfmt_out> [KEY VALUE ...]\n\n"
74 "Use -h for full help.");
75
76
78 const double atol =
scan_ctl(argc, argv,
"ATOL", -1,
"1e-9", NULL);
79 const double rtol =
scan_ctl(argc, argv,
"RTOL", -1,
"0.01", NULL);
80
81
82 sprintf(ctl.
tblbase,
"%s", argv[2]);
83 ctl.
tblfmt = atoi(argv[3]);
85
86
87 for (
int id = 0;
id < ctl.
nd;
id++)
88 for (
int ig = 0; ig < ctl.
ng; ig++) {
89
90
91 int total_input = 0;
92 int total_output = 0;
93
94
95 for (
int ip = 0; ip < tbl->
np[id][ig]; ip++) {
96 for (
int it = 0; it < tbl->
nt[id][ig][ip]; it++) {
97
98 const int num_points = tbl->
nu[id][ig][ip][it];
99
100
101 int write_idx = 1;
102
103
104 if (num_points > 2)
105 reduction(tbl, id, ig, ip, it, 0, num_points - 1, &write_idx,
106 atol, rtol);
107
108
109 if (num_points > 1) {
110 copy_density(tbl, id, ig, ip, it, write_idx, num_points - 1);
111 write_idx++;
112 }
113
114
115 tbl->
nu[id][ig][ip][it] = write_idx;
116 total_input += num_points;
117 total_output += write_idx;
118 }
119 }
120
121
122 LOG(1,
"Reduction: %s | %.4f cm^-1 | n= %d | CR= %g", ctl.
emitter[ig],
123 ctl.
nu[
id], total_input,
124 total_output > 0 ? (double) total_input / total_output : NAN);
125
126 }
127
128
129 sprintf(ctl.
tblbase,
"%s", argv[4]);
130 ctl.
tblfmt = atoi(argv[5]);
132
133
135
136 return EXIT_SUCCESS;
137}
void tbl_free(const ctl_t *ctl, tbl_t *tbl)
Free lookup table and all internally allocated memory.
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
void write_tbl(const ctl_t *ctl, const tbl_t *tbl)
Write emissivity lookup tables to disk.
double scan_ctl(int argc, char *argv[], const char *varname, const int arridx, const char *defvalue, char *value)
Scan control file or command-line arguments for a configuration variable.
tbl_t * read_tbl(const ctl_t *ctl)
Read emissivity lookup tables from disk.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define USAGE
Print usage information on -h or --help.
#define LOG(level,...)
Print a log message with a specified logging level.
double nu[ND]
Centroid wavenumber of each channel [cm^-1].
char tblbase[LEN]
Basename for table files and filter function files.
int ng
Number of emitters.
int nd
Number of radiance channels.
char emitter[NG][LEN]
Name of each emitter.
int tblfmt
Look-up table file format (1=ASCII, 2=binary, 3=netCDF).
Emissivity look-up tables.
int nu[ND][NG][TBLNP][TBLNT]
Number of column densities.
int nt[ND][NG][TBLNP]
Number of temperatures.
int np[ND][NG]
Number of pressure levels.