JURASSIC
Functions
planck.c File Reference

Convert brightness temperature to radiance. More...

#include "jurassic.h"

Go to the source code of this file.

Functions

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

Detailed Description

Convert brightness temperature to radiance.

Definition in file planck.c.

Function Documentation

◆ main()

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

Definition at line 39 of file planck.c.

41 {
42
43 /* Print usage information... */
44 USAGE;
45
46 /* Check arguments... */
47 if (argc != 3 && argc != 7)
48 ERRMSG("Missing or invalid command-line arguments.\n\n"
49 "Usage: planck <t> <nu>\n"
50 " or: planck <t0> <t1> <dt> <nu0> <nu1> <dnu>\n\n"
51 "Use -h for full help.");
52
53 /* Calculate single value... */
54 if (argc == 3) {
55
56 /* Read arguments... */
57 const double t = atof(argv[1]);
58 const double nu = atof(argv[2]);
59
60 /* Compute Planck function... */
61 printf("%.10g\n", PLANCK(t, nu));
62 }
63
64 /* Calculate table... */
65 else if (argc == 7) {
66
67 /* Read arguments... */
68 const double t0 = atof(argv[1]);
69 const double t1 = atof(argv[2]);
70 const double dt = atof(argv[3]);
71 const double nu0 = atof(argv[4]);
72 const double nu1 = atof(argv[5]);
73 const double dnu = atof(argv[6]);
74
75 /* Write header... */
76 printf("# $1 = brightness temperature [K]\n"
77 "# $2 = wavenumber [cm^-1]\n"
78 "# $3 = radiance [W/(m^2 sr cm^-1)]\n");
79
80 /* Compute Planck function... */
81 for (double t = t0; t <= t1; t += dt) {
82 printf("\n");
83 for (double nu = nu0; nu <= nu1; nu += dnu)
84 printf("%.10g %.4f %.10g\n", t, nu, PLANCK(t, nu));
85 }
86 }
87
88 return EXIT_SUCCESS;
89}
#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 PLANCK(T, nu)
Compute spectral radiance using Planck’s law.
Definition: jurassic.h:1004