Skip to content

Commit

Permalink
FIX: loading of corrupt files at TES
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgav committed Feb 13, 2024
1 parent 5fbe646 commit 4a3ac38
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ exclude =
pyxrf/_version.py,
docs/conf.py
# There are some errors produced by 'black', therefore unavoidable
ignore = E203, W503
ignore = E203, W503, E701, E704
max-line-length = 115
2 changes: 1 addition & 1 deletion pyxrf/core/tests/test_quant_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"name": "Test Micromatter 411640",
"serial": "411640",
"description": "CeF3 21.1 / Au 20.6",
"compounds": {"CeF3": 21.1, "Au": 20.6}
"compounds": {"CeF3": 21.1, "Au": 20.6},
# Missing optional 'density' field
},
]
Expand Down
3 changes: 1 addition & 2 deletions pyxrf/gui_module/wnd_detailed_fitting_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ def _validate_all(self):
self.pb_cancel.setEnabled(self._data_changed and not self._auto_update)
self.cb_auto_update.setChecked(Qt.Checked if self._auto_update else Qt.Unchecked)

def _load_dialog_data(self):
...
def _load_dialog_data(self): ...

def _save_dialog_data_function(self):
raise NotImplementedError()
Expand Down
3 changes: 2 additions & 1 deletion pyxrf/model/catalog_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ def set_name(self, name):
def get_catalog(catalog_name):
from packaging import version
import databroker

db_version_major = version.parse(databroker.__version__).major == 1
if db_version_major == 1:
raise ValueError("Non-tiled version of Databroker is installed")

from tiled.client import from_uri

c = from_uri("https://tiled.nsls2.bnl.gov")
Expand Down
9 changes: 4 additions & 5 deletions pyxrf/model/load_data_from_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2804,7 +2804,10 @@ def _get_row_len(row_data):
filler = Filler(db.reg.handler_reg, inplace=True)
docs_primary = hdr.documents("primary", fill=False)

m, n_pt_max, missing_rows = 0, -1, [] # m - index
# Assume that the number of positions reflect the size of the row
n_pt_max = pos_data.shape[2]

m, missing_rows = 0, [] # m - index
try:
while True:
try:
Expand All @@ -2823,10 +2826,6 @@ def _get_row_len(row_data):
if is_filled:
data = doc["data"][detector_field]
data_det1 = np.array(data[:, 0, :], dtype=np.float32)

# The following is the fix for the case when data has corrupt row (smaller number of data points).
# It will not work if the first row is corrupt.
n_pt_max = max(data_det1.shape[0], n_pt_max)
data_det1_adjusted = np.zeros([n_pt_max, data_det1.shape[1]])
data_det1_adjusted[: data_det1.shape[0], :] = data_det1

Expand Down

0 comments on commit 4a3ac38

Please sign in to comment.