Ejemplo n.º 1
0
    def _xafsft(self, chi, group=None, rmax_out=10, **kws):
        "returns "
        for key, val in kws:
            if key == 'kw':
                key = 'kweight'
            setattr(self, key, val)
        self.make_karrays()

        out = self.fftf(chi)

        irmax = min(self.nfft / 2, int(1.01 + rmax_out / self.rstep))

        group = set_xafsGroup(group, _larch=self._larch)
        r = self.rstep * arange(irmax)
        mag = sqrt(out.real**2 + out.imag**2)
        group.kwin = self.kwin[:len(chi)]
        group.r = r[:irmax]
        group.chir = out[:irmax]
        group.chir_mag = mag[:irmax]
        group.chir_pha = complex_phase(out[:irmax])
        group.chir_re = out.real[:irmax]
        group.chir_im = out.imag[:irmax]
Ejemplo n.º 2
0
    def _xafsft(self, chi, group=None, rmax_out=10, **kws):
        "returns "
        for key, val in kws:
            if key == 'kw':
                key = 'kweight'
            setattr(self, key, val)
        self.make_karrays()

        out = self.fftf(chi)

        irmax = min(self.nfft/2, int(1.01 + rmax_out/self.rstep))

        group = set_xafsGroup(group, _larch=self._larch)
        r   = self.rstep * arange(irmax)
        mag = sqrt(out.real**2 + out.imag**2)
        group.kwin  =  self.kwin[:len(chi)]
        group.r    =  r[:irmax]
        group.chir =  out[:irmax]
        group.chir_mag =  mag[:irmax]
        group.chir_pha =  complex_phase(out[:irmax])
        group.chir_re  =  out.real[:irmax]
        group.chir_im  =  out.imag[:irmax]
Ejemplo n.º 3
0
def xftf(k, chi=None, group=None, kmin=0, kmax=20, kweight=0,
         dk=1, dk2=None, with_phase=False, window='kaiser', rmax_out=10,
         nfft=2048, kstep=0.05, _larch=None, **kws):
    """
    forward XAFS Fourier transform, from chi(k) to chi(R), using
    common XAFS conventions.

    Parameters:
    -----------
      k:        1-d array of photo-electron wavenumber in Ang^-1 or group
      chi:      1-d array of chi
      group:    output Group
      rmax_out: highest R for output data (10 Ang)
      kweight:  exponent for weighting spectra by k**kweight
      kmin:     starting k for FT Window
      kmax:     ending k for FT Window
      dk:       tapering parameter for FT Window
      dk2:      second tapering parameter for FT Window
      window:   name of window type
      nfft:     value to use for N_fft (2048).
      kstep:    value to use for delta_k (0.05 Ang^-1).
      with_phase: output the phase as well as magnitude, real, imag  [False]

    Returns:
    ---------
      None   -- outputs are written to supplied group.

    Notes:
    -------
    Arrays written to output group:
        kwin               window function Omega(k) (length of input chi(k)).
	r                  uniform array of R, out to rmax_out.
	chir               complex array of chi(R).
	chir_mag           magnitude of chi(R).
	chir_re            real part of chi(R).
	chir_im            imaginary part of chi(R).
	chir_pha           phase of chi(R) if with_phase=True
                           (a noticable performance hit)

    Supports First Argument Group convention (with group member names 'k' and 'chi')
    """
    # allow kweight keyword == kw
    if 'kw' in kws:
        kweight = kws['kw']

    k, chi, group = parse_group_args(k, members=('k', 'chi'),
                                     defaults=(chi,), group=group,
                                     fcn_name='xftf')

    cchi, win  = xftf_prep(k, chi, kmin=kmin, kmax=kmax, kweight=kweight,
                               dk=dk, dk2=dk2, nfft=nfft, kstep=kstep,
                               window=window, _larch=_larch)

    out = xftf_fast(cchi*win, kstep=kstep, nfft=nfft)
    rstep = pi/(kstep*nfft)

    irmax = min(nfft/2, int(1.01 + rmax_out/rstep))

    group = set_xafsGroup(group, _larch=_larch)
    r   = rstep * arange(irmax)
    mag = sqrt(out.real**2 + out.imag**2)
    group.kwin =  win[:len(chi)]
    group.r    =  r[:irmax]
    group.chir =  out[:irmax]
    group.chir_mag =  mag[:irmax]
    group.chir_re  =  out.real[:irmax]
    group.chir_im  =  out.imag[:irmax]
    if with_phase:
        group.chir_pha =  complex_phase(out[:irmax])
