JURASSIC
Functions
obs2spec.c File Reference

Converter for spectra. More...

#include <omp.h>
#include "jurassic.h"

Go to the source code of this file.

Functions

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

Detailed Description

Converter for spectra.

Definition in file obs2spec.c.

Function Documentation

◆ main()

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

Definition at line 40 of file obs2spec.c.

42 {
43
44 static ctl_t ctl;
45
46 obs_t *obs;
47
48 FILE *out;
49
50 /* Print usage information... */
51 USAGE;
52
53 /* Check arguments... */
54 if (argc < 4)
55 ERRMSG("Missing or invalid command-line arguments.\n\n"
56 "Usage: obs2spec <ctl> <obs> <spec.tab> [KEY VALUE ...]\n\n"
57 "Use -h for full help.");
58
59 /* Allocate... */
60 ALLOC(obs, obs_t, 1);
61
62 /* Read control parameters... */
63 read_ctl(argc, argv, &ctl);
64
65 /* Read observation geometry... */
66 read_obs(NULL, argv[2], &ctl, obs, 0);
67
68 /* Write info... */
69 LOG(1, "Write spectra: %s", argv[3]);
70
71 /* Create file... */
72 if (!(out = fopen(argv[3], "w")))
73 ERRMSG("Cannot create file!");
74
75 /* Write header... */
76 fprintf(out,
77 "# $1 = time (seconds since 2000-01-01T00:00Z)\n"
78 "# $2 = observer altitude [km]\n"
79 "# $3 = observer longitude [deg]\n"
80 "# $4 = observer latitude [deg]\n"
81 "# $5 = view point altitude [km]\n"
82 "# $6 = view point longitude [deg]\n"
83 "# $7 = view point latitude [deg]\n"
84 "# $8 = tangent point altitude [km]\n"
85 "# $9 = tangent point longitude [deg]\n"
86 "# $10 = tangent point latitude [deg]\n"
87 "# $11 = channel frequency [cm^-1]\n"
88 "# $12 = channel radiance [W/(m^2 sr cm^-1)]\n"
89 "# $13 = channel transmittance [1]\n");
90
91 /* Write data... */
92 for (int ir = 0; ir < obs->nr; ir++) {
93 fprintf(out, "\n");
94 for (int id = 0; id < ctl.nd; id++)
95 fprintf(out, "%.2f %g %g %g %g %g %g %g %g %g %.4f %g %g\n",
96 obs->time[ir], obs->obsz[ir], obs->obslon[ir], obs->obslat[ir],
97 obs->vpz[ir], obs->vplon[ir], obs->vplat[ir], obs->tpz[ir],
98 obs->tplon[ir], obs->tplat[ir], ctl.nu[id], obs->rad[id][ir],
99 obs->tau[id][ir]);
100 }
101
102 /* Close file... */
103 fclose(out);
104
105 /* Free... */
106 free(obs);
107
108 return EXIT_SUCCESS;
109}
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
#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
#define ALLOC(ptr, type, n)
Allocate memory for an array.
Definition: jurassic.h:418
#define LOG(level,...)
Print a log message with a specified logging level.
Definition: jurassic.h:1255
Control parameters.
Definition: jurassic.h:1428
double nu[ND]
Centroid wavenumber of each channel [cm^-1].
Definition: jurassic.h:1452
int nd
Number of radiance channels.
Definition: jurassic.h:1449
Observation geometry and radiance data.
Definition: jurassic.h:1657
double tau[ND][NR]
Transmittance of ray path.
Definition: jurassic.h:1693
double rad[ND][NR]
Radiance [W/(m^2 sr cm^-1)].
Definition: jurassic.h:1696
double tplon[NR]
Tangent point longitude [deg].
Definition: jurassic.h:1687
double vpz[NR]
View point altitude [km].
Definition: jurassic.h:1675
double vplat[NR]
View point latitude [deg].
Definition: jurassic.h:1681
double obslon[NR]
Observer longitude [deg].
Definition: jurassic.h:1669
double obslat[NR]
Observer latitude [deg].
Definition: jurassic.h:1672
double obsz[NR]
Observer altitude [km].
Definition: jurassic.h:1666
double tplat[NR]
Tangent point latitude [deg].
Definition: jurassic.h:1690
double vplon[NR]
View point longitude [deg].
Definition: jurassic.h:1678
double time[NR]
Time (seconds since 2000-01-01T00:00Z).
Definition: jurassic.h:1663
double tpz[NR]
Tangent point altitude [km].
Definition: jurassic.h:1684
int nr
Number of ray paths.
Definition: jurassic.h:1660
Here is the call graph for this function: