Module to explore the P(r) inversion results for a range of D_max value. User picks a number of points and a range of distances, then get a series of outputs as a function of D_max over that range.
Bases: object
The explorer class
Class to hold the inversion output parameters as a function of D_max
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 vector b has its first Npts entries set to
b[j] = (I(q) observed for point 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:
Return a clone of this instance
Returns a reasonable guess for the regularization constant alpha
Parameters: | nfunc – number of terms to use in the expansion. |
---|---|
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: | isquit_func – reference to thread function to call to check whether the computation needs to be stopped. |
---|---|
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: | path – path of the file to load |
---|
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 vector b has its first Npts entries set to
b[j] = (I(q) observed for point 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: | args – c-parameters, and q |
---|---|
Returns: | 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 vector b has its first Npts entries set to
b[j] = (I(q) observed for point 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 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.
Save the state to a file that will be readable by SliceView.
Parameters: |
|
---|
Provide general online help text Future work: extend this function to allow topic selection
P(r) inversion for SAS