From 77c65bd7eab783dfe171dd71a9e625c9b16df8a5 Mon Sep 17 00:00:00 2001 From: Josh Cardenzana Date: Fri, 16 Nov 2018 16:08:24 +0100 Subject: [PATCH] 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 | 3 ++- examples/README.md | 3 +++ examples/show_variability_evolution.py | 14 +++++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index 18f5860..61efbed 100755 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -37,7 +37,8 @@ scripts = README.md \ show_phases.py \ show_ts_distribution.py \ show_obs.py \ - show_pointings.py + show_pointings.py \ + show_variability_evolution.py # Set install directories scriptsdir = $(datadir)/examples/python diff --git a/examples/README.md b/examples/README.md index edf76bb..eb37522 100755 --- a/examples/README.md +++ b/examples/README.md @@ -52,3 +52,6 @@ the ctools. `show_ts_distribution.py` > Displays Test Statistic histograms generated using the cstsdist script. + +`show_variability_evolution.py` +> Displays the results for a given source generated by the ctfindvar script. \ No newline at end of file diff --git a/examples/show_variability_evolution.py b/examples/show_variability_evolution.py index d9b6859..043109b 100755 --- a/examples/show_variability_evolution.py +++ b/examples/show_variability_evolution.py @@ -21,7 +21,6 @@ import sys import gammalib import cscripts -import numpy as np try: import matplotlib.pyplot as plt plt.figure() @@ -34,7 +33,7 @@ except (ImportError, RuntimeError): # ========================== # # Plot variability evolution # # ========================== # -def plot_variability_evolution(filename, plotfile): +def plot_variability_evolution(filename, plotfile, srcname): """ Plot variability evolution @@ -50,7 +49,7 @@ def plot_variability_evolution(filename, plotfile): table = fits.table(1) c_gti_start = table['TSTART'] c_gti_stop = table['TSTOP'] - c_sig = table['SOURCE'] + c_sig = table[srcname] #convert the c_sig object to list table_c_sig=[] @@ -91,20 +90,21 @@ def show_variability_evolution(): Show variability """ # Set usage string - usage = 'show_variability_evolution.py [-p plotfile] [file]' + usage = 'show_variability_evolution.py [-p plotfile] [-s source_name] [file]' # Set default options - options = [{'option': '-p', 'value': ''}] + options = [{'option': '-p', 'value': ''}, + {'option': '-s', 'value': 'MAXSIGPIXEL'}] # Get arguments and options from command line arguments args, options = cscripts.ioutils.get_args_options(options, usage) # Extract script parameters from options plotfile = options[0]['value'] - #hdu = int(options[1]['value']) + srcname = options[1]['value'] # Show variability evolution - plot_variability_evolution(args[0], plotfile) + plot_variability_evolution(args[0], plotfile, srcname) # Return return -- libgit2 0.21.4