Commit 1f0a80db authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

ver 1.0-rc1

parent d6b65567
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -12,11 +12,17 @@ def get_symmetry_phase(hdfile, iecho=None, **kwargs):
    "get the symmetry phase (for phase tables)"
    #
    tbin1   = kwargs.pop('tbin1', 0)
    tbin2   = kwargs.pop('tbin2',-1)
    tbin2   = kwargs.pop('tbin2', None)
    xpix1   = kwargs.pop('xpix1', 0)
    xpix2   = kwargs.pop('xpix2',-1)
    xpix2   = kwargs.pop('xpix2', None)
    ypix1   = kwargs.pop('ypix1', 0)
    ypix2   = kwargs.pop('ypix2',-1)
    ypix2   = kwargs.pop('ypix2', None)

    if kwargs.get('center_only'):
        tbin1, tbin2 = 4, -4
        xpix1, xpix2 = 5, -5
        ypix1, ypix2 = 5, -5


    log = logging.getLogger()

+37 −20
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ from pysen.plot import ( plot_echo, plot_atari, plot_map,
def action_default(filenames, **kwargs):
    "default action for echo, atari, etc"
    action  = kwargs.pop('action')
    tau     = kwargs.pop('tau')
    taus    = kwargs.pop('taus')
    outdir  = kwargs.pop('outdir')
    savefig = kwargs.pop('savefig')
    log = logging.getLogger()
@@ -37,7 +37,7 @@ def action_default(filenames, **kwargs):
            if ext != ".h5":
                filename = convert_to_hdf(filename, outdir, data_type='echo')
            with h5py.File(filename, 'r') as hdf5file:
                action(hdf5file, tau, **kwargs)
                action(hdf5file, taus, **kwargs)
            if savefig:
                plt.savefig(basename+'-'+savefig)
        except (OSError,KeyError,RuntimeError) as exc:
@@ -246,7 +246,7 @@ def arguments_selection_tof():
def arguments_selection_pix():
    """pixel selection arguments"""
    pars = argparse.ArgumentParser(add_help=False)
    pars.set_defaults(xpix1=10,xpix2=22,ypix1=10,ypix2=22, whole_detector=False)
    pars.set_defaults(xpix1=10,xpix2=-10,ypix1=10,ypix2=-10, whole_detector=False)
    grp  = pars.add_argument_group('options to select pixels')
    grp.add_argument('--x1' , dest='xpix1', type=int,
                     help='set min X pix (default=%(default)s)')
@@ -281,10 +281,14 @@ def add_echo_options(subparser, parents=None):
    pars = subparser.add_parser('echo', parents=parents,
                      help='plot echo (.echo or .h5 files)',
                      description='create echo plot(s)')
    pars.set_defaults(center_only=False, resolution_plot=False, absy=0, npix=4, tau=0)
    pars.set_defaults(center_only=False, resolution_plot=False, absy=0, npix=4, taus=None)
    pars.add_argument('file', metavar='filename', help='file to process', nargs='+')
    pars.add_argument('--tau', '-t',  dest='tau', type=int,
                       help='set tau to display (default=%(default)s)')
    try: # extend is only available in python 3.8 and newer
        pars.add_argument('--tau',  dest='taus', metavar='tau',  type=int, nargs='*', action='extend',
                        help='select list of taus')
    except ValueError:
        pars.add_argument('--tau',  dest='taus', metavar='tau',  type=int, nargs='*', action='append',
                        help='select list of taus')
    pars.add_argument('--center-only'   , '-C', dest='center_only', action='store_true',
                       help='show only center patch')
    pars.add_argument('--only-echo', dest='only_echo', action='store_true',
@@ -304,8 +308,12 @@ def add_atari_options(subparser, parents=None):
                      help='atari plot (.echo or .h5 files)',
                      description='create atari plot(s)')
    pars.add_argument('file', metavar='filename', help='file to process', nargs='+')
    pars.add_argument('--tau', '-t',  dest='tau', type=int,
                      help='set tau to display (default=%(default)s)')
    try: # extend is only available in python 3.8 and newer
        pars.add_argument('--tau',  dest='taus',  metavar='tau',  type=int, nargs='*', action='extend',
                        help='select list of taus')
    except ValueError:
        pars.add_argument('--tau',  dest='taus',  metavar='tau',  type=int, nargs='*', action='append',
                        help='select list of taus')
    pars.add_argument('--only-echo', dest='only_echo', action='store_true',
                      help='show only echo (no up/down)')
    pars.add_argument('--incoherent', '-I', dest='incoherent', action='store_true',
@@ -389,8 +397,12 @@ def add_plotmap_options(subparser, parents=None):
                      help='map',
                      description='create map plots')
    pars.add_argument('file', metavar='filename', help='file to process', nargs='+')
    pars.add_argument('--tau', '-t',  dest='tau', type=int,
                       help='set tau to display (default=%(default)s)')
    try: # extend is only available in python 3.8 and newer
        pars.add_argument('--tau',  dest='taus',  metavar='tau',  type=int, nargs='*', action='extend',
                        help='select list of taus')
    except ValueError:
        pars.add_argument('--tau',  dest='taus',  metavar='tau',  type=int, nargs='*', action='append',
                        help='select list of taus')
    pars.add_argument('--map-type', dest='map_type', choices=['all', 'up', 'down'],
                       help='(default: %(default)s)')
    pars.add_argument('--num-pix', '-N', dest='npix', type=int,
@@ -402,9 +414,13 @@ def add_bfield_options(subparser, parents=None):
                      help='bfield',
                      description='create bfield plots')
    pars.add_argument('file', metavar='filename', help='file to process', nargs='+')
    pars.set_defaults(tau=None,max_chi2=1e-2, axis=-1)
    pars.add_argument('--tau', '-t',  dest='tau', type=int,
                       help='set tau to display (default=%(default)s)')
    pars.set_defaults(max_chi2=1e-2, axis=-1)
    try: # extend is only available in python 3.8 and newer
        pars.add_argument('--tau',  dest='taus',  metavar='tau',  type=int, nargs='*', action='extend',
                        help='select list of taus')
    except ValueError:
        pars.add_argument('--tau',  dest='taus',  metavar='tau',  type=int, nargs='*', action='append',
                        help='select list of taus')
    pars.add_argument('--max-chi2', dest='max_chi2', type=float,
                       help='set max chi-square (default=%(default)s)')
    pars.add_argument('--axis', dest='axis', type=int,
@@ -429,17 +445,16 @@ def add_qtau_options(subparser, parents=None):
    pars.add_argument('--mode', '-m', dest='mode', choices=INST_MODES,
                        help='set instrument (default %(default)s)')
    try: # extend is only available in python 3.8 and newer
        pars.add_argument('--taus',  metavar='tau',  type=float, nargs='*', action='extend',
        pars.add_argument('--tau',  dest='taus',  metavar='tau',  type=float, nargs='*', action='extend',
                        help='select list of taus')
        pars.add_argument('--tbins', metavar='tbin', type=int,   nargs='*', action='extend',
        pars.add_argument('--tbin', dest='tbins', metavar='tbin', type=int,   nargs='*', action='extend',
                        help='select list of tbins')
    except ValueError:
        pars.add_argument('--taus',  metavar='tau',  type=float, nargs='*', action='append',
        pars.add_argument('--tau',  dest='taus',  metavar='tau',  type=float, nargs='*', action='append',
                        help='select list of taus')
        pars.add_argument('--tbins', metavar='tbin', type=int,   nargs='*', action='append',
        pars.add_argument('--tbin', dest='tbins', metavar='tbin', type=int,   nargs='*', action='append',
                        help='select list of tbins')


    grp = pars.add_argument_group('presentation options')
    grp.add_argument('--title',  dest='title', help='set plot title')
    grp.add_argument('--full', '-F', dest='full', action='store_true',
@@ -459,9 +474,8 @@ def add_ptab_options(subparser, parents=None):
    "make phase table"
    pars = subparser.add_parser('phase_table', parents=parents,
                     help='phase table', description='phase table')
    pars.set_defaults(pos='p2', polyfit=2, threshold=0.2)
    # defaults
    pars.set_defaults(tbin1=4, tbin2=38, xpix1=5, xpix2=27, ypix1=5, ypix2=27)
    pars.set_defaults(pos='p2', polyfit=2, threshold=0.2)
    pars.add_argument('file', metavar='filename', help='file to process', nargs='+')
    pars.add_argument('--pos' , '-p', dest='pos',  choices=INST_POSITIONS,
                     help='set instrument position: (default %(default)s)')
@@ -470,6 +484,9 @@ def add_ptab_options(subparser, parents=None):
    pars.add_argument('--threshold', dest='threshold', metavar='thres', type=float,
                     help=argparse.SUPPRESS)
                     #help='clustering threshold (advanced option)')
    pars.add_argument('--center-only'   , '-C', dest='center_only', action='store_true',
                       help='show only center patch')


# ============================================================================================
# the main command line interface
+66 −59
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ import logging

import numpy as np
import matplotlib.pyplot as plt

from numpy import sqrt, radians, average, mod, polyval
from  matplotlib import colors

from .. import (ANGSTROM, NANOSECOND, GAUSS, MICRO, OMEGA_N, config, get_q)
@@ -14,23 +16,30 @@ from ..mathutil import linear_fit
from .plotutil import get_nsubplots
from .echo     import plot_single_echo


MAX_CHI2_DEFAULT_BFIELD = 1e-2 # TODO: explain the meaning of this

def norm_pix(x1, x2, nx, whole_detector=False):
    "normalize pixel"
    if whole_detector:
        return 0, nx
    return mod(x1,nx), mod(x2,nx)

def plot_field(ax,t,v,**kwargs):
    "plot mag field"

    axis     = kwargs.get('axis', -1)
    label    = kwargs.get('label'  , '')
    max_chi2 = kwargs.get('max_chi2', MAX_CHI2_DEFAULT_BFIELD)
    v0 = np.sqrt(np.sum(v**2,axis=-1))
    v0 = sqrt(sum(v**2,axis=-1))
    if axis>0:
        v0 = v[:,axis-1]
        label = "%s (%s)" % (label,{1:'x',2:'y',3:'z'}.get(axis,''))
    a, b, chi2, corr, maxd = linear_fit(t, v0)
    v1   = np.polyval([a,b],t)
    v1   = polyval([a,b],t)
    descr1 = r'a=%.2e b=%.3g' % (a,b)
    descr2 = r'$\rho$=%.3g $\chi^2$=%.1e' % (corr, chi2) # pylint: disable=bad-string-format-type
    va   = np.average((max(v0), min(v0)))
    va   = average((max(v0), min(v0)))
    vd   = max(abs(v0-va))
    vmin = va-max(vd,1.5)
    vmax = va+max(vd,1.5)
@@ -49,7 +58,7 @@ def plot_field(ax,t,v,**kwargs):
    return ok, dict(chi2=chi2, maxd=maxd, corr=corr, slope=a, offset=b)


def plot_magnetic_fields(hdfile, iecho=0, **kwargs):
def plot_magnetic_fields(hdfile, iecho=None, **kwargs):
    "plot magnetic fields"
    #
    axis     = kwargs.get('axis', -1)
@@ -66,7 +75,7 @@ def plot_magnetic_fields(hdfile, iecho=0, **kwargs):
    nph     = hdfile['/'].attrs['point_to_down']

    for echo in list(hdfile['/data'].values()):
        if iecho and echo.attrs['id'] != iecho:
        if not (iecho is None or echo.attrs['id'] in iecho):
            continue

        phase   = echo['phase']
@@ -83,7 +92,7 @@ def plot_magnetic_fields(hdfile, iecho=0, **kwargs):

        bfield = phase['bfield']
        cur    = phase['phase_current'][:, 0] # actual value
        dj     = np.radians(phasesens*(cur-cur0))/OMEGA_N/lam0
        dj     = radians(phasesens*(cur-cur0))/OMEGA_N/lam0

        nxplot, nyplot = get_nsubplots(len(bfield))

@@ -112,7 +121,7 @@ def plot_magnetic_fields(hdfile, iecho=0, **kwargs):
            ax  = axes[iplt//nxplot,iplt%nxplot]
            ax.axis('off')

def plot_atari(hdfile, iecho=0, **kwargs):
def plot_atari(hdfile, iecho=None, **kwargs):
    "atari plot"
    #
    tbin1   = kwargs.pop('tbin1',0)      # TOF bins
@@ -147,12 +156,11 @@ def plot_atari(hdfile, iecho=0, **kwargs):
    nph     = n_idx['dn']
    comment = hdfile.attrs['master_comment']

    if whole_detector:
        xpix1, xpix2 = 0, nx
        ypix1, ypix2 = 0, ny
    xpix1, xpix2 = norm_pix(xpix1, xpix2, nx, whole_detector)
    ypix1, ypix2 = norm_pix(ypix1, ypix2, ny, whole_detector)

    for echo in list(hdfile['/data'].values()):
        if iecho and echo.attrs['id'] != iecho:
        if not (iecho is None or echo.attrs['id'] in iecho):
            continue

        phase   = echo['phase']
@@ -183,25 +191,25 @@ def plot_atari(hdfile, iecho=0, **kwargs):
        if normalize:
            pcha0 = 1
        else:
            pcha0 = np.average(pcha)
            pcha0 = average(pcha)
        pcha = pcha[:,np.newaxis,np.newaxis,np.newaxis]/float(pcha0)
        #
        edet = np.sqrt(det)/pcha
        edet = sqrt(det)/pcha
        det  = det/pcha
        wlen = np.sum(det, axis=(0,1,2)) # all but TOF axis
        wlen = sum(det, axis=(0,1,2)) # all but TOF axis
        #

        YY, XX, TT = np.mgrid[ypix1:ypix2, xpix1:xpix2, tbin1:tbin2 or nt]
        theta, _ = config.pixel_angle(XX, YY, np.radians(theta0)) # theta,phi
        theta, _ = config.pixel_angle(XX, YY, radians(theta0)) # theta,phi
        alam     = avlam[TT]
        q_pix    = get_q(alam, theta)*ANGSTROM
        tau_pix   = (alam/lam0)**3*tau0

        flux = np.tile(wlen[tbin1:tbin2], q_pix.shape[:-1]).reshape(q_pix.shape)
        qave = np.average(q_pix, weights=flux)
        qvar = np.sqrt(np.average((q_pix-qave)**2, weights=flux))
        tave = np.average(tau_pix, weights=flux)
        tvar = np.sqrt(np.average((tau_pix-tave)**2, weights=flux))
        qave = average(q_pix, weights=flux)
        qvar = sqrt(average((q_pix-qave)**2, weights=flux))
        tave = average(tau_pix, weights=flux)
        tvar = sqrt(average((tau_pix-tave)**2, weights=flux))

        #
        fig, axes = plt.subplots(2,2,figsize=(10,8))
@@ -213,7 +221,7 @@ def plot_atari(hdfile, iecho=0, **kwargs):
        ax.grid(True)

        ax = axes[0,1]
        xatari = np.sum(det, axis=(1,2)).T
        xatari = sum(det, axis=(1,2)).T
        extent = (cur[0], cur[nph-1])
        if tbin2 is None:
            extent = extent + (lmax[tbin1]/ANGSTROM, max(lmax)/ANGSTROM)
@@ -224,7 +232,7 @@ def plot_atari(hdfile, iecho=0, **kwargs):
        ax.imshow(xatari, origin='lower', extent=extent, aspect='auto')

        ax = axes[1,0]
        img = np.sum(det[:,:,:,tbin1:tbin2], axis=(0,-1))
        img = sum(det[:,:,:,tbin1:tbin2], axis=(0,-1))
        if logz:
            norm = colors.LogNorm(max(1,vmin), vmax)
            im = ax.imshow(img , aspect='equal', norm=norm)
@@ -243,13 +251,13 @@ def plot_atari(hdfile, iecho=0, **kwargs):
        ax = axes[1,1]
        pha  = det [:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2]
        epha = edet[:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2]
        wlen = np.sum(pha, axis=(0,1,2)) # all but TOF axis
        wlen = sum(pha, axis=(0,1,2)) # all but TOF axis

        dn   = np.sum(pha[nph:n_idx['up']], axis=(1,2,3))
        up   = np.sum(pha[n_idx['up']:], axis=(1,2,3))
        #epha = np.sqrt(np.sum(pha[:nph], axis=(1,2,3)))
        epha = np.sqrt(np.sum(epha[:nph]**2, axis=(1,2,3)))
        pha  = np.sum(pha[:nph], axis=(1,2,3))
        dn   = sum(pha[nph:n_idx['up']], axis=(1,2,3))
        up   = sum(pha[n_idx['up']:], axis=(1,2,3))
        #epha = sqrt(sum(pha[:nph], axis=(1,2,3)))
        epha = sqrt(sum(epha[:nph]**2, axis=(1,2,3)))
        pha  = sum(pha[:nph], axis=(1,2,3))

        spectrum =  Spectrum(lam=lmax[tbin1:tbin2], dlam=dlam[tbin1:tbin2], flux=wlen)# [tbin1:tbin2])
        (phase_ef, phase_err), (xef, yef), res = fit_echo_current(cur[:nph], (pha, epha), spectrum, global_fit=phase_pf is None,
@@ -271,16 +279,16 @@ def plot_atari(hdfile, iecho=0, **kwargs):
            _txt = r'$A(Q,t)$=%.3g$\pm$%.3g' % res['amplitude']
        else:
            minup = 0
            maxup = np.max((np.max(up), np.max(dn)))*1.2
            res['up'] = np.average(up),np.sqrt(np.sum(up)/len(up))
            res['dn'] = np.average(dn),np.sqrt(np.sum(dn)/len(dn))
            maxup = max((max(up), max(dn)))*1.2
            res['up'] = average(up),sqrt(sum(up)/len(up))
            res['dn'] = average(dn),sqrt(sum(dn)/len(dn))
            R  = 2*res['amplitude'][0]/( res['up'][0] - res['dn'][0] )
            eR = R * res['amplitude'][1]/res['amplitude'][0]
            ax.errorbar(cur[nph:n_idx['up']], dn, fmt='.', color=dcol)
            ax.errorbar(cur[n_idx['up']:],    up, fmt='.', color=dcol)
            _txt = r'$R(Q,t)$=%.3g$\pm$%.3g' % (R,eR)
            ax.axhline(np.average(up))
            ax.axhline(np.average(dn))
            ax.axhline(average(up))
            ax.axhline(average(dn))
            log.info("R=%.4g(%.4g) Phase=%.4g(%.4g) Amp=%.4g(%.4g) Up=%.4g(%.4g) Down=%.4g(%.4g)",
                R, eR,
                phase_ef, phase_err,
@@ -315,7 +323,7 @@ def plot_atari(hdfile, iecho=0, **kwargs):
        fig.suptitle(r'%s: %s $Q$=%.3f$\AA^{-1}$ $\tau$=%.3gns' % (base, comment, q0,tau0))


def plot_map(hdfile, iecho=0, **kwargs):
def plot_map(hdfile, iecho=None, **kwargs):
    "map plot"
    #
    npix    = kwargs.pop('npix',None) or 4    # pix
@@ -345,7 +353,7 @@ def plot_map(hdfile, iecho=0, **kwargs):

    itau = 0
    for echo in list(hdfile['/data'].values()):
        if iecho and echo.attrs['id'] != iecho:
        if not (iecho is None or echo.attrs['id'] in iecho):
            continue

        itau = itau + 1
@@ -372,10 +380,10 @@ def plot_map(hdfile, iecho=0, **kwargs):
        det  = phase['detector'][...]
        pcha = phase['proton_charge'][...]
        #cur  = phase['phase_current'][:, 0] # actual value
        pcha0 = np.average(pcha)
        pcha0 = average(pcha)
        pcha = pcha[:,np.newaxis,np.newaxis,np.newaxis]/float(pcha0)
        det  = det/pcha
        #wlen = np.sum(det, axis=(0,1,2))
        #wlen = sum(det, axis=(0,1,2))

        #spectrum =  Spectrum(lam=lmax, dlam=dlam, flux=wlen)
        #spectrum =  Spectrum(lam=lmax[tbin1:tbin2], dlam=dlam[tbin1:tbin2], flux=wlen[tbin1:tbin2])
@@ -387,14 +395,14 @@ def plot_map(hdfile, iecho=0, **kwargs):
        nxx = nx//npix
        pha = det.reshape(npx, nyy, npix, nxx, npix, nt)
        pha = pha.sum(axis=(2, 4)) # pixel rebin
        pha = np.sum(pha[:,:,:,tbin1:tbin2],axis=-1) # tof summation
        pha = sum(pha[:,:,:,tbin1:tbin2],axis=-1) # tof summation


        dn  = np.average(pha[nph:n_idx['up'],:,:], axis=0)
        up  = np.average(pha[n_idx['up']:   ,:,:], axis=0)
        dn  = average(pha[nph:n_idx['up'],:,:], axis=0)
        up  = average(pha[n_idx['up']:   ,:,:], axis=0)

        #y  = np.sum(det[:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2], axis=(1,2,3))
        #ey = np.sqrt(y)
        #y  = sum(det[:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2], axis=(1,2,3))
        #ey = sqrt(y)
        #(phase_ef0,_) , (xef,yef), res = fit_echo_current(cur[:nph], (y[:nph], ey[:nph]), spectrum,
        #                                             lam0=lam0, phase0=phase0, phasesens=phasesens,
        #                                             incoherent=incoherent)
@@ -409,7 +417,7 @@ def plot_map(hdfile, iecho=0, **kwargs):



def plot_echo(hdfile, iecho=0, **kwargs):
def plot_echo(hdfile, iecho=None, **kwargs):
    "echo plot"
    #
    center_only     = kwargs.pop('center_only', False)
@@ -457,15 +465,14 @@ def plot_echo(hdfile, iecho=0, **kwargs):
    nph     = n_idx['dn']
    miny, maxy    = np.inf, 0

    if whole_detector:
        xpix1, xpix2 = 0, nx
        ypix1, ypix2 = 0, ny
    xpix1, xpix2 = norm_pix(xpix1, xpix2, nx, whole_detector)
    ypix1, ypix2 = norm_pix(ypix1, ypix2, nx, whole_detector)

    if  center_only:
        ntaus = 0
        if not resolution_plot:
            for echo in list(hdfile['/data'].values()):
                if not iecho or echo.attrs['id'] == iecho:
                if iecho is None or echo.attrs['id'] in iecho:
                    ntaus = ntaus + 1
        if ntaus>1 or resolution_plot:
            ntaus = ntaus + 1 # resolution curve
@@ -476,7 +483,7 @@ def plot_echo(hdfile, iecho=0, **kwargs):
    itau = 0
    resolution = []
    for echo in list(hdfile['/data'].values()):
        if iecho and echo.attrs['id'] != iecho:
        if not (iecho is None or echo.attrs['id'] in iecho):
            continue

        itau = itau + 1
@@ -505,16 +512,16 @@ def plot_echo(hdfile, iecho=0, **kwargs):
        det  = phase['detector'][...]
        pcha = phase['proton_charge'][...]
        cur  = phase['phase_current'][:, 0] # actual value
        pcha0 = np.average(pcha)
        pcha0 = average(pcha)
        pcha = pcha[:,np.newaxis,np.newaxis,np.newaxis]/float(pcha0)
        det  = det/pcha
        wlen = np.sum(det, axis=(0,1,2))
        wlen = sum(det, axis=(0,1,2))

        #spectrum =  Spectrum(lam=lmax, dlam=dlam, flux=wlen)
        spectrum =  Spectrum(lam=lmax[tbin1:tbin2], dlam=dlam[tbin1:tbin2], flux=wlen[tbin1:tbin2])

        y  = np.sum(det[:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2], axis=(1,2,3))
        ey = np.sqrt(y)
        y  = sum(det[:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2], axis=(1,2,3))
        ey = sqrt(y)
        dn = y[nph:n_idx['up']]
        up = y[n_idx['up']:]
        _ = fit_echo_current(cur[:nph], (y[:nph], ey[:nph]), spectrum,
@@ -524,8 +531,8 @@ def plot_echo(hdfile, iecho=0, **kwargs):
        if center_only:
            res['current0'] = (phase_ef0, phase_err)
            if not only_echo:
                res['up'] = np.average(up), np.sqrt(np.sum(up)/len(up))
                res['dn'] = np.average(dn), np.sqrt(np.sum(dn)/len(dn))
                res['up'] = average(up), sqrt(sum(up)/len(up))
                res['dn'] = average(dn), sqrt(sum(dn)/len(dn))
                R = 2*res['amplitude'][0]/( res['up'][0] - res['dn'][0] )
                resolution.append((tau0, R))
                log.info("tau={0:.3g}ns R={1:.3g}".format(tau0,R))
@@ -556,7 +563,7 @@ def plot_echo(hdfile, iecho=0, **kwargs):
        nxx = nx//npix
        pha = det.reshape(npx, nyy, npix, nxx, npix, nt)
        pha = pha.sum(axis=(2, 4)) # pixel rebin
        pha = np.sum(pha[:,:,:,tbin1:tbin2],axis=-1) # tof summation
        pha = sum(pha[:,:,:,tbin1:tbin2],axis=-1) # tof summation


        fig, axes = plt.subplots(nxx,nyy, figsize=(8,8))
@@ -577,10 +584,10 @@ def plot_echo(hdfile, iecho=0, **kwargs):
                up = y[n_idx['up']:]
                #

                upave = np.average(up)
                dnave = np.average(dn)
                upave = average(up)
                dnave = average(dn)
                udave = (upave+dnave)/2
                ave   = np.average(y[:nph])
                ave   = average(y[:nph])
                #std   = np.std(y[:nph])

                if udave<min_counts or ave<min_counts:
@@ -601,8 +608,8 @@ def plot_echo(hdfile, iecho=0, **kwargs):
                    #if abs(R)<min_amp:
                    #    continue

                    res['up'] = upave, np.sqrt(np.sum(up)/len(up))
                    res['dn'] = dnave, np.sqrt(np.sum(dn)/len(dn))
                    res['up'] = upave, sqrt(sum(up)/len(up))
                    res['dn'] = dnave, sqrt(sum(dn)/len(dn))
                    res['current0'] = (phase_ef, phase_err)
                    plot_single_echo(ax, (cur, y, ey), (nph,n_idx['up']), fit=(xef, yef),
                                     res=res, label='(%s,%s)' % (i,j), only_echo=only_echo,
+3 −3
Original line number Diff line number Diff line
@@ -2,9 +2,9 @@
PySEN revision module
"""
import sys
__version__  = "0.76"
__release__  = "dev2"
__date__     = "Aug 19, 2022"
__version__  = "1.0"
__release__  = "rc1"
__date__     = "Aug 22, 2022"

def version(full=False):
    "get pysen version number"
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ else
fi


#complete -o filenames -F _pysen_completions nseplot
complete -o filenames -F _pysen_completions nseplot

# vim: filetype=bash
Loading