Commit 77c65bd7eab783dfe171dd71a9e625c9b16df8a5

Authored by Josh Cardenzana
Committed by Jürgen Knödlseder
1 parent bcce377e

Update example for plotting results from ctfindvar (#2713)

Change default source to plot MAXSIGPIXEL since SOURCE may not exist in output file
examples/Makefile.am
... ... @@ -37,7 +37,8 @@ scripts = README.md \
37 37 show_phases.py \
38 38 show_ts_distribution.py \
39 39 show_obs.py \
40   - show_pointings.py
  40 + show_pointings.py \
  41 + show_variability_evolution.py
41 42  
42 43 # Set install directories
43 44 scriptsdir = $(datadir)/examples/python
... ...
examples/README.md
... ... @@ -52,3 +52,6 @@ the ctools.
52 52  
53 53 `show_ts_distribution.py`
54 54 > Displays Test Statistic histograms generated using the cstsdist script.
  55 +
  56 +`show_variability_evolution.py`
  57 +> Displays the results for a given source generated by the ctfindvar script.
55 58 \ No newline at end of file
... ...
examples/show_variability_evolution.py
... ... @@ -21,7 +21,6 @@
21 21 import sys
22 22 import gammalib
23 23 import cscripts
24   -import numpy as np
25 24 try:
26 25 import matplotlib.pyplot as plt
27 26 plt.figure()
... ... @@ -34,7 +33,7 @@ except (ImportError, RuntimeError):
34 33 # ========================== #
35 34 # Plot variability evolution #
36 35 # ========================== #
37   -def plot_variability_evolution(filename, plotfile):
  36 +def plot_variability_evolution(filename, plotfile, srcname):
38 37 """
39 38 Plot variability evolution
40 39  
... ... @@ -50,7 +49,7 @@ def plot_variability_evolution(filename, plotfile):
50 49 table = fits.table(1)
51 50 c_gti_start = table['TSTART']
52 51 c_gti_stop = table['TSTOP']
53   - c_sig = table['SOURCE']
  52 + c_sig = table[srcname]
54 53  
55 54 #convert the c_sig object to list
56 55 table_c_sig=[]
... ... @@ -91,20 +90,21 @@ def show_variability_evolution():
91 90 Show variability
92 91 """
93 92 # Set usage string
94   - usage = 'show_variability_evolution.py [-p plotfile] [file]'
  93 + usage = 'show_variability_evolution.py [-p plotfile] [-s source_name] [file]'
95 94  
96 95 # Set default options
97   - options = [{'option': '-p', 'value': ''}]
  96 + options = [{'option': '-p', 'value': ''},
  97 + {'option': '-s', 'value': 'MAXSIGPIXEL'}]
98 98  
99 99 # Get arguments and options from command line arguments
100 100 args, options = cscripts.ioutils.get_args_options(options, usage)
101 101  
102 102 # Extract script parameters from options
103 103 plotfile = options[0]['value']
104   - #hdu = int(options[1]['value'])
  104 + srcname = options[1]['value']
105 105  
106 106 # Show variability evolution
107   - plot_variability_evolution(args[0], plotfile)
  107 + plot_variability_evolution(args[0], plotfile, srcname)
108 108  
109 109 # Return
110 110 return
... ...