Commit 5981b046 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

nxs detimage

parent a565fcb6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -432,6 +432,7 @@ ignored-parents=

# Maximum number of arguments for function / method.
max-args=7
max-positional-arguments=7

# Maximum number of attributes for a class (see R0902).
max-attributes=7
+5 −0
Original line number Diff line number Diff line
@@ -53,6 +53,11 @@ NTCHAN = 42 # default number of TOF channels
#dx   = XDET/NXCHAN # 30.0/32=0.009375 # m
#dy   = YDET/NYCHAN # 30.0/32=0.009375 # m

# NEW TDC-ROC
TDC_SHIFT  =    10       # x,y shift
TDC_MAXCH  = 0x3FF       # max channel
TDC_MAXPIX = TDC_MAXCH+1 # number of pixels

# 4. Instrument resolution, modes
H_FAC  = sqrt(log(2.0)/2.0)
H_RES  = 0.7   # [A^2/ns] - resolution coefficient
+2 −1
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@ MU_0 = _const.mu_0
ANGSTROM   = _const.angstrom # Angstrom in meters
GAUSS      = 1e-04 # Gauss-> Tesla
#
MICRO      = _const.micro # mu - micro prefix
MILLI      = _const.milli # m  - milli prefix (1e-3)
MICRO      = _const.micro # mu - micro prefix (1e-6)
NANO       = _const.nano
PICO       = _const.pico
#
+21 −19
Original line number Diff line number Diff line
@@ -25,11 +25,10 @@ import datetime as dtm
import numpy as np
import h5py

from pysen import MICRO, ANGSTROM, tof2lambda
from pysen.config import Ltot
from .. import MICRO, ANGSTROM, tof2lambda
from ..config import Ltot, TDC_SHIFT, TDC_MAXCH

TDC_SHIFT =    10
TDC_MAXCH = 0x3FF
from .utils import get_nsefiletype

# FIXME (hard coded detector geometry)
X0_PIX    =   516 # center pixel
@@ -87,7 +86,7 @@ def get_run_info(nxsfile):

    res = {}
    res['base'] = base
    res['time']     = time_format(nxsfile['/entry/start_time'][0].decode('ascii'))
    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['duration'] = nxsfile['/entry/duration'][0]
@@ -269,11 +268,15 @@ def process_nexus_scan(filename, **kwargs):
def process_nexus_plain(filename, **kwargs):
    "process nexus file (scan indices)"
    scan_type    = kwargs.pop('scan_type', None)
    data         = kwargs.pop('data', None)
    #
    log     = logging.getLogger('nexus')
    base    = os.path.basename(filename)
    nxsfile = h5py.File(filename, 'r')
    info, data = None, None
    with h5py.File(filename, 'r') as nxsfile:
    #
        filetype = get_nsefiletype(filename)
        if filetype is None or 'nexus-nse' not in filetype:
            raise RuntimeError(f"{filename} is not a NSE/NeXuS file ({filetype})")
        # get file info
        info    = get_run_info(nxsfile)
        if scan_type and scan_type not in info.get('notes','').lower():
@@ -282,8 +285,7 @@ def process_nexus_plain(filename, **kwargs):
        if info['proton_charge']<=0.0:
            log.warning("%s: empty run (pcharge=%g)", base, info['proton_charge'])
            return None
    if data is not None:
        res = process_events(nxsfile['entry/bank1_events'], timevalue_array(nxsfile, 'proton_charge'), info['mo_l'])
        data.update(res)
    return info
        data = process_events(nxsfile['entry/bank1_events'],
                timevalue_array(nxsfile, 'proton_charge'), info['mo_l'])
    return info, data
# EOF
+2 −2
Original line number Diff line number Diff line
@@ -38,8 +38,8 @@ def main():
            continue
        file_type = get_nsefiletype(file_name)
        writer_class = { 'application/nexus-nse-echo'     : EchoWriter,
                         'application/nexus-diffraction'  : DiffractionWriter,
                         'application/nexus-transmission' : TransmissionWriter,
                         'application/nexus-nse-diffraction'  : DiffractionWriter,
                         'application/nexus-nse-transmission' : TransmissionWriter,
                        }.get(file_type, None)
        if not isinstance(writer_class, type):
            log.warning("file '%s' unknown file type %s", file_name, file_type)
Loading