From c94550223c2fce40920c532a0ef75d8ffa8dfb5e Mon Sep 17 00:00:00 2001 From: Dylan McReynolds Date: Wed, 27 May 2020 09:23:00 -0700 Subject: [PATCH 1/2] Switch to Bluesky Utils --- xicam/catalog_viewer/__init__.py | 35 ++------------------------------ 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/xicam/catalog_viewer/__init__.py b/xicam/catalog_viewer/__init__.py index c00391e..2d78e04 100644 --- a/xicam/catalog_viewer/__init__.py +++ b/xicam/catalog_viewer/__init__.py @@ -4,7 +4,7 @@ from xicam.gui.widgets.imageviewmixins import XArrayView, CatalogView, StreamSelector, FieldSelector import logging from xicam.core import msg - +from xicam.core.data.bluesky_utils import get_all_image_fields # log = logging.getLogger('catalog_viewer') @@ -28,7 +28,7 @@ def __init__(self): def appendCatalog(self, run_catalog, **kwargs): try: self.stream_fields = get_all_image_fields(run_catalog) - stream_names = get_all_streams(run_catalog) + stream_names = list(run_catalog) msg.showMessage(f"Loading primary image for {run_catalog.name}") # try and startup with primary catalog and whatever fields it has @@ -41,36 +41,5 @@ def appendCatalog(self, run_catalog, **kwargs): msg.logError(e) msg.showMessage("Unable to display: ", str(e)) - -### small helper functions -def get_stream_data_keys(run_catalog, stream): - return run_catalog[stream].metadata["descriptors"][0]["data_keys"] - - -def get_all_streams(run_catalog): - return list(run_catalog) - - -def get_all_image_fields(run_catalog): - # image_fields = [] - all_streams_image_fields = {} - for stream in get_all_streams(run_catalog): - stream_fields = get_stream_data_keys(run_catalog, stream) - field_names = stream_fields.keys() - for field_name in field_names: - field_shape = len(stream_fields[field_name]["shape"]) - if field_shape > 1 and field_shape < 5: - # if field contains at least 1 entry that is at least one-dimensional (shape=2) - # or 2-dimensional (shape=3) or up to 3-dimensional (shape=4) - # then add field e.g. 'fccd_image' - if stream in all_streams_image_fields.keys(): # add values to stream dict key - all_streams_image_fields[stream].append(field_name) - else: # if stream does not already exist in dict -> create new entry - all_streams_image_fields[stream] = [field_name] - # TODO how to treat non image data fields in streams - # else: - return all_streams_image_fields - - # Problem: primary image field does not show up anymore... # Problem: primary image field does not show up anymore... From ccffd750a70a4ba7ac1ebb9190bf16cc4b6fe70e Mon Sep 17 00:00:00 2001 From: Dylan McReynolds Date: Thu, 28 May 2020 14:20:41 -0700 Subject: [PATCH 2/2] Cleanup of imports --- xicam/catalog_viewer/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/xicam/catalog_viewer/__init__.py b/xicam/catalog_viewer/__init__.py index 40ae42c..346bb70 100644 --- a/xicam/catalog_viewer/__init__.py +++ b/xicam/catalog_viewer/__init__.py @@ -29,4 +29,3 @@ def appendCatalog(self, run_catalog, **kwargs): except Exception as e: msg.logError(e) msg.showMessage("Unable to display: ", str(e)) -s \ No newline at end of file