Permalink
Browse files

bug fixes for real-time analysis

  • Loading branch information...
1 parent ed4f2a9 commit da88e98ddc93912287b193e49b3c7e4e116f27ac @ddale ddale committed Jan 20, 2012
@@ -114,9 +114,7 @@ def _data_processed(self, data):
def process_data(self):
while not self.stopped:
with self.lock:
- if self._available_workers:
- self._available_workers -= 1
- else:
+ if not self._available_workers:
time.sleep(0.01)
continue
@@ -137,6 +135,7 @@ def process_data(self):
self.job_server.apply_async(
f, args, callback=self._data_processed
)
+ self._available_workers -= 1
#self.job_queue.append(job)
self.n_processed += 1
@@ -274,11 +274,7 @@ def getElementMap(self, mapType=None, element=None):
)
def initializeElementMaps(self, elements):
- self._results = XRFMapResultProxy(
- self.scan_data,
- elements,
- self.scan_data.entry.npoints
- )
+ self._results = XRFMapResultProxy(self.scan_data, elements)
def processAverageSpectrum(self, indices=None):
with self.scan_data:
@@ -7,13 +7,15 @@
class XRFMapResultProxy(object):
- def __init__(self, storage, elements=None, shape=None):
+ def __init__(self, storage, elements=None):
self._lock = FastRLock()
self._storage = storage
self._cache = {}
self._is_zzmesh = storage.entry.acquisition_command.startswith('zzmesh')
- if elements and shape:
+ shape = self._storage.entry.acquisition_shape
+
+ if elements:
# we are overwriting an existing result:
with self._storage:
if 'element_maps' in self._storage:
@@ -29,15 +31,15 @@ def __init__(self, storage, elements=None, shape=None):
('mass_fraction', 'MassFraction')
]:
for element in elements:
- data = np.zeros(shape, 'f')
+ data = np.zeros(np.product(shape), 'f')
entry = '%s_%s'%(element, map_type)
element_maps.create_dataset(entry, type=cls, data=data)
with self._storage:
if 'element_maps' in self._storage:
- shape = self._storage.entry.acquisition_shape
for k, v in self._storage['element_maps'].items():
- self._cache[k] = v[()].reshape(shape)
+ self._cache[k] = np.zeros(shape, 'f')
+ self._cache[k].flat[:len(v)] = v[:]
def update_fit(self, element, index, value):
with self._lock:
@@ -139,11 +139,10 @@ def on_actionImportSpecFile_triggered(self, force=False):
self.statusBar.showMessage('Converting spec data...')
#QtGui.qApp.processEvents()
from praxes.io.phynx.migration.spec import convert_to_phynx
- f = convert_to_phynx(
+ h5file = convert_to_phynx(
f, h5_filename=h5_filename, force=True, report=True
)
- f.close()
- del f
+ h5file.close()
self.statusBar.clearMessage()
self.openFile(h5_filename)
@@ -67,7 +67,7 @@ def creator(self):
@property
def file(self):
- return self
+ return File(self._h5node.file, self._lock)
@property
def file_name(self):
@@ -146,6 +146,7 @@ def _chess_escan(scan_info, *args):
def process_mca(scan, measurement, masked=None, report=False):
mca_info = scan.attrs['mca_info']
num_mca = len(mca_info)
+ npoints = measurement.entry.npoints
monitor = scan.attrs.get('monitor', None)
monitor_efficiency = scan.attrs.get('monitor_efficiency', 1)
@@ -193,7 +194,7 @@ def process_mca(scan, measurement, masked=None, report=False):
'counts',
type='Spectrum',
dtype='float32',
- shape=val.shape
+ shape=(npoints, len(channels))
)
buff = []
@@ -223,8 +224,9 @@ def process_mca(scan, measurement, masked=None, report=False):
if key == monitor:
kwargs['efficiency'] = monitor_efficiency
dset = mca.create_dataset(
- key, data=val[:], dtype='float32', **kwargs
+ key, shape=(npoints,), dtype='float32', **kwargs
)
+ dset[:len(val)] = val
if masked is not None:
mca['masked'] = masked

0 comments on commit da88e98

Please sign in to comment.