Ejemplo n.º 4
0
def xftr(r, chir=None, group=None, rmin=0, rmax=20, with_phase=False,
            dr=1, dr2=None, rw=0, window='kaiser', qmax_out=None,
            nfft=2048, kstep=0.05, _larch=None, **kws):
    """
    reverse XAFS Fourier transform, from chi(R) to chi(q).

    calculate reverse XAFS Fourier transform
    This assumes that chir_re and (optional chir_im are
    on a uniform r-grid given by r.

    Parameters:
    ------------
      r:        1-d array of distance, or group.
      chir:     1-d array of chi(R)
      group:    output Group
      qmax_out: highest *k* for output data (30 Ang^-1)
      rweight:  exponent for weighting spectra by r^rweight (0)
      rmin:     starting *R* for FT Window
      rmax:     ending *R* for FT Window
      dr:       tapering parameter for FT Window
      dr2:      second tapering parameter for FT Window
      window:   name of window type
      nfft:     value to use for N_fft (2048).
      kstep:    value to use for delta_k (0.05).
      with_phase: output the phase as well as magnitude, real, imag  [False]

    Returns:
    ---------
      None -- outputs are written to supplied group.

    Notes:
    -------
    Arrays written to output group:
        rwin               window Omega(R) (length of input chi(R)).
	q                  uniform array of k, out to qmax_out.
	chiq               complex array of chi(k).
	chiq_mag           magnitude of chi(k).
	chiq_re            real part of chi(k).
	chiq_im            imaginary part of chi(k).
	chiq_pha           phase of chi(k) if with_phase=True
                           (a noticable performance hit)

    Supports First Argument Group convention (with group member names 'r' and 'chir')
    """
    if 'rweight' in kws:
        rw = kws['rweight']

    r, chir, group = parse_group_args(r, members=('r', 'chir'),
                                     defaults=(chir,), group=group,
                                     fcn_name='xftr')
    rstep = r[1] - r[0]
    kstep = pi/(rstep*nfft)
    scale = 1.0

    cchir = zeros(nfft, dtype='complex128')
    r_    = rstep * arange(nfft, dtype='float64')

    cchir[0:len(chir)] = chir
    if chir.dtype == np.dtype('complex128'):
        scale = 0.5

    win = ftwindow(r_, xmin=rmin, xmax=rmax, dx=dr, dx2=dr2, window=window)
    out = scale * xftr_fast( cchir*win * r_**rw, kstep=kstep, nfft=nfft)
    if qmax_out is None: qmax_out = 30.0
    q = linspace(0, qmax_out, int(1.05 + qmax_out/kstep))
    nkpts = len(q)

    group = set_xafsGroup(group, _larch=_larch)
    group.q = q
    mag = sqrt(out.real**2 + out.imag**2)
    group.rwin =  win[:len(chir)]
    group.chiq     =  out[:nkpts]
    group.chiq_mag =  mag[:nkpts]
    group.chiq_re  =  out.real[:nkpts]
    group.chiq_im  =  out.imag[:nkpts]
    if with_phase:
        group.chiq_pha =  complex_phase(out[:nkpts])
Ejemplo n.º 5
0
def xftf(k,
         chi=None,
         group=None,
         kmin=0,
         kmax=20,
         kweight=0,
         dk=1,
         dk2=None,
         with_phase=False,
         window='kaiser',
         rmax_out=10,
         nfft=2048,
         kstep=0.05,
         _larch=None,
         **kws):
    """
    forward XAFS Fourier transform, from chi(k) to chi(R), using
    common XAFS conventions.

    Parameters:
    -----------
      k:        1-d array of photo-electron wavenumber in Ang^-1 or group
      chi:      1-d array of chi
      group:    output Group
      rmax_out: highest R for output data (10 Ang)
      kweight:  exponent for weighting spectra by k**kweight
      kmin:     starting k for FT Window
      kmax:     ending k for FT Window
      dk:       tapering parameter for FT Window
      dk2:      second tapering parameter for FT Window
      window:   name of window type
      nfft:     value to use for N_fft (2048).
      kstep:    value to use for delta_k (0.05 Ang^-1).
      with_phase: output the phase as well as magnitude, real, imag  [False]

    Returns:
    ---------
      None   -- outputs are written to supplied group.

    Notes:
    -------
    Arrays written to output group:
        kwin               window function Omega(k) (length of input chi(k)).
	r                  uniform array of R, out to rmax_out.
	chir               complex array of chi(R).
	chir_mag           magnitude of chi(R).
	chir_re            real part of chi(R).
	chir_im            imaginary part of chi(R).
	chir_pha           phase of chi(R) if with_phase=True
                           (a noticable performance hit)

    Supports First Argument Group convention (with group member names 'k' and 'chi')
    """
    # allow kweight keyword == kw
    if 'kw' in kws:
        kweight = kws['kw']

    k, chi, group = parse_group_args(k,
                                     members=('k', 'chi'),
                                     defaults=(chi, ),
                                     group=group,
                                     fcn_name='xftf')

    cchi, win = xftf_prep(k,
                          chi,
                          kmin=kmin,
                          kmax=kmax,
                          kweight=kweight,
                          dk=dk,
                          dk2=dk2,
                          nfft=nfft,
                          kstep=kstep,
                          window=window,
                          _larch=_larch)

    out = xftf_fast(cchi * win, kstep=kstep, nfft=nfft)
    rstep = pi / (kstep * nfft)

    irmax = min(nfft / 2, int(1.01 + rmax_out / rstep))

    group = set_xafsGroup(group, _larch=_larch)
    r = rstep * arange(irmax)
    mag = sqrt(out.real**2 + out.imag**2)
    group.kwin = win[:len(chi)]
    group.r = r[:irmax]
    group.chir = out[:irmax]
    group.chir_mag = mag[:irmax]
    group.chir_re = out.real[:irmax]
    group.chir_im = out.imag[:irmax]
    if with_phase:
        group.chir_pha = complex_phase(out[:irmax])
