Commit a67e143b779f0e358a5b56885f4aa38eb977ab48

Authored by Jürgen Knödlseder
1 parent f8d59545

Read filename task parameters in save() methods, and use GFilename in all classes.

src/ctbin/ctbin.cpp
... ... @@ -325,6 +325,9 @@ void ctbin::save(void)
325 325 log.header1("Save counts cube");
326 326 }
327 327  
  328 + // Get counts cube filename
  329 + m_outcube = (*this)["outcube"].filename();
  330 +
328 331 // Save only if filename is non-empty
329 332 if (!m_outcube.is_empty()) {
330 333  
... ... @@ -336,7 +339,8 @@ void ctbin::save(void)
336 339  
337 340 // Log filename
338 341 if (logTerse()) {
339   - log << "Save \""+m_outcube+"\"." << std::endl;
  342 + log << "Save counts cube into file \""+m_outcube+"\".";
  343 + log << std::endl;
340 344 }
341 345  
342 346 // Save cube
... ...
src/ctbkgcube/ctbkgcube.cpp
... ... @@ -364,12 +364,17 @@ void ctbkgcube::save(void)
364 364 log.header1("Save background cube");
365 365 }
366 366  
  367 + // Get background cube and model file names
  368 + m_outcube = (*this)["outcube"].filename();
  369 + m_outmodel = (*this)["outmodel"].filename();
  370 +
