Commit 386bc8ec5d6e46c18335c3928e10ab9fd1cf8885

Authored by Jürgen Knödlseder
2 parents 9e8cbd09 949057f8

Merge branch '1254-problem-with-ctbin-save' into integration

src/ctbin/ctbin.cpp
... ... @@ -358,15 +358,19 @@ void ctbin::save(void)
358 358 }
359 359 }
360 360  
  361 + /*
361 362 // Case A: Save counts map(s) and XML metadata information
362 363 if (m_use_xml) {
363 364 save_xml();
364 365 }
365   -
366 366 // Case B: Save counts map as FITS file
367 367 else {
368 368 save_fits();
369 369 }
  370 + */
  371 +
  372 + // Always save FITS and an XML summary
  373 + save_xml();
370 374  
371 375 // Return
372 376 return;
... ... @@ -762,16 +766,27 @@ void ctbin::free_members(void)
762 766 * Converts an input filename into an output filename by prepending the
763 767 * prefix stored in the member m_prefix to the input filename. Any path will
764 768 * be stripped from the input filename. Also a trailing ".gz" will be
765   - * stripped.
  769 + * stripped. If no input file name exist, prefix and observation
  770 + * number are used.
766 771 ***************************************************************************/
767   -std::string ctbin::set_outfile_name(const std::string& filename) const
  772 +std::string ctbin::set_outfile_name(const int index) const
768 773 {
  774 +
  775 + // Initialize output file name
  776 + std::string outname="";
  777 +
769 778 // Split input filename into path elements
770   - std::vector<std::string> elements = gammalib::split(filename, "/");
771   -
772   - // The last path element is the filename
773   - std::string outname = m_prefix + elements[elements.size()-1];
774   -
  779 + std::vector<std::string> elements = gammalib::split(m_infiles[index], "/");
  780 +
  781 + // If there is an observation input file name
  782 + if (elements.size() > 0) {
  783 + outname = m_prefix + elements[elements.size()-1];
  784 + }
  785 + // ...else, use observation number
  786 + else {
  787 + outname = m_prefix + m_obs[index]->id() + ".fits";
  788 + }
  789 +
775 790 // Strip any ".gz"
776 791 outname = gammalib::strip_chars(outname, ".gz");
777 792  
... ... @@ -841,7 +856,7 @@ void ctbin::save_xml(void)
841 856 if (obs != NULL) {
842 857  
843 858 // Set event output file name
844   - std::string outfile = set_outfile_name(m_infiles[i]);
  859 + std::string outfile = set_outfile_name(i);
845 860  
846 861 // Store output file name in observation
847 862 obs->eventfile(outfile);
... ...
src/ctbin/ctbin.hpp
... ... @@ -73,7 +73,7 @@ protected:
73 73 void init_members(void);
74 74 void copy_members(const ctbin& app);
75 75 void free_members(void);
76   - std::string set_outfile_name(const std::string& filename) const;
  76 + std::string set_outfile_name(const int index) const;
77 77 void save_fits(void);
78 78 void save_xml(void);
79 79 void save_counts_map(const GCTAObservation* obs,
... ...