55 ERRMSG(
"Give parameters: <ctl> <filter>");
59 int type = (int)
scan_ctl(argc, argv,
"FILTER_TYPE", -1,
"1", NULL);
60 double opd =
scan_ctl(argc, argv,
"FILTER_OPD", -1,
"10.0", NULL);
61 double fwhm =
scan_ctl(argc, argv,
"FILTER_FWHM", -1,
"1.0", NULL);
62 double center =
scan_ctl(argc, argv,
"FILTER_CENTER", -1,
"1000.0", NULL);
63 double width =
scan_ctl(argc, argv,
"FILTER_WIDTH", -1,
"2.1", NULL);
64 double samp =
scan_ctl(argc, argv,
"FILTER_SAMP", -1,
"0.0005", NULL);
67 for (
double nu = center - 0.5 * width;
68 nu <= center + 0.5 * width; nu += samp) {
75 ff[fn] = (fabs(nu - center) <= 0.5 * fwhm ? 1.0 : 0.0);
79 ff[fn] = 1.0 - fabs(nu - center) / fwhm;
80 ff[fn] =
MAX(ff[fn], 0.0);
85 double sigma = fwhm / 2.355;
86 ff[fn] = exp(-0.5 *
POW2((nu - center) / sigma));
91 ff[fn] =
ails(0, opd, nu - center);
95 ff[fn] =
ails(1, opd, nu - center);
99 ERRMSG(
"Filter function type unknown!");
103 ERRMSG(
"Too many filter function data points!");
107 for (
int i = 0; i < fn; i++)
109 for (
int i = 0; i < fn; i++)
110 ff[i] /= (fsum * samp);
115 return (EXIT_SUCCESS);
125 double a, a2, a4, a6, a8, cosa, q0, q2, q4, sinca;
128 a = 2 * M_PI * dnu * opl;
137 return 1 - a2 / 6 + a4 / 120 - a6 / 5040 + a8 / 362880;
145 q0 = 1 - a2 / 6 + a4 / 120 - a6 / 5040 + a8 / 362880;
146 q2 = 1 - a2 / 14 + a4 / 504 - a6 / 33264 + a8 / 3459456;
147 q4 = 1 - a2 / 22 + a4 / 1144 - a6 / 102960 + a8 / 14002560;
152 q2 = -15 / a2 * ((1 - 3 / a2) * sinca + (3 / a2) * cosa);
154 945 / a4 * ((1 - 45 / a2 + 105 / a4) * sinca +
155 5 / a2 * (2 - 21 / a2) * cosa);
157 return 0.045335 * q0 + 0.554883 * q2 * 8. / 15. +
158 0.399782 * q4 * 384. / 945.;
163 ERRMSG(
"Unknown apodization!");
int main(int argc, char *argv[])
double ails(int apo, double opl, double dnu)
Compute apodized instrument line shape.
void read_ctl(int argc, char *argv[], ctl_t *ctl)
Read forward model control parameters.
void write_shape(const char *filename, const double *x, const double *y, const int n)
Write shape function.
double scan_ctl(int argc, char *argv[], const char *varname, int arridx, const char *defvalue, char *value)
Search control parameter file for variable entry.
JURASSIC library declarations.
#define POW2(x)
Compute x^2.
#define ERRMSG(...)
Print error message and quit program.
#define NSHAPE
Maximum number of shape function grid points.
#define MAX(a, b)
Macro to determine the maximum of two values.
Forward model control parameters.