Ejemplo n.º 6
0
def xftr(r,
         chir=None,
         group=None,
         rmin=0,
         rmax=20,
         with_phase=False,
         dr=1,
         dr2=None,
         rw=0,
         window='kaiser',
         qmax_out=None,
         nfft=2048,
         kstep=0.05,
         _larch=None,
         **kws):
    """
    reverse XAFS Fourier transform, from chi(R) to chi(q).

    calculate reverse XAFS Fourier transform
    This assumes that chir_re and (optional chir_im are
    on a uniform r-grid given by r.

    Parameters:
    ------------
      r:        1-d array of distance, or group.
      chir:     1-d array of chi(R)
      group:    output Group
      qmax_out: highest *k* for output data (30 Ang^-1)
      rweight:  exponent for weighting spectra by r^rweight (0)
      rmin:     starting *R* for FT Window
      rmax:     ending *R* for FT Window
      dr:       tapering parameter for FT Window
      dr2:      second tapering parameter for FT Window
      window:   name of window type
      nfft:     value to use for N_fft (2048).
      kstep:    value to use for delta_k (0.05).
      with_phase: output the phase as well as magnitude, real, imag  [False]

    Returns:
    ---------
      None -- outputs are written to supplied group.

    Notes:
    -------
    Arrays written to output group:
        rwin               window Omega(R) (length of input chi(R)).
	q                  uniform array of k, out to qmax_out.
	chiq               complex array of chi(k).
	chiq_mag           magnitude of chi(k).
	chiq_re            real part of chi(k).
	chiq_im            imaginary part of chi(k).
	chiq_pha           phase of chi(k) if with_phase=True
                           (a noticable performance hit)

    Supports First Argument Group convention (with group member names 'r' and 'chir')
    """
    if 'rweight' in kws:
        rw = kws['rweight']

    r, chir, group = parse_group_args(r,
                                      members=('r', 'chir'),
                                      defaults=(chir, ),
                                      group=group,
                                      fcn_name='xftr')
    rstep = r[1] - r[0]
    kstep = pi / (rstep * nfft)
    scale = 1.0

    cchir = zeros(nfft, dtype='complex128')
    r_ = rstep * arange(nfft, dtype='float64')

    cchir[0:len(chir)] = chir
    if chir.dtype == np.dtype('complex128'):
        scale = 0.5

    win = ftwindow(r_, xmin=rmin, xmax=rmax, dx=dr, dx2=dr2, window=window)
    out = scale * xftr_fast(cchir * win * r_**rw, kstep=kstep, nfft=nfft)
    if qmax_out is None: qmax_out = 30.0
    q = linspace(0, qmax_out, int(1.05 + qmax_out / kstep))
    nkpts = len(q)

    group = set_xafsGroup(group, _larch=_larch)
    group.q = q
    mag = sqrt(out.real**2 + out.imag**2)
    group.rwin = win[:len(chir)]
    group.chiq = out[:nkpts]
    group.chiq_mag = mag[:nkpts]
    group.chiq_re = out.real[:nkpts]
    group.chiq_im = out.imag[:nkpts]
    if with_phase:
        group.chiq_pha = complex_phase(out[:nkpts])