JURASSIC
brightness.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) 2003-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 /* Print usage information... */
44 USAGE;
45
46 /* Check arguments... */
47 if (argc != 3 && argc != 7)
48 ERRMSG
49 ("Missing or invalid command-line arguments.\n\n"
50 "Usage: brightness <rad> <nu>\n"
51 " or: brightness <rad0> <rad1> <drad> <nu0> <nu1> <dnu>\n\n"
52 "Use -h for full help.");
53
54 /* Calculate single value... */
55 if (argc == 3) {
56
57 /* Read arguments... */
58 double rad = atof(argv[1]);
59 double nu = atof(argv[2]);
60
61 /* Compute brightness temperature... */
62 printf("%.10g\n", BRIGHT(rad, nu));
63
64 }
65
66 /* Calculate table... */
67 else if (argc == 7) {
68
69 /* Read arguments... */
70 double rad0 = atof(argv[1]);
71 double rad1 = atof(argv[2]);
72 double drad = atof(argv[3]);
73 double nu0 = atof(argv[4]);
74 double nu1 = atof(argv[5]);
75 double dnu = atof(argv[6]);
76
77 /* Write header... */
78 printf("# $1 = radiance [W/(m^2 sr cm^-1)]\n"
79 "# $2 = wavenumber [cm^-1]\n"
80 "# $3 = brightness temperature [K]\n");
81
82 /* Compute brightness temperature... */
83 for (double rad = rad0; rad <= rad1; rad += drad) {
84 printf("\n");
85 for (double nu = nu0; nu <= nu1; nu += dnu)
86 printf("%.10g %.4f %.10g\n", rad, nu, BRIGHT(rad, nu));
87 }
88 }
89
90 return EXIT_SUCCESS;
91}
92
93/*****************************************************************************/
94
95static void usage(
96 void) {
97 printf("\nJURASSIC brightness-temperature converter.\n\n");
98 printf("Convert radiance to brightness temperature for a single value\n");
99 printf("or a tabulated radiance and wavenumber range.\n\n");
100 printf("Usage:\n");
101 printf(" brightness <rad> <nu>\n");
102 printf(" brightness <rad0> <rad1> <drad> <nu0> <nu1> <dnu>\n\n");
103 printf("Arguments:\n");
104 printf(" <rad> Radiance [W/(m^2 sr cm^-1)].\n");
105 printf(" <nu> Wavenumber [cm^-1].\n");
106 printf(" <rad0> First radiance value for table output.\n");
107 printf(" <rad1> Last radiance value for table output.\n");
108 printf(" <drad> Radiance increment for table output.\n");
109 printf(" <nu0> First wavenumber for table output.\n");
110 printf(" <nu1> Last wavenumber for table output.\n");
111 printf(" <dnu> Wavenumber increment for table output.\n\n");
112 printf("Output:\n");
113 printf(" Writes results to standard output.\n\n");
114 printf("Further information:\n");
115 printf(" Manual: https://slcs-jsc.github.io/jurassic/\n");
116}
int main(int argc, char *argv[])
Definition: brightness.c:39
JURASSIC library declarations.
#define BRIGHT(rad, nu)
Compute brightness temperature from radiance.
Definition: jurassic.h:448
#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