Commit acd50c73 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

ignore encoding errors in nexus

parent aca5d247
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -149,16 +149,24 @@ def get_run_info(nxsfile):
    res = {}
    res['base']     = base
    res['filename'] = nxsfile.filename
    res['time']     = nxsfile['/entry/start_time'][0].decode('ascii')
    res['title']    = nxsfile['/entry/title'][0].decode('ascii')
    res['notes']    = nxsfile['/entry/notes'][0].decode('ascii')
    res['time']     = nxsfile['/entry/start_time'][0].decode('ascii', errors='ignore')
    res['title']    = nxsfile['/entry/title'][0].decode('ascii', errors='ignore')
    res['notes']    = nxsfile['/entry/notes'][0].decode('ascii', errors='ignore')
    res['duration'] = nxsfile['/entry/duration'][0]
    res['total_counts']  = nxsfile['/entry/total_counts'][0]
    res['proton_charge'] = nxsfile['/entry/proton_charge'][0]
    res['experiment'] = nxsfile['/entry/experiment_title'][0].decode('ascii')
    res['ipts']       = nxsfile['/entry/experiment_identifier'][0].decode('ascii')
    res['samplename'] = nxsfile['/entry/sample/name'][0].decode('ascii')
    res['experiment'] = nxsfile['/entry/experiment_title'][0].decode('ascii', errors='ignore')
    res['ipts']       = nxsfile['/entry/experiment_identifier'][0].decode('ascii', errors='ignore')
    try:
        res['samplename'] = nxsfile['/entry/sample/name'][0].decode('ascii', errors='ignore')
    except KeyError:
        log.warning("*** %s: cannot find nexus key /entry/sample/name", base)
        res['samplename'] = 'unknown'
    try:
        res['sampleid']   = nxsfile['/entry/sample/identifier'][0]
    except KeyError:
        log.warning("*** %s: cannot find nexus key /entry/sample/identifier", base)
        res['sampleid']   = -1

    log.info("%s: %s, duration=%.1f min", base, res['time'], res['duration']/60)
    log.info("%s: %s %s", base, res['title'], res['notes'])
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ def get_hdf_filetype(filename):
        with h5py.File(filename, 'r') as nxsfile:
            try:
                notes   = nxsfile['/entry/notes']
                notes   = bytes(notes[0]).decode('ascii').lower()
                notes   = bytes(notes[0]).decode('ascii', erorrs='ingore').lower()
                ftype    = "application/nexus-nse-unknown"
                if 'scan=transmission' in notes:
                    ftype = "application/nexus-nse-transmission"
+2 −2
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@
PySEN revision module
"""
import sys
__version__  = "2.1.0.dev5"
__date__     = "Feb 23, 2026"
__version__  = "2.1.0.dev6"
__date__     = "Mar 6, 2026"

def version(full=False):
    "get pysen version number"