367 371 // Save only if filename is non-empty
368 372 if (!m_outcube.is_empty()) {
369 373  
370 374 // Log filename
371 375 if (logTerse()) {
372   - log << "Save \""+m_outcube+"\"." << std::endl;
  376 + log << "Save background cube into file \""+m_outcube+"\".";
  377 + log << std::endl;
373 378 }
374 379  
375 380 // Save background cube
... ... @@ -383,7 +388,8 @@ void ctbkgcube::save(void)
383 388  
384 389 // Log filename
385 390 if (logTerse()) {
386   - log << "Save \""+m_outmodel.url()+"\"." << std::endl;
  391 + log << "Save model into file \""+m_outmodel.url()+"\".";
  392 + log << std::endl;
387 393 }
388 394  
389 395 // Save output model for stacked analyses
... ...
src/ctbutterfly/ctbutterfly.cpp
1 1 /***************************************************************************
2 2 * ctbutterfly - butterfly calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2015 by Michael Mayer *
  4 + * copyright (C) 2014-2016 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -501,25 +501,36 @@ void ctbutterfly::save(void)
501 501 // Write header
502 502 if (logTerse()) {
503 503 log << std::endl;
504   - log.header1("Save Butterfly to file");
  504 + log.header1("Save Butterfly diagram");
505 505 }
506 506  
507 507 // Get output filename
508 508 m_outfile = (*this)["outfile"].filename();
509 509  
510   - // Create CSV table with 4 columns
511   - GCsv table(m_energies.size(), 4);
  510 + // Save only if filename is non-empty
  511 + if (!m_outfile.is_empty()) {
512 512  
513   - // Fill CSV table
514   - for (int i = 0; i < m_energies.size(); ++i) {
515   - table.real(i, 0, m_energies[i]);
516   - table.real(i, 1, m_intensities[i]);
517   - table.real(i, 2, m_min_intensities[i]);
518   - table.real(i, 3, m_max_intensities[i]);
519   - }
  513 + // Log filename
  514 + if (logTerse()) {
  515 + log << "Save butterfly diagram into file \""+m_outfile+"\".";
  516 + log << std::endl;
  517 + }
  518 +
  519 + // Create CSV table with 4 columns
  520 + GCsv table(m_energies.size(), 4);
520 521  
521   - // Save CSV table
522   - table.save(m_outfile, " ", clobber());
  522 + // Fill CSV table
  523 + for (int i = 0; i < m_energies.size(); ++i) {
  524 + table.real(i, 0, m_energies[i]);
  525 + table.real(i, 1, m_intensities[i]);
  526 + table.real(i, 2, m_min_intensities[i]);
  527 + table.real(i, 3, m_max_intensities[i]);
  528 + }
  529 +
  530 + // Save CSV table
  531 + table.save(m_outfile, " ", clobber());
  532 +
  533 + }
523 534  
524 535 // Return
525 536 return;
... ...
src/ctbutterfly/ctbutterfly.hpp
1 1 /***************************************************************************
2 2 * ctbutterfly - butterfly calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2015 by Michael Mayer *
  4 + * copyright (C) 2014-2016 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -34,7 +34,7 @@
34 34  
35 35 /* __Definitions _________________________________________________________ */
36 36 #define CTBUTTERFLY_NAME "ctbutterfly"
37   -#define CTBUTTERFLY_VERSION "1.0.0"
  37 +#define CTBUTTERFLY_VERSION "1.1.0"
38 38  
39 39  
40 40 /***********************************************************************//**
... ... @@ -95,7 +95,7 @@ protected:
95 95 bool m_apply_edisp; //!< Apply energy dispersion?
96 96 bool m_fit; //!< Do fit?
97 97 GEbounds m_ebounds; //!< Energy binning definition
98   - std::string m_outfile; //!< Output ascii file
  98 + GFilename m_outfile; //!< Output ASCII file name
99 99  
100 100 // Protected members
101 101 GOptimizerLM m_opt; //!< Optimizer
... ... @@ -107,6 +107,7 @@ protected:
107 107 std::vector<double> m_max_intensities; //!< Maximum intensities
108 108 };
109 109  
  110 +
110 111 /***********************************************************************//**
111 112 * @brief Return observation container
112 113 *
... ...
src/ctcubemask/ctcubemask.cpp
... ... @@ -324,8 +324,16 @@ void ctcubemask::save(void)
324 324 }
325 325 }
326 326  
  327 + // Get counts cube filename
  328 + m_outcube = (*this)["outcube"].filename();
  329 +
327 330 // Case A: Save event file(s) and XML metadata information
328 331 if (m_use_xml) {
  332 +
  333 + // Get prefix
  334 + m_prefix = (*this)["prefix"].string();
  335 +
  336 + // Save XML
329 337 save_xml();
330 338 }
331 339  
... ... @@ -755,9 +763,9 @@ std::string ctcubemask::set_outfile_name(const std::string&amp; filename) const
755 763  
756 764  
757 765 /***********************************************************************//**
758   - * @brief Save counts map in FITS format.
  766 + * @brief Save counts cube in FITS format.
759 767 *
760   - * Save the counts map as a FITS file. The filename of the FITS file is
  768 + * Save the counts cube as a FITS file. The filename of the FITS file is
761 769 * specified by the m_outfile member.
762 770 ***************************************************************************/
763 771 void ctcubemask::save_fits(void)
... ... @@ -770,7 +778,8 @@ void ctcubemask::save_fits(void)
770 778  
771 779 // Log filename
772 780 if (logTerse()) {
773   - log << "Save \""+m_outcube+"\"." << std::endl;
  781 + log << "Save counts cube into file \""+m_outcube+"\".";
  782 + log << std::endl;
774 783 }
775 784  
776 785 // Save event list
... ... @@ -825,7 +834,8 @@ void ctcubemask::save_xml(void)
825 834  
826 835 // Log filename
827 836 if (logTerse()) {
828   - log << "Save \""+outfile+"\"." << std::endl;
  837 + log << "Save counts cube into file \""+outfile+"\".";
  838 + log << std::endl;
829 839 }
830 840  
831 841 // Save event list
... ...
src/cterror/cterror.cpp
... ... @@ -412,9 +412,19 @@ void cterror::save(void)
412 412 // Get output filename
413 413 m_outmodel = (*this)["outmodel"].filename();
414 414  
415   - // Write results out as XML model
416   - if (gammalib::toupper(m_outmodel.url()) != "NONE") {
  415 + // Save only if filename is non-empty
  416 + if (!m_outmodel.is_empty() &&
  417 + gammalib::toupper(m_outmodel.url()) != "NONE") {
  418 +
  419 + // Log filename
  420 + if (logTerse()) {
  421 + log << "Save errors into file \""+m_outmodel+"\".";
  422 + log << std::endl;
  423 + }
  424 +
  425 + // Write results out as XML model
417 426 m_obs.models().save(m_outmodel);
  427 +
418 428 }
419 429  
420 430 // Return
... ...
src/ctexpcube/ctexpcube.cpp
... ... @@ -281,12 +281,16 @@ void ctexpcube::save(void)
281 281 log.header1("Save exposure cube");
282 282 }
283 283  
  284 + // Get exposure cube filename
  285 + m_outcube = (*this)["outcube"].filename();
  286 +
284 287 // Save only if filename is non-empty
285 288 if (!m_outcube.is_empty()) {
286 289  
287 290 // Log filename
288 291 if (logTerse()) {
289   - log << "Save \""+m_outcube+"\"." << std::endl;
  292 + log << "Save exposure cube into file \""+m_outcube+"\".";
  293 + log << std::endl;
290 294 }
291 295  
292 296 // Save exposure cube
... ...
src/ctlike/ctlike.cpp
... ... @@ -353,9 +353,19 @@ void ctlike::save(void)
353 353 // Get output filename
354 354 m_outmodel = (*this)["outmodel"].filename();
355 355  
356   - // Write results out as XML model
357   - if (gammalib::toupper(m_outmodel) != "NONE") {
  356 + // Save only if filename is non-empty
  357 + if (!m_outmodel.is_empty() &&
  358 + gammalib::toupper(m_outmodel.url()) != "NONE") {
  359 +
  360 + // Log filename
  361 + if (logTerse()) {
  362 + log << "Save fitted parameters into file \""+m_outmodel+"\".";
  363 + log << std::endl;
  364 + }
  365 +
  366 + // Write results out as XML model
358 367 m_obs.models().save(m_outmodel);
  368 +
359 369 }
360 370  
361 371 // Return
... ...
src/ctlike/ctlike.hpp
1 1 /***************************************************************************
2 2 * ctlike - Maximum likelihood fitting tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2015 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -35,7 +35,7 @@
35 35  
36 36 /* __Definitions _________________________________________________________ */
37 37 #define CTLIKE_NAME "ctlike"
38   -#define CTLIKE_VERSION "1.0.0"
  38 +#define CTLIKE_VERSION "1.1.0"
39 39  
40 40  
41 41 /***********************************************************************//**
... ... @@ -74,7 +74,7 @@ protected:
74 74  
75 75 // User parameters
76 76 bool m_refit; //!< Refitting
77   - std::string m_outmodel; //!< Source model output XML file
  77 + GFilename m_outmodel; //!< Source model output XML file name
78 78 bool m_apply_edisp; //!< Apply energy dispersion?
79 79 bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation?
80 80  
... ...
src/ctmodel/ctmodel.cpp
... ... @@ -348,12 +348,16 @@ void ctmodel::save(void)
348 348 log.header1("Save cube");
349 349 }
350 350  
  351 + // Get model cube filename
  352 + m_outcube = (*this)["outcube"].filename();
  353 +
351 354 // Save only if filename is non-empty
352 355 if (!m_outcube.is_empty()) {
353 356  
354   - // Dump filename
  357 + // Log filename
355 358 if (logTerse()) {
356   - log << "Save \""+m_outcube+"\"." << std::endl;
  359 + log << "Save model cube into file \""+m_outcube+"\".";
  360 + log << std::endl;
357 361 }
358 362  
359 363 // Save model cube into FITS file
... ...
src/ctobssim/ctobssim.cpp
... ... @@ -1454,6 +1454,12 @@ void ctobssim::save_fits(void)
1454 1454 // Get CTA observation from observation container
1455 1455 GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[0]);
1456 1456  
  1457 + // Log filename
  1458 + if (logTerse()) {
  1459 + log << "Save event list into file \""+m_outevents+"\".";
  1460 + log << std::endl;
  1461 + }
  1462 +
1457 1463 // Save observation into FITS file
1458 1464 obs->save(m_outevents, clobber());
1459 1465  
... ... @@ -1513,6 +1519,12 @@ void ctobssim::save_xml(void)
1513 1519 // Store output file name in observation
1514 1520 obs->eventfile(outfile);
1515 1521  
  1522 + // Log filename
  1523 + if (logTerse()) {
  1524 + log << "Save event list into file \""+outfile+"\".";
  1525 + log << std::endl;
  1526 + }
  1527 +
1516 1528 // Save observation into FITS file
1517 1529 obs->save(outfile, clobber());
1518 1530  
... ...
src/ctpsfcube/ctpsfcube.cpp
1 1 /***************************************************************************
2 2 * ctpsfcube - PSF cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2015 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2016 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -276,8 +276,19 @@ void ctpsfcube::save(void)
276 276 // Get output filename
277 277 m_outcube = (*this)["outcube"].filename();
278 278  
279   - // Save PSF cube
280   - m_psfcube.save(m_outcube, clobber());
  279 + // Save only if filename is non-empty
  280 + if (!m_outcube.is_empty()) {
  281 +
  282 + // Log filename
  283 + if (logTerse()) {
  284 + log << "Save PSF cube into file \""+m_outcube+"\".";
  285 + log << std::endl;
  286 + }
  287 +
  288 + // Save PSF cube
  289 + m_psfcube.save(m_outcube, clobber());
  290 +
  291 + }
281 292  
282 293 // Return
283 294 return;
... ...
src/ctpsfcube/ctpsfcube.hpp
1 1 /***************************************************************************
2 2 * ctpsfcube - PSF cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2015 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2016 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -34,7 +34,7 @@
34 34  
35 35 /* __Definitions _________________________________________________________ */
36 36 #define CTPSFCUBE_NAME "ctpsfcube"
37   -#define CTPSFCUBE_VERSION "1.0.0"
  37 +#define CTPSFCUBE_VERSION "1.1.0"
38 38  
39 39  
40 40 /***********************************************************************//**
... ... @@ -69,7 +69,7 @@ protected:
69 69 void get_parameters(void);
70 70  
71 71 // User parameters
72   - std::string m_outcube; //!< Output PSF cube file
  72 + GFilename m_outcube; //!< Output PSF cube file name
73 73 bool m_apply_edisp; //!< Apply energy dispersion?
74 74  
75 75 // Protected members
... ...
src/ctselect/ctselect.cpp
... ... @@ -413,10 +413,10 @@ void ctselect::save(void)
413 413 if (logTerse()) {
414 414 log << std::endl;
415 415 if (m_obs.size() > 1) {
416   - log.header1("Save observations");
  416 + log.header1("Save event lists");
417 417 }
418 418 else {
419   - log.header1("Save observation");
  419 + log.header1("Save event list");
420 420 }
421 421 }
422 422  
... ... @@ -1267,7 +1267,8 @@ void ctselect::save_fits(void)
1267 1267  
1268 1268 // Log filename
1269 1269 if (logTerse()) {
1270   - log << "Save \""+outfile+"\"" << std::endl;
  1270 + log << "Save event list into file \""+outfile+"\".";
  1271 + log << std::endl;
1271 1272 }
1272 1273  
1273 1274 // Save event list
... ... @@ -1335,7 +1336,8 @@ void ctselect::save_xml(void)
1335 1336  
1336 1337 // Log filename
1337 1338 if (logTerse()) {
1338   - log << "Save \""+outfile+"\"" << std::endl;
  1339 + log << "Save event list into file \""+outfile+"\".";
  1340 + log << std::endl;
1339 1341 }
1340 1342  
1341 1343 // Store output file name in observation
... ...
src/ctskymap/ctskymap.cpp
1 1 /***************************************************************************
2 2 * ctskymap - Sky mapping tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2015 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -314,12 +314,15 @@ void ctskymap::save(void)
314 314 log.header1("Save sky map");
315 315 }
316 316  
  317 + // Get sky map filename
  318 + m_outmap = (*this)["outmap"].filename();
  319 +
317 320 // Save only if filename is non-empty
318 321 if (!m_outmap.is_empty()) {
319 322  
320 323 // Log filename
321 324 if (logTerse()) {
322   - log << "Save \""+m_outmap+"\"." << std::endl;
  325 + log << "Save sky map into file \""+m_outmap+"\"." << std::endl;
323 326 }
324 327  
325 328 // Save sky map
... ...
src/cttsmap/cttsmap.cpp
... ... @@ -391,28 +391,41 @@ void cttsmap::save(void)
391 391 log.header1("Save TS map");
392 392 }
393 393  
394   - // Create fits file
395   - GFits fits;
  394 + // Get TS map filename
  395 + m_outmap = (*this)["outmap"].filename();
396 396  
397   - // Write the sky maps to the FITS file
398   - m_tsmap.write(fits);
399   - for (int i = 0; i < m_mapnames.size(); i++) {
400   - m_maps[i].write(fits);
401   - }
  397 + // Save only if filename is non-empty
  398 + if (!m_outmap.is_empty()) {
402 399  
403   - // Set extension name for all maps
404   - for (int i = 0; i < m_mapnames.size(); i++) {
405   - fits[i+1]->extname(m_mapnames[i]);
406   - }
  400 + // Log filename
  401 + if (logTerse()) {
  402 + log << "Save TS map into file \""+m_outmap+"\"." << std::endl;
  403 + }
407 404  
408   - // Add computation log if not all bins are computed
409   - if (m_binmin != -1 || m_binmax != -1) {
410   - m_statusmap.write(fits);
411   - fits[m_mapnames.size()+1]->extname("STATUS MAP");
412   - }
  405 + // Create fits file
  406 + GFits fits;
  407 +
  408 + // Write the sky maps to the FITS file
  409 + m_tsmap.write(fits);
  410 + for (int i = 0; i < m_mapnames.size(); i++) {
  411 + m_maps[i].write(fits);
  412 + }
  413 +
  414 + // Set extension name for all maps
  415 + for (int i = 0; i < m_mapnames.size(); i++) {
  416 + fits[i+1]->extname(m_mapnames[i]);
  417 + }
  418 +
  419 + // Add computation log if not all bins are computed
  420 + if (m_binmin != -1 || m_binmax != -1) {
  421 + m_statusmap.write(fits);
  422 + fits[m_mapnames.size()+1]->extname("STATUS MAP");
  423 + }
  424 +
  425 + // Save FITS file
  426 + fits.saveto(m_outmap, clobber());
413 427  
414   - // Save FITS file
415   - fits.saveto(m_outmap, clobber());
  428 + } // endif: TS map filename was valid
416 429  
417 430 // Return
418 431 return;
... ...