This module implements invariant and its related computations.
author: | Gervaise B. Alina/UTK |
---|---|
author: | Mathieu Doucet/UTK |
author: | Jae Cho/UTK |
Extrapolate I(q) distribution using a given model
Determine a and b given a linear equation y = ax + b
If a model is given, it will be used to linearize the data before the extrapolation is performed. If None, a simple linear fit will be done.
Parameters: |
|
---|
Fit data for y = ax + b return a and b
Parameters: |
|
---|
Bases: sans.invariant.invariant.Transform
class of type Transform that performs operations related to guinier function
alias of type
x.__delattr__(‘name’) <==> del x.name
x.__getattribute__(‘name’) <==> x.name
x.__hash__() <==> hash(x)
helper for pickle
helper for pickle
x.__repr__() <==> repr(x)
x.__setattr__(‘name’, value) <==> x.name = value
x.__str__() <==> str(x)
list of weak references to the object (if defined)
Retrive the guinier function after apply an inverse guinier function to x Compute a F(x) = scale* e-((radius*x)**2/3).
Parameters: |
|
---|---|
Returns: | F(x) |
return F(x)= scale* e-((radius*x)**2/3)
Returns the error on I(q) for the given array of q-values
Parameters: | x – array of q-values |
---|
assign new value to the scale and the radius
Goes through the data points and returns a list of boolean values to indicate whether each points is allowed by the model or not.
Parameters: | data – Data1D object |
---|
Linearize data so that a linear fit can be performed. Filter out the data that can’t be transformed.
Parameters: | data – LoadData1D instance |
---|
Transform the input q-value for linearization
Parameters: | value – q-value |
---|---|
Returns: | q*q |
Bases: object
Compute invariant if data is given. Can provide volume fraction and surface area if the user provides Porod constant and contrast values.
Precondition : | the user must send a data of type DataLoader.Data1D the user provide background and scale values. |
---|---|
Note : | Some computations depends on each others. |
alias of type
x.__delattr__(‘name’) <==> del x.name
x.__getattribute__(‘name’) <==> x.name
x.__hash__() <==> hash(x)
Initialize variables.
Parameters: |
|
---|
helper for pickle
helper for pickle
x.__repr__() <==> repr(x)
x.__setattr__(‘name’, value) <==> x.name = value
x.__str__() <==> str(x)
list of weak references to the object (if defined)
fit data with function using data = self._get_data() fx = Functor(data , function) y = data.y slope, constant = linalg.lstsq(y,fx)
Parameters: |
|
---|
:param power : power value to consider for power-law :param function: the function to use during the fit
Return a: | the scale of the function |
---|---|
Return b: | the other parameter of the function for guinier will be radius for power_law will be the power value |
Note : | this function must be call before computing any type of invariant |
---|---|
Returns: | new data = self._scale *data - self._background |
Returns: | extrapolate data create from data |
---|
Compute invariant for pinhole data. This invariant is given by:
q_star = x0**2 *y0 *dx0 +x1**2 *y1 *dx1
+ ..+ xn**2 *yn *dxn for non smeared data
q_star = dxl0 *x0 *y0 *dx0 +dxl1 *x1 *y1 *dx1
+ ..+ dlxn *xn *yn *dxn for smeared data
where n >= len(data.x)-1
dxl = slit height dQl
dxi = 1/2*(xi+1 - xi) + (xi - xi-1)
dx0 = (x1 - x0)/2
dxn = (xn - xn-1)/2
Parameters: | data – the data to use to compute invariant. |
---|---|
Return q_star: | invariant value for pinhole data. q_star > 0 |
Compute invariant uncertainty with with pinhole data. This uncertainty is given as follow:
dq_star = math.sqrt[(x0**2*(dy0)*dx0)**2 +
(x1**2 *(dy1)*dx1)**2 + ..+ (xn**2 *(dyn)*dxn)**2 ]
where n >= len(data.x)-1 dxi = 1/2*(xi+1 - xi) + (xi - xi-1) dx0 = (x1 - x0)/2 dxn = (xn - xn-1)/2 dyn: error on dy
Parameters: | data – |
---|---|
Note : | if data doesn’t contain dy assume dy= math.sqrt(data.y) |
Returns: | self._data |
---|
Returns the extrapolated data used for the high-Q invariant calculation. By default, the distribution will cover the data points used for the extrapolation. The number of overlap points is a parameter (npts_in). By default, the maximum q-value of the distribution will be Q_MAXIMUM, the maximum q-value used when extrapolating for the purpose of the invariant calculation.
Parameters: |
|
---|
Returns the extrapolated data used for the loew-Q invariant calculation. By default, the distribution will cover the data points used for the extrapolation. The number of overlap points is a parameter (npts_in). By default, the maximum q-value of the distribution will be the minimum q-value used when extrapolating for the purpose of the invariant calculation.
Parameters: |
|
---|
Returns: | the fitted power for power law function for a given |
---|
extrapolation range
Compute the invariant of the local copy of data.
Parameters: | extrapolation – string to apply optional extrapolation |
---|---|
Return q_star: | invariant of the data within data’s q range |
Warning : | When using setting data to Data1D , the user is responsible of checking that the scale and the background are properly apply to the data |
Compute the invariant for extrapolated data at high q range.
Return q_star: | the invariant for data extrapolated at high q. |
---|
Compute the invariant for extrapolated data at low q range.
Return q_star: | the invariant for data extrapolated at low q. |
---|
Compute the invariant uncertainty. This uncertainty computation depends on whether or not the data is smeared.
Parameters: | extrapolation – string to apply optional extrapolation |
---|---|
Returns: | invariant, the invariant uncertainty |
Compute the specific surface from the data.
Implementation:
V = self.get_volume_fraction(contrast, extrapolation)
Compute the surface given by:
surface = (2*pi *V(1- V)*porod_const)/ q_star
Parameters: |
|
---|---|
Returns: | specific surface |
Compute uncertainty of the surface value as well as the surface value. The uncertainty is given as follow:
dS = porod_const *2*pi[( dV -2*V*dV)/q_star
+ dq_star(v-v**2)
q_star: the invariant value
dq_star: the invariant uncertainty
V: the volume fraction value
dV: the volume uncertainty
Parameters: |
|
---|---|
Return S, dS: | the surface, with its uncertainty |
Compute volume fraction is deduced as follow:
q_star = 2*(pi*contrast)**2* volume( 1- volume)
for k = 10^(-8)*q_star/(2*(pi*|contrast|)**2)
we get 2 values of volume:
with 1 - 4 * k >= 0
volume1 = (1- sqrt(1- 4*k))/2
volume2 = (1+ sqrt(1- 4*k))/2
q_star: the invariant value included extrapolation is applied
unit 1/A^(3)*1/cm
q_star = self.get_qstar()
the result returned will be 0 <= volume <= 1
Parameters: |
|
---|---|
Returns: | volume fraction |
Note : | volume fraction must have no unit |
Compute uncertainty on volume value as well as the volume fraction This uncertainty is given by the following equation:
dV = 0.5 * (4*k* dq_star) /(2* math.sqrt(1-k* q_star))
for k = 10^(-8)*q_star/(2*(pi*|contrast|)**2)
q_star: the invariant value including extrapolated value if existing
dq_star: the invariant uncertainty
dV: the volume uncertainty
The uncertainty will be set to -1 if it can’t be computed.
Parameters: |
|
---|---|
Returns: | V, dV = volume fraction, error on volume fraction |
Set the extrapolation parameters for the high or low Q-range. Note that this does not turn extrapolation on or off.
Parameters: |
|
---|
Bases: sans.invariant.invariant.Transform
class of type transform that perform operation related to power_law function
alias of type
x.__delattr__(‘name’) <==> del x.name
x.__getattribute__(‘name’) <==> x.name
x.__hash__() <==> hash(x)
helper for pickle
helper for pickle
x.__repr__() <==> repr(x)
x.__setattr__(‘name’, value) <==> x.name = value
x.__str__() <==> str(x)
list of weak references to the object (if defined)
Parameters: | x – array |
---|---|
Returns: | F(x) |
given a scale and a radius transform x, y using a power_law function
Returns the error on I(q) for the given array of q-values :param x: array of q-values
Assign new value to the scale and the power
Goes through the data points and returns a list of boolean values to indicate whether each points is allowed by the model or not.
Parameters: | data – Data1D object |
---|
Linearize data so that a linear fit can be performed. Filter out the data that can’t be transformed.
Parameters: | data – LoadData1D instance |
---|
Transform the input q-value for linearization
Parameters: | value – q-value |
---|---|
Returns: | log(q) |
Bases: object
Define interface that need to compute a function or an inverse function given some x, y
alias of type
x.__delattr__(‘name’) <==> del x.name
x.__getattribute__(‘name’) <==> x.name
x.__hash__() <==> hash(x)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
helper for pickle
helper for pickle
x.__repr__() <==> repr(x)
x.__setattr__(‘name’, value) <==> x.name = value
x.__str__() <==> str(x)
list of weak references to the object (if defined)
Returns an array f(x) values where f is the Transform function.
Returns an array of I(q) errors
set private member
Goes through the data points and returns a list of boolean values to indicate whether each points is allowed by the model or not.
Parameters: | data – Data1D object |
---|
Linearize data so that a linear fit can be performed. Filter out the data that can’t be transformed.
Parameters: | data – LoadData1D instance |
---|
Transform the input q-value for linearization