Skip to content

Gracefully handle errors when scan file is no longer valid #7

@padraic-shafer

Description

@padraic-shafer

Issue

When an input scan file is modified after the scan is run, the data file can no longer rely on the scan file for recreating its scan parameters. There is no robust way to track when the scan file is no longer consistent with data file, until an error is found by comparing their contents.

In addition to logical errors (mismatched values or columns),als.bcs.scans.import_scan_file() and als.bcs.scans.get_scan_line_numbers() can raise exceptions when the following are true:

  • The scan file has been modified
  • There are more data files (file_number) than there are "file" commands in the scan file
  • If there are multiple blank lines after a "file" command, als.bcs.scans.import_scan_file() will import an empty dataframe when it should have ignored the blank lines
    • Symptom: "AttributeError: float has no attribute strip..."
  • If there is one or blank line (or none) after a "file" command, als.bcs.scans.import_scan_file() will fail trying to read the empty line when it should have ignored the blank line
    • Symptom: "EmptyDataError: 'No columns to parse...'"

Background

The scan parameters can be recreated from the data file values, but some assumptions must be made about:

  • The motors that were controlled
  • The precision of the values that were requested
  • The number of scan lines that correspond to the data file (for flying scans).

Recommendations

  • Should probably verify that data file output matches scan file input; the fallback response could be to infer values from the data file (possibly using the scan file motor names)
  • Should gracefully report that data file number exceeds the bounds of the scan file outputs
  • Raise an IndexError (or a subclass) instead of AttributeError or EmptyDataError; include message "data file number exceeds the bounds of the scan file outputs"
  • Should ignore blank lines when parsing scan file; treat them as comment lines
    • BCS appears to ignore them when running a scan

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions