def setCatalog(self, catalog, stream, field, *args, **kwargs): self.catalog = catalog self.stream = stream self.field = field if all([self.catalog, self.stream, self.field]): eventStream = getattr(self.catalog, self.stream).to_dask()[self.field] # Trim off event dimension (so transpose works) if eventStream.ndim > 3: eventStream = eventStream[0] self.xarray = MetaXArray(eventStream) self.setImage(img=self.xarray, *args, **kwargs) else: # TODO -- clear the current image pass
def setCatalog(self, catalog, stream, field, *args, **kwargs): self.catalog = catalog self.stream = stream self.field = field if all([self.catalog, self.stream, self.field]): eventStream = getattr(self.catalog, self.stream).to_dask()[self.field] # Trim off event dimension (so transpose works) if eventStream.ndim > 3: if eventStream.shape[ 0] == 1: # if only one event, drop the event axis eventStream = eventStream[0] if eventStream.shape[ 1] == 1: # if z axis is unitary, drop that axis eventStream = eventStream[:, 0] self.xarray = MetaXArray(eventStream) self.setImage(img=self.xarray, *args, **kwargs) else: # TODO -- clear the current image pass
def _updateCatalog(self, *args, **kwargs): if all([self.catalog, self.stream, self.field]): try: stream = getattr(self.catalog, self.stream) except AttributeError as ex: msg.logError(ex) return eventStream = stream.to_dask()[self.field] # Trim off event dimension (so transpose works) if eventStream.ndim > 3: if eventStream.shape[0] == 1: # if only one event, drop the event axis eventStream = eventStream[0] if eventStream.shape[1] == 1: # if z axis is unitary, drop that axis eventStream = eventStream[:, 0] self.xarray = MetaXArray(eventStream) self.setImage(img=self.xarray, *args, **kwargs) else: # TODO -- clear the current image pass
def doReduceWorkflow(self): return if not self.reducetabview.currentWidget(): return multimode = self.reducetoolbar.multiplot.isChecked() currentItem = self.catalogModel.itemFromIndex(self.selectionmodel.currentIndex()) # FIXME -- hardcoded stream stream = "primary" data = currentItem.data(Qt.UserRole) field = self.reducetoolbar.detectorcombobox.currentText() if not field: return eventStream = getattr(currentItem.data(Qt.UserRole), stream).to_dask()[ self.reducetoolbar.detectorcombobox.currentText()] if eventStream.ndim > 3: eventStream = eventStream[0] data = MetaXArray(eventStream) if not multimode: currentwidget = self.reducetabview.currentWidget() data = [data[currentwidget.timeIndex(currentwidget.timeLine)[0]]] device = self.reducetoolbar.detectorcombobox.currentText() ai = self.calibrationsettings.AI(device) if not ai: return ai = [ai] * len(data) mask = [self.maskingworkflow.lastresult[0]['mask'].value if self.maskingworkflow.lastresult else None] * len( data) def showReduce(*results): # FIXME -- Better way to get the hints from the results parentItem = CheckableItem("Scattering Reduction") for result in results: hints = next(iter(result.items()))[-1].parent.hints for hint in hints: item = CheckableItem(hint.name) item.setData(hint, Qt.UserRole) parentItem.appendRow(item) self.derivedDataModel.appendRow(parentItem) self.reduceworkflow.execute_all(None, data=data, ai=ai, mask=mask, callback_slot=showReduce, threadkey='reduce')
def appendCatalog(self, runcatalog, **kwargs): xdata = runcatalog().primary.read( )['random_img'][:, :, :, 0] # The test data is 4-dimensional; ignoring last dim self.imageview.setImage(MetaXArray(xdata))
def appendCatalog(self, runcatalog, **kwargs): xdata = runcatalog().primary.to_dask()['fccd_image'].data[ 0, :, :, :] # The test data is 4-dimensional; ignoring last dim self.imageview.setImage(MetaXArray(xdata))