Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gwpy workarounds #11

Open
wants to merge 73 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
53f2f33
Temporary workaround until the copy=True key works.
mikelovskij Sep 10, 2015
e916bb5
Workaround to avoid errors when the interval is not integer.
mikelovskij Sep 16, 2015
9e3768f
Workaround due to the missing copy of the epoch during the calculatio…
mikelovskij Sep 16, 2015
8aaed3e
added Shivaraj's spectrogram monitor
mikelovskij Sep 17, 2015
3e8a0f1
Cleaned some imports and updated the spectrum derivation from the spe…
mikelovskij Sep 18, 2015
9bb373e
Removed the root-squaring and the subsequent squaring of the evaluate…
mikelovskij Sep 18, 2015
ad21332
Re-added the root-squaring and the subsequent squaring, because in th…
mikelovskij Sep 18, 2015
374cd71
removed the bns range monitor from the master branch
mikelovskij Sep 18, 2015
e65159d
Merge pull request #4 from mikelovskij/master
mikelovskij Sep 18, 2015
105a8bd
Added logging of the channel names in case there is some error in suc…
mikelovskij Sep 21, 2015
cf7dc7b
first attempt in rewriting the reference spectra loading
mikelovskij Sep 21, 2015
103e5df
Merge pull request #1 from mikelovskij/reference_load_fix_develop
mikelovskij Sep 21, 2015
ec511cc
removed a comment
mikelovskij Sep 21, 2015
65ecc5f
corrected a typo
mikelovskij Sep 21, 2015
1fcb6eb
corrected another typo
mikelovskij Sep 22, 2015
2a37480
simplified the spectrum reading
mikelovskij Sep 22, 2015
59bbc47
reverted an unwanted change on the filtering of the spectrum
mikelovskij Sep 22, 2015
e0e1677
First attempt of handling some of the exceptions recieved when the nd…
mikelovskij Sep 22, 2015
5104e68
Updated the usage of the self._references dictionary also in the pars…
mikelovskij Sep 23, 2015
eece077
Merge branch 'reference_load_fix_develop' into nds_fail_handling_develop
mikelovskij Sep 23, 2015
7e96f21
It seems that it is not necessary to add the \ before the underscores…
mikelovskij Sep 25, 2015
e242a12
By increasing the default interval to two seconds, the de-syncronizat…
mikelovskij Sep 25, 2015
e4a18fd
If the buffer skips some data, it now warns the user that that data w…
mikelovskij Sep 30, 2015
f980f1c
Minor edits to follow the 79 line length convention
mikelovskij Sep 30, 2015
b8fab7f
Heavy changes in the nds iterator and buffer in order to allow reques…
mikelovskij Sep 30, 2015
cae96ed
Corrected a typo
mikelovskij Oct 1, 2015
effe18f
Solved the epoch issues happening when the epoch at the initializatio…
mikelovskij Oct 1, 2015
a9af487
Removed unnecessary imports
mikelovskij Oct 1, 2015
2ebb47b
Solved the issue happening sometimes during the first n cycles due to…
mikelovskij Oct 2, 2015
6a1125b
Added timing of the reconnection attempts, in order to make it slower…
mikelovskij Oct 2, 2015
7f9e4c0
Added 'basestring' instance recognition in order to correctly apply m…
mikelovskij Oct 2, 2015
7fe1587
Rewritten a debug message
mikelovskij Oct 2, 2015
3a4e6ea
Minor code cleaning performed, in order to remove excessively long co…
mikelovskij Oct 6, 2015
acfbb22
More minor code cleaning
mikelovskij Oct 6, 2015
9ea4ab1
Merge branch 'reference_load_fix_develop' into nds_fail_handling_develop
mikelovskij Oct 6, 2015
a121bcf
removed unused dependency
mikelovskij Oct 7, 2015
f3c59b5
- corrected the check that is performed during the replotting to deci…
mikelovskij Oct 8, 2015
14f444a
- Changed the string formatting method for the strings passed to the …
mikelovskij Oct 9, 2015
96986a0
Added 'attempts' as the various buffargs so that the maximum number o…
mikelovskij Oct 9, 2015
3b4cad7
Reordered some lines
mikelovskij Oct 9, 2015
ee67649
Reordered one more line
mikelovskij Oct 9, 2015
e2d8d4d
Corrected bugs generated by the reordering of the lines
mikelovskij Oct 9, 2015
13a1192
-Improved error handling in case of discontinuity or overlap between …
mikelovskij Oct 9, 2015
6aa443b
- Removed unused variable
mikelovskij Oct 9, 2015
12c3c60
- Rewritten a comment
mikelovskij Oct 9, 2015
9bf229c
- Solved an issue happening when resetting the nds buffer because of …
mikelovskij Oct 9, 2015
72c5598
- Renamed the "filter" variable to "filters" for more consistency wit…
mikelovskij Oct 9, 2015
7d24478
- Added .copy() otherwise the data in the dictionary couldn't be appe…
mikelovskij Oct 9, 2015
8e4566a
- Try to pass the string arguments directly to the logger
mikelovskij Oct 9, 2015
ec92ae9
- Added the handling of one more exception of the .append method.
mikelovskij Oct 9, 2015
9f9ef5d
Merge pull request #5 from mikelovskij/reference_load_fix_develop
Oct 9, 2015
7afd929
Merge pull request #4 from mikelovskij/reference_load_fix_develop
mikelovskij Oct 9, 2015
d2467c6
Merge pull request #6 from mikelovskij/nds_fail_handling_develop
Oct 9, 2015
8642a3f
Merge branch 'nds_fail_handling_develop'
mikelovskij Oct 12, 2015
936fc21
Increased the waiting time between one reconnection attempt and the n…
mikelovskij Oct 13, 2015
3181848
- Added xscale and yscale to the axes params so that is is possible t…
mikelovskij Oct 13, 2015
8667d88
- Corrected a typo in a warning message.
mikelovskij Oct 13, 2015
13bc671
- Removed unused dependency
mikelovskij Oct 13, 2015
4b62c99
- Added the setting of the spectrogram buffer logger during the initi…
mikelovskij Oct 13, 2015
8bda11d
- corrected a bug in the load of the combinations
mikelovskij Oct 13, 2015
20a68e4
Updated the removal of repeated titles and xaxes in the spectrogram m…
mikelovskij Oct 13, 2015
c406db4
Solved an issue created when a channel parameter was not set in one o…
mikelovskij Oct 13, 2015
b2d2d04
Fixed the removal of repeated titles and xlabels in the spectrum moni…
mikelovskij Oct 14, 2015
53d1ee2
Really- solved a Bug that happened when using references and multiple…
mikelovskij Oct 14, 2015
99ac081
- Added the fake invisible colorbar to all axes when there are multip…
mikelovskij Oct 14, 2015
9ee6403
- Added the fake invisible colorbar to all axes when there are multip…
mikelovskij Oct 14, 2015
20caecd
- Added conversion to int before making the comparison between alreay…
mikelovskij Oct 14, 2015
2d7eb1b
- Removed the subtitle and suptitle parameters since they cannot be s…
mikelovskij Oct 14, 2015
1ee6ec5
- This allows the usage of tuples as parameters in some more cases.
mikelovskij Oct 15, 2015
1f567e5
typo
mikelovskij Oct 15, 2015
8f11f61
Removed the parameter 'linesize', since it does not seem to exist in …
mikelovskij Oct 15, 2015
bfeb2d7
Added the setting of the buffer logger
mikelovskij Oct 15, 2015
2ed7895
Merge pull request #7 from mikelovskij/various_fixes
Oct 20, 2015
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
5 changes: 5 additions & 0 deletions bin/gwdv
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ if args.no_latex:

mon = from_ini(args.configuration)
mon.logger.setLevel(args.verbose)
try: # todo: put all the logger of all the monitors to the level?
mon.buffer.logger.setLevel(args.verbose)
mon.spectrograms.logger.setLevel(args.verbose)
except AttributeError:
pass
try:
if args.back_fill:
mon.backfill()
Expand Down
2 changes: 0 additions & 2 deletions dataviewer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
"""GWDV: The gravitational-wave data viewer
"""

import nds2

from . import version

__author__ = 'Duncan Macleod <[email protected]>'
Expand Down
78 changes: 37 additions & 41 deletions dataviewer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def from_ini(filepath, ifo=None):
basics = dict(cp.items('monitor', raw=True))
type_ = basics.pop('type')
channels = map(str, ChannelList.from_names(basics.pop('channels', '')))
references = basics.pop('references', None)
combinations = basics.pop('combinations', None)
basics = dict((key, safe_eval(val)) for (key, val) in basics.iteritems())
# get type
Expand All @@ -149,9 +148,9 @@ def from_ini(filepath, ifo=None):
if not channels:
channels = [c for c in sections if c not in ['monitor', 'plot']
if c[:4] not in ['ref:', 'com:']]
if references is None:
references = [c for c in sections if c not in ['monitor', 'plot']
if c[:4] == 'ref:']

