44 int prof_in, prof_out;
58 ERRMSG(
"Missing or invalid command-line arguments.\n\n"
59 "Usage: matfmt <ctl> <atm> <obs> <rowspace> <colspace> <sort> <matrix_in> <matrixfmt_in> <matrix_out> <matrixfmt_out> [KEY VALUE ...]\n\n"
60 "Use -h for full help.");
66 prof_in = (int)
scan_ctl(argc, argv,
"PROF_IN", -1,
"0", NULL);
67 prof_out = (int)
scan_ctl(argc, argv,
"PROF_OUT", -1,
"0", NULL);
70 if (argv[4][0] !=
'x' && argv[4][0] !=
'y')
71 ERRMSG(
"Unknown row space, use x or y!");
72 if (argv[5][0] !=
'x' && argv[5][0] !=
'y')
73 ERRMSG(
"Unknown column space, use x or y!");
74 if (argv[6][0] !=
'r' && argv[6][0] !=
'c')
75 ERRMSG(
"Unknown sort order, use r or c!");
78 if (argv[4][0] ==
'x' || argv[5][0] ==
'x')
79 read_atm(NULL, argv[2], &ctl, &atm, 0);
82 if (argv[4][0] ==
'y' || argv[5][0] ==
'y')
83 read_obs(NULL, argv[3], &ctl, &obs, 0);
86 if (argv[4][0] ==
'y')
87 nr =
obs2y(&ctl, &obs, NULL, NULL, NULL);
89 nr =
atm2x(&ctl, &atm, NULL, NULL, NULL);
91 if (argv[5][0] ==
'y')
92 nc =
obs2y(&ctl, &obs, NULL, NULL, NULL);
94 nc =
atm2x(&ctl, &atm, NULL, NULL, NULL);
97 matrix = gsl_matrix_alloc(nr, nc);
106 write_matrix(NULL, argv[9], &ctl, matrix, &atm, &obs, argv[4], argv[5],
110 gsl_matrix_free(matrix);
119 printf(
"\nJURASSIC matrix-format converter.\n\n");
120 printf(
"Convert matrix files between supported MATRIXFMT formats and\n");
121 printf(
"annotate them using atmospheric or observation metadata.\n\n");
123 printf(
" matfmt <ctl> <atm> <obs> <rowspace> <colspace> <sort>\n");
125 (
" <matrix_in> <matrixfmt_in> <matrix_out> <matrixfmt_out>\n");
126 printf(
" [KEY VALUE ...]\n\n");
127 printf(
"Arguments:\n");
128 printf(
" <ctl> Control file.\n");
129 printf(
" <atm> Atmospheric data file.\n");
130 printf(
" <obs> Observation data file.\n");
131 printf(
" <rowspace> Row space: x or y.\n");
132 printf(
" <colspace> Column space: x or y.\n");
133 printf(
" <sort> Sort order: r or c.\n");
134 printf(
" <matrix_in> Input matrix file.\n");
135 printf(
" <matrixfmt_in> Input matrix format identifier.\n");
136 printf(
" <matrix_out> Output matrix file.\n");
137 printf(
" <matrixfmt_out> Output matrix format identifier.\n");
138 printf(
" [KEY VALUE] Optional control parameters.\n\n");
139 printf(
"Tool-specific control parameters:\n");
140 printf(
" PROF_IN <n> Read profile index <n> from the input file.\n");
141 printf(
" PROF_OUT <n> Write output as profile index <n>.\n\n");
142 printf(
"Common control parameters:\n");
144 (
" ATMFMT, OBSFMT Atmospheric and observation file formats.\n");
145 printf(
" NG, EMITTER[i] Active emitters.\n");
146 printf(
" ND, NU[i], NW, WINDOW[i] Spectral channels and windows.\n");
148 (
" NCL, CLNU[i], NSF, SFNU[i] Cloud and surface spectral grids.\n");
149 printf(
" RET*_ZMIN, RET*_ZMAX State-vector altitude limits.\n\n");
150 printf(
"Further information:\n");
151 printf(
" Manual: https://slcs-jsc.github.io/jurassic/\n");
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_matrix(const char *dirname, const char *filename, const ctl_t *ctl, gsl_matrix *matrix, int dataset)
Read a numerical matrix from a 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.
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.
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 ERRMSG(...)
Print an error message with contextual information and terminate the program.
#define USAGE
Print usage information on -h or --help.
int main(int argc, char *argv[])
Atmospheric profile data.
int write_matrix
Write matrix file (0=no, 1=yes).
int matrixfmt
Matrix data file format (1=ASCII, 2=binary, 3=netCDF).
Observation geometry and radiance data.