41 {
42
43
45
46
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
54 if (argc == 3) {
55
56
57 const double t = atof(argv[1]);
58 const double nu = atof(argv[2]);
59
60
61 printf(
"%.10g\n",
PLANCK(t, nu));
62 }
63
64
65 else if (argc == 7) {
66
67
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
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
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.
#define USAGE
Print usage information on -h or --help.
#define PLANCK(T, nu)
Compute spectral radiance using Planck’s law.