Commit 913d1950 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

added q_vec to last_sqt_bin

also some python scripts to aid plotting q_vector
parent d0a355e9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ export PROJECT=drspine

export VERSION_MAJOR=1
export VERSION_MINOR=1
export VERSION_RELEASE=4
export VERSION_RELEASE=5

export PROJLIB=lib$(PROJECT).a
export PROJARCH=$(PROJECT)-$(VERSION_MAJOR).$(VERSION_MINOR)
+3 −2
Original line number Diff line number Diff line
#
__all__     = ['plot_sqt', 'plot_sqt_bin', 'plot_chi2', 'plot_q',
__all__     = ['plot_sqt', 'plot_sqt_bin', 'plot_chi2',
               'plot_q', 'plot_qvec', 'plot_qmap',
               'plot_fits', 'plot_maps', 'plot_fit_pixel', 'plot_fit_map',
               'drspine_version']

from .drspine import plot_sqt , plot_sqt_bin, plot_chi2, plot_q
from .drspine import plot_sqt , plot_sqt_bin, plot_chi2, plot_q, plot_qvec, plot_qmap
from .fits    import plot_fits, plot_maps, plot_fit_pixel, plot_fit_map
from .version import __version__ as drspine_version
+60 −1
Original line number Diff line number Diff line
@@ -262,6 +262,7 @@ def plot_sqt(filename, **kwargs):
#13,14 :  down, e_down  (sig)
#15,16 :  chisq (res), chisq (sig)
#17    :  run_number
#18-20 :  q_vec
def _load_sqt_bin(filename, full_bw=False):
    s = load_txt(filename, delimiter=',', cleanup=['NaN', 'Infinity'])

@@ -329,12 +330,70 @@ def plot_chi2(filename, chimax=100.0, nbins=101, ndf=19, full_bw=True):


def plot_q(filename, full_bw=False, **kwargs):
    """plot q, i.e. histograms of abs(q)"""
    d = _load_sqt_bin(filename, full_bw)

    bins     = kwargs.pop('bins', 41)
    histtype = kwargs.pop('histtype', 'step')

    plt.hist(d[:,4], weights=d[:,11], bins=bins, histtype=histtype, **kwargs)
    q = d[:, 4]
    w = d[:,11] + d[:,13]

    plt.hist(q, weights=w, bins=bins, histtype=histtype, **kwargs)

    plt.grid(True, which='both')
    plt.xlabel(r'Q [$\AA$]')
    plt.ylabel('Intensity (arb)')

def plot_qvec(filename, full_bw=False, **kwargs):
    """plot qvec, i.e. histograms of qx,qy and qz"""
    d = _load_sqt_bin(filename, full_bw)

    bins     = kwargs.pop('bins', 41)
    histtype = kwargs.pop('histtype', 'step')
    q = d[:,18:21]
    w = d[:,11] + d[:,13]

    plt.hist(q[:,0], weights=w, bins=bins, histtype=histtype, label=r'$q_x$', **kwargs)
    plt.hist(q[:,1], weights=w, bins=bins, histtype=histtype, label=r'$q_y$', **kwargs)
    plt.hist(q[:,2], weights=w, bins=bins, histtype=histtype, label=r'$q_z$', **kwargs)
    plt.legend()
    plt.grid(True, which='both')
    plt.xlabel(r'Q [$\AA$]')
    plt.ylabel('Intensity (arb)')

def plot_qmap(filename, full_bw=False, **kwargs):
    """plot q map, i.e. qA-vs-qB
    where A and B depend on maptype, see axes_mapping below

    a => |q|
    x => q(x)  - horizontal (beam) direction
    y => q(y)  - horizontal direction (perp. to x)
    z => q(z)  - vertical direction

    """
    axes_mapping = { 'a': 0, # abs value 
                     'x': 1,
                     'y': 2,
                     'z': 3,}

    d = _load_sqt_bin(filename, full_bw)

    bins    = kwargs.pop('bins', 41)
    maptype = kwargs.pop('type', 'yx')

    w  = d[:,11] + d[:,13]
    q0 = d[:,4]
    qv = d[:,18:21]
    #qp = np.sqrt(qv[:,1]**2 + qv[:,2]**2)
    q  = np.hstack([q0[:,np.newaxis],qv])

    idx1 = axes_mapping.get(maptype[0],0)
    idx2 = axes_mapping.get(maptype[1],1)

    plt.hist2d(q[:,idx1], q[:,idx2], weights=w, bins=bins, **kwargs)
    plt.colorbar()

    plt.xlabel(r'Q$_%s$ [$\AA$]' % maptype[0])
    plt.ylabel(r'Q$_%s$ [$\AA$]' % maptype[1])
    plt.grid(True, which='both')
+18 −0
Original line number Diff line number Diff line
@@ -2156,6 +2156,24 @@ CONTAINS
       extra_args = "npix="//trim(ctmp)//", "//trim(extra_args)
       write(ctmp,'(i0)') itau
       extra_args = "tau="//trim(ctmp)//","//trim(extra_args)
    else if ( found('qvec') ) then
       pyfunc='plot_qvec'
       filename = program_param%file_sqt_bin
       extra_args=' '
       if (found('nbins') ) then
           npix = get_named_value('nbins ', npix, inew)
           write(ctmp,'(i0)') npix
           extra_args = "bins="//trim(ctmp)//", "//trim(extra_args)
       endif
    else if ( found('qmap') ) then
       pyfunc='plot_qmap'
       filename = program_param%file_sqt_bin
       extra_args=' '
       if (found('nbins') ) then
           npix = get_named_value('nbins ', npix, inew)
           write(ctmp,'(i0)') npix
           extra_args = "bins="//trim(ctmp)//", "//trim(extra_args)
       endif
    else if ( found('q') ) then
       pyfunc='plot_q'
       filename = program_param%file_sqt_bin
+6 −2
Original line number Diff line number Diff line
@@ -492,6 +492,7 @@ bgr_pixel_bin(l)
    write (iunit,'(a)', advance='no') ' DOWN(Q,T)                  '
    write (iunit,'(a)', advance='no') '  CHI2_RES      CHI2_SIG    '
    write (iunit,'(a)', advance='no') '     RUN   '
    write (iunit,'(a)', advance='no') '     Q_VEC '
    write (iunit,*)
  end subroutine collect_sqt_raw_header

@@ -539,7 +540,10 @@ bgr_pixel_bin(l)
                    res_point%pixelbin(it, ix, iy)%chi_squared*res_point%pixelbin(it, ix, iy)%ndf
                write(iunit,'(g13.6,",")', advance='no') &
                    sig_point%pixelbin(it, ix, iy)%chi_squared*sig_point%pixelbin(it, ix, iy)%ndf
                write(iunit,'(i8)', advance='yes') sig_data%id
                write(iunit,'(i8,",")', advance='no') sig_data%id
                write(iunit,'(g13.6,",")', advance='no')  sig_point%pixelbin(it, ix, iy)%Q_vec(1)*ANGSTROEM
                write(iunit,'(g13.6,",")', advance='no')  sig_point%pixelbin(it, ix, iy)%Q_vec(2)*ANGSTROEM
                write(iunit,'(g13.6    )', advance='yes') sig_point%pixelbin(it, ix, iy)%Q_vec(3)*ANGSTROEM
             end do
          end do
       end do