Loading pysen/inout/history.py +6 −1 Original line number Diff line number Diff line Loading @@ -92,10 +92,15 @@ def list_variables(filenames): def extract_data(filenames, names, start_date=None, stop_date=None): "extract history data from history.log type files" #pylint: disable=too-many-branches logger = logging.getLogger() results = parse_indices(names) for filename in tqdm(filenames, colour='green', unit='file', disable=None): if tqdm is list: filenames = tqdm(filenames) else: filenames = tqdm(filenames, colour='green', unit='file', disable=None) for filename in filenames: open_file = get_open_file(filename) with open_file(filename) as fd: for line in fd.readlines(): Loading pysen/inout/reader.py +1 −0 Original line number Diff line number Diff line Loading @@ -812,6 +812,7 @@ def read_transmission(filename): def read_diffrun(filename, att_table=None): "read nse diffrun file" #pylint: disable=too-many-branches wavelength = 0.0 data_flag = False mon1_flag = False Loading pysen/physics/cloizeaux.py +3 −3 Original line number Diff line number Diff line Loading @@ -10,8 +10,8 @@ Formulas (19) and (23) TODO: implement de Gennes result, Sec.6 and [2] """ from numpy import exp, log, pi, sqrt, ceil, vectorize, arange import numpy as np from numpy import exp, log, pi, sqrt, vectorize, arange from numpy import sum as npsum from numpy.polynomial.laguerre import laggauss from scipy.integrate import quad Loading Loading @@ -67,7 +67,7 @@ def fa_kernel(a, y, z): def fb_kernel(b, a, y, z): "F(b) kernel of [1], see eq.(19)" pmax = max(int(ceil(GWIDTH*y/z))+2,2) pmax = max(int(np.ceil(GWIDTH*y/z))+2,2) #print("DEB: %8d %11.4g %11.4g %11.4g %11.4g " % (pmax,a,b,y,z)) p = arange(-pmax, pmax+1) u1 = abs((a-2*p)*z) Loading pysen/plot/nseplot.py +4 −4 Original line number Diff line number Diff line Loading @@ -507,7 +507,7 @@ def main(): parser = argparse.ArgumentParser(description=description) parser.set_defaults(loglevel=DEFAULT_LOG_LEVEL) subparsers = parser.add_subparsers(dest='plot', required=True, subparsers = parser.add_subparsers(dest='command', required=True, help='plot command', description=None) parser.add_argument('--version', '-V', action='version', Loading Loading @@ -549,7 +549,7 @@ def main(): plt.switch_backend('Agg') action = dict( echo=action_echo, ec=action_echo, atari=action_atari, at=action_atari, summary=action_atari, atari=action_atari, at=action_atari, maps=action_maps, bfield=action_bfield, bf=action_bfield, xyz=action_xyz, Loading @@ -557,9 +557,9 @@ def main(): transmission=action_transmission, tr=action_transmission, datreat=action_datreat, dat=action_datreat, qtau=action_qtau, qt=action_qtau, phase_table=action_phase_table, pt=action_phase_table).get(args.plot, None) phase_table=action_phase_table, pt=action_phase_table).get(args.command, None) if action is None: raise RuntimeError('no action specified for %s' % args.plot) raise RuntimeError('no action specified for %s' % args.command) kwargs = vars(args) action(args.file, **kwargs) Loading pysen/plot/nseplotlib.py +22 −37 Original line number Diff line number Diff line Loading @@ -25,6 +25,15 @@ def _norm_pix(x1, x2, nx, whole_detector=False): return 0, nx return mod(x1,nx), mod(x2,nx) def _get_lambda(params): "get lambda" lmax = [] try: lmax = params['lambdatable'] except KeyError: lmax = params['lambdaTable'] return np.asarray(lmax).flatten() def plot_field(ax,t,v,**kwargs): "plot mag field" Loading Loading @@ -175,11 +184,8 @@ def plot_atari(hdfile, iecho=None, **kwargs): #J1 = physics.attrs['prim_fieldintegral'] phase0 = float(tech.attrs['i5'][0]) or phase_pf theta0 = float(tech.attrs['mophi'][0]) try: lmax = params['lambdatable'] except KeyError: lmax = params['lambdaTable'] lmax = np.array(lmax).flatten() # lmax = _get_lambda(params) dlam = np.ones_like(lmax)*(lmax[1]-lmax[0]) avlam = lmax - dlam/2.0 Loading @@ -188,10 +194,7 @@ def plot_atari(hdfile, iecho=None, **kwargs): det = phase['detector'][...] pcha = phase['proton_charge'][...] cur = phase['phase_current'][:, 0] # actual value if normalize: pcha0 = 1 else: pcha0 = average(pcha) pcha0 = 1 if normalize else average(pcha) pcha = pcha[:,np.newaxis,np.newaxis,np.newaxis]/float(pcha0) # edet = sqrt(det)/pcha Loading Loading @@ -359,20 +362,14 @@ def plot_map(hdfile, iecho=None, **kwargs): itau = itau + 1 phase = echo['phase'] #physics = echo['phys'] params = echo['params'] #params = echo['params'] #tech = echo['tech'] #tau0 = physics.attrs['fouriertime']/NANOSECOND #q0 = physics.attrs['hkl'][0] #lam0 = physics.attrs['lambda'] #phase0 = float(tech.attrs['i5'][0]) try: lmax = params['lambdatable'] except KeyError: lmax = params['lambdaTable'] lmax = np.array(lmax).flatten() #lmax = _get_lambda(params) #dlam = np.ones_like(lmax)*(lmax[1]-lmax[0]) #phasesens = float(params['phaseangle'].attrs['sensitivities'][0]) Loading Loading @@ -414,11 +411,9 @@ def plot_map(hdfile, iecho=None, **kwargs): elif map_type in ('down',): axes.imshow(dn) def plot_echo(hdfile, iecho=None, **kwargs): "echo plot" #pylint: disable=too-many-branches # center_only = kwargs.pop('center_only', False) only_echo = kwargs.pop('only_echo', False) Loading Loading @@ -447,9 +442,7 @@ def plot_echo(hdfile, iecho=None, **kwargs): log = logging.getLogger() # center_only = center_only or resolution_plot base = os.path.splitext(os.path.basename(hdfile.filename))[0] comment = hdfile.attrs['master_comment'] #comment = comment.decode("utf-8") sample = comment.split()[0] Loading Loading @@ -493,20 +486,12 @@ def plot_echo(hdfile, iecho=None, **kwargs): params = echo['params'] tech = echo['tech'] tau0 = physics.attrs['fouriertime']/NANOSECOND q0 = physics.attrs['hkl'][0] lam0 = physics.attrs['lambda'] phase0 = float(tech.attrs['i5'][0]) try: lmax = params['lambdatable'] except KeyError: lmax = params['lambdaTable'] lmax = np.array(lmax).flatten() lmax = _get_lambda(params) dlam = np.ones_like(lmax)*(lmax[1]-lmax[0]) phasesens = float(params['phaseangle'].attrs['sensitivities'][0]) det = phase['detector'][...] Loading Loading @@ -552,10 +537,12 @@ def plot_echo(hdfile, iecho=None, **kwargs): ax.grid() if nytau>1 and (itau%nytau)!=1: ax.set_yticklabels([]) if max(y)>maxy: maxy = max(y) if min(y)<miny: miny = min(y) miny = min(miny, min(y)) maxy = max(maxy, max(y)) #if max(y)>maxy: # maxy = max(y) #if min(y)<miny: # miny = min(y) continue npx, nx, ny, nt = det.shape Loading @@ -565,7 +552,6 @@ def plot_echo(hdfile, iecho=None, **kwargs): pha = pha.sum(axis=(2, 4)) # pixel rebin pha = np.sum(pha[:,:,:,tbin1:tbin2],axis=-1) # tof summation fig, axes = plt.subplots(nxx,nyy, figsize=(8,8)) fig.subplots_adjust(hspace=0.05, wspace=0.05) Loading @@ -583,7 +569,6 @@ def plot_echo(hdfile, iecho=None, **kwargs): dn = y[nph:n_idx['up']] up = y[n_idx['up']:] # upave = average(up) dnave = average(dn) udave = (upave+dnave)/2 Loading Loading
pysen/inout/history.py +6 −1 Original line number Diff line number Diff line Loading @@ -92,10 +92,15 @@ def list_variables(filenames): def extract_data(filenames, names, start_date=None, stop_date=None): "extract history data from history.log type files" #pylint: disable=too-many-branches logger = logging.getLogger() results = parse_indices(names) for filename in tqdm(filenames, colour='green', unit='file', disable=None): if tqdm is list: filenames = tqdm(filenames) else: filenames = tqdm(filenames, colour='green', unit='file', disable=None) for filename in filenames: open_file = get_open_file(filename) with open_file(filename) as fd: for line in fd.readlines(): Loading
pysen/inout/reader.py +1 −0 Original line number Diff line number Diff line Loading @@ -812,6 +812,7 @@ def read_transmission(filename): def read_diffrun(filename, att_table=None): "read nse diffrun file" #pylint: disable=too-many-branches wavelength = 0.0 data_flag = False mon1_flag = False Loading
pysen/physics/cloizeaux.py +3 −3 Original line number Diff line number Diff line Loading @@ -10,8 +10,8 @@ Formulas (19) and (23) TODO: implement de Gennes result, Sec.6 and [2] """ from numpy import exp, log, pi, sqrt, ceil, vectorize, arange import numpy as np from numpy import exp, log, pi, sqrt, vectorize, arange from numpy import sum as npsum from numpy.polynomial.laguerre import laggauss from scipy.integrate import quad Loading Loading @@ -67,7 +67,7 @@ def fa_kernel(a, y, z): def fb_kernel(b, a, y, z): "F(b) kernel of [1], see eq.(19)" pmax = max(int(ceil(GWIDTH*y/z))+2,2) pmax = max(int(np.ceil(GWIDTH*y/z))+2,2) #print("DEB: %8d %11.4g %11.4g %11.4g %11.4g " % (pmax,a,b,y,z)) p = arange(-pmax, pmax+1) u1 = abs((a-2*p)*z) Loading
pysen/plot/nseplot.py +4 −4 Original line number Diff line number Diff line Loading @@ -507,7 +507,7 @@ def main(): parser = argparse.ArgumentParser(description=description) parser.set_defaults(loglevel=DEFAULT_LOG_LEVEL) subparsers = parser.add_subparsers(dest='plot', required=True, subparsers = parser.add_subparsers(dest='command', required=True, help='plot command', description=None) parser.add_argument('--version', '-V', action='version', Loading Loading @@ -549,7 +549,7 @@ def main(): plt.switch_backend('Agg') action = dict( echo=action_echo, ec=action_echo, atari=action_atari, at=action_atari, summary=action_atari, atari=action_atari, at=action_atari, maps=action_maps, bfield=action_bfield, bf=action_bfield, xyz=action_xyz, Loading @@ -557,9 +557,9 @@ def main(): transmission=action_transmission, tr=action_transmission, datreat=action_datreat, dat=action_datreat, qtau=action_qtau, qt=action_qtau, phase_table=action_phase_table, pt=action_phase_table).get(args.plot, None) phase_table=action_phase_table, pt=action_phase_table).get(args.command, None) if action is None: raise RuntimeError('no action specified for %s' % args.plot) raise RuntimeError('no action specified for %s' % args.command) kwargs = vars(args) action(args.file, **kwargs) Loading
pysen/plot/nseplotlib.py +22 −37 Original line number Diff line number Diff line Loading @@ -25,6 +25,15 @@ def _norm_pix(x1, x2, nx, whole_detector=False): return 0, nx return mod(x1,nx), mod(x2,nx) def _get_lambda(params): "get lambda" lmax = [] try: lmax = params['lambdatable'] except KeyError: lmax = params['lambdaTable'] return np.asarray(lmax).flatten() def plot_field(ax,t,v,**kwargs): "plot mag field" Loading Loading @@ -175,11 +184,8 @@ def plot_atari(hdfile, iecho=None, **kwargs): #J1 = physics.attrs['prim_fieldintegral'] phase0 = float(tech.attrs['i5'][0]) or phase_pf theta0 = float(tech.attrs['mophi'][0]) try: lmax = params['lambdatable'] except KeyError: lmax = params['lambdaTable'] lmax = np.array(lmax).flatten() # lmax = _get_lambda(params) dlam = np.ones_like(lmax)*(lmax[1]-lmax[0]) avlam = lmax - dlam/2.0 Loading @@ -188,10 +194,7 @@ def plot_atari(hdfile, iecho=None, **kwargs): det = phase['detector'][...] pcha = phase['proton_charge'][...] cur = phase['phase_current'][:, 0] # actual value if normalize: pcha0 = 1 else: pcha0 = average(pcha) pcha0 = 1 if normalize else average(pcha) pcha = pcha[:,np.newaxis,np.newaxis,np.newaxis]/float(pcha0) # edet = sqrt(det)/pcha Loading Loading @@ -359,20 +362,14 @@ def plot_map(hdfile, iecho=None, **kwargs): itau = itau + 1 phase = echo['phase'] #physics = echo['phys'] params = echo['params'] #params = echo['params'] #tech = echo['tech'] #tau0 = physics.attrs['fouriertime']/NANOSECOND #q0 = physics.attrs['hkl'][0] #lam0 = physics.attrs['lambda'] #phase0 = float(tech.attrs['i5'][0]) try: lmax = params['lambdatable'] except KeyError: lmax = params['lambdaTable'] lmax = np.array(lmax).flatten() #lmax = _get_lambda(params) #dlam = np.ones_like(lmax)*(lmax[1]-lmax[0]) #phasesens = float(params['phaseangle'].attrs['sensitivities'][0]) Loading Loading @@ -414,11 +411,9 @@ def plot_map(hdfile, iecho=None, **kwargs): elif map_type in ('down',): axes.imshow(dn) def plot_echo(hdfile, iecho=None, **kwargs): "echo plot" #pylint: disable=too-many-branches # center_only = kwargs.pop('center_only', False) only_echo = kwargs.pop('only_echo', False) Loading Loading @@ -447,9 +442,7 @@ def plot_echo(hdfile, iecho=None, **kwargs): log = logging.getLogger() # center_only = center_only or resolution_plot base = os.path.splitext(os.path.basename(hdfile.filename))[0] comment = hdfile.attrs['master_comment'] #comment = comment.decode("utf-8") sample = comment.split()[0] Loading Loading @@ -493,20 +486,12 @@ def plot_echo(hdfile, iecho=None, **kwargs): params = echo['params'] tech = echo['tech'] tau0 = physics.attrs['fouriertime']/NANOSECOND q0 = physics.attrs['hkl'][0] lam0 = physics.attrs['lambda'] phase0 = float(tech.attrs['i5'][0]) try: lmax = params['lambdatable'] except KeyError: lmax = params['lambdaTable'] lmax = np.array(lmax).flatten() lmax = _get_lambda(params) dlam = np.ones_like(lmax)*(lmax[1]-lmax[0]) phasesens = float(params['phaseangle'].attrs['sensitivities'][0]) det = phase['detector'][...] Loading Loading @@ -552,10 +537,12 @@ def plot_echo(hdfile, iecho=None, **kwargs): ax.grid() if nytau>1 and (itau%nytau)!=1: ax.set_yticklabels([]) if max(y)>maxy: maxy = max(y) if min(y)<miny: miny = min(y) miny = min(miny, min(y)) maxy = max(maxy, max(y)) #if max(y)>maxy: # maxy = max(y) #if min(y)<miny: # miny = min(y) continue npx, nx, ny, nt = det.shape Loading @@ -565,7 +552,6 @@ def plot_echo(hdfile, iecho=None, **kwargs): pha = pha.sum(axis=(2, 4)) # pixel rebin pha = np.sum(pha[:,:,:,tbin1:tbin2],axis=-1) # tof summation fig, axes = plt.subplots(nxx,nyy, figsize=(8,8)) fig.subplots_adjust(hspace=0.05, wspace=0.05) Loading @@ -583,7 +569,6 @@ def plot_echo(hdfile, iecho=None, **kwargs): dn = y[nph:n_idx['up']] up = y[n_idx['up']:] # upave = average(up) dnave = average(dn) udave = (upave+dnave)/2 Loading