From d1c59e2a2149388dcef394ea90302088ef2e697b Mon Sep 17 00:00:00 2001 From: Peter Beaucage Date: Tue, 8 Apr 2025 16:25:21 -0400 Subject: [PATCH 1/6] change proposal_id to numeric match --- src/PyHyperScattering/SST1RSoXSDB.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PyHyperScattering/SST1RSoXSDB.py b/src/PyHyperScattering/SST1RSoXSDB.py index c0913030..61a60335 100644 --- a/src/PyHyperScattering/SST1RSoXSDB.py +++ b/src/PyHyperScattering/SST1RSoXSDB.py @@ -212,7 +212,7 @@ def searchCatalog( 'ext_bio' returns default columns AND uid, saf, user_name 'all' is equivalent to 'default' and all other additive choices cycle (str, optional): NSLS2 beamtime cycle, regex search e.g., "2022" matches "2022-2", "2022-1" - proposal (str, optional): NSLS2 PASS proposal ID, case-insensitive, exact match, e.g., "GU-310176" + proposal (int, optional): NSLS2 PASS proposal ID, numeric, exact match, e.g., 310176 saf (str, optional): Safety Approval Form (SAF) number, exact match, e.g., "309441" user (str, optional): User name, case-insensitive, regex search e.g., "eliot" matches "Eliot", "Eliot Gann" institution (str, optional): Research Institution, case-insensitive, exact match, e.g., "NIST" @@ -253,7 +253,7 @@ def searchCatalog( # Plan the 'default' search through the keyword parameters, build list of [metadata ID, user input value, match type] defaultSearchDetails = [ ["cycle", cycle, "case-insensitive"], - ["proposal_id", proposal, "case-insensitive exact"], + ["proposal_id", proposal, "numeric"], ["saf_id", saf, "case-insensitive exact"], ["user_name", user, "case-insensitive"], ["institution", institution, "case-insensitive exact"], From 35a83caa5c243dbd421c2305cabaed219597e4af Mon Sep 17 00:00:00 2001 From: Peter Beaucage Date: Tue, 8 Apr 2025 16:34:18 -0400 Subject: [PATCH 2/6] Tidy error message when catalog reduces to zero. --- src/PyHyperScattering/SST1RSoXSDB.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PyHyperScattering/SST1RSoXSDB.py b/src/PyHyperScattering/SST1RSoXSDB.py index 61a60335..bd323ff7 100644 --- a/src/PyHyperScattering/SST1RSoXSDB.py +++ b/src/PyHyperScattering/SST1RSoXSDB.py @@ -293,7 +293,7 @@ def searchCatalog( df_SearchDet.iterrows(), total=df_SearchDet.shape[0], desc="Running catalog search..." ): # Skip arguments with value None, and quits if the catalog was reduced to 0 elements - if (searchSeries[1] is not None) and (len(reducedCatalog) > 0): + if (searchSeries.iloc[1] is not None) and (len(reducedCatalog) > 0): # For numeric entries, do Key equality if "numeric" in str(searchSeries.iloc[2]): reducedCatalog = reducedCatalog.search( @@ -321,7 +321,7 @@ def searchCatalog( # If a match fails, notify the user which search parameter yielded 0 results if len(reducedCatalog) == 0: warnString = ( - f"Catalog reduced to zero when attempting to match {searchSeries}\n" + f"Catalog reduced to zero when attempting to match {str(searchSeries.iloc[0])}\n" + f"If this is a user-provided search parameter, check spelling/syntax." ) warnings.warn(warnString, stacklevel=2) From f54c9e108ce38a3e8f6bcd0cbcb934f617e1c035 Mon Sep 17 00:00:00 2001 From: Peter Beaucage Date: Tue, 8 Apr 2025 16:50:20 -0400 Subject: [PATCH 3/6] Source polarization from baseline rather than plan args --- src/PyHyperScattering/SST1RSoXSDB.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PyHyperScattering/SST1RSoXSDB.py b/src/PyHyperScattering/SST1RSoXSDB.py index bd323ff7..7469b650 100644 --- a/src/PyHyperScattering/SST1RSoXSDB.py +++ b/src/PyHyperScattering/SST1RSoXSDB.py @@ -354,7 +354,7 @@ def searchCatalog( ["bar_spot", "bar_spot", r"catalog.start", "ext_msmt"], ["plan", "plan_name", r"catalog.start", "default"], ["detector", "RSoXS_Main_DET", r"catalog.start", "default"], - ["polarization", "pol", r'catalog.start["plan_args"]', "default"], + ["polarization", "en_polarization", r'catalog.baseline["data"]', "default"], ["sample_rotation", "angle", r"catalog.start", "ext_msmt"], ["exit_status", "exit_status", r"catalog.stop", "default"], ["num_Images", "primary", r'catalog.stop["num_events"]', "default"], @@ -438,6 +438,10 @@ def searchCatalog( singleScanOutput.append( currentCatalogStop["num_events"][metaDataLabel] ) + elif metaDataSource == r'catalog.baseline["data"]': + singleScanOutput.append( + scanEntry.baseline["data"][metaDataLabel].__array__().mean() + ) else: if debugWarnings: warnings.warn( From be393f4c309326d7e73e8ba3cb3b92879e7ac966 Mon Sep 17 00:00:00 2001 From: Peter Beaucage Date: Tue, 8 Apr 2025 17:04:24 -0400 Subject: [PATCH 4/6] make polarization non-default output --- src/PyHyperScattering/SST1RSoXSDB.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PyHyperScattering/SST1RSoXSDB.py b/src/PyHyperScattering/SST1RSoXSDB.py index 7469b650..177ec57a 100644 --- a/src/PyHyperScattering/SST1RSoXSDB.py +++ b/src/PyHyperScattering/SST1RSoXSDB.py @@ -208,7 +208,7 @@ def searchCatalog( 'default' returns scan_id, start time, cycle, institution, project, sample_name, sample_id, plan name, detector, polarization, exit_status, and num_images 'scans' returns only the scan_ids (1-column dataframe) - 'ext_msmt' returns default columns AND bar_spot, sample_rotation + 'ext_msmt' returns default columns AND bar_spot, sample_rotation, polarization (_very_ slow) 'ext_bio' returns default columns AND uid, saf, user_name 'all' is equivalent to 'default' and all other additive choices cycle (str, optional): NSLS2 beamtime cycle, regex search e.g., "2022" matches "2022-2", "2022-1" @@ -354,7 +354,7 @@ def searchCatalog( ["bar_spot", "bar_spot", r"catalog.start", "ext_msmt"], ["plan", "plan_name", r"catalog.start", "default"], ["detector", "RSoXS_Main_DET", r"catalog.start", "default"], - ["polarization", "en_polarization", r'catalog.baseline["data"]', "default"], + ["polarization", "en_polarization", r'catalog.baseline["data"]', "ext_msmt"], ["sample_rotation", "angle", r"catalog.start", "ext_msmt"], ["exit_status", "exit_status", r"catalog.stop", "default"], ["num_Images", "primary", r'catalog.stop["num_events"]', "default"], From 60fe145c972edfb34d6f0a2646bb4b3f0c18494c Mon Sep 17 00:00:00 2001 From: Peter Beaucage Date: Tue, 8 Apr 2025 17:05:49 -0400 Subject: [PATCH 5/6] Remove first progress bar --- src/PyHyperScattering/SST1RSoXSDB.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/PyHyperScattering/SST1RSoXSDB.py b/src/PyHyperScattering/SST1RSoXSDB.py index 177ec57a..4bd863f3 100644 --- a/src/PyHyperScattering/SST1RSoXSDB.py +++ b/src/PyHyperScattering/SST1RSoXSDB.py @@ -289,9 +289,7 @@ def searchCatalog( # Iterate through search terms sequentially, reducing the size of the catalog based on successful matches reducedCatalog = bsCatalog - for _, searchSeries in tqdm( - df_SearchDet.iterrows(), total=df_SearchDet.shape[0], desc="Running catalog search..." - ): + for _, searchSeries in df_SearchDet.iterrows(): # Skip arguments with value None, and quits if the catalog was reduced to 0 elements if (searchSeries.iloc[1] is not None) and (len(reducedCatalog) > 0): # For numeric entries, do Key equality From b450e03f188b5bf57b6afd2d19dd273cae3216e3 Mon Sep 17 00:00:00 2001 From: Peter Beaucage Date: Tue, 8 Apr 2025 17:13:13 -0400 Subject: [PATCH 6/6] better error message --- src/PyHyperScattering/SST1RSoXSDB.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PyHyperScattering/SST1RSoXSDB.py b/src/PyHyperScattering/SST1RSoXSDB.py index 4bd863f3..1a62cfcf 100644 --- a/src/PyHyperScattering/SST1RSoXSDB.py +++ b/src/PyHyperScattering/SST1RSoXSDB.py @@ -319,7 +319,7 @@ def searchCatalog( # If a match fails, notify the user which search parameter yielded 0 results if len(reducedCatalog) == 0: warnString = ( - f"Catalog reduced to zero when attempting to match {str(searchSeries.iloc[0])}\n" + f"No results found when searching {str(searchSeries.iloc[0])}. " + f"If this is a user-provided search parameter, check spelling/syntax." ) warnings.warn(warnString, stacklevel=2)