Skip to content
Snippets Groups Projects
Commit 90036974 authored by Jameson Graef Rollins's avatar Jameson Graef Rollins
Browse files

move to python3

parent 1f516c88
No related branches found
No related tags found
No related merge requests found
......@@ -47,7 +47,7 @@ exec {} -m locklost.{} "$@" 2>&1
sys.executable,
module,
))
os.chmod(path, 0755)
os.chmod(path, '0755')
class CondorSubmit(object):
......
......@@ -414,19 +414,19 @@ def find_events(**kwargs):
"""
for event in _generate_all_events():
if kwargs.has_key('after') and event.gps < kwargs['after']:
if 'after' in kwargs and event.gps < kwargs['after']:
# events generated in reverse chronological order, so we
# can just break at the first event before the requested
# search range
break
if kwargs.has_key('before') and event.gps > kwargs['before']:
if 'before' in kwargs and event.gps > kwargs['before']:
continue
if kwargs.has_key('state') and event.transition_index[0] != kwargs['state']:
if 'state' in kwargs and event.transition_index[0] != kwargs['state']:
continue
if kwargs.has_key('tag') and kwargs['tag'] not in event.list_tags():
if 'tag' in kwargs and kwargs['tag'] not in event.list_tags():
continue
yield event
......@@ -86,19 +86,19 @@ def plot_history(path, lookback='7 days ago', draw_segs=False):
# plot failed lock losses
escatter(
filter(lambda e: not e.analysis_succeeded, events),
[e for e in events if not e.analysis_succeeded],
s=100, color='red',
)
# plot non-observe lock losses
escatter(
filter(lambda e: e.analysis_succeeded and not e.has_tag('OBSERVE'), events),
[e for e in events if e.analysis_succeeded and not e.has_tag('OBSERVE')],
s=100, color='blue',
)
# plot observe lock losses (stars)
escatter(
filter(lambda e: e.analysis_succeeded and e.has_tag('OBSERVE'), events),
[e for e in events if e.analysis_succeeded and e.has_tag('OBSERVE')],
s=200, marker='*', color='green',
)
......
......@@ -22,7 +22,7 @@ def check_brs(event):
mod_window = [config.BRS_SEARCH_WINDOW[0], config.BRS_SEARCH_WINDOW[1]]
segment = Segment(mod_window).shift(int(event.gps))
for endstation, channel_names in config.BRS_CHANNELS.iteritems():
for endstation, channel_names in config.BRS_CHANNELS.items():
brs_channels = data.fetch(channel_names, segment)
glitch_count = 0
......
......@@ -11,7 +11,7 @@ from matplotlib import cm
from matplotlib import pyplot as plt
from matplotlib import rcParamsDefault
from matplotlib.colors import ListedColormap
from mpl_toolkits.axes_grid import make_axes_locatable
from mpl_toolkits.axes_grid1 import make_axes_locatable
from gwpy.segments import Segment, SegmentList
......
......@@ -46,7 +46,7 @@ def find_saturations(event):
reduced_data = buf.data/(saturation_threshold)
relative_datasets.append(reduced_data)
srate = buf.sample_rate
early_thresh = shift*srate
early_thresh = int(shift*srate)
if any(abs(reduced_data[:early_thresh]) >= 0.9):
problem_area = np.where(abs(reduced_data[:early_thresh]) >= 0.9)[0]
logging.info('Early saturation detected at index: '+str(problem_area[0]))
......@@ -166,7 +166,7 @@ def find_saturations(event):
#saves saturating channel names/times to lockloss directory
outfile_csv = 'saturations.csv'
outpath_csv = event.gen_path(outfile_csv)
with open(outpath_csv, 'wb') as myfile:
with open(outpath_csv, 'wt') as myfile:
for i in saturations:
myfile.write('%s %f\n' % (i[0], i[1]))
......
......@@ -5,7 +5,7 @@ import bottle
from .. import config
from ..event import LocklossEvent, find_events
from . import templates, utils
from . import utils
##################################################
......
......@@ -16,11 +16,11 @@ def query_to_dict(query):
}
out_query = {}
for key in filter_val.keys():
if query.has_key(key) and query[key]:
if key in query and query[key]:
out_query[key] = filter_val[key](query[key])
# limit events shown if date range hasn't been specified
if not (query.has_key('after') and query.has_key('before')) \
and not query.has_key('limit'):
if not ('after' in query and 'before' in query) \
and not 'limit' in query:
out_query['limit'] = config.QUERY_DEFAULT_SHOW
return out_query
......
#!/bin/bash -ex
PYTHON=python3
export IFO
case $IFO in
......@@ -28,9 +30,9 @@ export LOCKLOST_EVENT_ROOT=$(mktemp -d)
export LOCKLOST_WEB_ROOT=https://ldas-jobs.ligo.caltech.edu/~lockloss
# trap "rm -rf $LOCKLOST_EVENT_ROOT" EXIT
python -m locklost search "$START" "$END"
$PYTHON -m locklost search "$START" "$END"
python -m locklost compress
$PYTHON -m locklost compress
nsegs=$(ls -1 "${LOCKLOST_EVENT_ROOT}/.segments" | wc | awk '{print $1}')
test $nsegs -eq 1
......@@ -39,19 +41,19 @@ SSTART=$(printf %0.0f $(gpstime -g "$START"))
SEND=$(printf %0.0f $(gpstime -g "$END"))
test -e "${LOCKLOST_EVENT_ROOT}/.segments/${SSTART}-${SEND}"
python -m locklost list
$PYTHON -m locklost list
nevents=$(python -m locklost list | wc | awk '{print $1}')
nevents=$($PYTHON -m locklost list | wc | awk '{print $1}')
test $nevents -eq $NEVENTS
python -m locklost analyze $EVENT
$PYTHON -m locklost analyze $EVENT
python -m locklost show $EVENT
$PYTHON -m locklost show $EVENT
REQUEST_METHOD=GET python -m locklost.web
REQUEST_METHOD=GET $PYTHON -m locklost.web >/dev/null
REQUEST_METHOD=GET QUERY_STRING=event=$EVENT python -m locklost.web
REQUEST_METHOD=GET QUERY_STRING=event=$EVENT $PYTHON -m locklost.web >/dev/null
REQUEST_METHOD=GET QUERY_STRING=format=json python -m locklost.web | tail -n +5 | json_verify
REQUEST_METHOD=GET QUERY_STRING=format=json $PYTHON -m locklost.web | tail -n +5 | json_verify
rm -rf "$LOCKLOST_EVENT_ROOT"
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