21 const double nuHz_1micron = 1e4*
c_light;
22 Dust dust(1.0, 1e10, 0.0);
24 PACS pacs70(70, extend), pacs100(100, extend), pacs160(160, extend);
29 fputs(
"\n**** Effective bandwidth (Hz) ****\n", f);
30 fputs(
" 70u 100u 160u\n", f);
31 fprintf(f,
"%8.2e %8.2e %8.2e\n",
32 pacs70.freqWidth(), pacs100.freqWidth(), pacs160.
freqWidth());
34 fputs(
"\n**** Blackbody color corrections ****\n", f);
35 fputs(
"Temp(K) 70u 100u 160u\n", f);
36 for (
auto T: {1e4, 1e3, 1e2, 5e1, 1e1, 5e0}) {
37 fprintf(f,
"%5gK %7.3f %7.3f %7.3f\n", T,
38 pacs70.ccf(gray, T), pacs100.ccf(gray, T), pacs160.
ccf(gray, T));
41 fputs(
"\n**** Graybody color corrections ****\n", f);
42 fputs(
"(beta, T) 70u 100u 160u\n", f);
43 for (
double beta=1.0; beta <= 2.0; beta++) {
44 dust.
setModel(nuHz_1micron/1.0, 1.0, beta);
45 for (
auto T: {1e2, 1e1}) {
46 fprintf(f,
"(%g, %3gK) = %.3f %.3f %.3f\n", beta, T,
47 pacs70.ccf(gray, T), pacs100.ccf(gray, T), pacs160.
ccf(gray, T));
51 double T = 15.0, Sigma = 1.0, sr = 3.62e-9;
52 dust.
setModel(nuHz_1micron/157.0, 1.0, 1.5);
53 fprintf(f,
"\nExample flux = %.2e erg/cm^2/s, Fnu = %.2f Jy, 1/CCF = %.3f\n",
54 gray.
F(T, Sigma, &pacs100, sr),
55 gray.
Inu(pacs100.freqBand(), T, Sigma)*sr/1e-23,
56 1.0/pacs100.ccf(gray, T, Sigma));
58 fputs(
"\n**** Derivative test ****\n", f);
59 fprintf(f,
"dF/dT: %.4e calc, %.4e true\n",
60 (gray.
F(T+1e-3, Sigma, &pacs100, sr)-
61 gray.
F(T-1e-3, Sigma, &pacs100, sr))/2e-3,
62 gray.
dF_dT(T, Sigma, &pacs100, sr));
63 fprintf(f,
"dF/dS: %.4e calc, %.4e true\n",
64 (gray.
F(T, Sigma+1e-3, &pacs100, sr)-
65 gray.
F(T, Sigma-1e-3, &pacs100, sr))/2e-3,
66 gray.
dF_dS(T, Sigma, &pacs100, sr));
84 for (
unsigned i=0; i < table.
size(); i += stride) {
88 auto spline = gsl_spline_alloc(gsl_interp_akima, x.
size());
89 gsl_spline_init(spline, &x[0], &y[0], x.
size());
99 else { what =
"built", when =
std::string(__DATE__) +
" " + __TIME__; }
108 return (
int )hdu.keyWord(
"BAND").value(band);
114 int main(
int argc,
char *argv[])
119 {
'1',
"one-param",
"",
"",
"",
"",
120 "Fit one parameter dust emission model (default: two-param).\n" 121 "(Fixed-temperature cloud model.)"},
123 {
'2',
"two-param",
"",
"",
"",
"",
124 "Fit two parameter dust emission model (default).\n" 125 "(Single-temperature cloud model.)"},
127 {
'3',
"three-param",
"",
"",
"",
"",
128 "Fit three parameter dust emission model (default: two-param).\n" 129 "(Two-temperature cloud model with prescribed halo temperature.)"},
131 {
'4',
"four-param",
"",
"",
"",
"",
132 "Fit four parameter dust emission model (default: two-param).\n" 133 "(Two-temperature cloud model, all parameters free.)"},
135 {
'A',
"accuracy",
"RELERR",
"",
"",
"",
136 "Maximum relative error for least-squares fit (default: 1e-3)."},
138 {
'a',
"abs-diff",
"",
"",
"",
"",
139 "Output absolute differences in delta maps (default: sigma-relative)."},
141 {
'B',
"no-band-output",
"",
"",
"",
"",
142 "Do not append input band data to output FITS file."},
144 {
'C',
"cutout",
"COLSxROWS@COL0,ROW0",
"",
"",
"",
145 "Process only a COLSxROWS cutout at lower-left corner (COL0,ROW0)."},
147 {
'c',
"chi2-max",
"CHI2",
"",
"",
"",
148 "Maximum chi^2/DOF for meaningful 2-param result (default: 1.0)."},
150 {
'D',
"dust-model",
"(MODEL | MODELhalo,MODELcore)",
"",
"",
"",
151 "Dust opacity model(s) (default: DL3).\n" 152 "Use pow:nu0_GHz:kappa0:beta for power law kappa0*(nu/nu0)^beta."},
154 {
'e',
"error-map",
"FILE",
"",
"",
"",
155 "Input FITS error map (BAND and TELESCOP keys must match parent image)."},
157 {
'E',
"error-pct",
"PCT",
"",
"",
"",
158 "Percent flux error when error map unavailable (default: 3.0)."},
160 {
'F',
"force",
"",
"",
"",
"",
161 "Force overwrite of existing files."},
163 {
'G',
"grid-samp",
"",
"",
"",
"",
164 "Sample data on a fixed grid to estimate parameter variance.\n" 165 "(Total number of samples is 2^numBands.)"},
167 {
'g',
"gas-to-dust",
"(RATIO | RATIOhalo,RATIOcore)",
"",
"",
"",
168 "Gas-to-dust ratio(s) (default: 100.0)."},
170 {
'h',
"help",
"",
"",
"",
"",
171 "Display command line help summary and exit."},
173 {
'l',
"log-file",
"FILE",
"",
"",
"",
174 "Redirect log output to FILE (default is stderr)."},
176 {
'M',
"model-map",
"",
"",
"",
"",
177 "Replace input data with model observation grid."},
179 {
'm',
"max-iterations",
"NMAX",
"",
"",
"",
180 "Maximum least-squares iterations per pixel (default: 50)."},
182 {
'N',
"nh2-min",
"NH2MIN",
"",
"",
"",
183 "Minimum allowed (halo) N(H2) column density in cm^-2."},
185 {
'n',
"num-bands",
"NMIN",
"",
"",
"",
186 "Minimum number of bands required for least-squares fit (default: 3)."},
188 {
'o',
"output-file",
"FILE",
"",
"",
"",
189 "Output result to FITS file FILE (default: mtcore.fits)."},
191 {
'P',
"pacs-check",
"",
"",
"",
"",
192 "Generate comparative PACS color correction tables and exit."},
194 {
'p',
"point-source",
"",
"",
"",
"",
195 "Use point source detector response (default is extended sources)."},
197 {
'q',
"quiet",
"",
"",
"",
"",
198 "Quiet mode; decrement logging level (opposite of -v).\n" 199 "(Specify multiple times for added effect.)"},
201 {
'R',
"rand-samp",
"N",
"",
"",
"",
202 "Randomly sample data N times to estimate parameter variance.\n" 203 "(Without -G, -R or -S, the covariance matrix is used instead.)"},
205 {
'S',
"sys-samp",
"",
"",
"",
"",
206 "Sample systematic data errors to estimate parameter variance.\n" 207 "(May be combined with -G or -R.)"},
209 {
's',
"single-temp",
"FILE",
"",
"",
"",
210 "FITS output file from the single-temperature (2-param) fit."},
212 {
'T',
"temp0",
"T0",
"",
"",
"",
213 "Initial guess for (halo) temperature in Kelvin (default: 15.0)."},
215 {
't',
"threads",
"NTHREADS",
"",
"",
"",
216 "Use NTHREADS threads for processing (default: 1)."},
218 {
'v',
"verbose",
"",
"",
"",
"",
219 "Verbose mode; increment logging level (opposite of -q).\n" 220 "(Specify multiple times for added effect.)"},
222 {
'V',
"version",
"",
"",
"",
"",
223 "Display program version and exit."},
227 cli.
init(argc, argv, &opts);
233 CCfits::FITS::setVerboseMode(verb > 0);
void process(const mutils::CommandLine &cli)
Processes multi-wavelength maps into temperature/column density maps.
static FILE * stream
Message log file stream.
unsigned getOption(const Option &option, Arguments *values=nullptr, unsigned nMax=-1) const
Retrieves all copies of a command line option.
static constexpr int WARN
Warning condition.
Command line options and arguments.
std::string getString(char shortName, const std::string &defValue) const
Retrieves unique string option.
void setModel(const std::string &model, double rho=100.0)
Set dust properties model (table-based).
virtual double freqWidth() const noexcept
Effective flux-conversion bandwidth (Hz).
void printModels(std::vector< mu::CommandLine::Option > &opts, char name)
Add available dust model names to options summary.
virtual double ccf(const Graybody &gray, double T, double Sigma=1.0) const
Color correction factor.
double F(double T, double Sigma, const Detector *detect, double sr=1.0) const
Single-temperature graybody integrated flux (erg/cm^2/s).
constexpr double c_light
Speed of light (cm/s).
static int level
Message logging level for output to stream.
static int setStream(const std::string &fname, bool append=true)
Sets the logging stream.
void printVersion()
Prints version information to the log.
constexpr const char *const version
Version string.
virtual void init()
Initializes detector characteristics.
double dF_dT(double T, double Sigma, const Detector *detect, double sr=1.0) const
Single-temperature graybody integrated flux T-derivative (erg/cm^2/s/K).
constexpr const char *const reldate
Release date (if any).
int getBand(const CCfits::HDU &hdu)
Returns nominal band center (microns) from an HDU.
void init(int argc, char *argv[], const std::vector< Option > *opts)
Initializes new command line input.
gsl_spline * initSpline(const tableType &table, bool ln, unsigned stride)
Initializes cubic spline interpolator.
double Inu(double nu, double T, double Sigma) const
Single-temperature graybody specific intensity (erg/cm^2/s/Hz/sr).
double dF_dS(double T, double Sigma, const Detector *detect, double sr=1.0) const
Single-temperature graybody integrated flux Sigma-derivative (erg/s/g).
void usage(FILE *f, const std::vector< Option > &opts, const char *args="", bool quiet=false, bool basename=true) const
Summarizes command line usage (including options).
int main(int argc, char *argv[])
void printException(std::exception &ex)
Prints exception message.