Skip to content

Commit

Permalink
Merge 930a791 into a801697
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex L. Urban committed Apr 7, 2019
2 parents a801697 + 930a791 commit 89e96e3
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gwdetchar/lasso/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with GW DetChar. If not, see <http://www.gnu.org/licenses/>.

"""Tests for :mod:`gwdetchar.omega`
"""Tests for :mod:`gwdetchar.lasso`
"""

__author__ = 'Alex Urban <alexander.urban@ligo.org>'
30 changes: 30 additions & 0 deletions gwdetchar/scattering/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# coding=utf-8
# Copyright (C) Alex Urban (2019)
#
# This file is part of the GW DetChar python package.
#
# GW DetChar 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.
#
# GW DetChar 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 GW DetChar. If not, see <http://www.gnu.org/licenses/>.

"""Methods and utilties for optical scattering
"""

__author__ = 'Alex Urban <alexander.urban@ligo.org>'
__credits__ = 'Duncan Macleod <duncan.macleod@ligo.org>' \
'Joshua Smith <joshua.smith@ligo.org>' \
'Andrew Lundgren <andrew.lundgren>@ligo.org>'

# -- imports ------------------------------------------------------------------

# import scattering utils
from .core import *
100 changes: 100 additions & 0 deletions gwdetchar/scattering/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# coding=utf-8
# Copyright (C) Alex Urban (2019)
#
# This file is part of the GW DetChar python package.
#
# GW DetChar 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.
#
# GW DetChar 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 GW DetChar. If not, see <http://www.gnu.org/licenses/>.

"""Simple command-line interface to gwdetchar.scattering
"""

import os
import sys
import numpy

from matplotlib import (use, rcParams)
use('agg') # noqa

from gwpy.time import to_gps

from .. import (cli, const)
from ..omega import highpass
from ..io.datafind import get_data
from . import *

__author__ = 'Alex Urban <alexander.urban@ligo.org>'
__credits__ = 'Joshua Smith <joshua.smith@ligo.org>' \
'Andrew Lundgren <andrew.lundgren>@ligo.org>' \
'Duncan Macleod <duncan.macleod@ligo.org>'

ASD_KW = {
'method': 'median',
'fftlength': 8,
'overlap': 4,
}

logger = cli.logger('gwdetchar.scattering')


def main(args=None):
"""Parse command-line arguments, process optics, and write plots
"""
# define command-line arguments
parser = cli.create_parser(description=__doc__)
parser.add_argument('gpstime', type=to_gps,
help='GPS time or datestring to analyze')
cli.add_ifo_option(parser, ifo=const.IFO)
parser.add_argument('-d', '--duration', type=float, default=60,
help='Duration (seconds) of analysis, default: 60')
parser.add_argument('-f', '--frequency-threshold', type=float, default=15,
help='critical fringe frequency threshold (Hz), '
'default: %(default)s')
parser.add_argument('-w', '--witness-channel',
default='GDS-CALIB_STRAIN',
help='name of witness channel (without IFO prefix), '
'default: %(default)s')
parser.add_argument('-W', '--witness-frametype', default='{IFO}_HOFT_C00',
help='frametype from which to read witness channel, '
'default: %(default)s')
parser.add_argument('-o', '--output-dir', type=os.path.abspath,
default=os.curdir,
help='Output directory for analysis, '
'default: %(default)s')
parser.add_argument('-p', '--plot-spectrogram', action='store_true',
help='Include plot of a high-resolution spectrogram, '
'default: False')

# parse arguments
args = parser.parse_args(args)
ifo = args.ifo
gps = float(args.gpstime)
gpsstart = gps - 0.5 * args.duration
gpsend = gps + 0.5 * args.duration
witness = ':'.join([ifo, args.witness_channel])
thresh = args.frequency_threshold
logger.info('{0} Scattering: {1}'.format(ifo, gps))

# set up spectrogram
if args.plot_spectrogram:
logger.debug('Setting up a spectrogram of {}'.format(witness))
hoft = get_data(witness, start=gpsstart-2, end=gpsend+2,
frametype=args.witness_frametype.format(IFO=ifo),
verbose='Reading witness channel:'.rjust(30))
hoft = highpass(hoft, f_low=thresh)
qspecgram = hoft.q_transform(qrange=(4, 150), gps=gps, logf=True,
outseg=(gpsstart, gpsend), **ASD_KW)


if __name__ == "__main__": # pragma: no-cover
sys.exit(main())
File renamed without changes.
22 changes: 22 additions & 0 deletions gwdetchar/scattering/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# coding=utf-8
# Copyright (C) Alex Urban (2019)
#
# This file is part of the GW DetChar python package.
#
# GW DetChar 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.
#
# GW DetChar 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 GW DetChar. If not, see <http://www.gnu.org/licenses/>.

"""Tests for :mod:`gwdetchar.scattering`
"""

__author__ = 'Alex Urban <alexander.urban@ligo.org>'
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from gwpy.timeseries import TimeSeries

from .. import scattering
from .. import core

__author__ = 'Alex Urban <alexander.urban@ligo.org>'

Expand All @@ -40,7 +40,7 @@

def test_get_fringe_frequency():
# calculate the fringe frequency
fringef = scattering.get_fringe_frequency(OPTIC, multiplier=1)
fringef = core.get_fringe_frequency(OPTIC, multiplier=1)
assert str(fringef.unit) == 'Hz'
assert fringef.sample_rate.value == OPTIC.sample_rate.value
assert fringef.size == OPTIC.size - 1
Expand Down

0 comments on commit 89e96e3

Please sign in to comment.