Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions LMA/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
>>> current_events_flashes.targets.add(energy_spectrum_plotter.inlet)

"""
from __future__ import absolute_import
import numpy as np
from stormdrain.pipeline import coroutine
from stormdrain.support.matplotlib.artistupdaters import LineArtistUpdater
Expand Down
18 changes: 10 additions & 8 deletions LMA/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
understood by the lmatools package.

"""
from __future__ import absolute_import
from __future__ import print_function
import numpy as np

from lmatools.flashsort.autosort.LMAarrayFile import LMAdataFile
from lmatools.io.LMAarrayFile import LMAdataFile

from stormdrain.bounds import Bounds, BoundsFilter
from stormdrain.data import NamedArrayDataset, indexed
Expand Down Expand Up @@ -101,7 +103,7 @@ def flash_stat_printer(self, min_points=10):
good = (fl['n_points'] >= min_points)
N_good = len(fl[good])
area = np.mean(fl['area'][good])
print template.format(N_good, N, area, min_points)
print(template.format(N_good, N, area, min_points))

def flash_stats_for_dataset(self, d, selection_broadcaster):

Expand Down Expand Up @@ -163,20 +165,20 @@ def read_hdf5(self, LMAfileHDF):
try:
import tables
except ImportError:
print "couldn't import pytables"
print("couldn't import pytables")
return None
from hdf5_lma import HDF5Dataset
from .hdf5_lma import HDF5Dataset

# get the HDF5 table name
LMAh5 = tables.openFile(LMAfileHDF, 'r')
table_names = LMAh5.root.events._v_children.keys()
LMAh5 = tables.open_file(LMAfileHDF, 'r')
table_names = list(LMAh5.root.events._v_children.keys())
table_path = '/events/' + table_names[0]
LMAh5.close()
d = HDF5Dataset(LMAfileHDF, table_path=table_path, mode='a')
self.datasets.add(d)

if d.flash_table is not None:
print "found flash data"
print("found flash data")

return d

Expand All @@ -196,7 +198,7 @@ def load_hdf5_to_panels(self, panels, LMAfileHDF, scatter_kwargs={}):
def load_hdf5_flashes_to_panels(self, panels, hdf5dataset, min_points=10):
""" Set up a flash dataset display. The sole argument is usually the HDF5
LMA dataset returned by a call to self.load_hdf5_to_panels """
from hdf5_lma import HDF5FlashDataset
from .hdf5_lma import HDF5FlashDataset
if hdf5dataset.flash_table is not None:
point_count_dtype = hdf5dataset.flash_data['n_points'].dtype
self.bounds.n_points = (min_points, np.iinfo(point_count_dtype))
Expand Down
13 changes: 8 additions & 5 deletions LMA/hdf5_lma.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from __future__ import absolute_import
from __future__ import print_function
import tables

from stormdrain.pipeline import coroutine
from stormdrain.pubsub import get_exchange
from six.moves import zip

class HDF5FlashDataset(object):
""" Provides an pipeline source for the flash table part of an HDF5Dataset"""
Expand All @@ -19,19 +22,19 @@ class HDF5Dataset(object):
def __init__(self, h5filename, table_path=None, target=None, mode='r'):
self.target = target

self.h5file = tables.openFile(h5filename, mode=mode)
self.table = self.h5file.getNode(table_path)
self.h5file = tables.open_file(h5filename, mode=mode)
self.table = self.h5file.get_node(table_path)
self.data = self.table[:]

get_exchange('SD_reflow_start').attach(self)

flash_table_path = table_path.replace('events', 'flashes')
try:
self.flash_table = self.h5file.getNode(flash_table_path)
self.flash_table = self.h5file.get_node(flash_table_path)
self.flash_data = self.flash_table[:]
except tables.NoSuchNodeError:
self.flash_table = None
print "Did not find flash data at {0}".format(flash_table_path)
print("Did not find flash data at {0}".format(flash_table_path))


def update_h5(self, colname, coldata, row_ids):
Expand Down Expand Up @@ -65,7 +68,7 @@ def update(self, index_name="hdf_row_idx", field_names=None):
else:
# update everything
self.data[indices] = a
print "Did not update HDF5 file"
print("Did not update HDF5 file")


def send(self, msg):
Expand Down
1 change: 1 addition & 0 deletions LMA/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

"""

from __future__ import absolute_import
from datetime import datetime
import threading
from collections import deque
Expand Down
Loading