sas.sascalc.size_distribution package

Submodules

sas.sascalc.size_distribution.SizeDistribution module

sas.sascalc.size_distribution.SizeDistribution.add_gaussian_noise(x, dx, seed=None)

Add Gaussian noise to data based on the sigma of the Guassian uncertainty value associated with the data.

Args:

x (array-like): Input intensity values dx (array-like): sigma of Guassian uncertainties associated with the intensities

Returns:

array-like: Data with added Gaussian noise

sas.sascalc.size_distribution.SizeDistribution.background_fit(data, power=None, qmin=None, qmax=None)

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

Parameters:
  • data (Data1D) – data to fit

  • power – a fixed, otherwise None

  • qmin – Minimum Q-value

  • qmax – Maximum Q-value

If performing a linear fit for background, then set power = 0.0 and type = “fixed” Otherwise,

sas.sascalc.size_distribution.SizeDistribution.ellipse_volume(rp, re)
sas.sascalc.size_distribution.SizeDistribution.line_func(x, b, m)
class sas.sascalc.size_distribution.SizeDistribution.sizeDistribution(data: Data1D)

Bases: object

__dict__ = mappingproxy({'__module__': 'sas.sascalc.size_distribution.SizeDistribution', '__init__': <function sizeDistribution.__init__>, 'data': <property object>, 'qMin': <property object>, 'qMax': <property object>, 'ndx_qmin': <property object>, 'ndx_qmax': <property object>, 'diamMax': <property object>, 'diamMin': <property object>, 'nbins': <property object>, 'logbin': <property object>, 'bins': <property object>, 'set_bins': <function sizeDistribution.set_bins>, 'model': <property object>, 'aspectRatio': <property object>, 'contrast': <property object>, 'resolution': <property object>, 'background': <property object>, 'scale': <property object>, 'iterMax': <property object>, 'skyBackground': <property object>, 'weightFactor': <property object>, 'weightPercent': <property object>, 'weightType': <property object>, 'weights': <property object>, 'update_weights': <function sizeDistribution.update_weights>, 'generate_model_matrix': <function sizeDistribution.generate_model_matrix>, 'calc_volume_weighted_dist': <function sizeDistribution.calc_volume_weighted_dist>, 'prep_maxEnt': <function sizeDistribution.prep_maxEnt>, 'run_maxEnt': <function sizeDistribution.run_maxEnt>, 'calculate_statistics': <function sizeDistribution.calculate_statistics>, '__dict__': <attribute '__dict__' of 'sizeDistribution' objects>, '__weakref__': <attribute '__weakref__' of 'sizeDistribution' objects>, '__doc__': None, '__annotations__': {}})
__doc__ = None
__init__(data: Data1D)
__module__ = 'sas.sascalc.size_distribution.SizeDistribution'
__weakref__

list of weak references to the object

property aspectRatio
property background
property bins
calc_volume_weighted_dist(binmag)

This is not used right now. Calculate the volume weighted distribution.

calculate_statistics(bin_mag: list)
property contrast
property data
property diamMax
property diamMin
generate_model_matrix(moddata: Data1D)

generate a matrix of intensities from a specific sasmodels model; probably should be generalized to a class to use maxent on any parameter of interest w/in the model. For now, the pars are fixed. moddata :: Data1D object that has the data trimmed depending on background subtraction or powerlaw subtracted from the data. Also self.qMin and self.qMax.

property iterMax
property logbin
property model
property nbins
property ndx_qmax
property ndx_qmin
prep_maxEnt(sub_intensities: Data1D, full_fit: bool = False, nreps: int = 10, rngseed=None)
  1. Subtract intensities from the raw data.

  2. Trim the data to the correct q-range for maxEnt; Create new trimmed Data1D object to return after MaxEnt.

  3. Generate Model Data based of the trimmed data

  4. Create a list of intensities for maxEnt, if full_fit == True , call add_gausisan_noise nreps times; pass just subtracted intensities

  5. calculate initial bin weights, sigma, and return

property qMax
property qMin
property resolution
run_maxEnt(maxentdata: Data1D, intensities: list, BinsBack: array, sigma: array)
property scale
set_bins()
property skyBackground
update_weights(sigma=None)
property weightFactor
property weightPercent
property weightType
property weights

sas.sascalc.size_distribution.maxEnt_method module

sas.sascalc.size_distribution.maxEnt_method.MOVE_PASSES = 0.001

sbmaxent

Entropy maximization routine as described in the article J Skilling and RK Bryan; MNRAS 211 (1984) 111 - 124. (“MNRAS”: “Monthly Notices of the Royal Astronomical Society”)

License:

Copyright (c) 2013, UChicago Argonne, LLC

License:

This file is distributed subject to a Software License Agreement found in the file LICENSE that is included with this distribution.

