sas.sascalc.invariant package

Submodules

sas.sascalc.invariant.invariant module

This module implements invariant and its related computations.

author:

Gervaise B. Alina/UTK

author:

Mathieu Doucet/UTK

author:

Jae Cho/UTK

author:

Paul Butler/NIST/UD/UTK – refactor in 2020

class sas.sascalc.invariant.invariant.Extrapolator(data, model=None)

Bases: object

Extrapolate I(q) distribution using a given model.

__dict__ = mappingproxy({'__module__': 'sas.sascalc.invariant.invariant', '__firstlineno__': 292, '__doc__': 'Extrapolate I(q) distribution using a given model.', '__init__': <function Extrapolator.__init__>, 'fit': <function Extrapolator.fit>, '__static_attributes__': ('data', 'model', 'qmax', 'qmin'), '__dict__': <attribute '__dict__' of 'Extrapolator' objects>, '__weakref__': <attribute '__weakref__' of 'Extrapolator' objects>, '__annotations__': {}})
__doc__ = 'Extrapolate I(q) distribution using a given model.'
__firstlineno__ = 292
__init__(data, model=None)

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:
  • data – data containing x and y, such as y = ax + b

  • model – optional Transform object

__module__ = 'sas.sascalc.invariant.invariant'
__static_attributes__ = ('data', 'model', 'qmax', 'qmin')
__weakref__

list of weak references to the object

fit(power: float | None = None, qmin: float | None = None, qmax: float | None = None) tuple[list[float], list[float]]

Fit data for \(y = ax + b\) return \(a\) and \(b\)

Parameters:
  • power – a fixed, otherwise None

  • qmin – Minimum Q-value

  • qmax – Maximum Q-value

Returns:

a tuple containing two arrays: - the parameters of the model [a, b], - the uncertainties of the parameters [da, db].

class sas.sascalc.invariant.invariant.Guinier(scale: float = 1, Rg_squared: float = 3600)

Bases: Transform

Child class of Transform that performs operations related to Guinier function.

Rg_squared: float
__abstractmethods__ = frozenset({})
__annotations__ = {'Rg_squared': 'float', 'dRg_squared': 'float', 'dscale': 'float', 'scale': 'float'}
__doc__ = 'Child class of Transform that performs operations related to Guinier function.'
__firstlineno__ = 128
__init__(scale: float = 1, Rg_squared: float = 3600)
__module__ = 'sas.sascalc.invariant.invariant'
__static_attributes__ = ('Rg_squared', 'dRg_squared', 'dscale', 'scale')
_abc_impl = <_abc._abc_data object>
_guinier(x: ndarray) ndarray

Retrieve the Guinier function after apply an inverse guinier function to x. Compute \(F(x) = s * \exp\left(-(r x)^{2}/3\right)\).

Parameters:

x – a vector of q values

Also uses:
  • self.scale: \(s\), the scale value

  • self.Rg_squared: \(R_g^2\), the guinier radius value squared

Returns:

F(x), the form factor calculated by the Guinier function for the given q values.

dRg_squared: float
dscale: float
evaluate_model(x: ndarray) ndarray

Returns calculated I(q) for the model. Calculates the Guinier expression \(I(q)= s * \exp\left(-(R_g x)^{2}/3\right)\)

Parameters:

x – a vector of q values.

Returns:

an array of I(q) values calculated by the model.

evaluate_model_errors(x: ndarray) ndarray

Returns the error on I(q) for the given array of q-values.

Parameters:

x – array of q-values.

Returns:

an array of errors corresponding to the I(q) values calculated by the model.

extract_model_parameters(constant: float, slope: float, dconstant: float = 0, dslope: float = 0) tuple[list[float], list[float]]

Assign new value to the scale and the radius.

Parameters:
  • constant – the intercept from the linear fit.

  • slope – the slope from the linear fit.

  • dconstant – the uncertainty of the intercept from the linear fit.

  • dslope – the uncertainty of the slope from the linear fit.

Returns:

a tuple containing two lists: - the parameters of the model [Rg_squared, scale], - the uncertainties of the parameters [dRg_squared, dscale].

linearize_q_value(value: float) float

Transform the input q-value for linearization. Returns the square of the q-value, which is used for linearizing the Guinier function.

Parameters:

value – q-value

Returns:

\(q^2\)

scale: float
class sas.sascalc.invariant.invariant.InvariantCalculator(data: Data1D, background: float = 0, scale: float = 1)

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.

__annotations__ = {'_background': 'float', '_high_extrapolation_function': 'Transform', '_high_extrapolation_npts': 'int', '_high_extrapolation_power': 'float | None', '_high_extrapolation_power_fitted': 'float | None', '_low_extrapolation_function': 'Transform', '_low_extrapolation_npts': 'int', '_low_extrapolation_power': 'float | None', '_low_extrapolation_power_fitted': 'float | None', '_low_q_limit': 'float', '_qstar': 'float | None', '_qstar_err': 'float', '_scale': 'float'}
__dict__ = mappingproxy({'__module__': 'sas.sascalc.invariant.invariant', '__firstlineno__': 377, '__doc__': '\nCompute invariant if data is given.\nCan provide volume fraction and surface area if the user provides Porod constant and contrast values.\n\n:precondition:  the user must send a data of type DataLoader.Data1D\n                the user provide background and scale values.\n\n:note: Some computations depends on each others.\n', '__init__': <function InvariantCalculator.__init__>, 'background': <property object>, 'scale': <property object>, 'set_data': <function InvariantCalculator.set_data>, '_get_data': <function InvariantCalculator._get_data>, '_fit': <function InvariantCalculator._fit>, '_get_qstar': <function InvariantCalculator._get_qstar>, '_get_qstar_uncertainty': <function InvariantCalculator._get_qstar_uncertainty>, '_get_extrapolated_data': <function InvariantCalculator._get_extrapolated_data>, 'get_data': <function InvariantCalculator.get_data>, 'get_extrapolation_power': <function InvariantCalculator.get_extrapolation_power>, 'get_qstar_low': <function InvariantCalculator.get_qstar_low>, 'get_qstar_high': <function InvariantCalculator.get_qstar_high>, 'get_extra_data_low': <function InvariantCalculator.get_extra_data_low>, 'get_extra_data_high': <function InvariantCalculator.get_extra_data_high>, 'set_extrapolation': <function InvariantCalculator.set_extrapolation>, 'get_qstar': <function InvariantCalculator.get_qstar>, 'get_surface': <function InvariantCalculator.get_surface>, 'get_volume_fraction': <function InvariantCalculator.get_volume_fraction>, 'get_contrast': <function InvariantCalculator.get_contrast>, 'get_qstar_with_error': <function InvariantCalculator.get_qstar_with_error>, 'get_volume_fraction_with_error': <function InvariantCalculator.get_volume_fraction_with_error>, 'get_contrast_with_error': <function InvariantCalculator.get_contrast_with_error>, 'get_surface_with_error': <function InvariantCalculator.get_surface_with_error>, '__static_attributes__': ('_background', '_data', '_high_extrapolation_function', '_high_extrapolation_npts', '_high_extrapolation_power', '_high_extrapolation_power_fitted', '_low_extrapolation_function', '_low_extrapolation_npts', '_low_extrapolation_power', '_low_extrapolation_power_fitted', '_low_q_limit', '_qstar', '_qstar_err', '_scale', '_smeared'), '__dict__': <attribute '__dict__' of 'InvariantCalculator' objects>, '__weakref__': <attribute '__weakref__' of 'InvariantCalculator' objects>, '__annotations__': {'_background': 'float', '_scale': 'float', '_qstar': 'float | None', '_qstar_err': 'float', '_low_extrapolation_npts': 'int', '_low_extrapolation_function': 'Transform', '_low_extrapolation_power': 'float | None', '_low_extrapolation_power_fitted': 'float | None', '_low_q_limit': 'float', '_high_extrapolation_npts': 'int', '_high_extrapolation_function': 'Transform', '_high_extrapolation_power': 'float | None', '_high_extrapolation_power_fitted': 'float | None'}})
__doc__ = '\nCompute invariant if data is given.\nCan provide volume fraction and surface area if the user provides Porod constant and contrast values.\n\n:precondition:  the user must send a data of type DataLoader.Data1D\n                the user provide background and scale values.\n\n:note: Some computations depends on each others.\n'
__firstlineno__ = 377
__init__(data: Data1D, background: float = 0, scale: float = 1)

