From edcf83fe6261d52a1b407136632ab2f7a43d94e2 Mon Sep 17 00:00:00 2001 From: Jameson Graef Rollins <jrollins@finestructure.net> Date: Thu, 22 Mar 2018 16:09:08 -0700 Subject: [PATCH] show available included IFOs in CLI help --- gwinc/__main__.py | 10 ++++++++-- gwinc/ifo/__init__.py | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gwinc/__main__.py b/gwinc/__main__.py index 8a13612..f40b8c4 100644 --- a/gwinc/__main__.py +++ b/gwinc/__main__.py @@ -7,13 +7,19 @@ from IPython.terminal.embed import InteractiveShellEmbed import logging logging.basicConfig(level=logging.INFO) -from . import load_ifo +from .ifo import available_ifos, load_ifo from . import plot_noise ################################################## -description = """Plot GWINC noise budget for specified IFO +description = """Plot GWINC noise budget for specified IFO. +Available included IFOs: {} + +""".format(', '.join(["'{}'".format(ifo) for ifo in available_ifos()])) +# for ifo in available_ifos(): +# description += " '{}'\n".format(ifo) +description += """ If the inspiral_range package is installed, various figures of merit can be calculated for the resultant spectrum with the --fom argument, e.g.: diff --git a/gwinc/ifo/__init__.py b/gwinc/ifo/__init__.py index 29429f3..91932a5 100644 --- a/gwinc/ifo/__init__.py +++ b/gwinc/ifo/__init__.py @@ -1,5 +1,6 @@ import os import re +import fnmatch import yaml import scipy import scipy.io @@ -208,6 +209,14 @@ class Struct(object): raise IOError("Unknown file type: {}".format(ext)) +def available_ifos(): + """List available included IFO files""" + ifos = [] + for f in os.listdir(os.path.dirname(__file__)): + if fnmatch.fnmatch(f, '*.yaml'): + ifos.append(f.split('.')[0]) + return ifos + def load_ifo(name_or_path): """Load IFO by name or from file. -- GitLab