Commit e6be40b6 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

new SillyEchoSimulator app

parent 86c136a5
Loading
Loading
Loading
Loading

misc/nse-range.py

0 → 100755
+56 −0
Original line number Diff line number Diff line
#!/usr/bin/env python

import numpy as np
import matplotlib.pyplot as plt

from numpy import asarray, pi, sin, radians
from matplotlib.patches import Circle, Wedge, Polygon

kappa = 0.186 # 
hbar  = 0.658/1000.0

def heisenberg(x):
    return hbar/x

wlen  = asarray((3.0,14.0))
J     = asarray((0.00005, 0.56))
theta = asarray((3.0, 79.5))


xE = []
xQ = []

fig, ax1 = plt.subplots()

for lam in wlen:
    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]
        _q = q[0],q[1],q[1]
    #two
    if lam==wlen[1]:
        _e = e[1],e[1],e[0]
        _q = q[1],q[0],q[0]
    xE.extend(_e)
    xQ.extend(_q)
    print("lambda=%gA q=%s t=%s E=%s" % (lam, q, t, e))

qe = np.vstack((xE,xQ)).T
ax1.add_patch(Polygon(qe, fill=True, ls='-', lw=2))

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')


ax2 = ax1.secondary_xaxis('top', functions=(heisenberg, heisenberg))
ax2.set_xlabel(r'$\tau$ [ns]')

plt.suptitle('SNS-NSE Q-E Coverage')
plt.subplots_adjust(top=0.8)
plt.show()
+4 −4
Original line number Diff line number Diff line
@@ -54,11 +54,11 @@ NYCHAN = 32 # number of detector channels (vertical direction)
H_FAC  = sqrt(log(2.0)/2.0)
H_RES  = 0.7   # [A^2/ns] - resolution coefficient
# STANDARD MODE
J1_MIN = 0.001 # [T*m] min field integral (1 mT*m = 10 Gauss*m)
J1_MAX = 0.560 # [T*m] max field integral (nominal 1.0 T*m, actual 0.57 T*m)
J1_MIN = 0.005  # [T*m] min field integral (5 mT*m = 50 Gauss*m, somewhat arbitrary)
J1_MAX = 0.560  # [T*m] max field integral (actual 0.56 T*m, "nominal" 1.0 T*m)
# SHORTY_2 MODE
J2_MIN = 0.00001
J2_MAX = 0.02000
J2_MIN = 0.0005 # [T*m] min field integral (0.5 mTm =   5 Gauss*m) # TODO: verify this
J2_MAX = 0.0100 # [T*m] max field integral (10  mTm = 100 Gauss*m) # TODO: verify this

# 5. Misc other data
ATTENUATOR_TABLE_08A = {
+26 −19
Original line number Diff line number Diff line
@@ -102,17 +102,20 @@ def action_datreat(filenames, **kwargs):
def action_qtau(filenames, **kwargs):
    "action for q-tau plot"
    __template="""# -*- python -*-
# list of taus for 8A
taus_8A  = [0.1,0.2,0.4,0.7,1,2,4,7,10,20,30,50]
# list of taus for 11A
taus_11A = [50,70,100,120]

# coverage data, a list of coverage statements
data = [
    # 8A
    coverage( 8, qmin=0.050, pos='p2', taus=taus_8A ),
    coverage( 8, qmin=0.070, pos='p2', taus=taus_8A ),
    coverage( 8, qmin=0.095, pos='p2', taus=taus_8A ),
    # 11A
    coverage(11, qmin=0.050, pos='p2', taus=taus_11A),
    coverage(11, qmin=0.065, pos='p2', taus=taus_11A),
    # 8A coverage
    coverage(8.0,  qmin=0.050, pos=p2, taus=taus_8A ),
    coverage(8.0,  qmin=0.070, pos=p2, taus=taus_8A ),
    coverage(8.0,  qmin=0.095, pos=p2, taus=taus_8A ),
    # 11A coverage
    coverage(11.0, qmin=0.050, pos=p2, taus=taus_11A),
    coverage(11.0, qmin=0.065, pos=p2, taus=taus_11A),
]
"""
    savefig = kwargs.pop('savefig', None)
@@ -127,6 +130,7 @@ data = [
    center = kwargs.pop('center', True)
    legend = kwargs.pop('legend', True)
    full   = kwargs.pop('full'  , False)
    maxlimits = kwargs.pop('maxlimits', False)
    #
    title  = kwargs.pop('title' , None)
    cmap   = kwargs.pop('cmap'  , 'jet')
@@ -136,6 +140,9 @@ data = [
        return

    data  = []
    if max_limits:
        data = [ coverage(lmax, qmin, max_limits=True) ]
    else:
        try:
            lcls = locals()
            lcls['np'] = np
+2 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ PySEN revision module
"""
import sys
__version__  = "1.0"
__release__  = "rc4"
__date__     = "Aug 24, 2022"
__release__  = "rc5"
__date__     = "Sep 29, 2022"

def version(full=False):
    "get pysen version number"
+3 −1
Original line number Diff line number Diff line

UISRC=NSEMainWindow.ui \
      FileMonMainWindow.ui \
	  QTauMainWindow.ui
	  QTauMainWindow.ui \
	  SillyEchoSimulator.ui


PYSRC=${UISRC:%.ui=ui_%.py}

Loading