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