Initialize variables.

Parameters:
  • data – data must be of type DataLoader.Data1D.

  • background – Background value.

  • scale – Scaling factor for I(q).

The data will be corrected before processing.

__module__ = 'sas.sascalc.invariant.invariant'
__static_attributes__ = ('_background', '_data', '_high_extrapolation_function', '_high_extrapolation_npts', '_high_extrapolation_power', '_high_extrapolation_power_fitted', '_low_extrapolation_function', '_low_extrapolation_npts', '_low_extrapolation_power', '_low_extrapolation_power_fitted', '_low_q_limit', '_qstar', '_qstar_err', '_scale', '_smeared')
__weakref__

list of weak references to the object

_background: float
_fit(model: Transform, qmin: float = 1e-05, qmax: float = 10, power: float | None = None) tuple[list[float], list[float]]

Fit data with function using data = self._get_data() fx = Functor(data, function) y = data.y slope, constant = linalg.lstsq(y,fx)

Parameters:
  • model – the function to use for the fit. Must be a child class of Transform.

  • qmin – data first q value to consider during the fit.

  • qmax – data last q value to consider during the fit.

  • power – power value to consider for power-law,

  • function – the function to use during the fit,

Returns:

a tuple containing two lists: - the parameters of the model, which are scale and:

  • for Guinier, the radius of gyration,

  • for power law, the power value.

  • the uncertainties on the parameters.

_get_data(data: Data1D) Data1D

This function must be called before computing any type of invariant.

Parameters:

data – the data to use for the Invariant calculation. Must be of type DataLoader.Data1D.

Returns:

new data = self._scale x data - self._background

_get_extrapolated_data(model, npts=1000, q_start=1e-05, q_end=10)
Returns:

extrapolate data create from data

