Loading README.rst +7 −3 Original line number Diff line number Diff line The pysen package is a collection of Python modules and scripts for the SNS-NSE instrument (BL-15) but may be also useful for any neutron spin echo experimenter. pysen ------ The pysen package is a collection of Python modules and scripts that aid experiment planning, data collection, reduction, and analysis at the Neutron Spin Echo instrument (SNS-NSE) located at Beam Line 15 of the First Target Station at the Spallation Neutron Source. It may be also useful for any other neutron spin echo experimenter. doc/source/_static/atari_example.png 0 → 100644 +83.7 KiB Loading image diff... doc/source/intro.rst +60 −3 Original line number Diff line number Diff line Loading @@ -2,20 +2,77 @@ Introduction ============================ The pysen package is a collection of Python modules and scripts that aid experiment planning, data collection, reduction, and analysis at the Neutron Spin Echo instrument (SNS-NSE) located at Beam Line 15 of the First Target Station at the Spallation Neutron Source. It may be also useful for any other neutron spin echo experimenter. .. toctree:: The Quick Start Guide ========================================= The PySEN GUI ----------------------------------------- Generic Usage -------------- The most common usage pattern involves the ``nseplot`` command, followed by a subcommand what to plot. ``nseplot <subcommand> [subcomand-options] [filename(s)]`` For example, ``nseplot atari -t1 /SNS/NSE/IPTS-4531/s10922.echo`` which produces the following result: .. figure:: _static/atari_example.png Plot created by the above ``nseplot atari`` command. Each command provides a short help via ``--help`` option: ``nseplot atari --help`` or:: usage: nseplot atari [-h] [--version] [--save-figure file] [--save-file file] [--verbose | --quiet] [--tau TAU] [--t1 TBIN1] [--t2 TBIN2] [--x1 XPIX1] [--x2 XPIX2] [--y1 YPIX1] [--y2 YPIX2] [--whole-detector] [--vmin VMIN] [--vmax VMAX] [--logz] [--normalize] [--only-echo] [--incoherent] [--phase0 PHASE0] filename [filename ...] positional arguments: filename file to process optional arguments: -h, --help show this help message and exit --version, -V show program's version number and exit --save-figure file, -S file save figure to a file (do not show) --save-file file, -s file save data to a csv file --verbose, -v verbose output --quiet, -q suppres output --tau TAU, -t TAU set tau to display (default=0) --t1 TBIN1, -b TBIN1 set min TOF bin (default=0) --t2 TBIN2, -B TBIN2 set max TOF bin (default=None) --x1 XPIX1 set min X pix (default=10) --x2 XPIX2 set max X pix (default=22) --y1 YPIX1 set min Y pix (default=10) --y2 YPIX2 set max Y pix (default=22) --whole-detector, -W show sum over entire detector area --vmin VMIN set min vertical scale (default=0) --vmax VMAX set max vertical scale (default=None) --logz detector image log vertical scale --normalize, -n normalize results --only-echo show only echo (no up/down) --incoherent, -I treat data as from incoherent scatterer --phase0 PHASE0 set inital phase for echo fitting (default=None) pysen/plot/cmdline.py +18 −7 Original line number Diff line number Diff line Loading @@ -13,11 +13,12 @@ from pysen.plot import plot_echo, plot_atari class NsePlotApp(cmd.Cmd): """Simple NSE plotting utility""" prompt = 'nsepy> ' prompt = 'nseplot> ' intro = """ Welcome to NSEpy !!! Welcome to NSE Plot!!! """ filenames = [] def preloop(self): self.cmdqueue.append(" ".join(sys.argv[1:])) Loading Loading @@ -51,7 +52,7 @@ class NsePlotApp(cmd.Cmd): center_only=False, whole_detector=False, map_type='all', phase0=None, incoherent=False, max_chi2=1e3) parser.add_argument('file', metavar='filename', help='file to process', nargs='+') #parser.add_argument('file', metavar='filename', help='file to process', nargs='+') parser.add_argument('--tau', '-t', dest='tau', type=int, help='set tau to display (default=%(default)s)') parser.add_argument('--t1' , '-b', dest='tbin1', type=int, Loading @@ -73,18 +74,28 @@ class NsePlotApp(cmd.Cmd): try: args = parser.parse_args(line.split()) except argparse.ArgumentError as exc: print('Catching an argumentError', exc) return kwargs = vars(args) try: for filename in args.file: with h5py.File(filename, 'r') as hdf5file: func(hdf5file, iecho=args.tau, **kwargs) for f in self.filenames: func(f, iecho=args.tau, **kwargs) plt.show() except OSError as exc: print(exc) def do_ls(self, _line): for f in self.filenames: print(f.filename) def do_load(self, line): self.filenames.append(h5py.File(line, 'r')) def do_clear(self, _line): for f in self.filenames: f.close() self.filenames = [] def do_echo(self, line): "plot echo" self.plot_command("echo", line) Loading pysen/plot/nseplot.py +18 −8 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import os.path import argparse import cmd import numpy as np import h5py Loading @@ -14,7 +15,7 @@ from pysen.inout import convert_to_hdf from pysen.plot import ( plot_echo, plot_atari, plot_map, plot_xyz, plot_magnetic_fields, plot_diffrun, plot_transmission, plot_datreat) #from pysen.plot.cmdline import NsePlotApp def action_default(filenames, **kwargs): "default action for echo, atari, etc" Loading Loading @@ -145,6 +146,15 @@ def add_subparser(name, parent, sub, helpmsg=None, filearg=None): parser_name.add_argument('file', metavar='filename', help='file to process', nargs=filearg) return parser_name.add_argument_group() class NsePlotApp(cmd.Cmd): """Simple NSE plotting utility""" prompt = 'nseplot> ' intro = """ Welcome to NSE Plot!!! """ def main(): "the main" Loading @@ -154,7 +164,7 @@ def main(): parser_top.set_defaults(loglevel=1, outdir='.') parser_top.add_argument('--version', '-V', action='version', version='%(prog)s pysen={version}'.format(version=version(full=True))) subparsers = parser_top.add_subparsers(dest='plot', required=True, help='what to plot') subparsers = parser_top.add_subparsers(dest='plot', required=False, help='what to plot') # common arguments parser = argparse.ArgumentParser(add_help=False) Loading @@ -169,11 +179,11 @@ def main(): # version option parser.add_argument('--version', '-V', action='version', version='%(prog)s pysen={version}'.format(version=version(full=True))) # # save figure/data options parser.add_argument('--save-figure', '-S', dest='savefig', metavar='file', help='save figure to a file (do not show)') parser.add_argument('--save-file', '-s', dest='savefile', metavar='file', help='save data to a csv file') help='save data to a .csv file') # mutually exclusive [ -v | -q ] group_vrb = parser.add_mutually_exclusive_group() group_vrb.add_argument('--verbose', '-v', dest='loglevel', action='count', Loading @@ -189,7 +199,7 @@ def main(): help='show only echo (no up/down)') grp_echo.add_argument('--incoherent', '-I', dest='incoherent', action='store_true', help='treat data as from incoherent scatterer') grp_echo.add_argument('--absolute-y', '-Y', dest='absy', metavar='YMAX', type=float, grp_echo.add_argument('--absolute-y', '-Y', dest='absy', metavar='V', type=float, help='use the same vertical scale for all pixels') grp_echo.add_argument('--num-pix', '-N', dest='npix', metavar='N', type=int, help='set pixel binning (default=%(default)s)') Loading Loading @@ -295,9 +305,9 @@ def main(): log = setup_logger(args.loglevel) log.debug('program arguments %s', args) #if not args.plot # NsePlotApp().cmdloop() # return if not args.plot: NsePlotApp().cmdloop() return plt.rcParams.update({'figure.max_open_warning': 0}) if args.savefig: Loading Loading
README.rst +7 −3 Original line number Diff line number Diff line The pysen package is a collection of Python modules and scripts for the SNS-NSE instrument (BL-15) but may be also useful for any neutron spin echo experimenter. pysen ------ The pysen package is a collection of Python modules and scripts that aid experiment planning, data collection, reduction, and analysis at the Neutron Spin Echo instrument (SNS-NSE) located at Beam Line 15 of the First Target Station at the Spallation Neutron Source. It may be also useful for any other neutron spin echo experimenter.
doc/source/intro.rst +60 −3 Original line number Diff line number Diff line Loading @@ -2,20 +2,77 @@ Introduction ============================ The pysen package is a collection of Python modules and scripts that aid experiment planning, data collection, reduction, and analysis at the Neutron Spin Echo instrument (SNS-NSE) located at Beam Line 15 of the First Target Station at the Spallation Neutron Source. It may be also useful for any other neutron spin echo experimenter. .. toctree:: The Quick Start Guide ========================================= The PySEN GUI ----------------------------------------- Generic Usage -------------- The most common usage pattern involves the ``nseplot`` command, followed by a subcommand what to plot. ``nseplot <subcommand> [subcomand-options] [filename(s)]`` For example, ``nseplot atari -t1 /SNS/NSE/IPTS-4531/s10922.echo`` which produces the following result: .. figure:: _static/atari_example.png Plot created by the above ``nseplot atari`` command. Each command provides a short help via ``--help`` option: ``nseplot atari --help`` or:: usage: nseplot atari [-h] [--version] [--save-figure file] [--save-file file] [--verbose | --quiet] [--tau TAU] [--t1 TBIN1] [--t2 TBIN2] [--x1 XPIX1] [--x2 XPIX2] [--y1 YPIX1] [--y2 YPIX2] [--whole-detector] [--vmin VMIN] [--vmax VMAX] [--logz] [--normalize] [--only-echo] [--incoherent] [--phase0 PHASE0] filename [filename ...] positional arguments: filename file to process optional arguments: -h, --help show this help message and exit --version, -V show program's version number and exit --save-figure file, -S file save figure to a file (do not show) --save-file file, -s file save data to a csv file --verbose, -v verbose output --quiet, -q suppres output --tau TAU, -t TAU set tau to display (default=0) --t1 TBIN1, -b TBIN1 set min TOF bin (default=0) --t2 TBIN2, -B TBIN2 set max TOF bin (default=None) --x1 XPIX1 set min X pix (default=10) --x2 XPIX2 set max X pix (default=22) --y1 YPIX1 set min Y pix (default=10) --y2 YPIX2 set max Y pix (default=22) --whole-detector, -W show sum over entire detector area --vmin VMIN set min vertical scale (default=0) --vmax VMAX set max vertical scale (default=None) --logz detector image log vertical scale --normalize, -n normalize results --only-echo show only echo (no up/down) --incoherent, -I treat data as from incoherent scatterer --phase0 PHASE0 set inital phase for echo fitting (default=None)
pysen/plot/cmdline.py +18 −7 Original line number Diff line number Diff line Loading @@ -13,11 +13,12 @@ from pysen.plot import plot_echo, plot_atari class NsePlotApp(cmd.Cmd): """Simple NSE plotting utility""" prompt = 'nsepy> ' prompt = 'nseplot> ' intro = """ Welcome to NSEpy !!! Welcome to NSE Plot!!! """ filenames = [] def preloop(self): self.cmdqueue.append(" ".join(sys.argv[1:])) Loading Loading @@ -51,7 +52,7 @@ class NsePlotApp(cmd.Cmd): center_only=False, whole_detector=False, map_type='all', phase0=None, incoherent=False, max_chi2=1e3) parser.add_argument('file', metavar='filename', help='file to process', nargs='+') #parser.add_argument('file', metavar='filename', help='file to process', nargs='+') parser.add_argument('--tau', '-t', dest='tau', type=int, help='set tau to display (default=%(default)s)') parser.add_argument('--t1' , '-b', dest='tbin1', type=int, Loading @@ -73,18 +74,28 @@ class NsePlotApp(cmd.Cmd): try: args = parser.parse_args(line.split()) except argparse.ArgumentError as exc: print('Catching an argumentError', exc) return kwargs = vars(args) try: for filename in args.file: with h5py.File(filename, 'r') as hdf5file: func(hdf5file, iecho=args.tau, **kwargs) for f in self.filenames: func(f, iecho=args.tau, **kwargs) plt.show() except OSError as exc: print(exc) def do_ls(self, _line): for f in self.filenames: print(f.filename) def do_load(self, line): self.filenames.append(h5py.File(line, 'r')) def do_clear(self, _line): for f in self.filenames: f.close() self.filenames = [] def do_echo(self, line): "plot echo" self.plot_command("echo", line) Loading
pysen/plot/nseplot.py +18 −8 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import os.path import argparse import cmd import numpy as np import h5py Loading @@ -14,7 +15,7 @@ from pysen.inout import convert_to_hdf from pysen.plot import ( plot_echo, plot_atari, plot_map, plot_xyz, plot_magnetic_fields, plot_diffrun, plot_transmission, plot_datreat) #from pysen.plot.cmdline import NsePlotApp def action_default(filenames, **kwargs): "default action for echo, atari, etc" Loading Loading @@ -145,6 +146,15 @@ def add_subparser(name, parent, sub, helpmsg=None, filearg=None): parser_name.add_argument('file', metavar='filename', help='file to process', nargs=filearg) return parser_name.add_argument_group() class NsePlotApp(cmd.Cmd): """Simple NSE plotting utility""" prompt = 'nseplot> ' intro = """ Welcome to NSE Plot!!! """ def main(): "the main" Loading @@ -154,7 +164,7 @@ def main(): parser_top.set_defaults(loglevel=1, outdir='.') parser_top.add_argument('--version', '-V', action='version', version='%(prog)s pysen={version}'.format(version=version(full=True))) subparsers = parser_top.add_subparsers(dest='plot', required=True, help='what to plot') subparsers = parser_top.add_subparsers(dest='plot', required=False, help='what to plot') # common arguments parser = argparse.ArgumentParser(add_help=False) Loading @@ -169,11 +179,11 @@ def main(): # version option parser.add_argument('--version', '-V', action='version', version='%(prog)s pysen={version}'.format(version=version(full=True))) # # save figure/data options parser.add_argument('--save-figure', '-S', dest='savefig', metavar='file', help='save figure to a file (do not show)') parser.add_argument('--save-file', '-s', dest='savefile', metavar='file', help='save data to a csv file') help='save data to a .csv file') # mutually exclusive [ -v | -q ] group_vrb = parser.add_mutually_exclusive_group() group_vrb.add_argument('--verbose', '-v', dest='loglevel', action='count', Loading @@ -189,7 +199,7 @@ def main(): help='show only echo (no up/down)') grp_echo.add_argument('--incoherent', '-I', dest='incoherent', action='store_true', help='treat data as from incoherent scatterer') grp_echo.add_argument('--absolute-y', '-Y', dest='absy', metavar='YMAX', type=float, grp_echo.add_argument('--absolute-y', '-Y', dest='absy', metavar='V', type=float, help='use the same vertical scale for all pixels') grp_echo.add_argument('--num-pix', '-N', dest='npix', metavar='N', type=int, help='set pixel binning (default=%(default)s)') Loading Loading @@ -295,9 +305,9 @@ def main(): log = setup_logger(args.loglevel) log.debug('program arguments %s', args) #if not args.plot # NsePlotApp().cmdloop() # return if not args.plot: NsePlotApp().cmdloop() return plt.rcParams.update({'figure.max_open_warning': 0}) if args.savefig: Loading