Skip to content
Snippets Groups Projects
Commit cf5943a3 authored by Sebastian Steinlechner's avatar Sebastian Steinlechner
Browse files

fixed cmdline ignoring default freq spec

parent e340abb2
No related branches found
No related tags found
1 merge request!133Fix cmdline ignoring default freq spec
......@@ -27,6 +27,8 @@ logger = logging.getLogger('gwinc')
DEFAULT_FREQ = '5:3000:6000'
class InvalidFrequencySpec(Exception):
pass
def freq_from_spec(spec=None):
"""logarithmicly spaced frequency array, based on specification string
......@@ -41,13 +43,16 @@ def freq_from_spec(spec=None):
elif spec is None:
spec = DEFAULT_FREQ
fspec = spec.split(':')
if len(fspec) == 2:
fspec = fspec[0], DEFAULT_FREQ.split(':')[1], fspec[1]
return np.logspace(
np.log10(float(fspec[0])),
np.log10(float(fspec[2])),
int(fspec[1]),
)
try:
if len(fspec) == 2:
fspec = fspec[0], DEFAULT_FREQ.split(':')[1], fspec[1]
return np.logspace(
np.log10(float(fspec[0])),
np.log10(float(fspec[2])),
int(fspec[1]),
)
except (ValueError, IndexError):
raise InvalidFrequencySpec(f'Improper frequency specification: {spec}')
def load_module(name_or_path):
......
......@@ -8,7 +8,7 @@ from . import (
__version__,
IFOS,
DEFAULT_FREQ,
freq_from_spec,
InvalidFrequencySpec,
load_budget,
logger,
)
......@@ -58,7 +58,6 @@ See the inspiral_range package documentation for details.
"""
IFO = 'aLIGO'
FREQ = '5:3000:6000'
RANGE_PARAMS = dict(m1=1.4, m2=1.4)
DATA_SAVE_FORMATS = ['.hdf5', '.h5']
......@@ -142,11 +141,9 @@ def main():
else:
try:
freq = freq_from_spec(args.freq)
except IndexError:
parser.error(f"Improper frequency specification: {args.freq}")
try:
budget = load_budget(args.IFO, freq=freq, bname=args.bname)
budget = load_budget(args.IFO, freq=args.freq, bname=args.bname)
except InvalidFrequencySpec as e:
parser.error(e)
except RuntimeError as e:
parser.exit(2, f"Error: {e}\n")
name = budget.name
......@@ -258,7 +255,7 @@ def main():
if not trace:
logger.info("calculating budget...")
trace = budget.run(freq=freq)
trace = budget.run()
if args.range:
logger.info("calculating inspiral ranges...")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment