Commit c5a2d15fdefdbcf8b6f158ab01f4ffdad2b96716

Authored by Jürgen Knödlseder
1 parent 94494155

Adapt to new GFilename class interface.

cscripts/csfindobs.py
... ... @@ -178,7 +178,8 @@ class csfindobs(ctools.cscript):
178 178 # Check HDUs
179 179 if self.m_obs_index == "":
180 180 raise RuntimeError("FITS data store \""+self.m_prodname+"\" not available. Run csiactdata to get a list of available storage names")
181   - if not gammalib.is_fits(self.m_obs_index+"[OBS_INDEX]"):
  181 + filename = gammalib.GFilename(self.m_obs_index+"[OBS_INDEX]")
  182 + if not filename.is_fits():
182 183 raise RuntimeError("Observation index file \""+self.m_obs_index+"[OBS_INDEX]\" for FITS data store \""+self.m_prodname+"\" not available. Check your master index file or run csiactdata to get a list of available storage names.")
183 184  
184 185 # Set other members
... ...
cscripts/csiactcopy.py
... ... @@ -447,7 +447,8 @@ class csiactcopy(ctools.cscript):
447 447 obs = os.path.join(self.m_outpath, config["obsindx"])
448 448  
449 449 # Check if index files are available
450   - if not (gammalib.is_fits(str(hdu)) and gammalib.is_fits(str(obs))):
  450 + if not (gammalib.GFilename(str(hdu)).is_fits() and
  451 + gammalib.GFilename(str(obs)).is_fits()):
451 452 if self.logTerse():
452 453 self.log("Removing \""+str(config["name"])+"\" (not available)")
453 454 self.log("\n")
... ...
cscripts/csiactobs.py
... ... @@ -196,12 +196,14 @@ class csiactobs(ctools.cscript):
196 196 # Check HDUs
197 197 if self.m_hdu_index == "" or self.m_obs_index == "":
198 198 raise RuntimeError("*** ERROR: FITS data store \""+self.m_prodname+"\" not available. Run csiactdata to get a list of available storage names")
199   - if not gammalib.is_fits(self.m_hdu_index+"[HDU_INDEX]"):
  199 + filename = gammalib.GFilename(self.m_hdu_index+"[HDU_INDEX]")
  200 + if not filename.is_fits():
200 201 raise RuntimeError("*** ERROR: HDU index file \""+self.m_hdu_index+"[HDU_INDEX]\" for FITS data store \""+self.m_prodname+"\" not available. Check your master index file or run csiactdata to get a list of available storage names.")
201 202  
202 203 # Check for existence of "BKG_SCALE" in the observation index file if required
203 204 if self.m_use_bkg_scale:
204   - if gammalib.is_fits(self.m_obs_index+"[OBS_INDEX]"):
  205 + filename = gammalib.GFilename(self.m_obs_index+"[OBS_INDEX]")
  206 + if filename.is_fits():
205 207 fits = gammalib.GFits(self.m_obs_index)
206 208 if not fits["OBS_INDEX"].contains("BKG_SCALE"):
207 209 self.m_use_bkg_scale = False
... ... @@ -439,10 +441,10 @@ class csiactobs(ctools.cscript):
439 441 index = formats.index(version)
440 442 break
441 443 if index >= 0:
442   - eventfile = os.path.join(self.subdir, hduindx_hdu["FILE_DIR"][index], hduindx_hdu["FILE_NAME"][index])
443   - eventhdu = hduindx_hdu["HDU_NAME"][index]
  444 + eventfile = os.path.join(self.subdir, hduindx_hdu["FILE_DIR"][index], hduindx_hdu["FILE_NAME"][index])
  445 + eventhdu = hduindx_hdu["HDU_NAME"][index]
444 446 eventfile += "["+eventhdu+"]"
445   - if not gammalib.is_fits(eventfile):
  447 + if not gammalib.GFilename(eventfile).is_fits():
446 448 if self.logTerse():
447 449 self.log("Skipping observation "+str(obs_id)+": eventfile \""+eventfile+"\" not found\n")
448 450 continue
... ... @@ -455,10 +457,10 @@ class csiactobs(ctools.cscript):
455 457 index = formats.index(version)
456 458 break
457 459 if index >= 0:
458   - aefffile = os.path.join(self.subdir, hduindx_hdu["FILE_DIR"][index], hduindx_hdu["FILE_NAME"][index])
459   - aeffhdu = hduindx_hdu["HDU_NAME"][index]
  460 + aefffile = os.path.join(self.subdir, hduindx_hdu["FILE_DIR"][index], hduindx_hdu["FILE_NAME"][index])
  461 + aeffhdu = hduindx_hdu["HDU_NAME"][index]
460 462 aefffile += "["+aeffhdu+"]"
461   - if not gammalib.is_fits(aefffile):
  463 + if not gammalib.GFilename(aefffile).is_fits():
462 464 if self.logTerse():
463 465 self.log("Skipping observation "+str(obs_id)+": effective area \""+aefffile+"\" not found\n")
464 466 continue
... ... @@ -471,9 +473,9 @@ class csiactobs(ctools.cscript):
471 473 index = formats.index(version)
472 474 break
473 475 if index >= 0:
474   - psffile = os.path.join(self.subdir, hduindx_hdu["FILE_DIR"][index], hduindx_hdu["FILE_NAME"][index])
  476 + psffile = os.path.join(self.subdir, hduindx_hdu["FILE_DIR"][index], hduindx_hdu["FILE_NAME"][index])
475 477 psffile += "["+hduindx_hdu["HDU_NAME"][index]+"]"
476   - if not gammalib.is_fits(psffile):
  478 + if not gammalib.GFilename(psffile).is_fits():
477 479 if self.logTerse():
478 480 self.log("Skipping observation "+str(obs_id)+": point spread function \""+psffile+"\" not found\n")
479 481 continue
... ... @@ -486,9 +488,9 @@ class csiactobs(ctools.cscript):
486 488 index = formats.index(version)
487 489 break
488 490 if index >= 0:
489   - edispfile = os.path.join(self.subdir, hduindx_hdu["FILE_DIR"][index], hduindx_hdu["FILE_NAME"][index])
  491 + edispfile = os.path.join(self.subdir, hduindx_hdu["FILE_DIR"][index], hduindx_hdu["FILE_NAME"][index])
490 492 edispfile += "["+hduindx_hdu["HDU_NAME"][index]+"]"
491   - if not gammalib.is_fits(edispfile):
  493 + if not gammalib.GFilename(edispfile).is_fits():
492 494 if self.logTerse():
493 495 self.log("Warning: observation "+str(obs_id)+" has no energy dispersion \""+edispfile+"\" information\n")
494 496 edispfile = ""
... ... @@ -502,9 +504,9 @@ class csiactobs(ctools.cscript):
502 504 index = formats.index(version)
503 505 break
504 506 if index >= 0:
505   - bkgfile = os.path.join(self.subdir, hduindx_hdu["FILE_DIR"][index], hduindx_hdu["FILE_NAME"][index])
  507 + bkgfile = os.path.join(self.subdir, hduindx_hdu["FILE_DIR"][index], hduindx_hdu["FILE_NAME"][index])
506 508 bkgfile += "["+hduindx_hdu["HDU_NAME"][index]+"]"
507   - if not gammalib.is_fits(bkgfile):
  509 + if not gammalib.GFilename(bkgfile).is_fits():
508 510 if self.logTerse():
509 511 self.log("Warning: observation "+str(obs_id)+" has no background information (file=\""+bkgfile+"\"). IRF background cannot be used\n")
510 512 bkgfile = ""
... ...
cscripts/csobs2caldb.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Generation of an caldb entry from general IACT observation.
4 4 #
5   -# Copyright (C) 2015 Michael Mayer
  5 +# Copyright (C) 2015-2016 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -152,10 +152,10 @@ class csobs2caldb(ctools.cscript):
152 152 fname_bkg = gammalib.GFilename(rsp.background().filename())
153 153  
154 154 # Open FITS files of response components
155   - fits_aeff = gammalib.GFits(fname_aeff.filename())
156   - fits_psf = gammalib.GFits(fname_psf.filename())
157   - fits_edisp = gammalib.GFits(fname_edisp.filename())
158   - fits_bkg = gammalib.GFits(fname_bkg.filename())
  155 + fits_aeff = gammalib.GFits(fname_aeff)
  156 + fits_psf = gammalib.GFits(fname_psf)
  157 + fits_edisp = gammalib.GFits(fname_edisp)
  158 + fits_bkg = gammalib.GFits(fname_bkg)
159 159  
160 160 # Bundle IRFs into one file
161 161 fits.append(fits_aeff[fname_aeff.extname("EFFECTIVE AREA")])
... ...
cscripts/csresmap.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Residual map generation script.
4 4 #
5   -# Copyright (C) 2014-2015 Michael Mayer
  5 +# Copyright (C) 2014-2016 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -143,9 +143,10 @@ class csresmap(ctools.cscript):
143 143  
144 144 # First check if the inobs parameter is a counts cube
145 145 if self.obs.size() == 0 and self["inobs"].filename() != "NONE":
146   - if gammalib.is_fits(self["inobs"].filename()):
  146 + filename = gammalib.GFilename(self["inobs"].filename())
  147 + if filename.is_fits():
147 148 cta = gammalib.GCTAObservation()
148   - cta.load(self["inobs"].filename())
  149 + cta.load(filename)
149 150 if cta.eventtype() == "CountsCube":
150 151 self.m_skip_binning = True
151 152  
... ...
cscripts/cstsmapmerge.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Merges sliced TS map files into one map
4 4 #
5   -# Copyright (C) 2015 Michael Mayer
  5 +# Copyright (C) 2015-2016 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -261,7 +261,7 @@ class cstsmapmerge(ctools.cscript):
261 261 # Test files for the entry status map
262 262 # use the first one to appear useful
263 263 for fitsfile in self.files:
264   - if not gammalib.is_fits(fitsfile):
  264 + if not gammalib.GFilename(fitsfile).is_fits():
