Citlali
Loading...
Searching...
No Matches
pointing.h
Go to the documentation of this file.
1#pragma once
2
3#include <mutex>
4
6
10
11// selects the type of TCData
12using timestream::TCDataKind;
13
14class Pointing: public Engine {
15public:
16 // fit parameters
17 Eigen::MatrixXd params, perrors;
18
19 // meta information for ppt table
20 YAML::Node ppt_meta;
21
22 // ppt header information
23 std::vector<std::string> ppt_header = {
24 "array",
25 "amp",
26 "amp_err",
27 "x_t",
28 "x_t_err",
29 "y_t",
30 "y_t_err",
31 "a_fwhm",
32 "a_fwhm_err",
33 "b_fwhm",
34 "b_fwhm_err",
35 "angle",
36 "angle_err",
37 "sig2noise"
38 };
39
40 // ppt header units
41 std::map<std::string,std::string> ppt_header_units;
42
43 // initial setup for each obs
44 void setup();
45
46 // main grppi pipeline
47 template <class KidsProc, class RawObs>
48 void pipeline(KidsProc &, RawObs &);
49
50 // run the reduction for the obs
51 template <class KidsProc>
52 auto run(KidsProc &);
53
54 // fit the maps
55 void fit_maps();
56
57 // output files
58 template <mapmaking::MapType map_type>
59 void output();
60};
61
63 // run obsnum setup
65
66 // resize the current fit matrix
69
70 // units for positions
71 std::string pos_units = (telescope.pixel_axes == "radec") ? "deg" : "arcsec";
72
73 // units for ppt header
75 {"array","N/A"},
76 {"amp", omb.sig_unit},
77 {"amp_err", omb.sig_unit},
78 {"x_t", pos_units},
79 {"x_t_err", pos_units},
80 {"y_t", pos_units},
81 {"y_t_err", pos_units},
82 {"a_fwhm", "arcsec"},
83 {"a_fwhm_err", "arcsec"},
84 {"b_fwhm", "arcsec"},
85 {"b_fwhm_err", "arcsec"},
86 {"angle", "rad"},
87 {"angle_err", "rad"},
88 {"sig2noise", "N/A"}
89 };
90
91 /* populate ppt meta information */
92 ppt_meta.reset();
93
94 // add obsnum to meta data
95 ppt_meta["obsnum"] = obsnum;
96
97 // add source name
98 ppt_meta["source"] = telescope.source_name;
99
100 // add project id to meta data
101 ppt_meta["project_id"] = telescope.project_id;
102
103 // add date of file creation
104 ppt_meta["creation_date"] = engine_utils::current_date_time();
105
106 // add observation date
107 ppt_meta["date"] = date_obs.back();
108
109 // mean Modified Julian Date
111
112 // reference frame
113 ppt_meta["Radesys"] = telescope.pixel_axes;
114
115 // add array mapping
116 for (const auto &[arr_index,arr_name]: toltec_io.array_name_map) {
117 ppt_meta["array_order"].push_back(std::to_string(arr_index) + ": " + arr_name);
118 }
119
120 // populate ppt meta information
121 for (const auto &[param,unit]: ppt_header_units) {
122 ppt_meta[param].push_back("units: " + unit);
123 // description from apt
124 auto description = calib.apt_header_description[unit];
125 ppt_meta[param].push_back(description);
126 }
127
128 // add point model variables from telescope file
129 for (const auto &val: telescope.tel_header) {
130 std::size_t found = val.first.find("PointModel");
131 if (found!=std::string::npos) {
132 ppt_meta[val.first] = val.second(0);
133 }
134 }
135 // add m2 z position
136 ppt_meta["Header.M2.ZReq"] = telescope.tel_header["Header.M2.ZReq"](0);
137 // add first m1 zernike coefficient
138 ppt_meta["Header.M1.ZernikeC"] = telescope.tel_header["Header.M1.ZernikeC"](0);
139
140 for (int i=0; i< telescope.tel_header["Header.M1.ActPos"].size(); ++i) {
141 ppt_meta["Header.M1.ActPos"].push_back(telescope.tel_header["Header.M1.ActPos"](i));
142 ppt_meta["Header.M1.CmdPos"].push_back(telescope.tel_header["Header.M1.CmdPos"](i));
143 }
144}
145
146template <class KidsProc, class RawObs>
147void Pointing::pipeline(KidsProc &kidsproc, RawObs &rawobs) {
148 using tuple_t = std::tuple<TCData<TCDataKind::RTC, Eigen::MatrixXd>,
149 std::vector<kids::KidsData<kids::KidsDataKind::RawTimeStream>>>;
150 // initialize number of completed scans
151 n_scans_done = 0;
152
153 // declare random number generator
154 boost::random::mt19937 eng;
155
156 // boost random number generator (0,1)
157 boost::random::uniform_int_distribution<> rands{0,1};
158
159 // progress bar
160 tula::logging::progressbar pb(
161 [&](const auto &msg) { logger->info("{}", msg); }, 100, "citlali progress ");
162
163 // grppi generator function. gets time chunk data from files sequentially and passes them to grppi::farm
164 grppi::pipeline(tula::grppi_utils::dyn_ex(parallel_policy),
165 [&]() -> std::optional<tuple_t> {
166 // variable to hold current scan
167 static int scan = 0;
168 // loop through scans
169 while (scan < telescope.scan_indices.cols()) {
170 // update progress bar
171 pb.count(telescope.scan_indices.cols(), 1);
172
173 // create rtcdata
174 TCData<TCDataKind::RTC, Eigen::MatrixXd> rtcdata;
175 // get scan indices
176 rtcdata.scan_indices.data = telescope.scan_indices.col(scan);
177 // current scan
178 rtcdata.index.data = scan;
179
180 // populate noise matrix
181 if (run_noise) {
182 if (omb.randomize_dets) {
183 rtcdata.noise.data = Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic>::Zero(omb.n_noise, calib.n_dets)
184 .unaryExpr([&](int dummy){ return 2 * rands(eng) - 1; });
185 } else {
186 rtcdata.noise.data = Eigen::Matrix<int, Eigen::Dynamic, 1>::Zero(omb.n_noise)
187 .unaryExpr([&](int dummy){ return 2 * rands(eng) - 1; });
188 }
189 }
190
191 // vector to store kids data
192 std::vector<kids::KidsData<kids::KidsDataKind::RawTimeStream>> scan_rawobs;
193
194 // get kids data
195 if (!interp_over_gaps) {
196 scan_rawobs = kidsproc.load_rawobs(rawobs, scan, telescope.scan_indices, start_indices, end_indices);
197 }
198 else {
199 scan_rawobs = kidsproc.load_rawobs_gaps(rawobs, scan, telescope.scan_indices, start_indices,
200 t_common, nw_times, 1 / (2 * telescope.fsmp));
201 }
202 // current length of outer scans
203 Eigen::Index sl = rtcdata.scan_indices.data(3) - rtcdata.scan_indices.data(2) + 1;
204
205 // get raw tod from files
206 if (!interp_over_gaps) {
207 rtcdata.scans.data = kidsproc.populate_rtc(scan_rawobs, sl, calib.n_dets, tod_type);
208 }
209 else {
210 rtcdata.scans.data = kidsproc.populate_rtc_gaps(scan_rawobs, t_common, nw_times, masks, scan, 1 / (2 * telescope.fsmp),
212 }
213
214 // increment scan
215 scan++;
216 // return rtcdata, kidsproc, and raw data
217 return tuple_t(rtcdata,scan_rawobs);
218 }
219 // reset scan to zero for each obs
220 scan = 0;
221 return {};
222 },
223 run(kidsproc));
224
225 if (run_mapmaking) {
226 // normalize maps
227 logger->info("normalizing maps");
228 omb.normalize_maps();
229 // calculate map psds
230 logger->info("calculating map psd");
231 omb.calc_map_psd();
232 // calculate map histograms
233 logger->info("calculating map histogram");
234 omb.calc_map_hist();
235 // calculate mean error
236 omb.calc_median_err();
237 // calculate mean rms
238 omb.calc_median_rms();
239
240 // fit maps
241 fit_maps();
242 }
243}
244
245template <class KidsProc>
246auto Pointing::run(KidsProc &kidsproc) {
247 auto farm = grppi::farm(n_threads,[&](auto &input_tuple) {
248 // RTCData input
249 auto& rtcdata = std::get<0>(input_tuple);
250 // start index input
251 auto& scan_rawobs = std::get<1>(input_tuple);
252
253 // starting index for scan
254 Eigen::Index si = rtcdata.scan_indices.data(2);
255
256 // current length of outer scans
257 Eigen::Index sl = rtcdata.scan_indices.data(3) - rtcdata.scan_indices.data(2) + 1;
258
259 // copy scan's telescope vectors
260 for (auto const& x: telescope.tel_data) {
261 rtcdata.tel_data.data[x.first] = telescope.tel_data[x.first].segment(si,sl);
262 }
263
264 // copy pointing offsets
265 for (auto const& [axis,offset]: pointing_offsets_arcsec) {
266 rtcdata.pointing_offsets_arcsec.data[axis] = offset.segment(si,sl);
267 }
268
269 // get hwpr
271 if (calib.run_hwpr) {
272 rtcdata.hwpr_angle.data = calib.hwpr_angle.segment(si + hwpr_start_indices, sl);
273 }
274 }
275
276 // set up flags
277 rtcdata.flags.data.resize(rtcdata.scans.data.rows(), rtcdata.scans.data.cols());
278 rtcdata.flags.data.setConstant(0);
279
280 if (interp_over_gaps) {
281 int i = 0;
282 for (auto const& [key, val] : calib.nw_limits) {
283 auto& mask = masks[i];
284
285 Eigen::Index start = std::get<0>(calib.nw_limits[key]);
286 Eigen::Index end = std::get<1>(calib.nw_limits[key]) - 1;
287
288 for (int j = 0; j < rtcdata.flags.data.rows(); ++j) {
289 int start_index = j;
290 int size = 1;
292 start_index = std::max(j, static_cast<int>(j - rtcproc.filter.n_terms));
293 int end_index = std::min(j + rtcproc.filter.n_terms, rtcdata.flags.data.rows() - 1);
294 size = end_index - start_index + 1;
295 }
296 if (mask(j + si) == 0) {
297 rtcdata.flags.data.block(start_index, start, size, end - start + 1).setOnes();
298 }
299 }
300 logger->debug("{}/{} gaps flagged", rtcdata.flags.data.col(start).template cast<int>().sum(), rtcdata.flags.data.rows());
301 i++;
302 }
303 }
304
305 // create PTCData
307
308 logger->info("starting scan {}. {}/{} scans completed", rtcdata.index.data + 1, n_scans_done,
309 telescope.scan_indices.cols());
310
311 // run rtcproc
312 logger->info("raw time chunk processing for scan {}", rtcdata.index.data + 1);
313 auto map_indices = rtcproc.run(rtcdata, ptcdata, calib, telescope, omb.pixel_size_rad, map_grouping);
314
315 // remove flagged detectors
317
318 // remove outliers before cleaning
319 auto calib_scan = rtcproc.remove_bad_dets(ptcdata, calib, map_grouping);
320
321 // remove duplicate tones
322 if (!telescope.sim_obs) {
323 calib_scan = rtcproc.remove_nearby_tones(ptcdata, calib, map_grouping);
324 }
325
326 // write rtc timestreams
327 if (run_tod_output && !tod_filename.empty()) {
328 if (tod_output_type == "rtc" || tod_output_type == "both") {
329 logger->info("writing raw time chunk");
331 ptcdata.pointing_offsets_arcsec.data, calib);
332 }
333 }
334
335 // if running fruit loops and a map has been read in
336 if (ptcproc.run_fruit_loops && !ptcproc.tod_mb.signal.empty()) {
337 logger->info("subtracting map from tod");
338 // subtract map
340 map_indices, telescope.pixel_axes,
342 }
343
344 // run cleaning
345 logger->info("processed time chunk processing for scan {}", ptcdata.index.data + 1);
346 ptcproc.run(ptcdata, ptcdata, calib, telescope.pixel_axes, map_grouping);
347
348 // if running fruit loops and a map has been read in
349 if (ptcproc.run_fruit_loops && !ptcproc.tod_mb.signal.empty()) {
350 // calculate weights
351 logger->info("calculating weights");
353
354 // reset weights to median
355 auto calib_scans = ptcproc.reset_weights(ptcdata, calib, map_grouping);
356
357 // populate maps
358 if (run_mapmaking) {
359 bool run_omb = false;
360 logger->info("populating noise maps");
361 if (map_method=="naive") {
362 naive_mm.populate_maps_naive(ptcdata, omb, cmb, map_indices, telescope.pixel_axes,
363 calib.apt, telescope.d_fsmp, run_omb, run_noise);
364 }
365 else if (map_method=="jinc") {
366 jinc_mm.populate_maps_jinc(ptcdata, omb, cmb, map_indices, telescope.pixel_axes,
367 calib.apt, telescope.d_fsmp, run_omb, run_noise);
368 }
369 }
370 logger->info("adding map to tod");
371 // add map back
373 map_indices, telescope.pixel_axes,
375 }
376
377 // remove outliers after cleaning
378 calib_scan = ptcproc.remove_bad_dets(ptcdata, calib_scan, map_grouping);
379
380 // calculate weights
381 logger->info("calculating weights");
383
384 // reset weights to median
385 calib_scan = ptcproc.reset_weights(ptcdata, calib, map_grouping);
386
387 // write ptc timestreams
388 if (run_tod_output && !tod_filename.empty()) {
389 if (tod_output_type == "ptc" || tod_output_type == "both") {
390 logger->info("writing processed time chunk");
392 ptcdata.pointing_offsets_arcsec.data, calib);
393 }
394 }
395
396 // write out chunk summary
397 if (verbose_mode) {
398 write_chunk_summary(ptcdata);
399 }
400
401 // calc stats
402 logger->debug("calculating stats");
403 diagnostics.calc_stats(ptcdata);
404
405 // populate maps
406 if (run_mapmaking) {
407 bool run_omb = true;
408 bool run_noise_fruit;
409
410 // if running fruit loops, noise maps are made on source
411 // subtracted timestreams so don't make them here unless
412 // on first iteration
413 if (ptcproc.run_fruit_loops && !ptcproc.tod_mb.signal.empty()) {
414 run_noise_fruit = false;
415 }
416 else {
417 run_noise_fruit = run_noise;
418 }
419 logger->info("populating maps");
420 if (map_method=="naive") {
421 naive_mm.populate_maps_naive(ptcdata, omb, cmb, map_indices, telescope.pixel_axes,
422 calib.apt, telescope.d_fsmp, run_omb, run_noise_fruit);
423 }
424 else if (map_method=="jinc") {
425 jinc_mm.populate_maps_jinc(ptcdata, omb, cmb, map_indices, telescope.pixel_axes,
426 calib.apt, telescope.d_fsmp, run_omb, run_noise_fruit);
427 }
428 }
429 // increment number of completed scans
430 n_scans_done++;
431 logger->info("done with scan {}. {}/{} scans completed", ptcdata.index.data + 1, n_scans_done, telescope.scan_indices.cols());
432
433 });
434
435 return farm;
436}
437
439 // fit maps
440 logger->info("fitting maps");
441 // placeholder vectors for grppi map
442 std::vector<int> map_in_vec, map_out_vec;
443
444 map_in_vec.resize(n_maps);
445 std::iota(map_in_vec.begin(), map_in_vec.end(), 0);
446 map_out_vec.resize(n_maps);
447
448 double init_row = -99;
449 double init_col = -99;
450
451 // loop through maps
452 grppi::map(tula::grppi_utils::dyn_ex(parallel_policy), map_in_vec, map_out_vec, [&](auto i) {
453 auto array = maps_to_arrays(i);
454 // init fwhm in pixels
455 double init_fwhm = toltec_io.array_fwhm_arcsec[array]*ASEC_TO_RAD/omb.pixel_size_rad;
456 auto [map_params, map_perror, good_fit] =
457 map_fitter.fit_to_gaussian<engine_utils::mapFitter::pointing>(omb.signal[i], omb.weight[i], init_fwhm, init_row, init_col);
458 params.row(i) = map_params;
459 perrors.row(i) = map_perror;
460
461 if (good_fit) {
462 // rescale fit params from pixel to on-sky units
467
468 // rescale fit errors from pixel to on-sky units
473
474 // if in radec calculate absolute pointing
475 if (telescope.pixel_axes=="radec") {
476 Eigen::VectorXd lat(1), lon(1);
477 lat << params(i,2)*ASEC_TO_RAD;
478 lon << params(i,1)*ASEC_TO_RAD;
479
480 auto [adec, ara] = engine_utils::tangent_to_abs(lat, lon, omb.wcs.crval[0]*DEG_TO_RAD, omb.wcs.crval[1]*DEG_TO_RAD);
481
482 params(i,1) = ara(0)*RAD_TO_DEG;
483 params(i,2) = adec(0)*RAD_TO_DEG;
484
485 perrors(i,1) = perrors(i,1)*ASEC_TO_DEG;
486 perrors(i,2) = perrors(i,2)*ASEC_TO_DEG;
487 }
488 }
489 return 0;
490 });
491}
492
493template <mapmaking::MapType map_type>
495 // pointer to map buffer
496 mapmaking::MapBuffer* mb = nullptr;
497 // pointer to data file fits vector
498 std::vector<fitsIO<file_type_enum::write_fits, CCfits::ExtHDU*>>* f_io = nullptr;
499 // pointer to noise file fits vector
500 std::vector<fitsIO<file_type_enum::write_fits, CCfits::ExtHDU*>>* n_io = nullptr;
501
502 // directory name
503 std::string dir_name;
504
505 // matrix to hold pointing fit values and errors (n_params + 2 for array and S/N)
506 Eigen::MatrixXf ppt_table(n_maps, 2 * map_fitter.n_params + 2);
507
508 // determine pointers and directory name based on map_type
509 if constexpr (map_type == mapmaking::RawObs || map_type == mapmaking::FilteredObs) {
510 mb = &omb;
511 dir_name = obsnum_dir_name + (map_type == mapmaking::RawObs ? "raw/" : "filtered/");
512 f_io = (map_type == mapmaking::RawObs) ? &fits_io_vec : &filtered_fits_io_vec;
514
515 // filename for ppt table
518 (dir_name, redu_type, "", obsnum, telescope.sim_obs);
519
520 // add array and S/N to ppt
521 for (Eigen::Index i = 0; i < n_maps; ++i) {
522 ppt_table(i, 0) = maps_to_arrays(i);
523 double map_std_dev = engine_utils::calc_std_dev(mb->signal[i]);
524 ppt_table(i, 2 * map_fitter.n_params + 1) = params(i, 0) / map_std_dev;
525 }
526
527 Eigen::Index j = 0;
528 // populate ppt with fitted parameters and errors
529 for (Eigen::Index i = 1; i < 2 * map_fitter.n_params; i += 2) {
530 ppt_table.col(i) = params.col(j).cast<float>();
531 ppt_table.col(i + 1) = perrors.col(j).cast<float>();
532 j++;
533 }
534
535 // write ppt
536 to_ecsv_from_matrix(ppt_filename, ppt_table, ppt_header, ppt_meta);
537
538 if constexpr (map_type == mapmaking::RawObs) {
539 // write stats file
540 write_stats();
541 if (run_tod_output && !tod_filename.empty()) {
542 // add tod header information
544 }
545 }
546 } else if constexpr (map_type == mapmaking::RawCoadd || map_type == mapmaking::FilteredCoadd) {
547 mb = &cmb;
548 dir_name = coadd_dir_name + (map_type == mapmaking::RawCoadd ? "raw/" : "filtered/");
551 }
552
553 if (run_mapmaking) {
554 if (!f_io->empty()) {
555 {
556 // progress bar
557 tula::logging::progressbar pb(
558 [&](const auto &msg) { logger->info("{}", msg); }, 100, "output progress ");
559
560 for (Eigen::Index i=0; i<f_io->size(); i++) {
561 // add primary hdu
562 add_phdu(f_io, mb, i);
563
564 if (!mb->noise.empty()) {
565 add_phdu(n_io, mb, i);
566 }
567 }
568
569 Eigen::Index k = 0;
570
571 for (Eigen::Index i=0; i<n_maps; i++) {
572 // update progress bar
573 pb.count(n_maps, 1);
574 write_maps(f_io,n_io,mb,i);
575
576 Eigen::Index map_index = arrays_to_maps(i);
577
578 // check if we move from one file to the next
579 // if so go back to first hdu layer
580 if (i>0) {
581 if (map_index > arrays_to_maps(i-1)) {
582 k = 0;
583 }
584 }
585 // get current hdu extension name
586 std::string extname = f_io->at(map_index).hdus.at(k)->name();
587 // see if this is a signal extension
588 std::size_t found = extname.find("signal");
589
590 // find next signal extension
591 while (found==std::string::npos && k<f_io->at(map_index).hdus.size()) {
592 k = k + 1;
593 // get current hdu extension name
594 extname = f_io->at(map_index).hdus.at(k)->name();
595 // see if this is a signal extension
596 found = extname.find("signal");
597 }
598
599 // add ppt table
600 for (Eigen::Index j = 0; j < ppt_header.size(); ++j) {
601 const auto& key = ppt_header[j];
602 try {
603 f_io->at(map_index).hdus.at(k)->addKey("POINTING." + key, ppt_table(i, j), key + " (" + ppt_header_units[key] + ")");
604 } catch (...) {
605 f_io->at(map_index).hdus.at(k)->addKey("POINTING." + key, 0, key + " (" + ppt_header_units[key] + ")");
606 }
607 }
608 ++k; // Move to next extension
609 }
610 }
611
612 logger->info("maps have been written to:");
613 for (const auto& file: *f_io) {
614 logger->info("{}.fits", file.filepath);
615 }
616 }
617
618 // clear fits file vectors to ensure its closed.
619 f_io->clear();
620 n_io->clear();
621
622 // write psd and histogram files
623 logger->debug("writing psds");
624 write_psd<map_type>(mb, dir_name);
625 logger->debug("writing histograms");
626 write_hist<map_type>(mb, dir_name);
627
628 // write source table
629 if (run_source_finder) {
630 logger->debug("writing source table");
631 write_sources<map_type>(mb, dir_name);
632 }
633 }
634}
Definition engine.h:155
Eigen::Index hwpr_start_indices
Definition engine.h:208
void obsnum_setup()
Definition engine.h:353
std::string obsnum_dir_name
Definition engine.h:184
void write_stats()
Definition engine.h:2251
std::string parallel_policy
Definition engine.h:196
std::map< std::string, Eigen::VectorXd > pointing_offsets_arcsec
Definition engine.h:241
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > filtered_coadd_fits_io_vec
Definition engine.h:251
std::vector< Eigen::Index > start_indices
Definition engine.h:205
std::vector< Eigen::VectorXd > nw_times
Definition engine.h:166
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > noise_fits_io_vec
Definition engine.h:246
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > coadd_noise_fits_io_vec
Definition engine.h:250
std::string tod_output_type
Definition engine.h:223
std::string coadd_dir_name
Definition engine.h:184
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > filtered_noise_fits_io_vec
Definition engine.h:247
Eigen::VectorXI maps_to_arrays
Definition engine.h:232
bool verbose_mode
Definition engine.h:172
int n_maps
Definition engine.h:229
Eigen::VectorXI arrays_to_maps
Definition engine.h:232
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > filtered_fits_io_vec
Definition engine.h:247
int n_scans_done
Definition engine.h:199
void add_tod_header()
Definition engine.h:1054
std::vector< Eigen::Index > end_indices
Definition engine.h:205
Eigen::VectorXd t_common
Definition engine.h:164
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > filtered_coadd_noise_fits_io_vec
Definition engine.h:251
void add_phdu(fits_io_type &, map_buffer_t &, Eigen::Index)
Definition engine.h:1737
std::string redu_type
Definition engine.h:214
std::vector< Eigen::VectorXi > masks
Definition engine.h:165
std::string map_grouping
Definition engine.h:226
std::shared_ptr< spdlog::logger > logger
Definition engine.h:161
std::map< std::string, std::string > tod_filename
Definition engine.h:187
std::string tod_type
Definition engine.h:211
std::string obsnum
Definition engine.h:217
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > coadd_fits_io_vec
Definition engine.h:250
std::vector< std::string > date_obs
Definition engine.h:169
void write_chunk_summary(TCData< tc_t, Eigen::MatrixXd > &)
Definition engine.h:1529
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > fits_io_vec
Definition engine.h:246
int n_threads
Definition engine.h:193
std::string map_method
Definition engine.h:226
void write_maps(fits_io_type &, fits_io_type &, map_buffer_t &, Eigen::Index)
Definition engine.h:2030
Definition pointing.h:14
void pipeline(KidsProc &, RawObs &)
Definition pointing.h:147
Eigen::MatrixXd perrors
Definition pointing.h:17
Eigen::MatrixXd params
Definition pointing.h:17
YAML::Node ppt_meta
Definition pointing.h:20
void fit_maps()
Definition pointing.h:438
auto run(KidsProc &)
Definition pointing.h:246
void setup()
Definition pointing.h:62
std::vector< std::string > ppt_header
Definition pointing.h:23
std::map< std::string, std::string > ppt_header_units
Definition pointing.h:41
void output()
Definition pointing.h:494
bool run_hwpr
Definition calib.h:41
std::map< std::string, Eigen::VectorXd > apt
Definition calib.h:22
std::map< std::string, std::string > apt_header_description
Definition calib.h:151
Eigen::VectorXd hwpr_angle
Definition calib.h:24
std::map< Eigen::Index, std::tuple< Eigen::Index, Eigen::Index > > nw_limits
Definition calib.h:56
Eigen::Index n_dets
Definition calib.h:47
void calc_stats(timestream::TCData< tcdata_kind, Eigen::MatrixXd > &)
Definition diagnostics.h:61
bool sim_obs
Definition telescope.h:20
std::map< std::string, Eigen::VectorXd > tel_data
Definition telescope.h:54
double fsmp
Definition telescope.h:42
std::string source_name
Definition telescope.h:23
double d_fsmp
Definition telescope.h:42
Eigen::MatrixXI scan_indices
Definition telescope.h:51
std::string project_id
Definition telescope.h:23
std::string pixel_axes
Definition telescope.h:59
std::map< std::string, Eigen::VectorXd > tel_header
Definition telescope.h:56
auto fit_to_gaussian(Eigen::DenseBase< Derived > &, Eigen::DenseBase< Derived > &, double, double, double)
Definition fitting.h:172
int n_params
Definition fitting.h:23
@ pointing
Definition fitting.h:18
@ map
Definition toltec_io.h:22
std::map< Eigen::Index, std::string > array_name_map
Definition toltec_io.h:54
@ ppt
Definition toltec_io.h:16
@ filtered
Definition toltec_io.h:34
@ raw
Definition toltec_io.h:33
std::string create_filename(const std::string, const std::string, std::string, std::string, const bool)
Definition toltec_io.h:86
std::map< Eigen::Index, double > array_fwhm_arcsec
Definition toltec_io.h:75
void populate_maps_jinc(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, map_buffer_t &, map_buffer_t &, Eigen::DenseBase< Derived > &, std::string &, apt_t &, double, bool, bool)
Definition jinc_mm.h:211
Definition map.h:45
WCS wcs
Definition map.h:48
std::string sig_unit
Definition map.h:73
Eigen::Index n_rows
Definition map.h:65
Eigen::Index n_cols
Definition map.h:65
std::vector< Eigen::MatrixXd > signal
Definition map.h:78
std::vector< Eigen::MatrixXd > weight
Definition map.h:78
std::vector< Eigen::Tensor< double, 3 > > noise
Definition map.h:81
double pixel_size_rad
Definition map.h:69
void populate_maps_naive(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, map_buffer_t &, map_buffer_t &, Eigen::DenseBase< Derived > &, std::string &, apt_t &, double, bool, bool)
Definition naive_mm.h:95
Eigen::Index n_terms
Definition filter.h:19
Definition ptcproc.h:19
void append_to_netcdf(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, std::string, std::string, std::string &, pointing_offset_t &, calib_t &)
Definition ptcproc.h:498
void calc_weights(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, apt_type &, tel_type &)
Definition ptcproc.h:300
void run(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, TCData< TCDataKind::PTC, Eigen::MatrixXd > &, calib_type &, std::string, std::string)
Definition ptcproc.h:173
auto reset_weights(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, calib_t &, std::string)
Definition ptcproc.h:383
Definition rtcproc.h:18
void remove_flagged_dets(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, apt_t &)
Definition rtcproc.h:493
bool run_polarization
Definition rtcproc.h:23
timestream::Filter filter
Definition rtcproc.h:35
bool run_tod_filter
Definition rtcproc.h:26
auto remove_nearby_tones(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, calib_t &, std::string)
Definition rtcproc.h:516
void append_to_netcdf(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, std::string, std::string, std::string &, pointing_offset_t &, calib_t &)
Definition rtcproc.h:553
auto run(TCData< TCDataKind::RTC, Eigen::MatrixXd > &, TCData< TCDataKind::PTC, Eigen::MatrixXd > &, calib_t &, telescope_t &, double, std::string)
Definition rtcproc.h:261
void map_to_tod(mb_t &, TCData< tcdata_t, Eigen::MatrixXd > &, calib_t &, Eigen::DenseBase< Derived > &, std::string, std::string)
Definition timestream.h:624
auto remove_bad_dets(TCData< tcdata_t, Eigen::MatrixXd > &, calib_t &, std::string)
Definition timestream.h:703
@ NegativeMap
Definition timestream.h:272
@ Map
Definition timestream.h:271
bool run_fruit_loops
Definition timestream.h:279
mapmaking::MapBuffer tod_mb
Definition timestream.h:296
#define DEG_TO_RAD
Definition constants.h:27
#define STD_TO_FWHM
Definition constants.h:45
#define RAD_TO_ASEC
Definition constants.h:36
#define ASEC_TO_RAD
Definition constants.h:33
#define RAD_TO_DEG
Definition constants.h:30
#define ASEC_TO_DEG
Definition constants.h:24
void to_ecsv_from_matrix(std::string filepath, Eigen::DenseBase< Derived > &table, std::vector< std::string > header, YAML::Node meta)
Definition ecsv_io.h:50
static double unix_to_modified_julian_date(double unix_time)
Definition utils.h:170
auto tangent_to_abs(Eigen::DenseBase< Derived > &lat, Eigen::DenseBase< Derived > &lon, const double cra, const double cdec)
Definition pointing.h:88
static const std::string current_date_time()
Definition utils.h:91
auto calc_std_dev(Eigen::DenseBase< DerivedA > &data)
Definition utils.h:336
@ FilteredObs
Definition map.h:19
@ FilteredCoadd
Definition map.h:21
@ RawObs
Definition map.h:18
@ RawCoadd
Definition map.h:20
int run(const rc_t &rc)
Definition main.cpp:104
The raw obs struct This represents a single observation that contains a set of data items and calibra...
Definition io.h:50
std::vector< float > crval
Definition map.h:36
mapmaking::NaiveMapmaker naive_mm
Definition engine.h:109
engine::Telescope telescope
Definition engine.h:96
engine_utils::mapFitter map_fitter
Definition engine.h:99
engine::Diagnostics diagnostics
Definition engine.h:98
engine_utils::toltecIO toltec_io
Definition engine.h:97
timestream::PTCProc ptcproc
Definition engine.h:105
mapmaking::JincMapmaker jinc_mm
Definition engine.h:110
mapmaking::MapBuffer omb
Definition engine.h:108
mapmaking::MapBuffer cmb
Definition engine.h:108
timestream::RTCProc rtcproc
Definition engine.h:102
engine::Calib calib
Definition engine.h:95
bool run_noise
Definition engine.h:86
bool interp_over_gaps
Definition engine.h:73
bool run_source_finder
Definition engine.h:90
bool run_tod_output
Definition engine.h:81
bool run_mapmaking
Definition engine.h:84
TC data class.
Definition timestream.h:55