References:

  1. J Skilling and RK Bryan; MON NOT R ASTR SOC 211 (1984) 111 - 124.

  2. JA Potton, GJ Daniell, and BD Rainford; Proc. Workshop Neutron Scattering Data Analysis, Rutherford Appleton Laboratory, UK, 1986; ed. MW Johnson, IOP Conference Series 81 (1986) 81 - 86, Institute of Physics, Bristol, UK.

  3. ID Culverwell and GP Clarke; Ibid. 87 - 96.

  4. JA Potton, GK Daniell, & BD Rainford, J APPL CRYST 21 (1988) 663 - 668.

  5. JA Potton, GJ Daniell, & BD Rainford, J APPL CRYST 21 (1988) 891 - 897.

class sas.sascalc.size_distribution.maxEnt_method.decision_helper

Bases: object

ChiNow(ax, c1, c2, s1, s2)
Returns tuple:

(ChiNow computation of w, beta)

ChoSol(a, b)

ChoSol: Chop the solution vectors

Returns:

new vector beta

Dist(s2, beta)

Measure the distance of this possible solution

exception MaxEntException

Bases: Exception

Any exception from this module

__doc__ = 'Any exception from this module'
__module__ = 'sas.sascalc.size_distribution.maxEnt_method'
__weakref__

list of weak references to the object

__dict__ = mappingproxy({'__module__': 'sas.sascalc.size_distribution.maxEnt_method', 'MaxEntException': <class 'sas.sascalc.size_distribution.maxEnt_method.decision_helper.MaxEntException'>, 'Dist': <function decision_helper.Dist>, 'ChiNow': <function decision_helper.ChiNow>, 'ChoSol': <function decision_helper.ChoSol>, '__dict__': <attribute '__dict__' of 'decision_helper' objects>, '__weakref__': <attribute '__weakref__' of 'decision_helper' objects>, '__doc__': None, '__annotations__': {}})
__doc__ = None
__module__ = 'sas.sascalc.size_distribution.maxEnt_method'
__weakref__

list of weak references to the object

class sas.sascalc.size_distribution.maxEnt_method.maxEntMethod

Bases: object

MaxEntMove(fSum, blank, chisq, chizer, c1, c2, s1, s2)

Implementing the maximum entropy move for feature size distribution The goal of this function is to calculate distance and choose the next target \(\chi^2\) and to move beta one step closer towards the solution (see SB eq. 12 and the text below for the definition of beta).

MaxEnt_SB(Iq, sigma, Gqr, first_bins, IterMax=5000, report=True)

This function does the complete Maximum Entropy algorithm of Skilling and Bryan

The scattering intensity, I(Q), is related to the histogram size distribution, Np(r) by the following equation:

\[I_{Q}=|\Delta\rho^2|\int|F(Q,r)^2|(V(r))^2N_{P}(r)dr\]

Np(r) is a histogram size distribution where a fixed number of bins are defined over a given range of diameter with either constant diameter bins or constant proportional diameter bins. Solution of the histogram size distribution to the scattering equation above is obtained by fitting the scattering calculated from trial distributions to the measured data and then revising the amplitudes of the trial histogram distribution based upon the applied constraints. The trial histogram size distribution is not forced to adhere to a particular functional form, such as Gaussian or log-normal. However, in the current formulation, all sizes of the scatterer are expected to have the same scattering contrast and morphology (shape, degree of interaction, aspect ratio, orientation, etc.)

The maximum entropy method seeks solution of the functional, Ξ:

\[\equiv =\chi-\alpha S\]

Where \(\chi^2\) indicates the goodness of fit, S is the applied constraint, and alpha is a Lagrange multiplier used to ensure that the solution fits the measured data to some extent. But compared to a regular regularization method, maximum entropy method also forces all histograms in the size distribution to have a positive amplitude

Parameters:
  • Iq (float) – background-subtracted scattering intensity data

  • sigma (float) – normalization factor obtained using scale, weights, and weight factors

  • G (float[][]) – transformation matrix

  • first_bins[] (float) – initial guess for distribution

  • IterMax (int) – maximum iterations allowed

  • resolution (obj) – resolution object providing information about smearing

  • report (boolean) – print report if True; do not print if False

Returns float[]:

\(f(r) dr\)

__dict__ = mappingproxy({'__module__': 'sas.sascalc.size_distribution.maxEnt_method', 'MaxEntMove': <function maxEntMethod.MaxEntMove>, 'MaxEnt_SB': <function maxEntMethod.MaxEnt_SB>, '__dict__': <attribute '__dict__' of 'maxEntMethod' objects>, '__weakref__': <attribute '__weakref__' of 'maxEntMethod' objects>, '__doc__': None, '__annotations__': {}})
__doc__ = None
__module__ = 'sas.sascalc.size_distribution.maxEnt_method'
__weakref__

list of weak references to the object

Module contents