_get_qstar(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

_get_qstar_uncertainty(data)

Compute invariant uncertainty with with pinhole data. This uncertainty is given as follows:

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 return “None”

_high_extrapolation_function: Transform
_high_extrapolation_npts: int
_high_extrapolation_power: float | None
_high_extrapolation_power_fitted: float | None
_low_extrapolation_function: Transform
_low_extrapolation_npts: int
_low_extrapolation_power: float | None
_low_extrapolation_power_fitted: float | None
_low_q_limit: float
_qstar: float | None
_qstar_err: float
_scale: float
property background: float
get_contrast(volume, extrapolation=None)

Compute contrast is deduced as follows:

q_star = 2*(pi*contrast)**2 * volume*(1- volume)
contrast**2 = 10^(-8) * q_star / (2 * pi**2 * volume * (1- volume))
we get |contrast| = sqrt(10^(-8) * q_star / (2 * pi**2 * volume * (1- volume)))

    10^(-8) converts from cm^-1 to A^-1

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 <= |contrast|
Parameters:
  • volume – volume fraction provided by the user of type float. volume must be between 0 and 1 volume must have no unit

  • extrapolation – string to apply optional extrapolation

Returns:

contrast

Note:

contrast is returned in units of 1/A^(2) = 10^(16)cm^(2)

get_contrast_with_error(volume, volume_err=0.0, extrapolation=None)

Compute uncertainty on contrast value as well as the contrast This uncertainty is given by the following equation:

sigcontrast = sqrt((d contrast/d q_star * sigq_star)^2 + (d contrast/d k * sigk)^2)

for k = volume * (1 - volume)

so that:

sigcontrast = |contrast| / 2 * sqrt((sigq_star / q_star)^2 + (sigk / k)^2)

Notes:

  • q_star: the invariant, in cm^-1A^-3, including extrapolated values if they have been requested

  • sigq_star: the invariant uncertainty

  • k: volume * (1 - volume)

  • sigk: the uncertainty on k

  • sigcontrast: the contrast uncertainty

The uncertainty will be set to -1 if it can’t be computed.

Parameters:
  • volume – volume fraction value

  • volume_err – volume fraction uncertainty

  • extrapolation – string to apply optional extrapolation

Returns:

contrast, dcontrast = contrast, error on contrast

get_data()
Returns:

self._data

get_extra_data_high(npts_in=None, q_end=10, npts=20)

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:
  • npts_in – number of data points for which the extrapolated data overlap

  • q_end – is the maximum value to uses for extrapolated data

  • npts – the number of points in the extrapolated distribution

get_extra_data_low(npts_in=None, q_start=None, npts=20)

Returns the extrapolated data used for the low-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:
  • npts_in – number of data points for which the extrapolated data overlap

  • q_start – is the minimum value to uses for extrapolated data

  • npts – the number of points in the extrapolated distribution

get_extrapolation_power(range='high')
Returns:

the fitted power for power law function for a given extrapolation range

get_qstar(extrapolation=None)

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

get_qstar_high(high_q_limit=None)

Compute the invariant for extrapolated data at high q range.

Implementation:

data = self._get_extra_data_high()
return self._get_qstar()
Return q_star:

the invariant for data extrapolated at high q.

get_qstar_low(low_q_limit=None)

Compute the invariant for extrapolated data at low q range.

Implementation:

data = self._get_extra_data_low()
return self._get_qstar()
Return q_star:

the invariant for data extrapolated at low q.

get_qstar_with_error(extrapolation=None)

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

get_surface(contrast, porod_const, extrapolation=None)

Compute the specific surface from the data.

Historically, Sv was computed with the invariant and the Porod constant so as not to have to know the contrast in order to get the Sv as:

surface = (pi * V * (1- V) * porod_const) / q_star

However, that turns out to be a pointless exercise since it also requires a knowledge of the volume fractions and from the volume fraction and the invariant the contrast can be calculated as:

contrast**2 = q_star / (2 * pi**2 * V * (1- V))

Thus either way, mathematically it is always identical to computing with only the contrast and the Porod Constant. up to and including SasView versions 4.2.2 and 5.0.1 the implementation used the traditional circular approach.

Implementation:

Given the above, as of SasView 4.3 and 5.0.2 we compute Sv simply
from the Porod Constant and the contrast between the two phases as:

surface = porod_const / (2 * pi contrast**2)
Parameters:
  • contrast – contrast between the two phases

  • porod_const – Porod constant

  • extrapolation – string to apply optional extrapolation. This will only be needed if and when the contrast term is calculated from the invariant.

Returns:

specific surface

get_surface_with_error(contrast, porod_const, contrast_err=None, porod_const_err=None, extrapolation=None)

Compute the specific surface and its propagated uncertainty.

The specific surface S is computed via:

S = porod_const / (2 * pi * contrast**2)

where the Porod constant is internally converted to the units required by get_surface().

The uncertainty is calculated using standard linear error propagation, assuming independent and small uncertainties:

(dS / S)^2 = (dP / P)^2 + (2 dC / C)^2
where:

P = porod_const dP = porod_const_err C = contrast dC = contrast_err

This formulation automatically accounts for the internal unit conversion applied to the Porod constant.

Parameters

contrastfloat

Scattering length density contrast between the two phases. Must be non-zero. Units must be consistent with contrast_err.

porod_constfloat

Porod constant. Units must be consistent with porod_const_err. The value is converted internally to the units used by get_surface().

contrast_errfloat or None, optional

One-sigma uncertainty on contrast. If None, the uncertainty is assumed to be zero. Must be non-negative.

porod_const_errfloat or None, optional

One-sigma uncertainty on porod_const. If None, the uncertainty is assumed to be zero. Must be non-negative.

extrapolationstr or None, optional

Optional extrapolation mode. Currently passed through to get_surface() but not otherwise used here.

Returns

sfloat or None

Specific surface. Returned in the same units as get_surface().

dsfloat or None

One-sigma uncertainty on the specific surface. Returns None if the uncertainty cannot be determined (e.g. zero contrast, undefined relative error).

Notes

  • Assumes contrast and porod_const are independent variables.

  • Assumes uncertainties are small (linear approximation).

  • Correlated uncertainties are not supported.

  • If uncertainty cannot be determined (e.g. contrast == 0, or P==0

    while dP>0) the function returns (S, None).

get_volume_fraction(contrast, extrapolation=None)

Compute volume fraction is deduced as follows:

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:
  • contrast – contrast value provides by the user of type float. contrast unit is 1/A^(2)= 10^(16)cm^(2)

  • extrapolation – string to apply optional extrapolation

Returns:

volume fraction

Note:

volume fraction must have no unit

get_volume_fraction_with_error(contrast, contrast_err=0.0, extrapolation=None)

Compute uncertainty on volume value as well as the volume fraction This uncertainty is given by the following equation:

sig_V = sqrt((sig_Q / 2 pi |contrast|^2 * sqrt(1-4k))^2 + (sigcontrast * Q / pi^2 |contrast|^3 * sqrt(1-4k))^2)

where:

k = 10^(-8)*q_star/(2*(pi*|contrast|)**2)

Notes:

  • 10^(-8) converts from cm^-1 to A^-1

  • q_star: the invariant, in cm^-1A^-3, including extrapolated values if they have been requested

  • sig_Q: the invariant uncertainty

  • sigcontrast: the contrast uncertainty

  • sig_V: the volume uncertainty

The uncertainty will be set to -1 if it can’t be computed.

Parameters:
  • contrast – contrast value

  • contrast_err – contrast uncertainty

  • extrapolation – string to apply optional extrapolation

Returns:

V, dV = volume fraction, error on volume fraction

property scale: float
set_data(data: Data1D)
set_extrapolation(range, npts=4, function=None, power=None)

Set the extrapolation parameters for the high or low Q-range. Note that this does not turn extrapolation on or off.

Parameters:
  • range – a keyword set the type of extrapolation . type string

  • npts – the numbers of q points of data to consider for extrapolation

  • function – a keyword to select the function to use for extrapolation. of type string.

  • power – an power to apply power_low function

class sas.sascalc.invariant.invariant.PowerLaw(scale: float = 1, power: float = 4)

Bases: Transform

Child class of Transform that performs operation related to the power law function.

__abstractmethods__ = frozenset({})
__annotations__ = {'dpower': 'float', 'dscale': 'float', 'power': 'float', 'scale': 'float'}
__doc__ = 'Child class of Transform that performs operation related to the power law function.'
__firstlineno__ = 210
__init__(scale: float = 1, power: float = 4)
__module__ = 'sas.sascalc.invariant.invariant'
__static_attributes__ = ('dpower', 'dscale', 'power', 'scale')
_abc_impl = <_abc._abc_data object>
_power_law(x: ndarray) ndarray

\(F(x) = s * x^{-p}\), where \(s\) is the scale value and \(p\) is the power value. When power = 4, the model is porod, else it is a power law.

The model has three parameters:
  1. x: a vector of q values

  2. power: power of the function

  3. scale : scale factor value

Parameters:

x – array of q values.

Returns:

F(x), the form factor calculated by the power law function for the given q values.

dpower: float
dscale: float
evaluate_model(x: ndarray) ndarray

Given a scale and a radius, transform x, y using a power law function.

evaluate_model_errors(x: ndarray) ndarray

Returns the error on I(q) for the given array of q-values.

Parameters:

x – array of q-values

Returns:

array of I(q) errors

extract_model_parameters(constant: float, slope: float, dconstant: float = 0, dslope: float = 0) tuple[list[float], list[float]]

Assign new value to the scale and the power.

Parameters:
  • constant – the intercept from the linear fit.

  • slope – the slope from the linear fit.

  • dconstant – the uncertainty of the intercept from the linear fit.

  • dslope – the uncertainty of the slope from the linear fit.

Returns:

a tuple containing two lists: - the parameters of the model [power, scale], - the uncertainties of the parameters [dpower, dscale].

linearize_q_value(value: float) float

Transform the input q-value for linearization.

Parameters:

value – q-value.

Returns:

\(\log(q)\)

power: float
scale: float
class sas.sascalc.invariant.invariant.Transform

Bases: ABC

Define interface that is needed to compute a function or an inverse function given some x, y. This is an abstract class that should be inherited by any function that is used to extrapolate the data for the invariant calculation. This implements:

  1. linearize_data: linearize the data for a given function

  2. get_allowed_bins: filter out the data that can’t be transformed

The following are abstract methods that should be implemented by a child class:

  1. linearize_q_value: transform the input q-value for linearization

  2. extract_model_parameters: assign new value to the parameters of the model

  3. evaluate_model: returns an array f(x) values where f is the Transform function.

  4. evaluate_model_errors: returns an array of I(q) errors

__abstractmethods__ = frozenset({'evaluate_model', 'evaluate_model_errors', 'extract_model_parameters', 'linearize_q_value'})
__dict__ = mappingproxy({'__module__': 'sas.sascalc.invariant.invariant', '__firstlineno__': 39, '__doc__': "\nDefine interface that is needed to compute a function or an inverse function given some x, y.\nThis is an abstract class that should be inherited by any function that is used to\nextrapolate the data for the invariant calculation. This implements:\n\n1. linearize_data: linearize the data for a given function\n2. get_allowed_bins: filter out the data that can't be transformed\n\nThe following are abstract methods that should be implemented by a child class:\n\n1. linearize_q_value: transform the input q-value for linearization\n2. extract_model_parameters: assign new value to the parameters of the model\n3. evaluate_model: returns an array f(x) values where f is the Transform function.\n4. evaluate_model_errors: returns an array of I(q) errors\n", 'linearize_data': <function Transform.linearize_data>, 'get_allowed_bins': <function Transform.get_allowed_bins>, 'linearize_q_value': <function Transform.linearize_q_value>, 'extract_model_parameters': <function Transform.extract_model_parameters>, 'evaluate_model': <function Transform.evaluate_model>, 'evaluate_model_errors': <function Transform.evaluate_model_errors>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'Transform' objects>, '__weakref__': <attribute '__weakref__' of 'Transform' objects>, '__abstractmethods__': frozenset({'evaluate_model_errors', 'evaluate_model', 'linearize_q_value', 'extract_model_parameters'}), '_abc_impl': <_abc._abc_data object>})
__doc__ = "\nDefine interface that is needed to compute a function or an inverse function given some x, y.\nThis is an abstract class that should be inherited by any function that is used to\nextrapolate the data for the invariant calculation. This implements:\n\n1. linearize_data: linearize the data for a given function\n2. get_allowed_bins: filter out the data that can't be transformed\n\nThe following are abstract methods that should be implemented by a child class:\n\n1. linearize_q_value: transform the input q-value for linearization\n2. extract_model_parameters: assign new value to the parameters of the model\n3. evaluate_model: returns an array f(x) values where f is the Transform function.\n4. evaluate_model_errors: returns an array of I(q) errors\n"
__firstlineno__ = 39
__module__ = 'sas.sascalc.invariant.invariant'
__static_attributes__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
abstractmethod evaluate_model(x: ndarray) ndarray

Returns an array f(x) values where f is the Transform function.

abstractmethod evaluate_model_errors(x: ndarray) ndarray

Returns an array of I(q) errors.

abstractmethod extract_model_parameters(constant: float, slope: float, dconstant: float = 0, dslope: float = 0) tuple[list[float], list[float]]

Assign new value to the parameters of the model.

get_allowed_bins(data: Data1D) list[bool]

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

Returns:

a mask indicating whether each point is allowed by the model or not.

linearize_data(data: Data1D) Data1D

Linearize data so that a linear fit can be performed. Filter out the data that can’t be transformed.

Parameters:

data – LoadData1D instance containing the data to linearize.

Returns:

a new LoadData1D instance with the linearized data.

abstractmethod linearize_q_value(value: float) float

Transform the input q-value for linearization.

sas.sascalc.invariant.invariant_mapper module

This module is a wrapper to a map function. It allows to loop through different invariant objects to call the same function

sas.sascalc.invariant.invariant_mapper.get_qstar(inv, extrapolation=None)

Get invariant value (Q*)

sas.sascalc.invariant.invariant_mapper.get_qstar_with_error(inv, extrapolation=None)

Get invariant value with uncertainty

sas.sascalc.invariant.invariant_mapper.get_surface(inv, contrast, porod_const, extrapolation=None)

Get surface with uncertainty

sas.sascalc.invariant.invariant_mapper.get_surface_with_error(inv, contrast, porod_const, extrapolation=None)

Get surface with uncertainty

sas.sascalc.invariant.invariant_mapper.get_volume_fraction(inv, contrast, extrapolation=None)

Get volume fraction

sas.sascalc.invariant.invariant_mapper.get_volume_fraction_with_error(inv, contrast, extrapolation=None)

Get volume fraction with uncertainty

Module contents