Change request #2925

Run example scripts from objects in memory

Added by Cardenzana Josh over 5 years ago. Updated over 5 years ago.

Status:ClosedStart date:07/02/2019
Priority:NormalDue date:
Assigned To:Cardenzana Josh% Done:

100%

Category:-
Target version:1.7.0
Duration:

Description

There are a few example scripts that currently cannot be run without first saving outputs to disk. It would be nice if the following scripts could be run and the outputs completely viewable without saving to disk first or requiring filenames to plot the results.

The following currently require filenames to generate some of their plots. I propose a change to allow the underlying information to be extracted (so a user can plot them in their preferred way) or an alternative method added to generate the plots from objects in memory:
  • show_butterfly.py: Input generated by ctbutterfly
  • show_spectrum.py: Input generated by csspec
  • show_residuals.py: Input generated by csresspec
  • show_significance_distribution.py: Input generated by ctskymap
The following tools should also be modified to make this possible:
  • ctskymap: Only the generated skymap is accessible without first saving the skymap to a file.
  • csphagen: The exclusion map is only read if 'inexclusion’ filename parameter is set, even if the exclusion map is set by `csphagen.exclusion_map()`

Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen over 5 years ago

  • Tracker changed from Bug to Change request

#2 Updated by Cardenzana Josh over 5 years ago

  • Status changed from New to Pull request

I’ve made the following changes (and added tests):

ctskymap:
  • Add new methods including `ctskymap::fits()` that returns the generated GFits object. Using this fits object allows extracting the generated sky maps without calling `ctskymap::save()` first.
csphagen:
  • Setting the exclusion map via `csphagen.exclusion_map(object=<map>)` will now actually use the exclusion map even if the 'inexclusion’ parameter is not set. Before, the only exclusion that would be used was the exclusion passed via the 'inexclusion’ parameter. If re-running csphagen using the 'inexclusion’ parameter after setting the map with 'csphagen.exclusion_map()' you should first call `csphagen.exclusion_map(object=gammalib.GSkyRegionMap())`. This makes the map empty and csphagen then checks the 'inexclusion’ parameter.
show_butterfly.py:
  • Add method 'get_butterfly_file’ to extract butterfly parameters from the output file generated by ctbutterfly
  • Add method 'get_butterfly_csv’ to extract butterfly parameters from GCsv object returned by `ctbutterfly.butterfly()`
  • The output of these two methods is a python dictionary. To see how to use the dictionary to generate plots, see `show_butterfly.plot_butterfly()`
show_spectrum.py:
  • Add method 'get_spectrum_file’ to extract SED parameters from the output file generated by csspec
  • Add method 'get_spectrum_fits’ to extract SED parameters from GFits object returned by `csspec.spectrum()`
  • The output of these two methods is a python dictionary. To see how to use the dictionary to generate plots, see `show_spectrum.plot_spectrum()`
show_residuals.py:
  • Add `fits` parameter to `plot_residuals` method to generate residual plots from GFits object returned by `csresspec.resspec()`
show_significance_distribution.py:
  • Add method `plot_significance` that allows generating the significance distribution from significance map and exclusion regions defined in memory.

None of the above changes should break existing code.

Pull Request:
Fork: https://cta-gitlab.irap.omp.eu/jcardenzana/ctools.git
Branch: 2925_run_examples_in_memory

#3 Updated by Knödlseder Jürgen over 5 years ago

  • Target version changed from 1.6.2 to 1.7.0
  • % Done changed from 0 to 90

I will look into the changes. But given the fact that you added methods, the code can only go into release 1.7.0, since for increments of the patch level (i.e. 1.6.2), the interface has to stay strictly the same.

#4 Updated by Knödlseder Jürgen over 5 years ago

  • Status changed from Pull request to Closed
  • % Done changed from 90 to 100

Merged into devel.

Also available in: Atom PDF