Skip to content

Commit

Permalink
Do not set matplotlib's backend in internal modules
Browse files Browse the repository at this point in the history
  • Loading branch information
titodalcanton committed Dec 20, 2023
1 parent dab3943 commit f62aeec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions bin/pycbc_make_skymap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import logging
import subprocess
import tempfile
import shutil

# we will make plots on a likely headless machine, so make sure matplotlib's
# backend is set appropriately
from matplotlib import use as mpl_use_backend
mpl_use_backend('agg')

import numpy as np
import h5py
import pycbc
Expand Down
15 changes: 12 additions & 3 deletions bin/pycbc_optimize_snr
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
"""Followup utility to optimize the SNR of a PyCBC Live trigger."""

import os
import argparse, numpy, h5py
import argparse
import logging

# we will make plots on a likely headless machine, so make sure matplotlib's
# backend is set appropriately
from matplotlib import use as mpl_use_backend
mpl_use_backend('agg')

import numpy
import h5py
import pycbc
from pycbc import (
fft, scheme, version
)
from pycbc.types import MultiDetOptionAction, load_frequencyseries
import pycbc.conversions as cv
from pycbc.io import live
from pycbc.io.live import CandidateForGraceDB
from pycbc.io.hdf import load_hdf5_to_dict
from pycbc.detector import Detector
from pycbc.psd import interpolate
from pycbc.live import snr_optimizer


parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--version', action='version',
version=version.git_verbose_msg)
Expand Down Expand Up @@ -325,7 +334,7 @@ if 'p_terr' in fp:
kwargs['p_terr'] = fp['p_terr'][()]

# Treat all ifos as having triggers
doc = live.CandidateForGraceDB(
doc = CandidateForGraceDB(
ifos,
ifos,
coinc_results,
Expand Down
2 changes: 0 additions & 2 deletions pycbc/io/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ def upload(self, fname, gracedb_server=None, testing=True,
labels: list
Optional list of labels to tag the new event with.
"""
import matplotlib
matplotlib.use('Agg')
import pylab as pl

if fname.endswith('.xml.gz'):
Expand Down

0 comments on commit f62aeec

Please sign in to comment.