Transformer
This module defines the Transformer class that performs the Fourier transforms
- class pystog.transformer.Transformer[source]
Bases:
objectThe Transformer class is used to Fourier transform between the difference spaces. Either: a reciprocal space function -> real space function or a real space function -> reciprocal space function
- Examples:
>>> import numpy >>> from pystog import Transformer >>> transformer = Transformer() >>> q, sq = numpy.loadtxt("my_sofq_file.txt",unpack=True) >>> r = numpy.linspace(0., 25., 2500) >>> r, gr, dgr = transformer.S_to_G(q, sq, r) >>> q = numpy.linspace(0., 25., 2500) >>> q, sq, dsq = transformer.G_to_S(r, gr, q)
- DCS_to_G(q, dcs, r, ddcs=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectordcs (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectorddcs (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- DCS_to_GK(q, dcs, r, ddcs=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectordcs (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectorddcs (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- DCS_to_g(q, dcs, r, ddcs=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectordcs (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectorddcs (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- FK_to_G(q, fq_keen, r, dfq_keen=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectorfq_keen (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectordfq_keen (numpy.array or list) –
vector uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- FK_to_GK(q, fq_keen, r, dfq_keen=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectorfq_keen (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectordfq_keen (numpy.array or list) –
vector uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- FK_to_g(q, fq_keen, r, dfq_keen=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectorfq_keen (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectordfq_keen (numpy.array or list) –
vector uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- F_to_G(q, fq, r, dfq=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectorfq (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectordfq (numpy.array or list) – uncertainty on
![Q[S(Q)-1]](../_images/math/9196f18b3b0ead3d55df8e9f48862e8d1e5141e8.png)
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- F_to_GK(q, fq, r, dfq=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectorfq (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectordfq (numpy.array or list) – uncertainty on
![Q[S(Q)-1]](../_images/math/9196f18b3b0ead3d55df8e9f48862e8d1e5141e8.png)
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- F_to_g(q, fq, r, dfq=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectorfq (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectordfq (numpy.array or list) – uncertainty on
![Q[S(Q)-1]](../_images/math/9196f18b3b0ead3d55df8e9f48862e8d1e5141e8.png)
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- GK_to_DCS(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space 
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
,
and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- GK_to_F(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space ![Q[S(Q)-1]](../_images/math/9196f18b3b0ead3d55df8e9f48862e8d1e5141e8.png)
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- GK_to_FK(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space 
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- GK_to_S(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space 
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- G_to_DCS(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space

- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
,
and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- G_to_F(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space ![Q[S(Q)-1]](../_images/math/9196f18b3b0ead3d55df8e9f48862e8d1e5141e8.png)
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- G_to_FK(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space 
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- G_to_S(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space 
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- S_to_G(q, sq, r, dsq=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectorsq (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectordsq (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- S_to_GK(q, sq, r, dsq=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectorsq (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectordsq (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- S_to_g(q, sq, r, dsq=None, **kwargs)[source]
Transforms from reciprocal space
to real space 
- Parameters:
q (numpy.array or list) –
-space vectorsq (numpy.array or list) –
vectorr (numpy.array or list) –
-space vectordsq (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- apply_cropping(x, y, xmin, xmax, dy=None)[source]
Utility to crop x and y based on xmin and xmax along x. Provides the capability to specify the (Qmin,Qmax) or (Rmin,Rmax) in the Fourier transform
- Parameters:
x (numpy.array or list) – domain vector
y (numpy.array or list) – range vector
xmin (float) – minimum x-value for crop
xmax (float) – maximum x-value for crop
dy (numpy.array or list) – uncertainty vector
- Returns:
vector pair (x,y) with cropping applied
- Return type:
(numpy.array, numpy.array, numpy.array)
- fourier_transform(xin, yin, xout, xmin=None, xmax=None, dy_in=None, **kwargs)[source]
The Fourier transform function. The kwargs argument allows for different modifications: Lorch dampening, omitted low-x range correction,
- Parameters:
xin (numpy.array or list) – domain vector for space to be transformed from
yin (numpy.array or list) – range vector for space to be transformed from
xout (numpy.array or list) – domain vector for space to be transformed to
xmin (float) – minimum x-value for crop
xmax (float) – maximum x-value for crop
dy_in (numpy.array or list) – uncertainty vector for yin
- Returns:
vector pair of transformed domain, range vectors, and uncertainties
- Return type:
numpy.array, numpy.array, numpy.array
- g_to_DCS(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space 
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
,
and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- g_to_F(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space ![Q[S(Q)-1]](../_images/math/9196f18b3b0ead3d55df8e9f48862e8d1e5141e8.png)
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- g_to_FK(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space 
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array
- g_to_S(r, gr, q, dgr=None, **kwargs)[source]
Transforms from real space
to reciprocal space 
- Parameters:
r (numpy.array or list) –
-space vectorgr (numpy.array or list) –
vectorq (numpy.array or list) –
-space vectordgr (numpy.array or list) –
uncertainties
- Returns:
,
, and uncertainties- Return type:
numpy.array, numpy.array, numpy.array