38 const char *kernelfile);
61 ERRMSG(
"Missing or invalid command-line arguments.\n\n"
62 "Usage: kernel <ctl> <obs> <atm> <kernel> [KEY VALUE ...]\n\n"
63 "Use -h for full help.");
75 scan_ctl(argc, argv,
"DIRLIST", -1,
"-", dirlist);
81 if (dirlist[0] ==
'-')
82 call_kernel(&ctl, tbl, NULL, argv[2], argv[3], argv[4]);
89 if (!(in = fopen(dirlist,
"r")))
90 ERRMSG(
"Cannot open directory list!");
94 while (fscanf(in,
"%4999s", wrkdir) != EOF) {
97 LOG(1,
"\nWorking directory: %s", wrkdir);
100 call_kernel(&ctl, tbl, wrkdir, argv[2], argv[3], argv[4]);
120 printf(
"\nJURASSIC kernel tool.\n\n");
121 printf(
"Compute Jacobian or kernel matrices for the configured channels\n");
123 (
"from observation geometry, atmospheric state, and control settings.\n\n");
125 printf(
" kernel <ctl> <obs> <atm> <kernel> [KEY VALUE ...]\n\n");
126 printf(
"Arguments:\n");
127 printf(
" <ctl> Control file.\n");
128 printf(
" <obs> Observation geometry input file.\n");
129 printf(
" <atm> Atmospheric state input file.\n");
130 printf(
" <kernel> Output file for the kernel matrix.\n");
131 printf(
" [KEY VALUE] Optional control parameters.\n\n");
132 printf(
"Tool-specific control parameters:\n");
134 (
" DIRLIST <file> Read working directories from <file> and run one case\n");
136 (
" per directory using the same <obs>, <atm>, and\n");
138 (
" <kernel> filenames relative to each listed directory.\n");
140 printf(
"Common control parameters:\n");
142 (
" TBLBASE, TBLFMT Lookup-table base name and format.\n");
143 printf(
" ATMFMT, OBSFMT, MATRIXFMT Input/output file formats.\n");
144 printf(
" NG, EMITTER[i] Active emitters.\n");
145 printf(
" ND, NU[i], NW, WINDOW[i] Spectral channels and windows.\n");
147 (
" NCL, CLNU[i], NSF, SFNU[i] Cloud and surface spectral grids.\n");
148 printf(
" RET*_ZMIN, RET*_ZMAX State-vector altitude limits.\n");
150 (
" WRITE_BBT, FORMOD Output units and forward-model selection.\n");
151 printf(
" CTM_*, REFRAC Continua and refractivity.\n");
153 (
" RAYDS, RAYDZ, FOV Ray tracing and field of view.\n\n");
154 printf(
"Further information:\n");
155 printf(
" Manual: https://slcs-jsc.github.io/jurassic/\n");
166 const char *kernelfile) {
173 read_obs(wrkdir, obsfile, ctl, &obs, 0);
177 read_atm(wrkdir, atmfile, ctl, &atm, 0);
180 const size_t n =
atm2x(ctl, &atm, NULL, NULL, NULL);
181 const size_t m =
obs2y(ctl, &obs, NULL, NULL, NULL);
185 ERRMSG(
"No state vector elements!");
187 ERRMSG(
"No measurement vector elements!");
190 gsl_matrix *k = gsl_matrix_alloc(m, n);
194 kernel(ctl, tbl, &atm, &obs, k);
198 write_matrix(wrkdir, kernelfile, ctl, k, &atm, &obs,
"y",
"x",
"r", 0);
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 read_obs(const char *dirname, const char *filename, const ctl_t *ctl, obs_t *obs, int profile)
Read observation data from an input file.
void write_matrix(const char *dirname, const char *filename, const ctl_t *ctl, const gsl_matrix *matrix, const atm_t *atm, const obs_t *obs, const char *rowspace, const char *colspace, const char *sort, int dataset)
Write a fully annotated matrix (e.g., Jacobian or gain matrix) to file.
void read_atm(const char *dirname, const char *filename, const ctl_t *ctl, atm_t *atm, int profile)
Read atmospheric input data from a file.
void kernel(const ctl_t *ctl, const tbl_t *tbl, atm_t *atm, obs_t *obs, gsl_matrix *k)
Compute the Jacobian (kernel) matrix by finite differences.
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.
size_t obs2y(const ctl_t *ctl, const obs_t *obs, gsl_vector *y, int *ida, int *ira)
Convert observation radiances into a measurement vector.
size_t atm2x(const ctl_t *ctl, const atm_t *atm, gsl_vector *x, int *iqa, int *ipa)
Convert atmospheric data to state vector elements.
JURASSIC library declarations.
#define LEN
Maximum length of ASCII data lines.
#define SELECT_TIMER(id, group)
Switch to a named aggregated timer.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define USAGE
Print usage information on -h or --help.
#define PRINT_TIMERS
Print aggregated timer statistics.
#define LOG(level,...)
Print a log message with a specified logging level.
int main(int argc, char *argv[])
void call_kernel(const ctl_t *ctl, const tbl_t *tbl, const char *wrkdir, const char *obsfile, const char *atmfile, const char *kernelfile)
Perform kernel calculations in a single directory.
void usage(void)
Print command-line help.
Atmospheric profile data.
int write_matrix
Write matrix file (0=no, 1=yes).
Observation geometry and radiance data.
Emissivity look-up tables.