references = [c for c in sections if c not in ['monitor', 'plot']
if c[:4] == 'ref:']
if combinations is None:
combinations = [c for c in sections if c not in ['monitor', 'plot']
if c[:4] == 'com:']
Expand All @@ -171,49 +170,46 @@ def from_ini(filepath, ifo=None):
val = safe_eval(val)
if param not in cparams:
cparams[param] = []
while len(cparams[param]) < i:
while len(cparams[param]) < len(channels):
cparams[param].append(None)
cparams[param].append(val)
cparams[param][i] = val


# get reference parameters
# reference parameters will be sent to the monitor in a dictionary
# with the path of each reference as keys and with the name and the other
# parameters as a dictionary for each key

rparams = OrderedDict()
for reference in references:
if os.path.basename(reference[4:]) == '':
# Section is a directory:
# get parameters (will be applied to all refrences)
_params = cp.items(reference)
rparamsi = OrderedDict()
for param, val in _params:
val = safe_eval(val)
if param == 'format':
refform = val
else:
rparamsi[param] = val
# import all references in folder (assumes 'dat' format)
refdir = reference[4:]
for f in os.listdir(refdir):
if os.path.splitext(f)[1] in ['.txt', '.dat', '.gz']:
refspec = Spectrum.read(refdir + f)
refspec.name = f.split('.')[0].replace('_', r' ')
rparams[refspec] = rparamsi
else:
# get rerference section
_params = cp.items(reference)
refpath = reference[4:]
refform = 'txt'
deflabel = os.path.basename(refpath).split('.')[0]
rparamsi = OrderedDict([('label', deflabel)])
for param, val in _params:
val = safe_eval(val)
if param == 'path':
refpath = val
elif param == 'format':
refform = val
rparamsi = OrderedDict([('name', reference[4:])])
for param, val in cp.items(reference):
val = safe_eval(val)
if param == 'path':
refpath = val
else:
rparamsi[param] = val
try:
if os.path.isdir(refpath):
# Section is a directory:
# import all references in folder (assumes 'dat' format)
for f in os.listdir(refpath):
if os.path.splitext(f)[1] in ['.txt', '.dat', '.gz']:
refpath += f
rparamsi.setdefault(
'label', os.path.basename(refpath).split('.')
[0].replace('_', r' '))
rparams[refpath] = rparamsi

else:
rparamsi[param] = val
# load curve
refspec = Spectrum.read(refpath, format=refform)
rparams[refspec] = rparamsi
rparamsi.setdefault(
'label', os.path.basename(refpath).split('.')[0]
.replace('_', r' '))
rparams[refpath] = rparamsi
except NameError:
raise ValueError('Cannot load reference {0} plot if no '
'parameter "path" is defined'
.format(reference))

