mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
aoPaths.hpp
Go to the documentation of this file.
1 /** \file aoPaths.hpp
2  * \author Jared R. Males (jaredmales@gmail.com)
3  * \brief Standardized paths for the mx::AO system.
4  * \ingroup mxAO_files
5  *
6  */
7 
8 #ifndef __aoPaths_hpp__
9 #define __aoPaths_hpp__
10 
11 #include "../sys/environment.hpp"
12 
13 #include "../ioutils/fileUtils.hpp"
14 
15 namespace mx
16 {
17 
18 namespace AO
19 {
20 
21 
22 
23 
24 ///Namespace for paths
25 /** \ingroup mxAO_paths
26  */
27 namespace path
28 {
29 
30 
31 ///Namespace for basis paths
32 /** \ingroup mxAO_paths
33  */
34 namespace basis
35 {
36 
37  ///The root path for basis files
38  /**
39  * \param[in] basisName the name of the basis
40  * \param[in] create [optional] create the directory if it noes not exist.
41  *
42  * \returns the root path for basis files.
43  *
44  * \ingroup mxAO_paths
45  */
46  std::string root(const std::string & basisName, bool create = false)
47  {
48 
49  std::string path = mx::sys::getEnv("MX_AO_DATADIR");
50 
51  path += "/basis/" + basisName;
52 
53  if(create)
54  {
56  }
57  return path;
58  }
59 
60  std::string modes(const std::string & basisName, bool create = false)
61  {
62  std::string path = root(basisName, create) + "/modes.fits";
63 
64  return path;
65  }
66 
67  std::string spectrum(const std::string & basisName, bool create = false)
68  {
69  std::string path = root(basisName, create) + "/spectrum.fits";
70 
71  return path;
72  }
73 } //namespace basis
74 
75 //--------------------------------------------------------------------------------
76 
77 
78 namespace dm
79 {
80 
81  ///The root path for deformable mirror (DM) files
82  /**
83  * \param[in] dmName the name of the DM
84  * \param[in] create [optional] create the directory if it noes not exist.
85  *
86  * \returns the root path for DM files.
87  */
88  std::string root(const std::string & dmName, bool create = false)
89  {
90  std::string path = mx::sys::getEnv("MX_AO_DATADIR");
91 
92  path += "/dm/" + dmName;
93 
94  if(create)
95  {
97  }
98 
99  return path;
100  }
101 
102  ///The path for the deformable mirror (DM) influence functions.
103  /**
104  * \param[in] dmName the name of the DM
105  * \param[in] create [optional] create the root directory if it noes not exist.
106  *
107  * \returns the path to the FITS file containing the DM influence functions.
108  */
109  std::string influenceFunctions(const std::string & dmName, bool create = false)
110  {
111  std::string path = root(dmName, create) + "/inf.fits";
112 
113  return path;
114  }
115 
116  ///The path for the deformable mirror (DM) actuator positions
117  /**
118  * \param[in] dmName the name of the DM
119  * \param[in] create [optional] create the root directory if it noes not exist.
120  *
121  * \returns the path to the FITS file containing the DM actuator positions
122  */
123  std::string actuatorPositions(const std::string & dmName, bool create = false)
124  {
125  std::string path = root(dmName, create) + "/actPos.fits";
126 
127  return path;
128  }
129 
130  ///The path for the deformable mirror (DM) influence function pseudo-inverse.
131  /**
132  * \param[in] dmName the name of the DM
133  * \param[in] create [optional] create the root directory if it noes not exist.
134  *
135  * \returns the path to the FITS file containing the DM influence function pseudo-inverse matrix
136  */
137  std::string pseudoInverse(const std::string & dmName, bool create = false)
138  {
139  std::string path = root(dmName, create) + "/pinv.fits";
140 
141  return path;
142  }
143 
144 ///The path for the deformable mirror (DM) influence function based mirror modes.
145 /**
146  * \param[in] dmName the name of the DM
147  * \param[in] create [optional] create the root directory if it noes not exist.
148  *
149  * \returns the path to the FITS file containing the DM influence function based mirror modes
150  */
151 std::string mirrorModes(const std::string & dmName, bool create = false)
152 {
153  std::string path = basis::modes(dmName, create);
154 
155  return path;
156 }
157 
158 ///The path for the deformable mirror (DM) influence function pseudo-inverse singular values.
159 /**
160  * \param[in] dmName the name of the DM
161  * \param[in] create [optional] create the root directory if it noes not exist.
162  *
163  * \returns the path to the FITS file containing the DM influence function pseudo-inverse singular values
164  */
165 std::string singularValues(const std::string & dmName, bool create = false)
166 {
167  std::string path = root(dmName, create) + "/singularValues.dat";
168 
169  return path;
170 }
171 
172 ///The root path for the deformable mirror (DM) basis related files.
173 /**
174  * \param[in] dmName the name of the DM
175  * \param[in] basisName the name of the basis set
176  * \param[in] create [optional] create the root directory if it noes not exist.
177  *
178  * \returns the root path for the DM basis related files
179  */
180 std::string basisRoot(const std::string & dmName, const std::string & basisName, bool create = false)
181 {
182  std::string path = root(dmName, create) + "/basis/" + basisName;
183 
184  if(create)
185  {
187  }
188 
189  return path;
190 }
191 
192 ///The path for the modes-to-commands (M2c) matrix for a deformable mirror (DM) and a basis set.
193 /**
194  * \param[in] dmName the name of the DM
195  * \param[in] basisName the name of the basis set
196  * \param[in] create [optional] create the root directory if it noes not exist.
197  *
198  * \returns the path to the FITS file containting the M2c matrix for a DM and a basis set.
199  */
200 std::string M2c(const std::string & dmName, const std::string & basisName, bool create = false)
201 {
202  std::string path = basisRoot(dmName, basisName, create);
203 
204  if(create)
205  {
207  }
208 
209  path += "/M2c.fits";
210 
211  return path;
212 }
213 
214 // ///The path for the modes-to-commands (M2c) matrix for a deformable mirror (DM) and an orthogonalized basis set.
215 // /**
216 // * \param[in] dmName the name of the DM
217 // * \param[in] basisName the name of the basis set
218 // * \param[in] create [optional] create the root directory if it noes not exist.
219 // *
220 // * \returns the path to the FITS file containting the Mortho2c matrix for a DM and a basis set.
221 // */
222 // std::string Mortho2c(const std::string & dmName, const std::string & basisName, const std::string & pupilName, bool create = false)
223 // {
224 //
225 // std::string path = basisRoot(dmName, basisName, create);
226 //
227 // path += "/" + pupilName;
228 //
229 // if(create)
230 // {
231 // ioutils::createDirectories(path);
232 // }
233 //
234 // path += "/Mortho2c.fits";
235 //
236 // return path;
237 // }
238 
239 ///The path for the projected modes for a deformable mirror (DM) and a basis set.
240 /** These are the modes as reproduced by the DM actuators.
241  *
242  * \param[in] dmName the name of the DM
243  * \param[in] basisName the name of the basis set
244  * \param[in] pupilName the name of the pupil
245  * \param[in] create [optional] create the root directory if it noes not exist.
246  *
247  * \returns the path to the FITS file containting the M2c matrix for a DM and a basis set.
248  */
249 std::string projectedModes(const std::string & dmName, const std::string & basisName, bool create = false)
250 {
251 
252  std::string path = basisRoot(dmName, basisName, create);
253 
254  if(create)
255  {
257  }
258 
259  path += "/projectedModes.fits";
260 
261  return path;
262 }
263 
264 // ///The path for the projected modes for a deformable mirror (DM) and an orthogonalized basis set.
265 // /** These are the modes as reproduced by the DM actuators.
266 // *
267 // * \param[in] dmName the name of the DM
268 // * \param[in] basisName the name of the basis set
269 // * \param[in] pupilName the name of the pupil
270 // * \param[in] create [optional] create the root directory if it noes not exist.
271 // *
272 // * \returns the path to the FITS file containting the M2c matrix for a DM and a basis set.
273 // */
274 // std::string projectedOrthoModes(const std::string & dmName, const std::string & basisName, const std::string & pupilName, bool create = false)
275 // {
276 //
277 // std::string path = basisRoot(dmName, basisName, create);
278 //
279 // path += "/" + pupilName;
280 //
281 // if(create)
282 // {
283 // ioutils::createDirectories(path);
284 // }
285 //
286 // path += "/projectedOrthoModes.fits";
287 //
288 // return path;
289 // }
290 
291 } //namespace dm
292 
293 //--------------------------------------------------------------------------------
294 
295 namespace pupil
296 {
297 ///The root path for pupil files
298 /**
299  * \param[in] pupilName the name of the basis
300  * \param[in] create [optional] create the directory if it noes not exist.
301  *
302  * \returns the root path for pupil files.
303  */
304 std::string root(const std::string & pupilName, bool create = false)
305 {
306 
307  std::string path = mx::sys::getEnv("MX_AO_DATADIR");
308 
309  path += "/pupil/" + pupilName;
310 
311  if(create)
312  {
314  }
315 
316 
317  return path;
318 }
319 
320 
321 ///The path for the pupil FITS file.
322 /**
323  * \param[in] pupilName the name of the pupil file
324  * \param[in] create [optional] create the root directory if it noes not exist.
325  *
326  * \returns the path to the FITS file containing the pupil as a 1/0 mask
327  */
328 std::string pupilFile(const std::string & pupilName, bool create = false)
329 {
330  std::string path = root(pupilName, create) + "/pupil.fits";
331 
332  return path;
333 }
334 
335 }// namespace pupil
336 
337 //--------------------------------------------------------------------------------
338 
339 namespace sys
340 {
341 
342  ///The root path for system files
343  /**
344  * \param[in] sysName the name of the system
345  * \param[in] create [optional] create the directory if it noes not exist.
346  *
347  * \returns the root path for calibration files.
348  */
349  std::string root(const std::string & sysName, bool create = false)
350  {
351  std::string path = mx::sys::getEnv("MX_AO_DATADIR");
352 
353  path += "/system/" + sysName;
354 
355  if(create)
356  {
358  }
359 
360  return path;
361  }
362 
363  namespace cal
364  {
365 
366  ///The root path for system calibration files
367  /**
368  * \param[in] sysName the name of the system
369  * \param[in] create [optional] create the directory if it noes not exist.
370  *
371  * \returns the root path for calibration files.
372  */
373  std::string root(const std::string & sysName, bool create = false)
374  {
375 
376  std::string path = mx::AO::path::sys::root(sysName, create);
377 
378  path += "/cal";
379 
380  if(create)
381  {
383  }
384 
385  return path;
386  }
387 
388  ///Path for the system response calibration
389  std::string sysResp( const std::string & sysName,
390  const std::string & dmName,
391  const std::string & wfsName,
392  const std::string & pupilName,
393  const std::string & basisName,
394  bool create = false)
395  {
396  std::string path = root(sysName, create);
397 
398  path += "/" + dmName + "/" + wfsName + "/" + pupilName + "/" + basisName;
399 
400  if(create)
401  {
403  }
404 
405  return path;
406  }
407 
408 
409  ///Path for the system response calibration
410  std::string rMat( const std::string & sysName,
411  const std::string & dmName,
412  const std::string & wfsName,
413  const std::string & pupilName,
414  const std::string & basisName,
415  const std::string & id,
416  bool create = false)
417  {
418 
419  std::string path = sysResp(sysName, dmName, wfsName, pupilName, basisName, create);
420 
421  path += "/";
422  path += "rMat_";
423 
424  path += id;
425  path += ".fits";
426 
427  return path;
428  }
429 
430  ///Path for the system response calibration
431  std::string rImages( const std::string & sysName,
432  const std::string & dmName,
433  const std::string & wfsName,
434  const std::string & pupilName,
435  const std::string & basisName,
436  const std::string & id,
437  bool create = false)
438  {
439 
440  std::string path = sysResp(sysName, dmName, wfsName, pupilName, basisName, create);
441 
442  path += "/";
443  path += "rImages_";
444 
445  path += id;
446  path += ".fits";
447 
448  return path;
449  }
450 
451  ///Path for the system response interaction matrix
452  std::string iMat( const std::string & sysName,
453  const std::string & dmName,
454  const std::string & wfsName,
455  const std::string & pupilName,
456  const std::string & basisName,
457  const std::string & id,
458  bool create = false)
459  {
460 
461  std::string path = sysResp(sysName, dmName, wfsName, pupilName, basisName, create);
462 
463  path += "/";
464 
465  path += "iMat_";
466 
467  path += id;
468  path += ".fits";
469 
470  return path;
471  }
472 
473  ///Path for the system response interaction matrix
474  std::string U( const std::string & sysName,
475  const std::string & dmName,
476  const std::string & wfsName,
477  const std::string & pupilName,
478  const std::string & basisName,
479  const std::string & id,
480  bool create = false)
481  {
482 
483  std::string path = sysResp(sysName, dmName, wfsName, pupilName, basisName, create);
484 
485  path += "/";
486 
487  path += "U_";
488 
489  path += id;
490  path += ".fits";
491 
492  return path;
493  }
494 
495  ///Path for the system response interaction matrix
496  std::string S( const std::string & sysName,
497  const std::string & dmName,
498  const std::string & wfsName,
499  const std::string & pupilName,
500  const std::string & basisName,
501  const std::string & id,
502  bool create = false)
503  {
504 
505  std::string path = sysResp(sysName, dmName, wfsName, pupilName, basisName, create);
506 
507  path += "/";
508 
509  path += "S_";
510 
511  path += id;
512  path += ".fits";
513 
514  return path;
515  }
516 
517  ///Path for the system response interaction matrix
518  std::string VT( const std::string & sysName,
519  const std::string & dmName,
520  const std::string & wfsName,
521  const std::string & pupilName,
522  const std::string & basisName,
523  const std::string & id,
524  bool create = false)
525  {
526 
527  std::string path = sysResp(sysName, dmName, wfsName, pupilName, basisName, create);
528 
529  path += "/";
530 
531  path += "VT_";
532 
533  path += id;
534  path += ".fits";
535 
536  return path;
537  }
538 
539  std::string siGains( const std::string & sysName,
540  const std::string & dmName,
541  const std::string & wfsName,
542  const std::string & pupilName,
543  const std::string & basisName,
544  double mag,
545  bool create = false
546  )
547  {
548  std::string path = root(sysName, create);
549  path += "/" + dmName + "/" + wfsName + "/" + pupilName + "/" + basisName + "/gains/si";
550 
551  if(create)
552  {
554  }
555 
556  path += "/optg_" + std::to_string(mag) + "mag.fits";
557 
558  return path;
559  }
560 
561  std::string lpGains( const std::string & sysName,
562  const std::string & dmName,
563  const std::string & wfsName,
564  const std::string & pupilName,
565  const std::string & basisName,
566  double mag,
567  int lpNc,
568  bool create = false
569  )
570  {
571  std::string path = root(sysName, create);
572  path += "/" + dmName + "/" + wfsName + "/" + pupilName + "/" + basisName + "/gains/lp";
573 
574  if(create)
575  {
577  }
578 
579  path += "/optg_" + std::to_string(mag) + "mag_lpNc_" + std::to_string(lpNc) + ".fits";
580 
581  return path;
582  }
583 
584  std::string lpCoeff( const std::string & sysName,
585  const std::string & dmName,
586  const std::string & wfsName,
587  const std::string & pupilName,
588  const std::string & basisName,
589  double mag,
590  int lpNc,
591  bool create = false
592  )
593  {
594  std::string path = root(sysName, create);
595  path += "/" + dmName + "/" + wfsName + "/" + pupilName + "/" + basisName + "/gains/lp";
596 
597  if(create)
598  {
600  }
601 
602  path += "/lpc_" + std::to_string(mag) + "mag_lpNc_" + std::to_string(lpNc) + ".fits";
603 
604  return path;
605  }
606  }// namespace cal
607 
608 } //namespace sys
609 
610 //--------------------------------------------------------------------------------
611 
612 } //namespace path
613 
614 
615 
616 } //namespace AO
617 
618 } //namespace mx
619 
620 
621 #endif //__mxao_hpp__
std::string M2c(const std::string &dmName, const std::string &basisName, bool create=false)
The path for the modes-to-commands (M2c) matrix for a deformable mirror (DM) and a basis set.
Definition: aoPaths.hpp:200
std::string U(const std::string &sysName, const std::string &dmName, const std::string &wfsName, const std::string &pupilName, const std::string &basisName, const std::string &id, bool create=false)
Path for the system response interaction matrix.
Definition: aoPaths.hpp:474
std::string root(const std::string &sysName, bool create=false)
The root path for system files.
Definition: aoPaths.hpp:349
std::string pupilFile(const std::string &pupilName, bool create=false)
The path for the pupil FITS file.
Definition: aoPaths.hpp:328
std::string rImages(const std::string &sysName, const std::string &dmName, const std::string &wfsName, const std::string &pupilName, const std::string &basisName, const std::string &id, bool create=false)
Path for the system response calibration.
Definition: aoPaths.hpp:431
std::string mirrorModes(const std::string &dmName, bool create=false)
The path for the deformable mirror (DM) influence function based mirror modes.
Definition: aoPaths.hpp:151
std::string basisRoot(const std::string &dmName, const std::string &basisName, bool create=false)
The root path for the deformable mirror (DM) basis related files.
Definition: aoPaths.hpp:180
std::string rMat(const std::string &sysName, const std::string &dmName, const std::string &wfsName, const std::string &pupilName, const std::string &basisName, const std::string &id, bool create=false)
Path for the system response calibration.
Definition: aoPaths.hpp:410
std::string S(const std::string &sysName, const std::string &dmName, const std::string &wfsName, const std::string &pupilName, const std::string &basisName, const std::string &id, bool create=false)
Path for the system response interaction matrix.
Definition: aoPaths.hpp:496
std::string projectedModes(const std::string &dmName, const std::string &basisName, bool create=false)
The path for the projected modes for a deformable mirror (DM) and a basis set.
Definition: aoPaths.hpp:249
std::string sysResp(const std::string &sysName, const std::string &dmName, const std::string &wfsName, const std::string &pupilName, const std::string &basisName, bool create=false)
Path for the system response calibration.
Definition: aoPaths.hpp:389
std::string pseudoInverse(const std::string &dmName, bool create=false)
The path for the deformable mirror (DM) influence function pseudo-inverse.
Definition: aoPaths.hpp:137
std::string actuatorPositions(const std::string &dmName, bool create=false)
The path for the deformable mirror (DM) actuator positions.
Definition: aoPaths.hpp:123
std::string iMat(const std::string &sysName, const std::string &dmName, const std::string &wfsName, const std::string &pupilName, const std::string &basisName, const std::string &id, bool create=false)
Path for the system response interaction matrix.
Definition: aoPaths.hpp:452
std::string VT(const std::string &sysName, const std::string &dmName, const std::string &wfsName, const std::string &pupilName, const std::string &basisName, const std::string &id, bool create=false)
Path for the system response interaction matrix.
Definition: aoPaths.hpp:518
std::string singularValues(const std::string &dmName, bool create=false)
The path for the deformable mirror (DM) influence function pseudo-inverse singular values.
Definition: aoPaths.hpp:165
std::string influenceFunctions(const std::string &dmName, bool create=false)
The path for the deformable mirror (DM) influence functions.
Definition: aoPaths.hpp:109
int createDirectories(const std::string &path)
Create a directory or directories.
Definition: fileUtils.cpp:52
std::string root(const std::string &basisName, bool create=false)
The root path for basis files.
Definition: aoPaths.hpp:46
std::string getEnv(const std::string &estr)
Return the value of an environment variable.
Definition: environment.cpp:33
The mxlib c++ namespace.
Definition: mxError.hpp:107