JURASSIC
obsfmt.c
Go to the documentation of this file.
1/*
2 This file is part of JURASSIC.
3
4 JURASSIC is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 JURASSIC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with JURASSIC. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright (C) 2013-2026 Forschungszentrum Juelich GmbH
18*/
19
25#include "jurassic.h"
26
27/* ------------------------------------------------------------
28 Functions...
29 ------------------------------------------------------------ */
30
32static void usage(
33 void);
34
35/* ------------------------------------------------------------
36 Main...
37 ------------------------------------------------------------ */
38
39int main(
40 int argc,
41 char *argv[]) {
42
43 ctl_t ctl;
44
45 static obs_t obs;
46
47 /* Print usage information... */
48 USAGE;
49
50 /* Check arguments... */
51 if (argc < 6)
52 ERRMSG("Missing or invalid command-line arguments.\n\n"
53 "Usage: obsfmt <ctl> <obs_in> <obsfmt_in> <obs_out> <obsfmt_out> [KEY VALUE ...]\n\n"
54 "Use -h for full help.");
55
56 /* Read control parameters... */
57 read_ctl(argc, argv, &ctl);
58
59 /* Read profile indices... */
60 const int prof_in = (int) scan_ctl(argc, argv, "PROF_IN", -1, "0", NULL);
61 const int prof_out = (int) scan_ctl(argc, argv, "PROF_OUT", -1, "0", NULL);
62
63 /* Read observation data... */
64 ctl.obsfmt = atoi(argv[3]);
65 read_obs(NULL, argv[2], &ctl, &obs, prof_in);
66
67 /* Write observation data... */
68 ctl.obsfmt = atoi(argv[5]);
69 write_obs(NULL, argv[4], &ctl, &obs, prof_out);
70
71 return EXIT_SUCCESS;
72}
73
74/*****************************************************************************/
75
76static void usage(
77 void) {
78 printf("\nJURASSIC observation-format converter.\n\n");
79 printf("Convert observation files between supported OBSFMT formats.\n\n");
80 printf("Usage:\n");
81 printf(" obsfmt <ctl> <obs_in> <obsfmt_in> <obs_out> <obsfmt_out>\n");
82 printf(" [KEY VALUE ...]\n\n");
83 printf("Arguments:\n");
84 printf(" <ctl> Control file.\n");
85 printf(" <obs_in> Input observation data file.\n");
86 printf(" <obsfmt_in> Input observation file format identifier.\n");
87 printf(" <obs_out> Output observation data file.\n");
88 printf(" <obsfmt_out> Output observation file format identifier.\n");
89 printf(" [KEY VALUE] Optional control parameters.\n\n");
90 printf("Tool-specific control parameters:\n");
91 printf(" PROF_IN <n> Read profile index <n> from the input file.\n");
92 printf(" PROF_OUT <n> Write output as profile index <n>.\n\n");
93 printf("Common control parameters:\n");
94 printf
95 (" ND, NU[i] Spectral channels in observation files.\n");
96 printf(" WRITE_BBT Brightness-temperature output flag.\n\n");
97 printf("Further information:\n");
98 printf(" Manual: https://slcs-jsc.github.io/jurassic/\n");
99}
void usage(void)
Print command-line help.
Definition: formod.c:163
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read model control parameters from command-line and configuration input.
Definition: jurassic.c:5516
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.
Definition: jurassic.c:5810
void write_obs(const char *dirname, const char *filename, const ctl_t *ctl, const obs_t *obs, int profile)
Write observation data to an output file in ASCII or binary format.
Definition: jurassic.c:8275
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.
Definition: jurassic.c:6612
JURASSIC library declarations.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: jurassic.h:1325
#define USAGE
Print usage information on -h or --help.
Definition: jurassic.h:1206
int main(int argc, char *argv[])
Definition: obsfmt.c:39
Control parameters.
Definition: jurassic.h:1428
int obsfmt
Observation data file format (1=ASCII, 2=binary, 3=netCDF).
Definition: jurassic.h:1488
Observation geometry and radiance data.
Definition: jurassic.h:1657