Feature #2208

Create csphagen script

Added by Knödlseder Jürgen over 6 years ago. Updated over 6 years ago.

Status:ClosedStart date:10/09/2017
Priority:NormalDue date:
Assigned To:Tibaldo Luigi% Done:

100%

Category:-
Target version:1.5.0
Duration:

Description

Add csphagen script to produce XML/PHA/ARF/RMF data to be fed into ctlike, csspec, etc.

Inputs:
  • Event list or XML file
  • On region
  • Exclusion region (optional)
  • Minimum number of reflected regions (use all reflected regions that you can)
  • Flag to toggle between stacking and joint analysis
Outputs:
  • PHA file(s), ARF file(s), RMF file(s), XML file
  • DS9 file of ON and OFF regions

Recurrence

No recurrence.

History

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

  • Assigned To set to Tibaldo Luigi

#2 Updated by Tibaldo Luigi over 6 years ago

Need also to add energy binning parameters.

#3 Updated by Tibaldo Luigi over 6 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 20

Committed running version.
Still need to add:
- id assignment for ON/OFF obs
- read energy binning from file
- ds9 regions
- log information
- stacking of multiple runs
- exclusion regions
Also need to create test unit.

#4 Updated by Tibaldo Luigi over 6 years ago

  • % Done changed from 20 to 50

All done except:
- observation stacking
- log information
- unit test

#5 Updated by Tibaldo Luigi over 6 years ago

  • % Done changed from 50 to 90

All done except stacking.

#6 Updated by Tibaldo Luigi over 6 years ago

Script broken by latest gammalib revision where GCTAOnOffObservation only accepts GSkyRegionMap for region definition. Waiting on Jürgen to change this to finalize.

#7 Updated by Knödlseder Jürgen over 6 years ago

  • Target version set to 1.5.0

I updated GammaLib and put back GSkyRegions as input arguments of the GCTAOnOffObservation constructor.

#8 Updated by Tibaldo Luigi over 6 years ago

  • Status changed from In Progress to Pull request
  • % Done changed from 90 to 100

Everything implemented and tested. From my point view it may be ready to merge.
The code is in the branch 2208-create-csphagen

#9 Updated by Knödlseder Jürgen over 6 years ago

I integrated the code and did a couple of minor changes.

I changed the exclusion parameter to inexclusion since we decided some time ago to preceed all input file parameters with in while all output file parameters are preceeded with out. I also changed rootobs to prefix for consistency with ctselect.

Furthermore, I put all saving operations into a save() method which is the convention for all ctools and cscripts. If run() is called the ctools or cscripts should never save anything on disk to allow the construction of in-memory pipelines. I also added an obs() method to recover the result observation container from the script in case one want to use it in an in-memory pipeline. I also added a call of save() to execute() which is also the standard way of working (files are saved when execute() is called).

I also avoided storing some of the parameters into global class values since the code quality check always recommends to avoid global class members. Instead they are read on the fly from the parameter interface. To make sure that values are however queried at the beginning, I kept the query logic (meaning that the parameter values are requested once but not stored). For values that are stored I also added initialisations into the init method to make sure that the class is always setup properly. This should catch some of the issues that Sonar will come up ;)

Finally, the DS9 On region is only stored once since the On region is the same for all observations. I also slightly adapted the file names.

I updated the unit test to take the changes I made into account and all tests passed.

Code is currently in the integration pipeline.

#10 Updated by Knödlseder Jürgen over 6 years ago

The Python string.format() directive posed some problems on some of the platforms during the integration tests (CentOS 6, Debian 6, OpenSolaris, Scientific Linux 6).

The Python string.format() was apparently introduced in Python 2.6, but seems to have evolved for Python 2.7. I replaced the format directives by the classical % directives to assure that the code also works on the older Python versions.

#11 Updated by Knödlseder Jürgen over 6 years ago

  • Status changed from Pull request to Closed

Code is integrated and merged into devel.

Also available in: Atom PDF