Module to perform P(r) inversion. The module contains the Invertor class.
Bases: Cinvertor
Invertor class to perform P(r) inversion
The problem is solved by posing the problem as Ax = b, where x is the set of coefficients we are looking for.
Npts is the number of points.
In the following i refers to the ith base function coefficient. The matrix has its entries j in its first Npts rows set to
A[j][i] = (Fourier transformed base function for point j)
We them choose a number of r-points, n_r, to evaluate the second derivative of P(r) at. This is used as our regularization term. For a vector r of length n_r, the following n_r rows are set to
A[j+Npts][i] = (2nd derivative of P(r), d**2(P(r))/d(r)**2, evaluated at r[j])
The following n_r entries are set to zero.
The result is found by using scipy.linalg.basic.lstsq to invert the matrix and find the coefficients x.
Methods inherited from Cinvertor: - get_peaks(pars): returns the number of P(r) peaks - oscillations(pars): returns the oscillation parameters for the output P(r) - get_positive(pars): returns the fraction of P(r) that is above zero - get_pos_err(pars): returns the fraction of P(r) that is 1-sigma above zero
Returns a reasonable guess for the regularization constant alpha
Parameters: |
|
---|---|
Returns: | alpha, message, elapsed |
where alpha is the estimate for alpha, message is a message for the user, elapsed is the computation time
Returns a reasonable guess for the number of terms
Parameters: |
|
---|---|
Returns: | number of terms, alpha, message |
Load the state of the Invertor from a file, to be able to generate P(r) from a set of parameters.
Parameters: |
|
---|
Function to get the err data Takes an array of doubles as input.
@return: number of entries found
Returns the number of peaks in the output P(r) distrubution for the given set of coefficients.
@param args: c-parameters @return: number of P(r) peaks
Returns the fraction of P(r) that is 1 standard deviation above zero over the full range of r for the given set of coefficients.
@param args: c-parameters @return: fraction of P(r) that is positive
Returns the fraction of P(r) that is positive over the full range of r for the given set of coefficients.
@param args: c-parameters @return: fraction of P(r) that is positive
Function to get the x data Takes an array of doubles as input.
@return: number of entries found
Function to get the y data Takes an array of doubles as input.
@return: number of entries found
Perform inversion to P(r)
The problem is solved by posing the problem as Ax = b, where x is the set of coefficients we are looking for.
Npts is the number of points.
In the following i refers to the ith base function coefficient. The matrix has its entries j in its first Npts rows set to
A[i][j] = (Fourier transformed base function for point j)
We them choose a number of r-points, n_r, to evaluate the second derivative of P(r) at. This is used as our regularization term. For a vector r of length n_r, the following n_r rows are set to
A[i+Npts][j] = (2nd derivative of P(r), d**2(P(r))/d(r)**2, evaluated at r[j])
The following n_r entries are set to zero.
The result is found by using scipy.linalg.basic.lstsq to invert the matrix and find the coefficients x.
Parameters: |
|
---|---|
Returns: | c_out, c_cov - the coefficients with covariance matrix |
Slower version of the P(r) inversion that uses scipy.optimize.leastsq.
This probably produce more reliable results, but is much slower. The minimization function is set to sum_i[ (I_obs(q_i) - I_theo(q_i))/err**2 ] + alpha * reg_term, where the reg_term is given by Svergun: it is the integral of the square of the first derivative of P(r), d(P(r))/dr, integrated over the full range of r.
Parameters: |
|
---|---|
Returns: | c_out, c_cov - the coefficients with covariance matrix |
Function to call to evaluate the scattering intensity
Parameters: |
|
---|---|
Returns: | I(q) |
Function to call to evaluate the scattering intensity. The scattering intensity is slit-smeared. @param args: c-parameters, and q
@return: I(q)
The problem is solved by posing the problem as Ax = b, where x is the set of coefficients we are looking for.
Npts is the number of points.
In the following i refers to the ith base function coefficient. The matrix has its entries j in its first Npts rows set to
A[i][j] = (Fourier transformed base function for point j)
We them choose a number of r-points, n_r, to evaluate the second derivative of P(r) at. This is used as our regularization term. For a vector r of length n_r, the following n_r rows are set to
A[i+Npts][j] = (2nd derivative of P(r), d**2(P(r))/d(r)**2, evaluated at r[j])
The following n_r entries are set to zero.
The result is found by using scipy.linalg.basic.lstsq to invert the matrix and find the coefficients x.
Parameters: |
|
---|
If the result does not allow us to compute the covariance matrix, a matrix filled with zeros will be returned.
Returns the value of the oscillation figure of merit for the given set of coefficients. For a sphere, the oscillation figure of merit is 1.1.
@param args: c-parameters @return: oscillation figure of merit
Returns the value of P(r) for a given r, and base function coefficients, with error.
Parameters: |
|
---|---|
Returns: | P(r) |
This is a direct fit to a given P(r). It assumes that the y data is set to some P(r) distribution that we are trying to reproduce with a set of base functions.
This method is provided as a test.
Function to call to evaluate the residuals for P(r) minimization (for testing purposes)
@param args: input parameters @return: list of residuals
Function to call to evaluate the residuals for P(r) inversion
@param args: input parameters @return: list of residuals
Function to set the err data Takes an array of doubles as input.
@return: number of entries found
Function to set the x data Takes an array of doubles as input.
@return: number of entries found
Function to set the y data Takes an array of doubles as input.
@return: number of entries found
Save the state to a file that will be readable by SliceView.
Parameters: |
|
---|