Loading misc/mkedmac.py +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import numpy as np from pysen.lib import t_binning from pysen.physics import t_binning def make_macro(lmax, qmin, q0, dq, data, dlam=3.0, nt=42, mint=3, maxt=39): Loading misc/nse-range.py +30 −13 Original line number Diff line number Diff line Loading @@ -5,51 +5,68 @@ import matplotlib.pyplot as plt from numpy import asarray, pi, sin, radians from matplotlib.patches import Circle, Wedge, Polygon from scipy.constants import physical_constants, milli, nano kappa = 0.186 # hbar = 0.658/1000.0 from pysen import KAPPA_N_NSA as KAPPA from pysen.config import PHI_LIMS, J_LIMS HBAR = physical_constants['reduced Planck constant in eV s'][0]/milli/nano def heisenberg(x): return hbar/x with np.errstate(divide='ignore'): return HBAR/x wlen = asarray((3.0,14.0)) J = asarray((0.00005, 0.56)) theta = asarray((3.0, 79.5)) J = asarray(J_LIMS) theta = asarray(PHI_LIMS) xE = [] xT = [] xQ = [] qe_plot = True fig, ax1 = plt.subplots() for lam in wlen: t = kappa*J*lam**3 t = KAPPA*J*lam**3 e = heisenberg(t) q = 4*pi/lam*sin(radians(theta/2)) # one if lam==wlen[0]: _e = e[0],e[0],e[1] _t = t[0],t[0],t[1] _q = q[0],q[1],q[1] #two if lam==wlen[1]: _e = e[1],e[1],e[0] _t = t[1],t[1],t[0] _q = q[1],q[0],q[0] xE.extend(_e) xT.extend(_t) xQ.extend(_q) print("lambda=%gA q=%s t=%s E=%s" % (lam, q, t, e)) if qe_plot: qe = np.vstack((xE,xQ)).T ax1.add_patch(Polygon(qe, fill=True, ls='-', lw=2)) ax1.set_xlabel('E [meV]') else: qt = np.vstack((xT,xQ)).T ax1.add_patch(Polygon(qt, fill=True, ls='-', lw=2)) ax1.set_xlabel(r'$\tau$ [ns]') ax1.set_xscale('log') ax1.set_yscale('log') ax1.set_xlabel('E [meV]') ax1.set_ylabel(r'Q [$\AA^-1$]') ax1.grid(True, which='both') if qe_plot: ax2 = ax1.secondary_xaxis('top', functions=(heisenberg, heisenberg)) ax2.set_xlabel(r'$\tau$ [ns]') else: ax2 = ax1.secondary_xaxis('top', functions=(heisenberg, heisenberg)) ax2.set_xlabel('E [meV]') plt.suptitle('SNS-NSE Q-E Coverage') plt.subplots_adjust(top=0.8) Loading pysen/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ from math import pi as PI import scipy.constants as sc from .lib import get_theta, get_q, q_binning, l_binning, t_binning # NOQA from .physics import get_theta, get_q, q_binning, l_binning, t_binning # NOQA from .misc import setup_logger, dictionary_hash, DEFAULT_LOG_LEVEL # NOQA from .revision import version # NOQA Loading pysen/config.py +2 −1 Original line number Diff line number Diff line Loading @@ -300,6 +300,7 @@ def coverage(lmax, qmin, **kwargs): detpos = kwargs.pop('pos', 'p2' ) dlam = kwargs.pop('dlam', wavelength_bandwitdh(detpos)) rpixel = kwargs.pop('rpixel', (NXCHAN//2)) check_limits = kwargs.pop('limits', True) # check limits out = StringIO() tau_min, tau_max = tau_limits(lmax, mode) Loading Loading @@ -343,7 +344,7 @@ def coverage(lmax, qmin, **kwargs): q, dq = q_binning(lmax, qmin, it1, it2, dlam=dlam, nt=ntbin) out.write("qave=({0:.3f} +/- {1:.3f})\t".format(q, dq)) out.write("lave={0:.2f} [{1} {2}]\n".format(lave, it1, it2)) _coverage_check_tau(taus, (tau_min, tau_max), lmax, limits_error=limits) _coverage_check_tau(taus, (tau_min, tau_max), lmax, limits_error=check_limits) for tau in taus: res = _gen_plot_data(out, q, tau, lmax, l1,l2) plot_data.append(res+(dq,dq,tau)) Loading pysen/physics/__init__.py +5 −0 Original line number Diff line number Diff line """ 'physics' module """ from .elastic import get_theta, get_q, q_binning, l_binning, t_binning # NOQA Loading
misc/mkedmac.py +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import numpy as np from pysen.lib import t_binning from pysen.physics import t_binning def make_macro(lmax, qmin, q0, dq, data, dlam=3.0, nt=42, mint=3, maxt=39): Loading
misc/nse-range.py +30 −13 Original line number Diff line number Diff line Loading @@ -5,51 +5,68 @@ import matplotlib.pyplot as plt from numpy import asarray, pi, sin, radians from matplotlib.patches import Circle, Wedge, Polygon from scipy.constants import physical_constants, milli, nano kappa = 0.186 # hbar = 0.658/1000.0 from pysen import KAPPA_N_NSA as KAPPA from pysen.config import PHI_LIMS, J_LIMS HBAR = physical_constants['reduced Planck constant in eV s'][0]/milli/nano def heisenberg(x): return hbar/x with np.errstate(divide='ignore'): return HBAR/x wlen = asarray((3.0,14.0)) J = asarray((0.00005, 0.56)) theta = asarray((3.0, 79.5)) J = asarray(J_LIMS) theta = asarray(PHI_LIMS) xE = [] xT = [] xQ = [] qe_plot = True fig, ax1 = plt.subplots() for lam in wlen: t = kappa*J*lam**3 t = KAPPA*J*lam**3 e = heisenberg(t) q = 4*pi/lam*sin(radians(theta/2)) # one if lam==wlen[0]: _e = e[0],e[0],e[1] _t = t[0],t[0],t[1] _q = q[0],q[1],q[1] #two if lam==wlen[1]: _e = e[1],e[1],e[0] _t = t[1],t[1],t[0] _q = q[1],q[0],q[0] xE.extend(_e) xT.extend(_t) xQ.extend(_q) print("lambda=%gA q=%s t=%s E=%s" % (lam, q, t, e)) if qe_plot: qe = np.vstack((xE,xQ)).T ax1.add_patch(Polygon(qe, fill=True, ls='-', lw=2)) ax1.set_xlabel('E [meV]') else: qt = np.vstack((xT,xQ)).T ax1.add_patch(Polygon(qt, fill=True, ls='-', lw=2)) ax1.set_xlabel(r'$\tau$ [ns]') ax1.set_xscale('log') ax1.set_yscale('log') ax1.set_xlabel('E [meV]') ax1.set_ylabel(r'Q [$\AA^-1$]') ax1.grid(True, which='both') if qe_plot: ax2 = ax1.secondary_xaxis('top', functions=(heisenberg, heisenberg)) ax2.set_xlabel(r'$\tau$ [ns]') else: ax2 = ax1.secondary_xaxis('top', functions=(heisenberg, heisenberg)) ax2.set_xlabel('E [meV]') plt.suptitle('SNS-NSE Q-E Coverage') plt.subplots_adjust(top=0.8) Loading
pysen/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ from math import pi as PI import scipy.constants as sc from .lib import get_theta, get_q, q_binning, l_binning, t_binning # NOQA from .physics import get_theta, get_q, q_binning, l_binning, t_binning # NOQA from .misc import setup_logger, dictionary_hash, DEFAULT_LOG_LEVEL # NOQA from .revision import version # NOQA Loading
pysen/config.py +2 −1 Original line number Diff line number Diff line Loading @@ -300,6 +300,7 @@ def coverage(lmax, qmin, **kwargs): detpos = kwargs.pop('pos', 'p2' ) dlam = kwargs.pop('dlam', wavelength_bandwitdh(detpos)) rpixel = kwargs.pop('rpixel', (NXCHAN//2)) check_limits = kwargs.pop('limits', True) # check limits out = StringIO() tau_min, tau_max = tau_limits(lmax, mode) Loading Loading @@ -343,7 +344,7 @@ def coverage(lmax, qmin, **kwargs): q, dq = q_binning(lmax, qmin, it1, it2, dlam=dlam, nt=ntbin) out.write("qave=({0:.3f} +/- {1:.3f})\t".format(q, dq)) out.write("lave={0:.2f} [{1} {2}]\n".format(lave, it1, it2)) _coverage_check_tau(taus, (tau_min, tau_max), lmax, limits_error=limits) _coverage_check_tau(taus, (tau_min, tau_max), lmax, limits_error=check_limits) for tau in taus: res = _gen_plot_data(out, q, tau, lmax, l1,l2) plot_data.append(res+(dq,dq,tau)) Loading
pysen/physics/__init__.py +5 −0 Original line number Diff line number Diff line """ 'physics' module """ from .elastic import get_theta, get_q, q_binning, l_binning, t_binning # NOQA