# get combination parameters # IN PROGRESS
combparams = OrderedDict()
Expand Down
39 changes: 28 additions & 11 deletions dataviewer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@
# fixed parameters
PARAMS = {}
PARAMS['figure'] = ['figsize']
PARAMS['init'] = ['title', 'subtitle', 'xlabel', 'ylabel', 'xscale', 'yscale',
'suptitle']
PARAMS['draw'] = ['marker', 'linestyle', 'linewidth', 'linesize', 'markersize',
PARAMS['init'] = ['title', 'xlabel', 'ylabel', 'xscale', 'yscale']
PARAMS['draw'] = ['marker', 'linestyle', 'linewidth', 'markersize',
'color', 'alpha', 'norm', 'vmin', 'vmax', 'cmap']
PARAMS['refresh'] = ['xlim', 'ylim']
PARAMS['legend'] = ['bbox_to_anchor', 'loc', 'borderaxespad', 'ncol']
PARAMS['colorbar'] = ['log', 'clim', 'label']

FIGURE_PARAMS = ['title', 'subtitle']
AXES_PARAMS = ['xlim', 'ylim', 'xlabel', 'ylabel']
FIGURE_PARAMS = ['title']
AXES_PARAMS = ['xlim', 'ylim', 'xlabel', 'ylabel', 'xscale', 'yscale']



Expand All @@ -70,7 +69,7 @@ class Monitor(TimedAnimation):
# -------------------------------------------------------------------------
# Initialise the figure

def __init__(self, fig=None, interval=1, blit=True, repeat=False,
def __init__(self, fig=None, interval=2, blit=True, repeat=False,
logger=Logger('monitor'), figname=None, save_every=1,
tight_bbox=False, pause=False, clock=False, **kwargs):
self.logger = logger
Expand All @@ -85,7 +84,7 @@ def __init__(self, fig=None, interval=1, blit=True, repeat=False,
fig = self.init_figure()
# generate monitor
self.interval = interval
super(Monitor, self).__init__(fig, interval=int(interval * 1000),
super(Monitor, self).__init__(fig, interval=int(100),
blit=blit, repeat=repeat, **kwargs)

self.figname = figname
Expand Down Expand Up @@ -243,16 +242,34 @@ def set_params(self, action):
if not isinstance(val, (list, tuple)):
val = [val] * len(self._fig.axes)
for ax, v in izip_longest(self._fig.axes, val):
getattr(ax, 'set_%s' % key)(v)
try:
getattr(ax, 'set_%s' % key)(v)
except ValueError as e:
if 'too many values to unpack' in e:
getattr(ax, 'set_%s' % key)(*v)
else:
raise
elif key in AXES_PARAMS:
if not (isinstance(val, (list, tuple)) and
isinstance(val[0], (list, tuple))):
isinstance(val[0], (list, tuple, basestring))):
val = [val] * len(self._fig.axes)
for ax, v in zip(self._fig.axes, val):
getattr(ax, 'set_%s' % key)(v)
try:
getattr(ax, 'set_%s' % key)(v)
except ValueError as e:
if 'too many values to unpack' in e:
getattr(ax, 'set_%s' % key)(*v)
else:
raise
else:
for ax in self._fig.axes:
getattr(ax, 'set_%s' % key)(val)
try:
getattr(ax, 'set_%s' % key)(val)
except ValueError as e:
if 'too many values to unpack' in e:
getattr(ax, 'set_%s' % key)(*val)
else:
raise

# -------------------------------------------------------------------------
# Event connections
Expand Down
2 changes: 1 addition & 1 deletion dataviewer/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, *channels, **kwargs):

# separate keyword arguments
buffkeys = ['host', 'port', 'connection', 'interval', 'duration', 'pad',
'gap']
'gap', 'attempts']
buffargs = {'logger': kwargs.get('logger')}
for key in buffkeys:
if key in kwargs:
Expand Down
Loading