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 // get kids data
194 scan_rawobs = kidsproc.load_rawobs(rawobs, scan, telescope.scan_indices, start_indices, end_indices);
195
196 // increment scan
197 scan++;
198 // return rtcdata, kidsproc, and raw data
199 return tuple_t(rtcdata,scan_rawobs);
200 }
201 // reset scan to zero for each obs
202 scan = 0;
203 return {};
204 },
205 run(kidsproc));
206
207 if (run_mapmaking) {
208 // normalize maps
209 logger->info("normalizing maps");
210 omb.normalize_maps();
211 // calculate map psds
212 logger->info("calculating map psd");
213 omb.calc_map_psd();
214 // calculate map histograms
215 logger->info("calculating map histogram");
216 omb.calc_map_hist();
217 // calculate mean error
218 omb.calc_median_err();
219 // calculate mean rms
220 omb.calc_median_rms();
221
222 // fit maps
223 fit_maps();
224 }
225}
226
227template <class KidsProc>
228auto Pointing::run(KidsProc &kidsproc) {
229 auto farm = grppi::farm(n_threads,[&](auto &input_tuple) {
230 // RTCData input
231 auto& rtcdata = std::get<0>(input_tuple);
232 // start index input
233 auto& scan_rawobs = std::get<1>(input_tuple);
234
235 // starting index for scan
236 Eigen::Index si = rtcdata.scan_indices.data(2);
237
238 // current length of outer scans
239 Eigen::Index sl = rtcdata.scan_indices.data(3) - rtcdata.scan_indices.data(2) + 1;
240
241 // copy scan's telescope vectors
242 for (auto const& x: telescope.tel_data) {
243 rtcdata.tel_data.data[x.first] = telescope.tel_data[x.first].segment(si,sl);
244 }
245
246 // copy pointing offsets
247 for (auto const& [axis,offset]: pointing_offsets_arcsec) {
248 rtcdata.pointing_offsets_arcsec.data[axis] = offset.segment(si,sl);
249 }
250
251 // get hwpr
253 if (calib.run_hwpr) {
254 rtcdata.hwpr_angle.data = calib.hwpr_angle.segment(si + hwpr_start_indices, sl);
255 }
256 }
257
258 // get raw tod from files
259 rtcdata.scans.data = kidsproc.populate_rtc(scan_rawobs, sl, calib.n_dets, tod_type);
260 std::vector<kids::KidsData<kids::KidsDataKind::RawTimeStream>>().swap(scan_rawobs);
261
262 // create PTCData
264
265 logger->info("starting scan {}. {}/{} scans completed", rtcdata.index.data + 1, n_scans_done,
266 telescope.scan_indices.cols());
267
268 // run rtcproc
269 logger->info("raw time chunk processing for scan {}", rtcdata.index.data + 1);
270 auto map_indices = rtcproc.run(rtcdata, ptcdata, calib, telescope, omb.pixel_size_rad, map_grouping);
271
272 // remove flagged detectors
274
275 // remove outliers before cleaning
276 auto calib_scan = rtcproc.remove_bad_dets(ptcdata, calib, map_grouping);
277
278 // remove duplicate tones
279 if (!telescope.sim_obs) {
280 calib_scan = rtcproc.remove_nearby_tones(ptcdata, calib, map_grouping);
281 }
282
283 // write rtc timestreams
284 if (run_tod_output && !tod_filename.empty()) {
285 if (tod_output_type == "rtc" || tod_output_type == "both") {
286 logger->info("writing raw time chunk");
288 ptcdata.pointing_offsets_arcsec.data, calib);
289 }
290 }
291
292 // if running fruit loops and a map has been read in
293 if (ptcproc.run_fruit_loops && !ptcproc.tod_mb.signal.empty()) {
294 logger->info("subtracting map from tod");
295 // subtract map
297 map_indices, telescope.pixel_axes,
299 }
300
301 // run cleaning
302 logger->info("processed time chunk processing for scan {}", ptcdata.index.data + 1);
303 ptcproc.run(ptcdata, ptcdata, calib, telescope.pixel_axes, map_grouping);
304
305 // if running fruit loops and a map has been read in
306 if (ptcproc.run_fruit_loops && !ptcproc.tod_mb.signal.empty()) {
307 // calculate weights
308 logger->info("calculating weights");
310
311 // reset weights to median
312 auto calib_scans = ptcproc.reset_weights(ptcdata, calib, map_grouping);
313
314 // populate maps
315 if (run_mapmaking) {
316 bool run_omb = false;
317 logger->info("populating noise maps");
318 if (map_method=="naive") {
319 naive_mm.populate_maps_naive(ptcdata, omb, cmb, map_indices, telescope.pixel_axes,
320 calib.apt, telescope.d_fsmp, run_omb, run_noise);
321 }
322 else if (map_method=="jinc") {
323 jinc_mm.populate_maps_jinc(ptcdata, omb, cmb, map_indices, telescope.pixel_axes,
324 calib.apt, telescope.d_fsmp, run_omb, run_noise);
325 }
326 }
327 logger->info("adding map to tod");
328 // add map back
330 map_indices, telescope.pixel_axes,
332 }
333
334 // remove outliers after cleaning
335 calib_scan = ptcproc.remove_bad_dets(ptcdata, calib_scan, map_grouping);
336
337 // calculate weights
338 logger->info("calculating weights");
340
341 // reset weights to median
342 calib_scan = ptcproc.reset_weights(ptcdata, calib, map_grouping);
343
344 // write ptc timestreams
345 if (run_tod_output && !tod_filename.empty()) {
346 if (tod_output_type == "ptc" || tod_output_type == "both") {
347 logger->info("writing processed time chunk");
349 ptcdata.pointing_offsets_arcsec.data, calib);
350 }
351 }
352
353 // write out chunk summary
354 if (verbose_mode) {
355 write_chunk_summary(ptcdata);
356 }
357
358 // calc stats
359 logger->debug("calculating stats");
360 diagnostics.calc_stats(ptcdata);
361
362 // populate maps
363 if (run_mapmaking) {
364 bool run_omb = true;
365 bool run_noise_fruit;
366
367 // if running fruit loops, noise maps are made on source
368 // subtracted timestreams so don't make them here unless
369 // on first iteration
370 if (ptcproc.run_fruit_loops && !ptcproc.tod_mb.signal.empty()) {
371 run_noise_fruit = false;
372 }
373 else {
374 run_noise_fruit = run_noise;
375 }
376 logger->info("populating maps");
377 if (map_method=="naive") {
378 naive_mm.populate_maps_naive(ptcdata, omb, cmb, map_indices, telescope.pixel_axes,
379 calib.apt, telescope.d_fsmp, run_omb, run_noise_fruit);
380 }
381 else if (map_method=="jinc") {
382 jinc_mm.populate_maps_jinc(ptcdata, omb, cmb, map_indices, telescope.pixel_axes,
383 calib.apt, telescope.d_fsmp, run_omb, run_noise_fruit);
384 }
385 }
386 // increment number of completed scans
387 n_scans_done++;
388 logger->info("done with scan {}. {}/{} scans completed", ptcdata.index.data + 1, n_scans_done, telescope.scan_indices.cols());
389
390 });
391
392 return farm;
393}
394
396 // fit maps
397 logger->info("fitting maps");
398 // placeholder vectors for grppi map
399 std::vector<int> map_in_vec, map_out_vec;
400
401 map_in_vec.resize(n_maps);
402 std::iota(map_in_vec.begin(), map_in_vec.end(), 0);
403 map_out_vec.resize(n_maps);
404
405 double init_row = -99;
406 double init_col = -99;
407
408 // loop through maps
409 grppi::map(tula::grppi_utils::dyn_ex(parallel_policy), map_in_vec, map_out_vec, [&](auto i) {
410 auto array = maps_to_arrays(i);
411 // init fwhm in pixels
412 double init_fwhm = toltec_io.array_fwhm_arcsec[array]*ASEC_TO_RAD/omb.pixel_size_rad;
413 auto [map_params, map_perror, good_fit] =
414 map_fitter.fit_to_gaussian<engine_utils::mapFitter::pointing>(omb.signal[i], omb.weight[i], init_fwhm, init_row, init_col);
415 params.row(i) = map_params;
416 perrors.row(i) = map_perror;
417
418 if (good_fit) {
419 // rescale fit params from pixel to on-sky units
424
425 // rescale fit errors from pixel to on-sky units
430
431 // if in radec calculate absolute pointing
432 if (telescope.pixel_axes=="radec") {
433 Eigen::VectorXd lat(1), lon(1);
434 lat << params(i,2)*ASEC_TO_RAD;
435 lon << params(i,1)*ASEC_TO_RAD;
436
437 auto [adec, ara] = engine_utils::tangent_to_abs(lat, lon, omb.wcs.crval[0]*DEG_TO_RAD, omb.wcs.crval[1]*DEG_TO_RAD);
438
439 params(i,1) = ara(0)*RAD_TO_DEG;
440 params(i,2) = adec(0)*RAD_TO_DEG;
441
442 perrors(i,1) = perrors(i,1)*ASEC_TO_DEG;
443 perrors(i,2) = perrors(i,2)*ASEC_TO_DEG;
444 }
445 }
446 return 0;
447 });
448}
449
450template <mapmaking::MapType map_type>
452 // pointer to map buffer
453 mapmaking::MapBuffer* mb = nullptr;
454 // pointer to data file fits vector
455 std::vector<fitsIO<file_type_enum::write_fits, CCfits::ExtHDU*>>* f_io = nullptr;
456 // pointer to noise file fits vector
457 std::vector<fitsIO<file_type_enum::write_fits, CCfits::ExtHDU*>>* n_io = nullptr;
458
459 // directory name
460 std::string dir_name;
461
462 // matrix to hold pointing fit values and errors (n_params + 2 for array and S/N)
463 Eigen::MatrixXf ppt_table(n_maps, 2 * map_fitter.n_params + 2);
464
465 // determine pointers and directory name based on map_type
466 if constexpr (map_type == mapmaking::RawObs || map_type == mapmaking::FilteredObs) {
467 mb = &omb;
468 dir_name = obsnum_dir_name + (map_type == mapmaking::RawObs ? "raw/" : "filtered/");
469 f_io = (map_type == mapmaking::RawObs) ? &fits_io_vec : &filtered_fits_io_vec;
471
472 // filename for ppt table
475 (dir_name, redu_type, "", obsnum, telescope.sim_obs);
476
477 // add array and S/N to ppt
478 for (Eigen::Index i = 0; i < n_maps; ++i) {
479 ppt_table(i, 0) = maps_to_arrays(i);
480 double map_std_dev = engine_utils::calc_std_dev(mb->signal[i]);
481 ppt_table(i, 2 * map_fitter.n_params + 1) = params(i, 0) / map_std_dev;
482 }
483
484 Eigen::Index j = 0;
485 // populate ppt with fitted parameters and errors
486 for (Eigen::Index i = 1; i < 2 * map_fitter.n_params; i += 2) {
487 ppt_table.col(i) = params.col(j).cast<float>();
488 ppt_table.col(i + 1) = perrors.col(j).cast<float>();
489 j++;
490 }
491
492 // write ppt
493 to_ecsv_from_matrix(ppt_filename, ppt_table, ppt_header, ppt_meta);
494
495 if constexpr (map_type == mapmaking::RawObs) {
496 // write stats file
497 write_stats();
498 if (run_tod_output && !tod_filename.empty()) {
499 // add tod header information
501 }
502 }
503 } else if constexpr (map_type == mapmaking::RawCoadd || map_type == mapmaking::FilteredCoadd) {
504 mb = &cmb;
505 dir_name = coadd_dir_name + (map_type == mapmaking::RawCoadd ? "raw/" : "filtered/");
508 }
509
510 if (run_mapmaking) {
511 if (!f_io->empty()) {
512 {
513 // progress bar
514 tula::logging::progressbar pb(
515 [&](const auto &msg) { logger->info("{}", msg); }, 100, "output progress ");
516
517 for (Eigen::Index i=0; i<f_io->size(); i++) {
518 // add primary hdu
519 add_phdu(f_io, mb, i);
520
521 if (!mb->noise.empty()) {
522 add_phdu(n_io, mb, i);
523 }
524 }
525
526 Eigen::Index k = 0;
527
528 for (Eigen::Index i=0; i<n_maps; i++) {
529 // update progress bar
530 pb.count(n_maps, 1);
531 write_maps(f_io,n_io,mb,i);
532
533 Eigen::Index map_index = arrays_to_maps(i);
534
535 // check if we move from one file to the next
536 // if so go back to first hdu layer
537 if (i>0) {
538 if (map_index > arrays_to_maps(i-1)) {
539 k = 0;
540 }
541 }
542 // get current hdu extension name
543 std::string extname = f_io->at(map_index).hdus.at(k)->name();
544 // see if this is a signal extension
545 std::size_t found = extname.find("signal");
546
547 // find next signal extension
548 while (found==std::string::npos && k<f_io->at(map_index).hdus.size()) {
549 k = k + 1;
550 // get current hdu extension name
551 extname = f_io->at(map_index).hdus.at(k)->name();
552 // see if this is a signal extension
553 found = extname.find("signal");
554 }
555
556 // add ppt table
557 for (Eigen::Index j = 0; j < ppt_header.size(); ++j) {
558 const auto& key = ppt_header[j];
559 try {
560 f_io->at(map_index).hdus.at(k)->addKey("POINTING." + key, ppt_table(i, j), key + " (" + ppt_header_units[key] + ")");
561 } catch (...) {
562 f_io->at(map_index).hdus.at(k)->addKey("POINTING." + key, 0, key + " (" + ppt_header_units[key] + ")");
563 }
564 }
565 ++k; // Move to next extension
566 }
567 }
568
569 logger->info("maps have been written to:");
570 for (const auto& file: *f_io) {
571 logger->info("{}.fits", file.filepath);
572 }
573 }
574
575 // clear fits file vectors to ensure its closed.
576 f_io->clear();
577 n_io->clear();
578
579 // write psd and histogram files
580 logger->debug("writing psds");
581 write_psd<map_type>(mb, dir_name);
582 logger->debug("writing histograms");
583 write_hist<map_type>(mb, dir_name);
584
585 // write source table
586 if (run_source_finder) {
587 logger->debug("writing source table");
588 write_sources<map_type>(mb, dir_name);
589 }
590 }
591}
Definition engine.h:153
Eigen::Index hwpr_start_indices
Definition engine.h:201
void obsnum_setup()
Definition engine.h:346
std::string obsnum_dir_name
Definition engine.h:177
void write_stats()
Definition engine.h:2239
std::string parallel_policy
Definition engine.h:189
std::map< std::string, Eigen::VectorXd > pointing_offsets_arcsec
Definition engine.h:234
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > filtered_coadd_fits_io_vec
Definition engine.h:244
std::vector< Eigen::Index > start_indices
Definition engine.h:198
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > noise_fits_io_vec
Definition engine.h:239
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > coadd_noise_fits_io_vec
Definition engine.h:243
std::string tod_output_type
Definition engine.h:216
std::string coadd_dir_name
Definition engine.h:177
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > filtered_noise_fits_io_vec
Definition engine.h:240
Eigen::VectorXI maps_to_arrays
Definition engine.h:225
bool verbose_mode
Definition engine.h:165
int n_maps
Definition engine.h:222
Eigen::VectorXI arrays_to_maps
Definition engine.h:225
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > filtered_fits_io_vec
Definition engine.h:240
int n_scans_done
Definition engine.h:192
void add_tod_header()
Definition engine.h:1044
std::vector< Eigen::Index > end_indices
Definition engine.h:198
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > filtered_coadd_noise_fits_io_vec
Definition engine.h:244
void add_phdu(fits_io_type &, map_buffer_t &, Eigen::Index)
Definition engine.h:1727
std::string redu_type
Definition engine.h:207
std::string map_grouping
Definition engine.h:219
std::shared_ptr< spdlog::logger > logger
Definition engine.h:159
std::map< std::string, std::string > tod_filename
Definition engine.h:180
std::string tod_type
Definition engine.h:204
std::string obsnum
Definition engine.h:210
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > coadd_fits_io_vec
Definition engine.h:243
std::vector< std::string > date_obs
Definition engine.h:162
void write_chunk_summary(TCData< tc_t, Eigen::MatrixXd > &)
Definition engine.h:1519
std::vector< fitsIO< file_type_enum::write_fits, CCfits::ExtHDU * > > fits_io_vec
Definition engine.h:239
int n_threads
Definition engine.h:186
std::string map_method
Definition engine.h:219
void write_maps(fits_io_type &, fits_io_type &, map_buffer_t &, Eigen::Index)
Definition engine.h:2018
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:395
auto run(KidsProc &)
Definition pointing.h:228
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:451
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
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
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
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:499
void calc_weights(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, apt_type &, tel_type &)
Definition ptcproc.h:301
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:384
Definition rtcproc.h:18
void remove_flagged_dets(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, apt_t &)
Definition rtcproc.h:497
bool run_polarization
Definition rtcproc.h:23
auto remove_nearby_tones(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, calib_t &, std::string)
Definition rtcproc.h:520
void append_to_netcdf(TCData< TCDataKind::PTC, Eigen::MatrixXd > &, std::string, std::string, std::string &, pointing_offset_t &, calib_t &)
Definition rtcproc.h:557
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:107
engine::Telescope telescope
Definition engine.h:94
engine_utils::mapFitter map_fitter
Definition engine.h:97
engine::Diagnostics diagnostics
Definition engine.h:96
engine_utils::toltecIO toltec_io
Definition engine.h:95
timestream::PTCProc ptcproc
Definition engine.h:103
mapmaking::JincMapmaker jinc_mm
Definition engine.h:108
mapmaking::MapBuffer omb
Definition engine.h:106
mapmaking::MapBuffer cmb
Definition engine.h:106
timestream::RTCProc rtcproc
Definition engine.h:100
engine::Calib calib
Definition engine.h:93
bool run_noise
Definition engine.h:84
bool run_source_finder
Definition engine.h:88
bool run_tod_output
Definition engine.h:79
bool run_mapmaking
Definition engine.h:82
TC data class.
Definition timestream.h:55