Skip to content

Commit

Permalink
Revert "72 sst1rsoxsdb and sst1rsoxsloader warn on saturation and war…
Browse files Browse the repository at this point in the history
…n on underexposure"
  • Loading branch information
pbeaucage authored Sep 4, 2024
1 parent 0f2f903 commit 464e822
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 49 deletions.
48 changes: 6 additions & 42 deletions src/PyHyperScattering/SST1RSoXSDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,17 +609,17 @@ def loadRun(
else:
axes_to_include = []
rsd_cutoff = 0.005

# begin with a list of the things that are primary streams
axis_list = list(run["primary"]["data"].keys())

# next, knock out anything that has 'image', 'fullframe' in it - these aren't axes
axis_list = [x for x in axis_list if "image" not in x]
axis_list = [x for x in axis_list if "fullframe" not in x]
axis_list = [x for x in axis_list if "stats" not in x]
axis_list = [x for x in axis_list if "saturated" not in x]
axis_list = [x for x in axis_list if "under_exposed" not in x]

# knock out any known names of scalar counters
axis_list = [x for x in axis_list if "Beamstop" not in x]
axis_list = [x for x in axis_list if "Current" not in x]
Expand All @@ -638,10 +638,10 @@ def loadRun(
rsd = 0
else:
rsd = std / motion
# print(f'Evaluating {axis} for inclusion as a dimension with rsd {rsd}...')
#print(f'Evaluating {axis} for inclusion as a dimension with rsd {rsd}...')
if rsd > rsd_cutoff:
axes_to_include.append(axis)
# print(f' --> it was included')
#print(f' --> it was included')

# next, construct the reverse lookup table - best mapping we can make of key to pyhyper word
# we start with the lookup table used by loadMd()
Expand Down Expand Up @@ -697,7 +697,7 @@ def loadRun(
data = run["primary"]["data"].read()[md["detector"] + "_image"]
elif isinstance(data,tiled.client.array.DaskArrayClient):
data = run["primary"]["data"].read()[md["detector"] + "_image"]

data = data.astype(int) # convert from uint to handle dark subtraction

if self.dark_subtract:
Expand Down Expand Up @@ -1085,46 +1085,10 @@ def loadMd(self, run):
md[phs] = None
md["epoch"] = md["meas_time"].timestamp()

# looking at exposure tests in the stream and issuing warnings
if "Wide Angle CCD Detector_under_exposed" in md:
if np.any(md["Wide Angle CCD Detector_under_exposed"]):
message = "\nWide Angle CCD Detector is reported as underexposed\n"
message += "at one or more energies per definitions here:\n"
message += "https://github.com/NSLS-II-SST/rsoxs/blob/10c2c41b695c1db552f62decdde571472b71d981/rsoxs/Base/detectors.py#L110-L119\n"
if np.all(md["Wide Angle CCD Detector_under_exposed"]):
message += "Wide Angle CCD Detector is reported as underexposed at all energies."
else:
idx = np.where(md["Wide Angle CCD Detector_under_exposed"])
warning_e = md["energy"][idx]
message += f"Affected energies include: \n{warning_e}"
warnings.warn(message, stacklevel=2)
else:
warnings.warn(
"'Wide Angle CCD Detector_under_exposed' not found in stream."
)
if "Wide Angle CCD Detector_saturated" in md:
if np.any(md["Wide Angle CCD Detector_saturated"]):
message = "\nWide Angle CCD Detector is reported as saturated\n"
message += "at one or more energies per definitions here:\n"
message += "https://github.com/NSLS-II-SST/rsoxs/blob/10c2c41b695c1db552f62decdde571472b71d981/rsoxs/Base/detectors.py#L110-L119\n"
if np.all(md["Wide Angle CCD Detector_saturated"]):
message += "\tWide Angle CCD Detector is reported as saturated at all energies."
else:
idx = np.where(md["Wide Angle CCD Detector_saturated"])
warning_e = md["energy"][idx]
message += f"Affected energies include: \n{warning_e}"
warnings.warn(message, stacklevel=2)
else:
warnings.warn(
"'Wide Angle CCD Detector_saturated' not found in stream."
)
md["epoch"] = md["meas_time"].timestamp()

try:
md["wavelength"] = 1.239842e-6 / md["energy"]
except TypeError:
md["wavelength"] = None

md["sampleid"] = start["scan_id"]

md["dist"] = md["sdd"] / 1000
Expand Down
7 changes: 0 additions & 7 deletions tests/test_SST1DBLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,3 @@ def test_SST1DB_load_snake_scan_explicit_dims(sstdb):
assert type(run) == xr.DataArray
assert 'sam_th' in run.indexes
assert 'polarization' in run.indexes

@must_have_tiled
def test_SST1DB_exposurewarnings(sstdb):
with pytest.warns(UserWarning, match="Wide Angle CCD Detector is reported as underexposed"):
sstdb.loadRun(83192)
with pytest.warns(UserWarning, match="Wide Angle CCD Detector is reported as saturated"):
sstdb.loadRun(67522)

0 comments on commit 464e822

Please sign in to comment.