mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
ADIobservation.hpp
Go to the documentation of this file.
1 /** \file ADIobservation.hpp
2  * \author Jared R. Males
3  * \brief Defines the ADI high contrast imaging data type.
4  * \ingroup hc_imaging_files
5  * \ingroup image_processing_files
6  *
7  */
8 
9 #ifndef __ADIobservation_hpp__
10 #define __ADIobservation_hpp__
11 #include "../ioutils/fileUtils.hpp"
12 
13 #include "HCIobservation.hpp"
14 #include "../ioutils/fits/fitsHeader.hpp"
15 
16 #include "imagePads.hpp"
17 
18 
19 
20 namespace mx
21 {
22 namespace improc
23 {
24 namespace HCI
25 {
26  /// Fake injection PSF file specification methods
27  /** \ingroup hc_imaging_enums
28  */
29  enum fakeMethods{ single, ///< A single PSF is used
30  list ///< A list of PSF files, one per input image, is used.
31  };
32 
33  /// Get the string name of a fake injection method
34  /**
35  * \returns the string name corresponding to the fake injection method
36  */
37  std::string fakeMethodsStr( int method /**< [in] the fake injection method */);
38 
39  /// Get the fake injection method from its string name
40  /**
41  * \returns the corresponding member of the fakeMethods enum
42  */
43  int fakeMethodFmStr( const std::string & method /**< [in] the fake injection method name*/);
44 
45 }
46 
47 ///Process an angular differential imaging (ADI) observation
48 /** Angular differential imaging (ADI) uses sky rotation to differentiate real objects from
49  * speckles.
50  *
51  * \tparam realT is the floating point type in which to do calculations
52  *
53  * \tparam _derotFunctObj
54  * \parblock
55  * is the derotation object with the following minimum interface:
56  * \code
57  * template<typename _realT>
58  * struct derotF
59  * {
60  * typedef _realT realT;
61  *
62  * //Vector of keywords to extract from the fits headers
63  * std::vector<std::string> keywords;
64  *
65  * //Vector(s) to hold the keyword values
66  * std::vector<realT> keyValue1;
67  *
68  * ///To allow ADIobservation to check for errors.
69  * bool isSetup()
70  * {
71  * if( <any condition indicating not set up>) return false;
72  * return true;
73  * }
74  *
75  * //Method called by HCIobservation to get keyword-values
76  * void extractKeywords(vector<fitsHeader> & heads)
77  * {
78  * keyValue1 = headersToValues<float>(heads, "KEYWORD1");
79  * }
80  *
81  * //Calculate the derotation angle for a given image number
82  * realT derotAngle(size_t imno) const
83  * {
84  * return some_function_of(keyValue1[imno]); //This function uses keyValue1[imno] to produce the derotation angle in radians.
85  * }
86  * };
87  * \endcode
88  * \endparblock
89  *
90  * \ingroup hc_imaging
91  */
92 template<typename _realT, class _derotFunctObj>
93 struct ADIobservation : public HCIobservation<_realT>
94 {
95  typedef _realT realT;
96  typedef _derotFunctObj derotFunctObj;
97  typedef Eigen::Array<realT, Eigen::Dynamic, Eigen::Dynamic> eigenImageT;
98 
99  derotFunctObj m_derotF;
100 
101  derotFunctObj m_RDIderotF;
102 
103  bool m_doDerotate {true};
104 
105  bool m_postMedSub {false};
106 
107  ADIobservation();
108 
109  ADIobservation( const std::string &dir, ///< [in] the directory to search.
110  const std::string &prefix, ///< [in] the initial part of the file name. Can be empty "".
111  const std::string &ext ///< [in] the extension to append to the file name, must include the '.'.
112  );
113 
114  explicit ADIobservation( const std::string & fileListFile /**< [in] a file name path to read.*/);
115 
116  ADIobservation( const std::string &dir, ///< [in] the directory to search.
117  const std::string &prefix, ///< [in] the initial part of the file name. Can be empty "".
118  const std::string &ext, ///< [in] the extension to append to the file name, must include the '.'.
119  const std::string &RDIdir, ///< [in] the directory to search for the reference files.
120  const std::string &RDIprefix, ///< [in] the initial part of the file name for the reference files. Can be empty "".
121  const std::string &RDIext="" ///< [in] [optional] the extension to append to the RDI file name, must include the '.'. If empty "" then same extension as target files is used.
122  );
123 
124  ADIobservation( const std::string & fileListFile, ///< [in] a file name path to read for the target file names.
125  const std::string & RDIfileListFile ///< [in] a file name path to read for the reference file names.
126  );
127 
128 
129  ///Read in the target files
130  /** First sets up the keywords, then calls HCIobservation readFiles
131  */
132  int readFiles();
133 
134  ///Post target read actions, including fake injection
135  virtual int postReadFiles();
136 
137  ///Post target coadd actions.
138  /** Here updates derotation for new average values.
139  */
140  virtual int postCoadd();
141 
142  ///Read in the RDI files
143  /** First sets up the keywords, then calls HCIobservation readRDIFiles
144  */
145  int readRDIFiles();
146 
147  ///Post reference read actions, including fake injection
148  virtual int postRDIReadFiles();
149 
150  ///Post reference coadd actions.
151  /** Here updates derotation for new average values.
152  */
153  virtual int postRDICoadd();
154 
155  /// Read in already PSF-subtracted files
156  /** Used to take up final processing after applying some non-klipReduce processing steps to
157  * PSF-subtracted images.
158  */
159  int readPSFSub( const std::string & dir,
160  const std::string & prefix,
161  const std::string & ext,
162  size_t nReductions
163  );
164 
165  /** \name Fake Planets
166  * @{
167  */
168  int m_fakeMethod {HCI::single}; ///< Method for reading fake files, either HCI::single or HCI::list.
169 
170  std::string m_fakeFileName; ///<FITS file containing the fake planet PSF to inject or a list of fake images
171 
172  std::string m_fakeScaleFileName; ///< One-column text file containing a scale factor for each point in time.
173 
174  std::vector<realT> m_fakeSep; ///< Separation(s) of the fake planet(s)
175  std::vector<realT> m_fakePA; ///< Position angles(s) of the fake planet(s)
176  std::vector<realT> m_fakeContrast; ///< Contrast(s) of the fake planet(s)
177 
178  realT m_RDIFluxScale {1}; ///< Flux scaling to apply to fake planets injected in RDI. Would depend on the assumed spectrum in SDI.
179  realT m_RDISepScale {1}; ///< Scaling to apply to fake planet separation in RDI. Would be ratio of wavelengths for SDI.
180 
181 
182  ///Inect the fake plants
183  int injectFake( eigenCube<realT> & ims, ///< [in.out] the image cube in which to inject the fakes.
184  std::vector<std::string> & fileList, ///< [in] a list of file paths used for per-image fake PSFs. If empty, then m_fakeFileName is used.
185  derotFunctObj & derotF,
186  realT RDIfluxScale, ///< [in] the flux scaling for RDI. In SDI, this is from the planet spectrum.
187  realT RDISepScale ///< [in] the separation scale for RDI. In SDI, this is the ratio of wavlengths after lambda/D scaling.
188  );
189 
190  int injectFake( eigenImageT & fakePSF,
191  eigenCube<realT> & ims,
192  int image_i,
193  realT derotAngle,
194  realT PA,
195  realT sep,
196  realT contrast,
197  realT scale,
198  realT RDIfluxScale,
199  realT RDISepScale
200  );
201 
202  /// @}
203 
204  void stdFitsHeader(fits::fitsHeader * head);
205 
206  virtual void makeMaskCube();
207 
208  ///De-rotate the PSF subtracted images
209  void derotate();
210 
211  double t_fake_begin {0};
212  double t_fake_end {0};
213 
214  double t_derotate_begin {0};
215  double t_derotate_end {0};
216 
217 };
218 
219 template<typename _realT, class _derotFunctObj>
220 ADIobservation<_realT, _derotFunctObj>::ADIobservation()
221 {
222 }
223 
224 template<typename _realT, class _derotFunctObj>
226  const std::string & prefix,
227  const std::string & ext
228  ) : HCIobservation<realT>(dir,prefix,ext)
229 {
230 }
231 
232 template<typename _realT, class _derotFunctObj>
233 ADIobservation<_realT, _derotFunctObj>::ADIobservation( const std::string & fileListFile) : HCIobservation<realT>(fileListFile)
234 {
235 }
236 
237 template<typename _realT, class _derotFunctObj>
239  const std::string & prefix,
240  const std::string & ext,
241  const std::string & RDIdir,
242  const std::string & RDIprefix,
243  const std::string & RDIext
244  ) : HCIobservation<realT>(dir,prefix,ext, RDIdir, RDIprefix, RDIext)
245 {
246 }
247 
248 template<typename _realT, class _derotFunctObj>
250  const std::string & RDIfileListFile
251  ) : HCIobservation<realT>(fileListFile, RDIfileListFile)
252 {
253 }
254 
255 template<typename _realT, class _derotFunctObj>
257 {
258  this->m_keywords.clear();
259 
260  if(!m_derotF.isSetup())
261  {
262  mxError("ADIobservation::readFiles", MXE_PARAMNOTSET, "Derotator is not configured.");
263  return -1;
264  }
265 
266  /*----- Append the ADI keywords to propagate them if needed -----*/
267 
268  for(size_t i=0;i<m_derotF.m_keywords.size();++i)
269  {
270  this->m_keywords.push_back(m_derotF.m_keywords[i]);
271  }
272 
273  if( HCIobservation<realT>::readFiles() < 0) return -1;
274 
275  return 0;
276 }
277 
278 template<typename _realT, class _derotFunctObj>
280 {
281  m_derotF.extractKeywords(this->m_heads);
282 
283  if(m_fakeFileName != "" && !this->m_skipPreProcess)
284  {
285  std::cerr << "Injecting fakes in target images...\n";
286  if( injectFake(this->m_tgtIms, this->m_fileList, m_derotF, 1, 1) < 0) return -1;
287  }
288 
289  return 0;
290 }
291 
292 template<typename _realT, class _derotFunctObj>
294 {
295  m_derotF.extractKeywords(this->m_heads);
296  return 0;
297 }
298 
299 template<typename _realT, class _derotFunctObj>
301 {
302  this->m_RDIkeywords.clear();
303 
304  if(!m_RDIderotF.isSetup())
305  {
306  mxError("ADIobservation::readRDIFiles", MXE_PARAMNOTSET, "Derotator is not configured.");
307  return -1;
308  }
309 
310  /*----- Append the ADI keywords to propagate them if needed -----*/
311 
312  for(size_t i=0;i<m_RDIderotF.m_keywords.size();++i)
313  {
314  this->m_RDIkeywords.push_back(m_RDIderotF.m_keywords[i]);
315  }
316 
317  if( HCIobservation<realT>::readRDIFiles() < 0) return -1;
318 
319  return 0;
320 }
321 
322 template<typename _realT, class _derotFunctObj>
324 {
325  m_RDIderotF.extractKeywords(this->m_RDIheads);
326 
327  /*if(m_fakeFileName != "" && !this->m_skipPreProcess)
328  {
329  if( injectFake(this->m_refIms, this->m_RDIfileList, m_RDIderotF, m_RDIFluxScale, m_RDISepScale) < 0) return -1;
330  }*/
331 
332  return 0;
333 }
334 
335 template<typename _realT, class _derotFunctObj>
337 {
338  m_RDIderotF.extractKeywords(this->m_RDIheads);
339  return 0;
340 }
341 
342 
343 
344 
345 template<typename _realT, class _derotFunctObj>
347  const std::string & prefix,
348  const std::string & ext,
349  size_t nReductions
350  )
351 {
352  //Load first file to condigure based on its header.
353  std::vector<std::string> flist = ioutils::getFileNames(dir, prefix, "000", ext);
354 
355  fits::fitsHeader fh;
358 
359  ff.read(im, fh, flist[0]);
360 
361  if(!m_derotF.isSetup())
362  {
363  mxError("ADIobservation::readFiles", MXE_PARAMNOTSET, "Derotator is not configured.");
364  return -1;
365  }
366 
367  if(fh.count("POSTMEDS") != 0)
368  {
369  m_postMedSub = fh["POSTMEDS"].Int();
370  std::cerr << "postMedSub: " << m_postMedSub << "\n";
371  }
372 
373  if(fh.count("FAKEFILE") != 0)
374  {
375  m_fakeFileName = fh["FAKEFILE"].String();
376  std::cerr << "fakeFileName: " << m_fakeFileName << "\n";
377  }
378 
379  if(fh.count("FAKESCFL") != 0)
380  {
381  m_fakeScaleFileName = fh["FAKESCFL"].String();
382  std::cerr << "fakeScaleFileName: " << m_fakeScaleFileName << "\n";
383  }
384 
385  if(fh.count("FAKESEP") != 0)
386  {
387  ioutils::parseStringVector(m_fakeSep, fh["FAKESEP"].String(), ",");
388 
389  if(m_fakeSep.size() == 0)
390  {
391  mxError("KLIPReduction", MXE_PARSEERR, "FAKESEP vector did not parse correctly.");
392  return -1;
393  }
394  std::cerr << "fakeSep: " << fh["FAKESEP"].String() << "\n";
395  }
396 
397  if(fh.count("FAKEPA") != 0)
398  {
399  ioutils::parseStringVector(m_fakePA, fh["FAKEPA"].String(), ",");
400 
401  if(m_fakePA.size() == 0)
402  {
403  mxError("KLIPReduction", MXE_PARSEERR, "FAKEPA vector did not parse correctly.");
404  return -1;
405  }
406  std::cerr << "fakePA: " << fh["FAKEPA"].String() << "\n";
407  }
408 
409  if(fh.count("FAKECONT") != 0)
410  {
411  ioutils::parseStringVector(m_fakeContrast, fh["FAKECONT"].String(), ",");
412 
413  if(m_fakeContrast.size() == 0)
414  {
415  mxError("KLIPReduction", MXE_PARSEERR, "FAKECONT vector did not parse correctly.");
416  return -1;
417  }
418  std::cerr << "fakeContrast: " << fh["FAKECONT"].String() << "\n";
419  }
420 
421 
422  /*----- Append the ADI keywords to propagate them if needed -----*/
423 
424  for(size_t i=0;i<m_derotF.m_keywords.size();++i)
425  {
426  this->m_keywords.push_back(m_derotF.m_keywords[i]);
427  }
428 
429 
430  if( HCIobservation<realT>::readPSFSub(dir,prefix,ext, nReductions) < 0) return -1;
431 
432  m_derotF.extractKeywords(this->m_heads);
433 
434  return 0;
435 }
436 
437 template<typename _realT, class _derotFunctObj>
439  std::vector<std::string> & fileList,
440  derotFunctObj & derotF,
441  realT RDIFluxScale,
442  realT RDISepScale
443  )
444 {
445  t_fake_begin = sys::get_curr_time();
446 
447  //typedef Eigen::Array<realT, Eigen::Dynamic, Eigen::Dynamic> imT;
448  eigenImageT fakePSF;
449  std::vector<std::string> fakeFiles; //used if m_fakeMethod == HCI::list
450 
452  std::ifstream scaleFin; //for reading the scale file.
453 
454 
455  //Fake Scale -- default to 1, read from file otherwise
456  std::vector<realT> fakeScale(ims.planes(), 1.0);
457  if(m_fakeScaleFileName != "")
458  {
459  std::vector<std::string> sfileNames;
460  std::vector<realT> imS;
461 
462  //Read the scale file and load it into a map
463  if( ioutils::readColumns(m_fakeScaleFileName, sfileNames, imS) < 0) return -1;
464 
465  if(sfileNames.size() != imS.size())
466  {
467  std::cerr << "fake scale file must be two columns of: fileName scale\n";
468  exit(-1);
469  }
470  std::map<std::string, realT> scales;
471  for(size_t i=0;i<sfileNames.size();++i) scales[ioutils::pathFilename(sfileNames[i].c_str())] = imS[i];
472 
473  for(size_t i=0; i<fileList.size(); ++i)
474  {
475  if(scales.count(ioutils::pathFilename(fileList[i].c_str())) > 0)
476  {
477  fakeScale[i] = scales[ioutils::pathFilename(fileList[i].c_str())];
478  }
479  else
480  {
481  std::cerr << "File name not found in fakeScaleFile:\n";
482  std::cerr << ioutils::pathFilename(fileList[i].c_str()) << "\n";
483  exit(-1);
484  }
485  }
486  } //if(fakeScaleFileName != "")
487 
488  if(m_fakeMethod == HCI::single)
489  {
490  if( ff.read( fakePSF, m_fakeFileName ) < 0) return -1;
491  }
492 
493  if(m_fakeMethod == HCI::list)
494  {
495  if( ioutils::readColumns(m_fakeFileName, fakeFiles) < 0) return -1;
496  }
497 
498  for(int i=0; i<ims.planes(); ++i)
499  {
500  if(m_fakeMethod == HCI::list)
501  {
502  ff.read(fakePSF, fakeFiles[i]);
503  }
504 
505  for(size_t j=0;j<m_fakeSep.size(); ++j)
506  {
507  if( injectFake(fakePSF, ims, i, derotF.derotAngle(i), m_fakePA[j], m_fakeSep[j], m_fakeContrast[j], fakeScale[j], RDIFluxScale, RDISepScale) < 0) return -1;
508  }
509  }
510 
511 
512  t_fake_end = sys::get_curr_time();
513 
514  return 0;
515 }
516 
517 
518 template<typename _realT, class _derotFunctObj>
519 int ADIobservation<_realT, _derotFunctObj>::injectFake( eigenImageT & fakePSF,
520  eigenCube<realT> & ims,
521  int image_i,
522  realT derotAngle,
523  realT PA,
524  realT sep,
525  realT contrast,
526  realT scale,
527  realT RDIFluxScale,
528  realT RDISepScale
529  )
530 {
531  //Check for correct sizing
532  if( (fakePSF.rows() < ims.rows() && fakePSF.cols() >= ims.cols()) ||
533  (fakePSF.rows() >= ims.rows() && fakePSF.cols() < ims.cols()))
534  {
535  mxThrowException(err::sizeerr, "ADIobservation::injectFake", "fake PSF has different dimensions and can't be sized properly");
536  }
537 
538  //Check if fake needs to be padded out
539  if(fakePSF.rows() < ims.rows() && fakePSF.cols() < ims.cols())
540  {
541  eigenImageT pfake(ims.rows(), ims.cols());
542  padImage(pfake, fakePSF, 0.5*(ims.rows()-fakePSF.rows()), 0);
543  fakePSF = pfake;
544  }
545 
546  //Check if fake needs to be cut down
547  if(fakePSF.rows() > ims.rows() && fakePSF.cols() > ims.cols())
548  {
549  eigenImageT cfake(ims.rows(), ims.cols());
550  cutPaddedImage(cfake, fakePSF, 0.5*(fakePSF.rows() - ims.rows()));
551  fakePSF = cfake;
552  }
553 
554  if(fakePSF.rows() != ims.rows() || fakePSF.cols() != ims.cols())
555  {
556  mxThrowException(err::sizeerr, "ADIobservation::injectFake", "fake PSF has different dimensions and can't be sized properly (is it even in rows and cols?)");
557  }
558 
559  /*** Now shift to the separation and PA, scale, apply contrast, and inject ***/
560  //allocate shifted fake psf
561  eigenImageT shiftFake(fakePSF.rows(), fakePSF.cols());
562 
563 
564  realT ang, dx, dy;
565 
566  ang = math::dtor(-1*PA) + derotAngle;
567 
568  dx = sep * RDISepScale * sin(ang);
569  dy = sep * RDISepScale * cos(ang);
570 
571 
572  imageShift(shiftFake, fakePSF, dx, dy, cubicConvolTransform<realT>());
573 
574  ims.image(image_i) = ims.image(image_i) + shiftFake*scale*RDIFluxScale*contrast;
575 
576  return 0;
577 
578 }
579 
580 template<typename _realT, class _derotFunctObj>
582 {
583  if( this->m_mask.rows() != this->m_Nrows || this->m_mask.cols() != this->m_Ncols)
584  {
585  std::cerr << "\nMask is not the same size as images.\n\n";
586  exit(-1);
587  }
588 
589  this->m_maskCube.resize( this->m_Nrows, this->m_Ncols, this->m_Nims);
590 
591  #pragma omp parallel
592  {
593  eigenImageT rm;
594 
595  #pragma omp for
596  for(int i=0; i< this->m_Nims; ++i)
597  {
598  rotateMask( rm, this->m_mask, m_derotF.derotAngle(i));
599  this->m_maskCube.image(i) = rm;
600  }
601  }
602 
604  ff.write("maskCube.fits", this->m_maskCube);
605 }
606 
607 template<typename _realT, class _derotFunctObj>
609 {
610  t_derotate_begin = sys::get_curr_time();
611 
612  for(size_t n=0; n<this->m_psfsub.size(); ++n)
613  {
614  #pragma omp parallel
615  {
616  eigenImageT rotim;
617  realT derot;
618 
619  #pragma omp for
620  for(int i=0; i<this->m_psfsub[n].planes();++i)
621  {
622  derot = m_derotF.derotAngle(i);
623  if(derot != 0)
624  {
625  imageRotate(rotim, this->m_psfsub[n].image(i), derot, cubicConvolTransform<realT>());
626  this->m_psfsub[n].image(i) = rotim;
627  }
628  }
629  }
630  }
631 
632  t_derotate_end = sys::get_curr_time();
633 }
634 
635 
636 //If fakeFileName == "" or skipPreProcess == true then use the structure of propagated values
637 
638 template<typename _realT, class _derotFunctObj>
640 {
641  if(head == 0) return;
642 
643  head->append("", fits::fitsCommentType(), "----------------------------------------");
644  head->append("", fits::fitsCommentType(), "mx::ADIobservation parameters:");
645  head->append("", fits::fitsCommentType(), "----------------------------------------");
646 
647  head->append("POSTMEDS", m_postMedSub, "median subtraction after processing");
648 
649  if(m_fakeFileName != "")
650  head->append("FAKEFILE", m_fakeFileName, "name of fake planet PSF file");
651 
652  if(m_fakeScaleFileName != "")
653  head->append("FAKESCFL", m_fakeScaleFileName, "name of fake planet scale file name");
654 
655  std::stringstream str;
656 
657  if(m_fakeSep.size() > 0)
658  {
659  for(size_t nm=0;nm < m_fakeSep.size()-1; ++nm) str << m_fakeSep[nm] << ",";
660  str << m_fakeSep[m_fakeSep.size()-1];
661  head->append<char *>("FAKESEP", (char *)str.str().c_str(), "separation of fake planets");
662  }
663 
664  if(m_fakePA.size() > 0 )
665  {
666  str.str("");
667  for(size_t nm=0;nm < m_fakePA.size()-1; ++nm) str << m_fakePA[nm] << ",";
668  str << m_fakePA[m_fakePA.size()-1];
669  head->append<char *>("FAKEPA", (char *)str.str().c_str(), "PA of fake planets");
670  }
671 
672  if( m_fakeContrast.size() > 0)
673  {
674  str.str("");
675  for(size_t nm=0;nm < m_fakeContrast.size()-1; ++nm) str << m_fakeContrast[nm] << ",";
676  str << m_fakeContrast[m_fakeContrast.size()-1];
677  head->append<char *>("FAKECONT", (char *)str.str().c_str(), "Contrast of fake planets");
678  }
679 }
680 
681 template<typename realT> class ADIDerotator;
682 
683 extern template class ADIobservation<float, ADIDerotator<float>>;
684 extern template class ADIobservation<double, ADIDerotator<double>>;
685 
686 } //namespace improc
687 } //namespace mx
688 
689 #endif //__ADIobservation_hpp__
690 
691 
Defines the basic high contrast imaging data type.
mxException for a size error
Class to manage interactions with a FITS file.
Definition: fitsFile.hpp:54
int write(const dataT *im, int d1, int d2, int d3, fitsHeader *head)
Write the contents of a raw array to the FITS file.
Definition: fitsFile.hpp:1301
int read(dataT *data)
Read the contents of the FITS file into an array.
Definition: fitsFile.hpp:828
Class to manage a complete fits header.
Definition: fitsHeader.hpp:52
size_t count(const std::string &keyword)
Get number of cards with a given keyword.
Definition: fitsHeader.cpp:97
void append(fitsHeaderCard card)
Append a fitsHeaderCard to the end of the header.
Definition: fitsHeader.cpp:156
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > image(Index n)
Returns a 2D Eigen::Eigen::Map pointed at the specified image.
Definition: eigenCube.hpp:376
int readColumns(const std::string &fname, arrTs &... arrays)
Read in columns from a text file.
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
Definition: eigenImage.hpp:44
std::vector< std::string > getFileNames(const std::string &directory, const std::string &prefix, const std::string &substr, const std::string &extension)
Get a list of file names from the specified directory, specifying a prefix, a substring to match,...
Definition: fileUtils.cpp:85
std::string pathFilename(const std::string &fname)
Get the base filename.
Definition: fileUtils.cpp:71
realT dtor(realT q)
Convert from degrees to radians.
Definition: geo.hpp:132
fakeMethods
Fake injection PSF file specification methods.
@ single
A single PSF is used.
@ list
A list of PSF files, one per input image, is used.
int padImage(imOutT &imOut, imInT &imIn, unsigned int padSz, typename imOutT::Scalar value)
Pad an image with a constant value.
Definition: imagePads.hpp:57
int cutPaddedImage(imOutT &imOut, const imInT &imIn, unsigned int padSz)
Cut down a padded image.
Definition: imagePads.hpp:273
void imageRotate(arrT &transim, const arrT2 &im, floatT dq, transformT trans)
Rotate an image represented as an eigen array.
void imageShift(arrOutT &transim, const arrInT &im, floatT1 dx, floatT2 dy, transformT trans)
Shift an image.
void parseStringVector(std::vector< typeT > &v, const std::string &s, char delim=',')
Parses a string into a vector of tokens delimited by a character.
typeT get_curr_time(timespec &tsp)
Get the current system time in seconds.
Definition: timeUtils.hpp:63
void rotateMask(imageT &rotMask, imageT &mask, typename imageT::Scalar angle)
Rotate a binary mask.
Definition: imageMasks.hpp:822
Image padding.
int fakeMethodFmStr(const std::string &method)
Get the fake injection method from its string name.
std::string fakeMethodsStr(int method)
Get the string name of a fake injection method.
The mxlib c++ namespace.
Definition: mxError.hpp:107
Process an angular differential imaging (ADI) observation.
int readRDIFiles()
Read in the RDI files.
virtual int postRDIReadFiles()
Post reference read actions, including fake injection.
int injectFake(eigenCube< realT > &ims, std::vector< std::string > &fileList, derotFunctObj &derotF, realT RDIfluxScale, realT RDISepScale)
Inect the fake plants.
std::vector< realT > m_fakeSep
Separation(s) of the fake planet(s)
realT m_RDIFluxScale
Flux scaling to apply to fake planets injected in RDI. Would depend on the assumed spectrum in SDI.
virtual int postReadFiles()
Post target read actions, including fake injection.
virtual void makeMaskCube()
Populate the mask cube which is used for post-processing. Derived classes can do this as appropriate,...
int readFiles()
Read in the target files.
std::vector< realT > m_fakePA
Position angles(s) of the fake planet(s)
std::vector< realT > m_fakeContrast
Contrast(s) of the fake planet(s)
virtual int postRDICoadd()
Post reference coadd actions.
void derotate()
De-rotate the PSF subtracted images.
std::string m_fakeScaleFileName
One-column text file containing a scale factor for each point in time.
realT m_RDISepScale
Scaling to apply to fake planet separation in RDI. Would be ratio of wavelengths for SDI.
std::string m_fakeFileName
FITS file containing the fake planet PSF to inject or a list of fake images.
int m_fakeMethod
Method for reading fake files, either HCI::single or HCI::list.
virtual int postCoadd()
Post target coadd actions.
int readPSFSub(const std::string &dir, const std::string &prefix, const std::string &ext, size_t nReductions)
Read in already PSF-subtracted files.
The basic high contrast imaging data type.
Transformation by cubic convolution interpolation.