Skip to content

Commit

Permalink
NeXuS Handling Fix 1 / ??? (#449)
Browse files Browse the repository at this point in the history
* Check for existence of key values before trying to read them.

* Format.

* More (gee this is fun).

* Apply suggestions from code review

Co-authored-by: Noella Spitz <[email protected]>

* Apply suggestions from code review

Co-authored-by: Noella Spitz <[email protected]>

* not in.

---------

Co-authored-by: Noella Spitz <[email protected]>
  • Loading branch information
trisyoungs and rhinoella authored Sep 20, 2023
1 parent ea30ef5 commit 0a553db
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions gudpy/gui/widgets/dialogs/nexus_processing_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,35 @@ def initComponents(self):
)
) as fp:

spectra = fp["/raw_data_1/detector_1/spectrum_index"][()][
:
].tolist()
if "/raw_data_1/detector_1/spectrum_index" in fp:
spectra = fp["/raw_data_1/detector_1/spectrum_index"][()][
:
].tolist()
else:
spectra = [0]
self.widget.lowerSpecSpinBox.setRange(min(spectra), max(spectra))
self.widget.upperSpecSpinBox.setRange(min(spectra), max(spectra))

start = fp["/raw_data_1/start_time"][()][0].decode("utf8")
end = fp["/raw_data_1/end_time"][()][0].decode("utf8")
start = (
datetime.strptime(start, "%Y-%m-%dT%H:%M:%S")
datetime.today()
if "/raw_data_1/start_time" not in fp
else datetime.strptime(
fp["/raw_data_1/start_time"][()][0].decode("utf8"),
"%Y-%m-%dT%H:%M:%S",
)
)
end = (
datetime.strptime(end, "%Y-%m-%dT%H:%M:%S")
datetime.today()
if "/raw_data_1/end_time" not in fp
else datetime.strptime(
fp["/raw_data_1/end_time"][()][0].decode("utf8"),
"%Y-%m-%dT%H:%M:%S",
)
)
self.start = QDateTime.fromString(
start.isoformat(), Qt.ISODateWithMs
)
self.end = QDateTime.fromString(
end.isoformat(), Qt.ISODateWithMs
)
self.end = QDateTime.fromString(end.isoformat(), Qt.ISODateWithMs)

self.widget.lowerSpecSpinBox.setValue(min(spectra))
self.widget.upperSpecSpinBox.setValue(max(spectra))
Expand Down

0 comments on commit 0a553db

Please sign in to comment.