Loading pysen/config.py +12 −1 Original line number Diff line number Diff line Loading @@ -94,7 +94,18 @@ ATTENUATOR_TABLE_11A = { 'Pos_7' : 15.4, 'Pos_8' : 53.8, 'Pos_9' : 42.1, 'Pos19' : 71.8, } 'Pos10' : 71.8, } def get_attenuator_pos(attenuator_angle): "for new DAQ (EPICS)" moatt = int(round(attenuator_angle)) moatt = ((moatt + 330) % 360 )//30 -1 if moatt==-1: return 'CLOSED' if moatt==0: return 'OPEN' return f"Pos_{moatt:d}" # Loading pysen/inout/__init__.py +2 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ from .hdf import HdfConverter, convert_to_hdf # NOQA from .reader import ( read_echo, read_magnetic, read_xyz, # NOQA read_detimage, read_datfile, read_diffrun, # NOQA read_datreat , read_transmission ) # NOQA from .writer import EchoWriter, make_echofilename # NOQA from .scans import EchoScan, XYZScan # NOQA from .writer import EchoWriter, DiffractionWriter # NOQA from .scans import EchoScan, DiffractionScan, XYZScan # NOQA # from .legacy_writer import write_csv, generate_echo # NOQA # from .legacy_history import extract_data, list_variables, parse_date # NOQA pysen/inout/nexus.py +1 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,7 @@ def process_nexus(filename, **kwargs): values = { 'i00' : timevalue_array(nxsfile, 'BL15:Bruker:ReadOutCurrent'), 'phase': timevalue_array(nxsfile, 'BL15:CAENELS5:ActualCurrent'), 'qmin' : timevalue_array(nxsfile, 'BL15:Mot:Qmin'), } for bsens in ('sample', 'encl1', 'encl2', 'ext1','ext2', 'ext3','ext4','ext5'): values['b_'+bsens] = timevalue_array(nxsfile, f"BL15:PLC:Mag:{bsens}") Loading pysen/inout/nxs2echo.py +8 −7 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ import os.path import logging import argparse from pysen.inout import EchoWriter, make_echofilename from pysen.inout import EchoWriter def main(): "the main" Loading @@ -27,7 +27,6 @@ def main(): const=logging.DEBUG, help='increase verbosity level') parser.add_argument('--quiet' , '-q', dest='loglevel', action='store_const', const=logging.WARNING, help='suppress info messages') args = parser.parse_args() Loading @@ -38,12 +37,14 @@ def main(): if not os.path.exists(file_name): log.warning("file '%s' does not exist", file_name) continue echo = EchoWriter(make_echofilename(file_name)) if not echo.read_nexus(file_name, npix=args.npix, ntof=args.ntof, phase_step=args.step): continue echo.to_echo(args.outdir) writer = EchoWriter() #writer = DiffractionWriter() if not writer.read_nexus(file_name, npix=args.npix, ntof=args.ntof, phase_step=args.step): continue writer.save(outdir=args.outdir) if __name__ == "__main__": main() #EOF pysen/inout/scans.py +38 −3 Original line number Diff line number Diff line Loading @@ -31,7 +31,10 @@ class BaseScan: self.info = None def phasepoint_callback(self, _data, **_kwargs): "phase point callback" """phase point callback _data is a dictionary of results (float, ndarray) for a given phase point """ return True def read_nexus(self, nxsfile, **kwargs): Loading Loading @@ -59,11 +62,40 @@ class BaseScan: return True class DiffractionScan(BaseScan): """Read SNS-NSE EPICS/NeXus diffraction scan file """ def phasepoint_callback(self, data, **kwargs): """phase point callback data is a dictionary of results (float, ndarray) for a given phase point """ filename = kwargs.get('filename', '<unset>') begin = kwargs.get('begin') indx = begin['value'] rate = 0.0 if data['pcharge']>0: rate = data['neutron'].shape[1]/data['pcharge']*1e12 self.data.setdefault(indx, data) self.log.debug("%s: processing %s, pc=%.5f, rate=%10.1f", filename, indx, data['pcharge']*1e-12, rate) return True def read_nexus(self, nxsfile, **kwargs): """read nexus file""" return super().read_nexus(nxsfile, scan_type='diffraction', **kwargs) class EchoScan(BaseScan): """Read SNS-NSE EPICS/NeXus echo scan file""" def phasepoint_callback(self, data, **kwargs): "phase point callback" """phase point callback data is a dictionary of results (float, ndarray) for a given phase point """ filename = kwargs.get('filename', '<unset>') begin = kwargs.get('begin') end = kwargs.get('end') Loading Loading @@ -165,7 +197,10 @@ class XYZScan(BaseScan): 31: 'x_dn',} def phasepoint_callback(self, data, **kwargs): "phase point callback" """phase point callback data is a dictionary of results (float, ndarray) for a given phase point """ filename = kwargs.get('filename', '<unset>') begin = kwargs.get('begin') xyz = self.XYZ_MAP.get(begin['value']) Loading Loading
pysen/config.py +12 −1 Original line number Diff line number Diff line Loading @@ -94,7 +94,18 @@ ATTENUATOR_TABLE_11A = { 'Pos_7' : 15.4, 'Pos_8' : 53.8, 'Pos_9' : 42.1, 'Pos19' : 71.8, } 'Pos10' : 71.8, } def get_attenuator_pos(attenuator_angle): "for new DAQ (EPICS)" moatt = int(round(attenuator_angle)) moatt = ((moatt + 330) % 360 )//30 -1 if moatt==-1: return 'CLOSED' if moatt==0: return 'OPEN' return f"Pos_{moatt:d}" # Loading
pysen/inout/__init__.py +2 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ from .hdf import HdfConverter, convert_to_hdf # NOQA from .reader import ( read_echo, read_magnetic, read_xyz, # NOQA read_detimage, read_datfile, read_diffrun, # NOQA read_datreat , read_transmission ) # NOQA from .writer import EchoWriter, make_echofilename # NOQA from .scans import EchoScan, XYZScan # NOQA from .writer import EchoWriter, DiffractionWriter # NOQA from .scans import EchoScan, DiffractionScan, XYZScan # NOQA # from .legacy_writer import write_csv, generate_echo # NOQA # from .legacy_history import extract_data, list_variables, parse_date # NOQA
pysen/inout/nexus.py +1 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,7 @@ def process_nexus(filename, **kwargs): values = { 'i00' : timevalue_array(nxsfile, 'BL15:Bruker:ReadOutCurrent'), 'phase': timevalue_array(nxsfile, 'BL15:CAENELS5:ActualCurrent'), 'qmin' : timevalue_array(nxsfile, 'BL15:Mot:Qmin'), } for bsens in ('sample', 'encl1', 'encl2', 'ext1','ext2', 'ext3','ext4','ext5'): values['b_'+bsens] = timevalue_array(nxsfile, f"BL15:PLC:Mag:{bsens}") Loading
pysen/inout/nxs2echo.py +8 −7 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ import os.path import logging import argparse from pysen.inout import EchoWriter, make_echofilename from pysen.inout import EchoWriter def main(): "the main" Loading @@ -27,7 +27,6 @@ def main(): const=logging.DEBUG, help='increase verbosity level') parser.add_argument('--quiet' , '-q', dest='loglevel', action='store_const', const=logging.WARNING, help='suppress info messages') args = parser.parse_args() Loading @@ -38,12 +37,14 @@ def main(): if not os.path.exists(file_name): log.warning("file '%s' does not exist", file_name) continue echo = EchoWriter(make_echofilename(file_name)) if not echo.read_nexus(file_name, npix=args.npix, ntof=args.ntof, phase_step=args.step): continue echo.to_echo(args.outdir) writer = EchoWriter() #writer = DiffractionWriter() if not writer.read_nexus(file_name, npix=args.npix, ntof=args.ntof, phase_step=args.step): continue writer.save(outdir=args.outdir) if __name__ == "__main__": main() #EOF
pysen/inout/scans.py +38 −3 Original line number Diff line number Diff line Loading @@ -31,7 +31,10 @@ class BaseScan: self.info = None def phasepoint_callback(self, _data, **_kwargs): "phase point callback" """phase point callback _data is a dictionary of results (float, ndarray) for a given phase point """ return True def read_nexus(self, nxsfile, **kwargs): Loading Loading @@ -59,11 +62,40 @@ class BaseScan: return True class DiffractionScan(BaseScan): """Read SNS-NSE EPICS/NeXus diffraction scan file """ def phasepoint_callback(self, data, **kwargs): """phase point callback data is a dictionary of results (float, ndarray) for a given phase point """ filename = kwargs.get('filename', '<unset>') begin = kwargs.get('begin') indx = begin['value'] rate = 0.0 if data['pcharge']>0: rate = data['neutron'].shape[1]/data['pcharge']*1e12 self.data.setdefault(indx, data) self.log.debug("%s: processing %s, pc=%.5f, rate=%10.1f", filename, indx, data['pcharge']*1e-12, rate) return True def read_nexus(self, nxsfile, **kwargs): """read nexus file""" return super().read_nexus(nxsfile, scan_type='diffraction', **kwargs) class EchoScan(BaseScan): """Read SNS-NSE EPICS/NeXus echo scan file""" def phasepoint_callback(self, data, **kwargs): "phase point callback" """phase point callback data is a dictionary of results (float, ndarray) for a given phase point """ filename = kwargs.get('filename', '<unset>') begin = kwargs.get('begin') end = kwargs.get('end') Loading Loading @@ -165,7 +197,10 @@ class XYZScan(BaseScan): 31: 'x_dn',} def phasepoint_callback(self, data, **kwargs): "phase point callback" """phase point callback data is a dictionary of results (float, ndarray) for a given phase point """ filename = kwargs.get('filename', '<unset>') begin = kwargs.get('begin') xyz = self.XYZ_MAP.get(begin['value']) Loading