265 265 self.log("Skipping file \""+fitsfile+" (not a FITS file)\n")
266 266 fits = gammalib.GFits(fitsfile)
267 267  
... ... @@ -297,7 +297,7 @@ class cstsmapmerge(ctools.cscript):
297 297 for fitsfile in workfiles:
298 298  
299 299 # Skip if file is not FITS
300   - if not gammalib.is_fits(fitsfile):
  300 + if not gammalib.GFilename(fitsfile).is_fits():
301 301 if self.logTerse():
302 302 self.log("Skipping file \""+fitsfile+" (not a FITS file)\n")
303 303 continue
... ...
src/ctmodel/ctmodel.cpp
1 1 /***************************************************************************
2 2 * ctmodel - Model cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2015 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -303,8 +303,7 @@ void ctmodel::run(void)
303 303 fill_cube(obs);
304 304  
305 305 // Dispose events to free memory if event file exists on disk
306   - if (obs->eventfile().length() > 0 &&
307   - gammalib::file_exists(obs->eventfile())) {
  306 + if (obs->eventfile().length() > 0 && obs->eventfile().exists()) {
308 307 obs->dispose_events();
309 308 }
310 309  
... ... @@ -673,7 +672,7 @@ void ctmodel::get_obs(void)
673 672  
674 673 // If file is a FITS file then create an empty CTA observation
675 674 // and load file into observation
676   - if (gammalib::is_fits(filename)) {
  675 + if (GFilename(filename).is_fits()) {
677 676  
678 677 // Allocate empty CTA observation
679 678 GCTAObservation cta;
... ...
src/ctselect/ctselect.cpp
... ... @@ -295,7 +295,7 @@ void ctselect::run(void)
295 295 if (fname.has_extname()) {
296 296 m_evtname[i] = fname.extname();
297 297 }
298   - m_gtiname[i] = get_gtiname(fname.filename(), m_evtname[i]);
  298 + m_gtiname[i] = get_gtiname(fname.url(), m_evtname[i]);
299 299  
300 300 // Log input file information
301 301 if (logTerse()) {
... ... @@ -1184,7 +1184,7 @@ std::string ctselect::set_outfile_name(const std::string& filename) const
1184 1184 GFilename fname(filename);
1185 1185  
1186 1186 // Split input filename without any extensions into path elements
1187   - std::vector<std::string> elements = gammalib::split(fname.filename(), "/");
  1187 + std::vector<std::string> elements = gammalib::split(fname.url(), "/");
1188 1188  
1189 1189 // The last path element is the filename
1190 1190 std::string outname = m_prefix + elements[elements.size()-1];
... ... @@ -1254,7 +1254,7 @@ void ctselect::save_fits(void)
1254 1254 GFilename fname(m_outobs);
1255 1255  
1256 1256 // Extract filename and event extension name
1257   - std::string outfile = fname.filename();
  1257 + std::string outfile = fname.url();
1258 1258  
1259 1259 // Append event extension name. We handle here the possibility
1260 1260 // to write the events into a different extension.
... ... @@ -1458,7 +1458,7 @@ void ctselect::save_event_list(const GCTAObservation* obs,
1458 1458 infits.close();
1459 1459  
1460 1460 // Save file to disk and close it (we need both operations)
1461   - outfits.saveto(outname.filename(), clobber());
  1461 + outfits.saveto(outname.url(), clobber());
1462 1462 outfits.close();
1463 1463  
1464 1464 } // endif: observation was unbinned
... ...
src/support/ctool.cpp
1 1 /***************************************************************************
2 2 * ctool - ctool base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2015 by Juergen Knoedlseder *
  4 + * copyright (C) 2014-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -327,7 +327,7 @@ GObservations ctool::get_observations(const bool&amp; get_response)
327 327  
328 328 // If file is a FITS file then create an empty CTA observation
329 329 // and load file into observation
330   - if (gammalib::is_fits(filename)) {
  330 + if (GFilename(filename).is_fits()) {
331 331  
332 332 // Allocate empty CTA observation
333 333 GCTAObservation cta_obs;
... ... @@ -705,10 +705,10 @@ void ctool::require_inobs(const std::string&amp; method)
705 705 void ctool::require_inobs_nolist(const std::string& method)
706 706 {
707 707 // Get inobs filename
708   - std::string filename = (*this)["inobs"].filename();
  708 + GFilename filename = (*this)["inobs"].filename();
709 709  
710 710 // Continue only if we have a FITS file
711   - if (gammalib::is_fits(filename)) {
  711 + if (filename.is_fits()) {
712 712  
713 713 // Signal no list
714 714 bool is_list = false;
... ... @@ -757,10 +757,10 @@ void ctool::require_inobs_nolist(const std::string&amp; method)
757 757 void ctool::require_inobs_nocube(const std::string& method)
758 758 {
759 759 // Get inobs filename
760   - std::string filename = (*this)["inobs"].filename();
  760 + GFilename filename = (*this)["inobs"].filename();
761 761  
762 762 // Continue only if we have a FITS file
763   - if (gammalib::is_fits(filename)) {
  763 + if (filename.is_fits()) {
764 764  
765 765 // Signal no cube
766 766 bool is_cube = false;
... ...