Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions gwsumm/plot/sei.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""

import re
from configparser import NoOptionError
from configparser import NoSectionError, NoOptionError

from matplotlib.pyplot import subplots
from matplotlib.ticker import NullLocator
Expand All @@ -45,9 +45,9 @@ def __init__(self, gpstime, chamber, sensor, config, outfile, ifo=None,
duration=30, nds=False, datacache=None):
"""Configure a new `SeiWatchDogPlot`.
"""
super(SeiWatchDogPlot, self).__init__([],
int(gpstime) - duration/2.,
int(gpstime) + duration/2.)
super().__init__(
[], int(gpstime) - duration/2., int(gpstime) + duration/2.,
)

# get params
if ifo is None:
Expand All @@ -59,27 +59,31 @@ def __init__(self, gpstime, chamber, sensor, config, outfile, ifo=None,
self.duration = duration
self.outputfile = outfile
self.use_nds = nds
try:
self.host = config.get('datafind', 'server')
except (NoSectionError, NoOptionError):
self.host = None

system = (sensor.split(' ')[0] == 'HEPI' and
'HPI' or sensor.split(' ')[0])

# get channels
mapsec = 'sei-wd-map-%s' % sensor
mapsec = f'sei-wd-map-{sensor}'
if not config.has_section(mapsec) and re.match(r'ISI ST\d ', sensor):
mapsec = ('sei-wd-map-%s'
% (' '.join(sensor.split(' ', 2)[::2])))
mapsec = (
"sei-wd-map-"
f"{' '.join(sensor.split(' ', 2)[::2])}"
)
stubs = list(zip(*sorted(
[o for o in config.items(mapsec) if o[0].isdigit()],
key=lambda x: x[0],
)))[1]
if re.search(r'ISI ST\d ', sensor):
stage = sensor.split(' ')[1]
channels = [get_channel('%s:%s-%s_%s_%s'
% (ifo, system, chamber, stage, stub))
channels = [get_channel(f'{ifo}:{system}-{chamber}_{stage}_{stub}')
for stub in stubs]
else:
channels = [get_channel('%s:%s-%s_%s'
% (ifo, system, chamber, stub))
channels = [get_channel(f'{ifo}:{system}-{chamber}_{stub}')
for stub in stubs]

# set types
Expand All @@ -98,7 +102,7 @@ def __init__(self, gpstime, chamber, sensor, config, outfile, ifo=None,
raise ValueError("Geometry does not match number of channels.")

try:
self.unit = '[%s]' % re_quote.sub('', config.get(mapsec, 'unit'))
self.unit = f"[{re_quote.sub('', config.get(mapsec, 'unit'))}]"
except NoOptionError:
self.unit = ''

Expand All @@ -121,8 +125,11 @@ def draw(self):
data = TimeSeriesDict.fetch(self.chanlist, start, end)
else:
from gwdatafind import find_urls
cache = find_urls(self.ifo[0], f'{self.ifo}_R',
self.start, self.end, urltype='file')
cache = find_urls(
self.ifo[0], f'{self.ifo}_R',
self.start, self.end, urltype='file',
host=self.host,
)
if len(cache) == 0:
data = {}
else:
Expand Down
Loading