diff --git a/gwinc/__init__.py b/gwinc/__init__.py index efa72a1cd02b15dd4279a56261d7668d79a3e054..d528c5a47496c3876ac1d0b9581db16ee2dc9065 100644 --- a/gwinc/__init__.py +++ b/gwinc/__init__.py @@ -4,7 +4,7 @@ import logging import importlib import numpy as np -from .ifo import available_ifos +from .ifo import IFOS from .struct import Struct from .plot import plot_noise from .io import load_hdf5, save_hdf5 @@ -37,9 +37,9 @@ def load_budget(name_or_path): """Load GWINC IFO Budget by name or from path. Named IFOs should correspond to one of the IFOs available in the - gwinc package (see gwinc.available_ifos()). If a path is provided - it should either be a budget package (directory) or module (ending - in .py), or an IFO struct definition (see gwinc.Struct). + gwinc package (see gwinc.IFOS). If a path is provided it should + either be a budget package (directory) or module (ending in .py), + or an IFO struct definition (see gwinc.Struct). If a budget package path is provided, and the package includes an 'ifo.yaml' file, that file will be loaded into a Struct and @@ -71,10 +71,10 @@ def load_budget(name_or_path): logging.info("loading module path {}...".format(modname)) else: - if name_or_path not in available_ifos(): + if name_or_path not in IFOS: raise RuntimeError("Unknonw IFO '{}' (available IFOs: {}).".format( name_or_path, - available_ifos(), + IFOS, )) bname = name_or_path modname = 'gwinc.ifo.'+name_or_path diff --git a/gwinc/__main__.py b/gwinc/__main__.py index beb810e52a1ddbd781f3e9e50e77dfefb95ff5f7..72573767ebe7acbd0b3dd18fca9a90bf428e089c 100644 --- a/gwinc/__main__.py +++ b/gwinc/__main__.py @@ -9,7 +9,7 @@ import logging logging.basicConfig(format='%(message)s', level=os.getenv('LOG_LEVEL', logging.INFO)) -from . import available_ifos, load_budget, plot_noise +from . import IFOS, load_budget, plot_noise from . import io ################################################## @@ -18,7 +18,7 @@ description = """Plot GWINC noise budget for specified IFO. Available included IFOs: {} -""".format(', '.join(["'{}'".format(ifo) for ifo in available_ifos()])) +""".format(', '.join(["'{}'".format(ifo) for ifo in IFOS])) # for ifo in available_ifos(): # description += " '{}'\n".format(ifo) description += """ diff --git a/gwinc/ifo/__init__.py b/gwinc/ifo/__init__.py index 0c5b6ff1cf6f8d4b2cb2df42dd1ce68c4f30d868..281a5a05c1b5df45234b97a0439bfa6caa837949 100644 --- a/gwinc/ifo/__init__.py +++ b/gwinc/ifo/__init__.py @@ -1,6 +1,14 @@ import os +IFOS = [ + 'aLIGO', + 'Aplus', + 'Voyager', + 'CE1', + 'CE2', +] + PLOT_STYLE = dict( ylabel=u"Strain [1/\u221AHz]", ) @@ -18,15 +26,3 @@ def lpath(file0, file1): """ return os.path.abspath(os.path.join(os.path.dirname(file0), file1)) - - -def available_ifos(): - """List available included pre-defined IFOs - - """ - ifos = [] - root = os.path.dirname(__file__) - for f in os.listdir(root): - if os.path.isdir(os.path.join(root, f)) and f[0] != '_': - ifos.append(f) - return sorted(ifos) diff --git a/gwinc/plot.py b/gwinc/plot.py index 1b70bdce953925f908c77003255382ef5e64a3d4..a22abe008fb69f01b116685fdb79f431b01899f7 100644 --- a/gwinc/plot.py +++ b/gwinc/plot.py @@ -1,6 +1,7 @@ from numpy import sqrt from collections import OrderedDict + def plot_noise( freq, traces, diff --git a/gwinc/test/__main__.py b/gwinc/test/__main__.py index 41c684f492244b56ab83b9143f2c36fe9cca3b3b..83fc338fd6bb9d33910f5bbdde89bda97a678802 100644 --- a/gwinc/test/__main__.py +++ b/gwinc/test/__main__.py @@ -14,7 +14,7 @@ from PyPDF2 import PdfFileReader, PdfFileWriter logging.basicConfig(format='%(message)s', level=os.getenv('LOG_LEVEL', logging.INFO)) -from .. import available_ifos, load_budget +from .. import IFOS, load_budget from .. import load_hdf5, save_hdf5 try: