Revision 6e053776a85e84f8665f99053ebacccb4e6eced1 authored by Collin Capano on 17 March 2020, 11:11:22 UTC, committed by GitHub on 17 March 2020, 11:11:22 UTC
* make add_input a public method * add separate funtions for pp plots and injection recovery * first stab at updating injection workflow * add function to create pp summary table; update the workflow * make default distribution section in create injections be 'prior' * use function for boiler-plate workflow options * set config-files in create injection node; whitespace * fix bug in setting injection file * fix some typos; use pp_summary_table to determine whether to do pp test * try to make pp jobs their own sub workflow * try not using any container workflow * fix bugs in figuring out dependencies for sub workflows * fix pp test page layout * make inj recovery plots have the same aspect ratio as pp plots * ensure pp params are enclosed in quotes * python 3: fix issue saving approximant to injection file * save metadata with inj recovery plots, and use bbox inches tight * whitespace * another fix to making the workflow dependencies * move function to add workflow cli group to workflow/core.py
1 parent 3c48bfd
pycbc_pygrb_plot_skygrid
#!/usr/bin/env python
#
# Copyright (C) 2019 Gino Contestabile, Francesco Pannarale
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# =============================================================================
# Preamble
# =============================================================================
from __future__ import division
import sys
import glob
import os
import copy
import logging
from glue.ligolw import lsctables
import pycbc.version
from pycbc.results.pygrb_plotting_utils import *
plt.switch_backend('Agg')
__author__ = "Francesco Pannarale <francesco.pannarale@ligo.org>"
__version__ = pycbc.version.git_verbose_msg
__date__ = pycbc.version.date
__program__ = "pycbc_pygrb_plot_skygrid"
# =============================================================================
# Main script starts here
# =============================================================================
description = 'pycbc_pygrb_plot_skygrid will produce the sky grid plot.'
usage = __program__ + ' [--options]'
opts = pygrb_plot_opts_parser(usage=usage, description=description, version=__version__)
if opts.verbose:
level = logging.INFO
else:
level = logging.WARNING
logging.basicConfig(format="%(asctime)s:%(levelname)s : %(message)s",
level=level)
trig_file = os.path.abspath(opts.trig_file)
inj_file = None
if opts.inj_file:
inj_file = os.path.abspath(opts.inj_file)
outfile = opts.output_file
seg_dir = opts.segment_dir
veto_files = []
if opts.veto_directory:
veto_string = ','.join([str(i) for i in range(2,opts.veto_category+1)])
veto_files = glob.glob(opts.veto_directory +'/*CAT[%s]*.xml' %(veto_string))
if opts.plot_title is None:
opts.plot_title = 'PyGRB sky grid'
logging.info("Imported and ready to go.")
# Set output directories
outdirs = [os.path.split(os.path.abspath(outfile))[0]]
for outdir in outdirs:
if not os.path.isdir(outdir):
os.makedirs(outdir)
# Extract IFOs and vetoes
ifos = extract_ifos(trig_file)
# Extract IFOs and vetoes
vetoes = extract_vetoes(trig_file, ifos)
# Load triggers
trigs = load_triggers(trig_file, vetoes, ifos)
# Extract trigger data
trig_data = PygrbFilterOutput(trigs, ifos,
lsctables.MultiInspiralTable.loadcolumns,
"triggers", opts)
#
# Generate sky grid plot
#
xlabel = "Longitude (Degrees)"
ylabel = "Latitude (Degrees)"
if opts.verbose:
sys.stdout.write("\nPlotting...\n")
fig_name = os.path.split(os.path.abspath(outfile))[1]
sys.stdout.write(" * %s (%s vs %s)...\n" % (fig_name, xlabel, ylabel))
pygrb_shared_plot_setups()
fig = plt.figure()
ax = fig.gca()
ax.set_xlabel(xlabel)#, fontsize=16)
ax.set_ylabel(ylabel)#, fontsize=16)
ax.plot(trig_data.longitude, trig_data.latitude, 'ko', markerfacecolor='blue')
# Wrap up
save_fig_with_metadata(fig, outfile, cmd=' '.join(sys.argv),
title=opts.plot_title, caption=opts.plot_caption)
#fig_kwds=fig_kwds,
plt.close()
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...