sas.sascalc.calculator package¶
Subpackages¶
Submodules¶
sas.sascalc.calculator.BaseComponent module¶
Provide base functionality for all model components
- class sas.sascalc.calculator.BaseComponent.BaseComponent¶
Bases:
object
Basic model component
Since version 0.5.0, basic operations are no longer supported.
- __add__(other)¶
add
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.BaseComponent', '__doc__': '\n Basic model component\n\n Since version 0.5.0, basic operations are no longer supported.\n ', '__init__': <function BaseComponent.__init__>, '__str__': <function BaseComponent.__str__>, 'is_fittable': <function BaseComponent.is_fittable>, 'run': <function BaseComponent.run>, 'runXY': <function BaseComponent.runXY>, 'calculate_ER': <function BaseComponent.calculate_ER>, 'calculate_VR': <function BaseComponent.calculate_VR>, 'evalDistribution': <function BaseComponent.evalDistribution>, 'clone': <function BaseComponent.clone>, '_clone': <function BaseComponent._clone>, 'set_dispersion': <function BaseComponent.set_dispersion>, 'getProfile': <function BaseComponent.getProfile>, 'setParam': <function BaseComponent.setParam>, 'getParam': <function BaseComponent.getParam>, 'getParamList': <function BaseComponent.getParamList>, 'getDispParamList': <function BaseComponent.getDispParamList>, 'setParamWithToken': <function BaseComponent.setParamWithToken>, 'getParamWithToken': <function BaseComponent.getParamWithToken>, 'getParamListWithToken': <function BaseComponent.getParamListWithToken>, '__add__': <function BaseComponent.__add__>, '__sub__': <function BaseComponent.__sub__>, '__mul__': <function BaseComponent.__mul__>, '__div__': <function BaseComponent.__div__>, '__dict__': <attribute '__dict__' of 'BaseComponent' objects>, '__weakref__': <attribute '__weakref__' of 'BaseComponent' objects>, '__annotations__': {}})¶
- __div__(other)¶
div
- __doc__ = '\n Basic model component\n\n Since version 0.5.0, basic operations are no longer supported.\n '¶
- __init__()¶
Initialization
- __module__ = 'sas.sascalc.calculator.BaseComponent'¶
- __mul__(other)¶
mul
- __str__()¶
- Returns:
string representatio
- __sub__(other)¶
sub
- __weakref__¶
list of weak references to the object
- _clone(obj)¶
Internal utility function to copy the internal data members to a fresh copy.
- calculate_ER()¶
Calculate effective radius
- calculate_VR()¶
Calculate volume fraction ratio
- clone()¶
Returns a new object identical to the current object
- evalDistribution(qdist)¶
Evaluate a distribution of q-values.
For 1D, a numpy array is expected as input:
evalDistribution(q)
where q is a numpy array.
For 2D, a list of numpy arrays are expected: [qx_prime,qy_prime], where 1D arrays,
qx_prime = [ qx[0], qx[1], qx[2], ....]
and
qy_prime = [ qy[0], qy[1], qy[2], ....]
Then get
q = np.sqrt(qx_prime^2+qy_prime^2)
that is a qr in 1D array;
q = [q[0], q[1], q[2], ....]
Note
Due to 2D speed issue, no anisotropic scattering is supported for python models, thus C-models should have their own evalDistribution methods.
The method is then called the following way:
evalDistribution(q)
where q is a numpy array.
- Parameters:
qdist – ndarray of scalar q-values or list [qx,qy] where qx,qy are 1D ndarrays
- getDispParamList()¶
Return a list of all available parameters for the model
- getParam(name)¶
Set the value of a model parameter :param name: name of the parameter
- getParamList()¶
Return a list of all available parameters for the model
- getParamListWithToken(token, member)¶
get Param List With Token
- getParamWithToken(name, token, member)¶
get Param With Token
- getProfile()¶
Get SLD profile
- : return: (z, beta) where z is a list of depth of the transition points
beta is a list of the corresponding SLD values
- is_fittable(par_name)¶
Check if a given parameter is fittable or not
- Parameters:
par_name – the parameter name to check
- run(x)¶
run 1d
- runXY(x)¶
run 2d
- setParam(name, value)¶
Set the value of a model parameter
- Parameters:
name – name of the parameter
value – value of the parameter
- setParamWithToken(name, value, token, member)¶
set Param With Token
- set_dispersion(parameter, dispersion)¶
model dispersions
- sas.sascalc.calculator.BaseComponent._ordered_keys(d)¶
sas.sascalc.calculator.geni module¶
Compute scattering from a set of points. For 1-D scattering use Iq(q, x, y, z, sld, vol, is_avg)
- sas.sascalc.calculator.geni.Iq(q, x, y, z, sld, vol, is_avg=False)¶
Computes 1D isotropic. Isotropic: Assumes all slds are real (no magnetic) Also assumes there is no polarization: No dependency on spin. All values must be numpy vectors of the correct size. Returns I(q)
- sas.sascalc.calculator.geni.Iqxy(qx, qy, x, y, z, sld, vol, mx, my, mz, in_spin, out_spin, s_theta, s_phi, elements=None, is_elements=False)¶
Computes 2D anisotropic. in_spin and out_spin indicate portion of polarizer and analyzer transmission that are spin up. s_theta and s_phi are the polarization direction angles. All other values must be numpy vectors of the correct size. Returns I(qx, qy)
- sas.sascalc.calculator.geni._calc_Iq_avg(q, r, w)¶
- sas.sascalc.calculator.geni._calc_Iq_numba(Iq, q, coords, sld, vol)¶
DEPRECATED Numba version of the _calc_Iq since the pure numpy version is too difficult for numpy to handle. Even with with numba this code is slower than the pure numpy version. Without numba it is much much slower. Test for a few examples with smallish numbers of points. The algorithm is O(n^2) which makes it unusable for a larger number of points. A GPU implementation would help, maybe allowing 10x the number of points.
- sas.sascalc.calculator.geni._calc_Iqxy(scale, x, y, qx, qy)¶
Compute I(q) for a set of points (x, y).
Uses: I(q) = |sum V(r) rho(r) e^(1j q.r)|^2 / sum V(r) Since qz is zero for SAS, only need 2D vectors q = (qx, qy) and r = (x, y).
- sas.sascalc.calculator.geni._calc_Iqxy_elements(sld, x, y, z, elements, vol, qx, qy)¶
Compute I(q) for a set of elements, without magnetism.
- sas.sascalc.calculator.geni._calc_Iqxy_magnetic(qx, qy, x, y, rho, vol, rho_m, up_frac_i=1, up_frac_f=1, up_theta=0.0, up_phi=0.0)¶
Compute I(q) for a set of points (x, y), with magnetism on each point.
Uses: I(q) = sum_xs w_xs |sum V(r) rho(q, r, xs) e^(1j q.r)|^2 / sum V(r) where rho is adjusted for the particular q and polarization cross section. The cross section weights depends on the polarizer and analyzer efficiency of the measurement. For example, with polarization up at 100% efficiency and no analyzer, (up_frac_i=1, up_frac_f=0.5), then uu and ud will both be 0.5. Since qz is zero for SAS, only need 2D vectors q = (qx, qy) and r = (x, y).
- sas.sascalc.calculator.geni._calc_Iqxy_magnetic_elements(qx, qy, x, y, z, sld, mx, my, mz, elements, vol, up_frac_i=1, up_frac_f=1, up_angle=0.0, up_phi=0.0)¶
Compute I(q) for a set of elements, with magnetism.
- sas.sascalc.calculator.geni._calc_Iqxy_magnetic_elements_helper(Iq, qx, qy, geometry, normals, rn_norm, rho, M, vol, cos_spin, sin_spin, cos_phi, sin_phi, dd, du, ud, uu)¶
- sas.sascalc.calculator.geni._calc_Iqxy_magnetic_helper(Iq, qx, qy, x, y, rho, vol, M, cos_spin, sin_spin, cos_phi, sin_phi, dd, du, ud, uu)¶
- sas.sascalc.calculator.geni._get_normal_vec(geometry)¶
return array of normal vectors of elements
This function returns an array of unit normal vectors to faces, pointing out of the elements, as well as altering the geometry to ensure the vertices are ordered the correct way around
Warning
This function alters geometry in place as well as returning it - so when this function is called the geometry array will always be re-ordered.
- Parameters:
geometry (numpy.ndarray) – an array of the position data for the mesh which goes as (elements x faces x vertices x coordinates)
- Returns:
normals, geometry - where geometry has been adjusted to ensure all vertices go anticlockwise around the unit normal vector, and the unit normal vectors are pointed out of the element.
- Return type:
tuple
- sas.sascalc.calculator.geni._spin_weights(in_spin, out_spin)¶
Compute spin cross weights given in_spin and out_spin Returns weights (dd, du, ud, uu)
- sas.sascalc.calculator.geni.center_of_mass(nuc_sl_data: MagSLD | OMF2SLD) list[float] ¶
Calculate Center of Mass(CoM) of provided molecule using an SL profile
- Parameters:
nuc_sl_data – A coordinate data object (MagSLD or OMF2SLD)
- Returns:
A list of the calculated spatial center of mass, given as cartesian coordinates.
- sas.sascalc.calculator.geni.create_beta_plot(q_x: ndarray, nuc_sl_data: MagSLD | OMF2SLD, form_factor: ndarray) ndarray ¶
Carry out the computation of beta Q using provided & calculated data
- Parameters:
q_x – The Q values where the beta will be calculated.
nuc_sl_data – A coordinate data object (MagSLD or OMF2SLD)
form_factor – The form factor calculated prior to applying the beta approximation.
- Returns:
An array of form factor values with the beta approximation applied.
- sas.sascalc.calculator.geni.element_transform(geometry, normals, rn_norm, volumes, qx, qy)¶
carries out fourier transform on elements
This function carries out the polyhedral transformation on the elements that make up the mesh. This algorithm only works on meshes where all the elements have the same number of faces, and each face has the same number of vertices. It is heavily based on the algorithm in:
An implementation of an efficient direct Fourier transform of polygonal areas and volumes. Brian B. Maranville. https://arxiv.org/abs/2104.08309
- Parameters:
geometry (numpy.ndarray) – A 4D numpy array of the form elements x faces x vertices x vertex_coordinates.
normals (numpy.ndarray) – A 3D numpy array of the form elements x faces x normal_coordinates. The normals provided should be normalised.
rn_normals – A 2D numpy array of the form elements x faces containing the perpendicular distances from each face to the origin of the co-ordinate system.
volumes (nump.ndarray) – A 1D numpy array containing the volumes of the elements
qx (float) – The x component of the Q vector which represents the position in fourier space.
qy (float) – The y component of the Q vector which represents the position in fourier space.
- Returns:
A 1D numpy array of the fourier transforms of each element at the given Q value
- Return type:
numpy.ndarray
- sas.sascalc.calculator.geni.f_of_q(q_x: ndarray, nuc_sl_data: MagSLD | OMF2SLD) ndarray ¶
Compute the base F(Q) calculation based from the nuclear data.
- Parameters:
q_x – The Q values where the beta will be calculated.
nuc_sl_data – A coordinate data object (MagSLD or OMF2SLD)
- Returns:
An array of form factor data.
- sas.sascalc.calculator.geni.orth(A, b)¶
- sas.sascalc.calculator.geni.radius_of_gyration(nuc_sl_data: MagSLD | OMF2SLD) tuple[str, str, float] ¶
Calculate parameters related to the radius of gyration using and SLD profile.
- Parameters:
nuc_sl_data – A scattering length object for a series of atomic points in space
- Returns:
A tuple of the string representation of the radius of gyration, Guinier slope, and Rg as a float.
sas.sascalc.calculator.gsc_model module¶
create plugin model from the Generic Scattering Calculator
- sas.sascalc.calculator.gsc_model.generate_model(f_name: str, data_to_plot: ndarray, x_values: ndarray, f_q: list, mass: float) str ¶
Generate an empirical model from the current plugin state
- sas.sascalc.calculator.gsc_model.generate_plugin(f_name: str, data_to_plot: ndarray, x_values: ndarray, f_q: list, mass: float) tuple[str, Path] ¶
Generate an empirical plugin model using calculated data.
- Parameters:
f_name – The desired file name for the resulting model
data_to_plot – The plottable data
x_values – The x values, as a numpy array
f_q – The calculated F(Q)
mass – The mass associated with the Rg calculation
sas.sascalc.calculator.instrument module¶
This module is a small tool to allow user to control instrumental parameters
- class sas.sascalc.calculator.instrument.Aperture¶
Bases:
object
An object class that defines the aperture variables
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.instrument', '__doc__': '\n An object class that defines the aperture variables\n ', '__init__': <function Aperture.__init__>, 'set_source_size': <function Aperture.set_source_size>, 'set_sample_size': <function Aperture.set_sample_size>, 'set_sample_distance': <function Aperture.set_sample_distance>, '__dict__': <attribute '__dict__' of 'Aperture' objects>, '__weakref__': <attribute '__weakref__' of 'Aperture' objects>, '__annotations__': {}})¶
- __doc__ = '\n An object class that defines the aperture variables\n '¶
- __init__()¶
- __module__ = 'sas.sascalc.calculator.instrument'¶
- __weakref__¶
list of weak references to the object
- set_sample_distance(distance=[])¶
Set the sample aperture distance
- set_sample_size(size=[])¶
Set the sample aperture size
- set_source_size(size=[])¶
Set the source aperture size
- class sas.sascalc.calculator.instrument.Detector¶
Bases:
object
An object class that defines the detector variables
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.instrument', '__doc__': '\n An object class that defines the detector variables\n ', '__init__': <function Detector.__init__>, 'set_size': <function Detector.set_size>, 'set_pix_size': <function Detector.set_pix_size>, 'set_distance': <function Detector.set_distance>, '__dict__': <attribute '__dict__' of 'Detector' objects>, '__weakref__': <attribute '__weakref__' of 'Detector' objects>, '__annotations__': {}})¶
- __doc__ = '\n An object class that defines the detector variables\n '¶
- __init__()¶
- __module__ = 'sas.sascalc.calculator.instrument'¶
- __weakref__¶
list of weak references to the object
- set_distance(distance=[])¶
Set the detector distance
- set_pix_size(size=[])¶
Set the detector pix_size
- set_size(size=[])¶
Set the detector size
- class sas.sascalc.calculator.instrument.Neutron¶
Bases:
object
An object that defines the wavelength variables
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.instrument', '__doc__': '\n An object that defines the wavelength variables\n ', '__init__': <function Neutron.__init__>, 'set_full_band': <function Neutron.set_full_band>, 'set_spectrum': <function Neutron.set_spectrum>, 'setup_spectrum': <function Neutron.setup_spectrum>, 'set_band': <function Neutron.set_band>, 'set_intensity': <function Neutron.set_intensity>, 'set_wavelength': <function Neutron.set_wavelength>, 'set_mass': <function Neutron.set_mass>, 'set_wavelength_spread': <function Neutron.set_wavelength_spread>, 'get_intensity': <function Neutron.get_intensity>, 'get_wavelength': <function Neutron.get_wavelength>, 'get_mass': <function Neutron.get_mass>, 'get_wavelength_spread': <function Neutron.get_wavelength_spread>, 'get_ramdom_value': <function Neutron.get_ramdom_value>, 'get_spectrum': <function Neutron.get_spectrum>, 'get_default_spectrum': <function Neutron.get_default_spectrum>, 'get_band': <function Neutron.get_band>, 'plot_spectrum': <function Neutron.plot_spectrum>, '__dict__': <attribute '__dict__' of 'Neutron' objects>, '__weakref__': <attribute '__weakref__' of 'Neutron' objects>, '__annotations__': {}})¶
- __doc__ = '\n An object that defines the wavelength variables\n '¶
- __init__()¶
- __module__ = 'sas.sascalc.calculator.instrument'¶
- __weakref__¶
list of weak references to the object
- get_band()¶
To get the wavelength band
- get_default_spectrum()¶
get default spectrum
- get_intensity()¶
To get the value of intensity
- get_mass()¶
To get the neutron mass
- get_ramdom_value()¶
To get the value of wave length
- get_spectrum()¶
To get the wavelength spectrum
- get_wavelength()¶
To get the value of wavelength
- get_wavelength_spread()¶
To get the value of wavelength spread
- plot_spectrum()¶
To plot the wavelength spactrum : requirement: matplotlib.pyplot
- set_band(band=[])¶
To set the wavelength band
- Parameters:
band – array of [min, max]
- set_full_band()¶
set band to default value
- set_intensity(intensity=368428)¶
Sets the intensity in counts/sec
- set_mass(mass=1.67492729e-24)¶
Sets the wavelength
- set_spectrum(spectrum)¶
Set spectrum
- Parameters:
spectrum – numpy array
- set_wavelength(wavelength=6.0)¶
Sets the wavelength
- set_wavelength_spread(spread=0.125)¶
Sets the wavelength spread
- setup_spectrum()¶
To set the wavelength spectrum, and intensity, assumes wavelength is already within the spectrum
- class sas.sascalc.calculator.instrument.Sample¶
Bases:
object
An object class that defines the sample variables
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.instrument', '__doc__': '\n An object class that defines the sample variables\n ', '__init__': <function Sample.__init__>, 'set_size': <function Sample.set_size>, 'set_thickness': <function Sample.set_thickness>, 'set_distance': <function Sample.set_distance>, '__dict__': <attribute '__dict__' of 'Sample' objects>, '__weakref__': <attribute '__weakref__' of 'Sample' objects>, '__annotations__': {}})¶
- __doc__ = '\n An object class that defines the sample variables\n '¶
- __init__()¶
- __module__ = 'sas.sascalc.calculator.instrument'¶
- __weakref__¶
list of weak references to the object
- set_distance(distance=[])¶
Set the sample distance
- set_size(size=[])¶
Set the sample size
- set_thickness(thickness=0.0)¶
Set the sample thickness
- class sas.sascalc.calculator.instrument.TOF¶
Bases:
Neutron
TOF: make list of wavelength and wave length spreads
- __annotations__ = {}¶
- __doc__ = '\n TOF: make list of wavelength and wave length spreads\n '¶
- __init__()¶
Init
- __module__ = 'sas.sascalc.calculator.instrument'¶
- get_intensity_list()¶
get list of the intensity wrt wavelength_list
- get_wave_list()¶
Get wavelength and wavelength_spread list
- set_wave_list(wavelength=[])¶
Set wavelength list
- Parameters:
wavelength – list of wavelengths
- set_wave_spread_list(wavelength_spread=[])¶
Set wavelength_spread list
- Parameters:
wavelength_spread – list of wavelength spreads
- sas.sascalc.calculator.instrument.validate(value=None)¶
Check if the value is folat > 0.0
- Return value:
True / False
sas.sascalc.calculator.kiessig_calculator module¶
This module is a small tool to allow user to quickly determine the size value in real space from the fringe width in q space.
- class sas.sascalc.calculator.kiessig_calculator.KiessigThicknessCalculator¶
Bases:
object
compute thickness from the fringe width of data
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.kiessig_calculator', '__doc__': '\n compute thickness from the fringe width of data\n ', '__init__': <function KiessigThicknessCalculator.__init__>, 'set_deltaq': <function KiessigThicknessCalculator.set_deltaq>, 'get_deltaq': <function KiessigThicknessCalculator.get_deltaq>, 'compute_thickness': <function KiessigThicknessCalculator.compute_thickness>, 'get_thickness_unit': <function KiessigThicknessCalculator.get_thickness_unit>, '__dict__': <attribute '__dict__' of 'KiessigThicknessCalculator' objects>, '__weakref__': <attribute '__weakref__' of 'KiessigThicknessCalculator' objects>, '__annotations__': {}})¶
- __doc__ = '\n compute thickness from the fringe width of data\n '¶
- __init__()¶
- __module__ = 'sas.sascalc.calculator.kiessig_calculator'¶
- __weakref__¶
list of weak references to the object
- compute_thickness()¶
Calculate thickness.
- Returns:
the thickness.
- get_deltaq()¶
return deltaQ value in 1/A unit
- get_thickness_unit()¶
- Returns:
the thickness unit.
- set_deltaq(dq=None)¶
Receive deltaQ value
- Parameters:
dq – q fringe width in 1/A unit
sas.sascalc.calculator.resolution_calculator module¶
This object is a small tool to allow user to quickly determine the variance in q from the instrumental parameters.
- class sas.sascalc.calculator.resolution_calculator.ResolutionCalculator¶
Bases:
object
compute resolution in 2D
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.resolution_calculator', '__doc__': '\n compute resolution in 2D\n ', '__init__': <function ResolutionCalculator.__init__>, 'compute_and_plot': <function ResolutionCalculator.compute_and_plot>, 'setup_tof': <function ResolutionCalculator.setup_tof>, 'compute': <function ResolutionCalculator.compute>, '_within_detector_range': <function ResolutionCalculator._within_detector_range>, 'get_image': <function ResolutionCalculator.get_image>, 'plot_image': <function ResolutionCalculator.plot_image>, 'reset_image': <function ResolutionCalculator.reset_image>, 'get_variance': <function ResolutionCalculator.get_variance>, 'get_variance_wave': <function ResolutionCalculator.get_variance_wave>, 'get_variance_gravity': <function ResolutionCalculator.get_variance_gravity>, '_cal_A_value': <function ResolutionCalculator._cal_A_value>, 'get_intensity': <function ResolutionCalculator.get_intensity>, 'get_wavelength': <function ResolutionCalculator.get_wavelength>, 'get_default_spectrum': <function ResolutionCalculator.get_default_spectrum>, 'get_spectrum': <function ResolutionCalculator.get_spectrum>, 'get_wavelength_spread': <function ResolutionCalculator.get_wavelength_spread>, 'get_neutron_mass': <function ResolutionCalculator.get_neutron_mass>, 'get_source_aperture_size': <function ResolutionCalculator.get_source_aperture_size>, 'get_sample_aperture_size': <function ResolutionCalculator.get_sample_aperture_size>, 'get_detector_pix_size': <function ResolutionCalculator.get_detector_pix_size>, 'get_detector_size': <function ResolutionCalculator.get_detector_size>, 'get_source2sample_distance': <function ResolutionCalculator.get_source2sample_distance>, 'get_sample2sample_distance': <function ResolutionCalculator.get_sample2sample_distance>, 'get_sample2detector_distance': <function ResolutionCalculator.get_sample2detector_distance>, 'set_intensity': <function ResolutionCalculator.set_intensity>, 'set_wave': <function ResolutionCalculator.set_wave>, 'set_wave_spread': <function ResolutionCalculator.set_wave_spread>, 'set_wavelength': <function ResolutionCalculator.set_wavelength>, 'set_spectrum': <function ResolutionCalculator.set_spectrum>, 'set_wavelength_spread': <function ResolutionCalculator.set_wavelength_spread>, 'set_wave_list': <function ResolutionCalculator.set_wave_list>, 'get_wave_list': <function ResolutionCalculator.get_wave_list>, 'get_intensity_list': <function ResolutionCalculator.get_intensity_list>, 'set_source_aperture_size': <function ResolutionCalculator.set_source_aperture_size>, 'set_neutron_mass': <function ResolutionCalculator.set_neutron_mass>, 'set_sample_aperture_size': <function ResolutionCalculator.set_sample_aperture_size>, 'set_detector_pix_size': <function ResolutionCalculator.set_detector_pix_size>, 'set_detector_size': <function ResolutionCalculator.set_detector_size>, 'set_source2sample_distance': <function ResolutionCalculator.set_source2sample_distance>, 'set_sample2sample_distance': <function ResolutionCalculator.set_sample2sample_distance>, 'set_sample2detector_distance': <function ResolutionCalculator.set_sample2detector_distance>, 'get_all_instrument_params': <function ResolutionCalculator.get_all_instrument_params>, 'get_detector_qrange': <function ResolutionCalculator.get_detector_qrange>, '_rotate_z': <function ResolutionCalculator._rotate_z>, '_gaussian2d': <function ResolutionCalculator._gaussian2d>, '_gaussian2d_polar': <function ResolutionCalculator._gaussian2d_polar>, '_gaussian1d': <function ResolutionCalculator._gaussian1d>, '_atan_phi': <function ResolutionCalculator._atan_phi>, '_get_detector_qxqy_pixels': <function ResolutionCalculator._get_detector_qxqy_pixels>, '_get_qx': <function ResolutionCalculator._get_qx>, '_get_polar_value': <function ResolutionCalculator._get_polar_value>, '_get_beamcenter_position': <function ResolutionCalculator._get_beamcenter_position>, '_get_beamcenter_drop': <function ResolutionCalculator._get_beamcenter_drop>, '__dict__': <attribute '__dict__' of 'ResolutionCalculator' objects>, '__weakref__': <attribute '__weakref__' of 'ResolutionCalculator' objects>, '__annotations__': {}})¶
- __doc__ = '\n compute resolution in 2D\n '¶
- __init__()¶
- __module__ = 'sas.sascalc.calculator.resolution_calculator'¶
- __weakref__¶
list of weak references to the object
- _atan_phi(qy_value, qx_value)¶
Find the angle phi of q on the detector plane for qx_value, qy_value given : qx_value: x component of q : qy_value: y component of q
: return phi: the azimuthal angle of q on x-y plane
- _cal_A_value(lamda, s_distance, d_distance)¶
Calculate A value for gravity
: s_distance: source to sample distance : d_distance: sample to detector distance
- _gaussian1d(value, mean, sigma)¶
Calculate 1D Gaussian distribution : value: value : mean: mean value : sigma: variance
: return: gaussian (value)
- _gaussian2d(x_val, y_val, x0_val, y0_val, sigma_x, sigma_y, sigma_r)¶
Calculate 2D Gaussian distribution : x_val: x value : y_val: y value : x0_val: mean value in x-axis : y0_val: mean value in y-axis : sigma_x: variance in x-direction : sigma_y: variance in y-direction
: return: gaussian (value)
- _gaussian2d_polar(x_val, y_val, x0_val, y0_val, sigma_x, sigma_y, sigma_r)¶
Calculate 2D Gaussian distribution for polar coodinate : x_val: x value : y_val: y value : x0_val: mean value in x-axis : y0_val: mean value in y-axis : sigma_x: variance in r-direction : sigma_y: variance in phi-direction : sigma_r: wavelength variance in r-direction
: return: gaussian (value)
- _get_beamcenter_drop()¶
Get the beam center drop (delta y) in y diection due to gravity
- Return delta y:
the beam center drop in cm
- _get_beamcenter_position(num_x, num_y, offset_x, offset_y)¶
- Parameters:
num_x – number of pixel in x-direction
num_y – number of pixel in y-direction
offset – detector offset in x-direction in pix number
- Returns:
pix number; pos_x, pos_y in pix index
- _get_detector_qxqy_pixels()¶
Get the pixel positions of the detector in the qx_value-qy_value space
- _get_polar_value(qx_value, qy_value)¶
Find qr_value and phi from qx_value and qy_value values
: return qr_value, phi
- _get_qx(dx_size, det_dist, wavelength)¶
- Parameters:
dx_size – x-distance from beam center [cm]
det_dist – sample to detector distance [cm]
- Returns:
q-value at the given position
- _rotate_z(x_value, y_value, theta=0.0)¶
Rotate x-y cordinate around z-axis by theta : x_value: numpy array of x values : y_value: numpy array of y values : theta: angle to rotate by in rad
- Returns:
x_prime, y-prime
- _within_detector_range(qx_value, qy_value)¶
check if qvalues are within detector range
- compute(wavelength, wavelength_spread, qx_value, qy_value, coord='cartesian', tof=False)¶
Compute the Q resoltuion in || and + direction of 2D : qx_value: x component of q : qy_value: y component of q
- compute_and_plot(qx_value, qy_value, qx_min, qx_max, qy_min, qy_max, coord='cartesian')¶
Compute the resolution : qx_value: x component of q : qy_value: y component of q
- get_all_instrument_params()¶
Get all instrumental parameters
- get_default_spectrum()¶
Get default_spectrum
- get_detector_pix_size()¶
Get detector pixel size
- get_detector_qrange()¶
get max detector q ranges
: return: qx_min, qx_max, qy_min, qy_max tuple
- get_detector_size()¶
Get detector size
- get_image(qx_value, qy_value, sigma_1, sigma_2, sigma_r, qx_min, qx_max, qy_min, qy_max, coord='cartesian', full_cal=True)¶
Get the resolution in polar coordinate ready to plot : qx_value: qx_value value : qy_value: qy_value value : sigma_1: variance in r direction : sigma_2: variance in phi direction : coord: coordinate system of image, ‘polar’ or ‘cartesian’
- get_intensity()¶
Get intensity
- get_intensity_list()¶
Set wavelength spread
- get_neutron_mass()¶
Get Neutron mass
- get_sample2detector_distance()¶
Get detector sample2detector_distance
- get_sample2sample_distance()¶
Get detector sampleslitsample_distance
- get_sample_aperture_size()¶
Get sample aperture size
- get_source2sample_distance()¶
Get detector source2sample_distance
- get_source_aperture_size()¶
Get source aperture size
- get_spectrum()¶
Get _spectrum
- get_variance(size=[], distance=0, phi=0, comp='radial')¶
Get the variance when the slit/pinhole size is given : size: list that can be one(diameter for circular) or two components(lengths for rectangular) : distance: [z, x] where z along the incident beam, x // qx_value : comp: direction of the sigma; can be ‘phi’, ‘y’, ‘x’, and ‘radial’
: return variance: sigma^2
- get_variance_gravity(s_distance, d_distance, wavelength, spread, phi, comp='radial', switch='on')¶
Get the variance from gravity when the wavelength spread is given
: s_distance: source to sample distance : d_distance: sample to detector distance : wavelength: wavelength : spread: wavelength spread (ratio) : comp: direction of the sigma; can be ‘phi’, ‘y’, ‘x’, and ‘radial’
: return variance: sigma^2
- get_variance_wave(A_value, radius, distance, spread, phi, comp='radial', switch='on')¶
Get the variance when the wavelength spread is given
: radius: the radial distance from the beam center to the pix of q : distance: sample to detector distance : spread: wavelength spread (ratio) : comp: direction of the sigma; can be ‘phi’, ‘y’, ‘x’, and ‘radial’
: return variance: sigma^2 for 2d, sigma^2 for 1d [tuple]
- get_wave_list()¶
Set wavelength spread
- get_wavelength()¶
Get wavelength
- get_wavelength_spread()¶
Get wavelength spread
- plot_image(image)¶
Plot image using pyplot : image: 2d resolution image
: return plt: pylab object
- reset_image()¶
Reset image to default (=[])
- set_detector_pix_size(size)¶
Set detector pixel size
- set_detector_size(size)¶
Set detector size in number of pixels : param size: [pixel_nums] or [x_pix_num, yx_pix_num]
- set_intensity(intensity)¶
Set intensity
- set_neutron_mass(mass)¶
Set Neutron mass
- set_sample2detector_distance(distance)¶
Set detector sample2detector_distance
: param distance: [distance, x_offset]
- set_sample2sample_distance(distance)¶
Set detector sample_slit2sample_distance
: param distance: [distance, x_offset]
- set_sample_aperture_size(size)¶
Set sample aperture size
: param size: [dia_value] or [xheight_value, yheight_value]
- set_source2sample_distance(distance)¶
Set detector source2sample_distance
: param distance: [distance, x_offset]
- set_source_aperture_size(size)¶
Set source aperture size
: param size: [dia_value] or [x_value, y_value]
- set_spectrum(spectrum)¶
Set spectrum
- set_wave(wavelength)¶
Set wavelength list or wavelength
- set_wave_list(wavelength_list, wavelengthspread_list)¶
Set wavelength and its spread list
- set_wave_spread(wavelength_spread)¶
Set wavelength spread or wavelength spread
- set_wavelength(wavelength)¶
Set wavelength
- set_wavelength_spread(wavelength_spread)¶
Set wavelength spread
- setup_tof(wavelength, wavelength_spread)¶
Setup all parameters in instrument
: param ind: index of lambda, etc
sas.sascalc.calculator.sas_gen module¶
SAS generic computation and sld file readers.
Calculation checked by sampling from an ellipsoid and comparing Iq with the 1D, 2D oriented and 2D oriented magnetic analytical model from sasmodels.
- class sas.sascalc.calculator.sas_gen.GenSAS¶
Bases:
object
Generic SAS computation Model based on sld (n & m) arrays
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.sas_gen', '__doc__': '\n Generic SAS computation Model based on sld (n & m) arrays\n ', '__init__': <function GenSAS.__init__>, 'set_pixel_volumes': <function GenSAS.set_pixel_volumes>, 'set_is_avg': <function GenSAS.set_is_avg>, 'reset_transformations': <function GenSAS.reset_transformations>, 'transform_positions': <function GenSAS.transform_positions>, 'transform_magnetic_slds': <function GenSAS.transform_magnetic_slds>, 'transform_angles': <function GenSAS.transform_angles>, 'calculate_Iq': <function GenSAS.calculate_Iq>, 'set_rotations': <function GenSAS.set_rotations>, 'set_sld_data': <function GenSAS.set_sld_data>, 'getProfile': <function GenSAS.getProfile>, 'run': <function GenSAS.run>, 'runXY': <function GenSAS.runXY>, 'evalDistribution': <function GenSAS.evalDistribution>, 'file_verification': <function GenSAS.file_verification>, '__dict__': <attribute '__dict__' of 'GenSAS' objects>, '__weakref__': <attribute '__weakref__' of 'GenSAS' objects>, '__annotations__': {}})¶
- __doc__ = '\n Generic SAS computation Model based on sld (n & m) arrays\n '¶
- __init__()¶
Init :Params sld_data: MagSLD object
- __module__ = 'sas.sascalc.calculator.sas_gen'¶
- __weakref__¶
list of weak references to the object
- calculate_Iq(qx, qy=None)¶
Evaluate the function :Param x: array of x-values :Param y: array of y-values :return: function value
- evalDistribution(qdist)¶
Evaluate a distribution of q-values.
- Parameters:
qdist – ndarray of scalar q-values (for 1D) or list [qx,qy] where qx,qy are 1D ndarrays (for 2D).
- file_verification(nuc_data, mag_data)¶
Verifies that enabled files are compatible and can be combined
When the user wishes to combine two different files for nuclear (nuc_data) and magnetic (mag_data) data they must have the same 3D data points in real-space. This function decides whther verification of this is necessary and if so carries it out. In the case that the two files have the same real-space data points in different orders this function re-orders the stored data within the MagSLD objects to make them align. The full verification is only carried out once for any pair of loaded files.
- getProfile()¶
Get SLD profile : return: sld_data
- reset_transformations()¶
Set previous transformations as invalid
- run(x=0.0)¶
Evaluate the model :param x: simple value :return: (I value)
- runXY(x=0.0)¶
Evaluate the model :param x: simple value :return: I value :Use this runXY() for the computation
- set_is_avg(is_avg=False)¶
Sets is_avg: [bool]
- set_pixel_volumes(volume)¶
Set the volume of a pixel in (A^3) unit :Param volume: pixel volume [float]
- set_rotations(uvw_to_UVW=<scipy.spatial.transform._rotation.Rotation object>, xyz_to_UVW=<scipy.spatial.transform._rotation.Rotation object>)¶
Set the rotations for the coordinate systems
The rotation matrices are given for the COMPONENTS of the vectors - that is xyz_to_UVW transforms the components of a vector from the xyz to UVW frame. This is the same rotation that transforms the basis vectors from UVW to xyz.
- set_sld_data(sld_data=None)¶
Sets sld_data
- transform_angles()¶
- transform_magnetic_slds()¶
- transform_positions()¶
Transform position data
- class sas.sascalc.calculator.sas_gen.MagSLD(pos_x, pos_y, pos_z, sld_n=None, sld_mx=None, sld_my=None, sld_mz=None, vol_pix=None)¶
Bases:
object
Magnetic SLD.
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.sas_gen', '__doc__': '\n Magnetic SLD.\n ', 'pos_x': None, 'pos_y': None, 'pos_z': None, 'sld_n': None, 'sld_mx': None, 'sld_my': None, 'sld_mz': None, '_pos_unit': 'A', '_sld_unit': '1/A^(2)', '_pix_type': 'pixel', '__init__': <function MagSLD.__init__>, '__str__': <function MagSLD.__str__>, 'set_pix_type': <function MagSLD.set_pix_type>, 'set_sldn': <function MagSLD.set_sldn>, 'set_sldms': <function MagSLD.set_sldms>, 'set_pixel_symbols': <function MagSLD.set_pixel_symbols>, 'set_pixel_volumes': <function MagSLD.set_pixel_volumes>, 'set_elements': <function MagSLD.set_elements>, 'get_sldn': <function MagSLD.get_sldn>, 'set_nodes': <function MagSLD.set_nodes>, 'set_stepsize': <function MagSLD.set_stepsize>, 'set_conect_lines': <function MagSLD.set_conect_lines>, '__dict__': <attribute '__dict__' of 'MagSLD' objects>, '__weakref__': <attribute '__weakref__' of 'MagSLD' objects>, '__annotations__': {'line_x': 'list[tuple[float, float]] | None', 'line_y': 'list[tuple[float, float]] | None', 'line_z': 'list[tuple[float, float]] | None'}})¶
- __doc__ = '\n Magnetic SLD.\n '¶
- __init__(pos_x, pos_y, pos_z, sld_n=None, sld_mx=None, sld_my=None, sld_mz=None, vol_pix=None)¶
Init for mag SLD :params : All should be np 1D array
- __module__ = 'sas.sascalc.calculator.sas_gen'¶
- __str__()¶
doc strings
- __weakref__¶
list of weak references to the object
- _pix_type = 'pixel'¶
- _pos_unit = 'A'¶
- _sld_unit = '1/A^(2)'¶
- get_sldn()¶
Returns nuclear sld
- pos_x = None¶
- pos_y = None¶
- pos_z = None¶
- set_conect_lines(line_x: list[tuple[float, float]], line_y: list[tuple[float, float]], line_z: list[tuple[float, float]])¶
Set bonding line data if taken from pdb
- set_elements(elements, are_elements_array)¶
Set elements for a non-rectangular grid
This sets element data for the object allowing non rectangular grids to be used. It sets a boolean flag in the class, stores the structure of the elements and sets the pixel type to ‘element’, and hence nodes and stepsize to None. Once this flag is enabled the sld data is expected to match up to elements as opposed to points.
- Parameters:
elements (list) – The elements which describe the volume. This should be a list (of elements) of a list (of faces) of a list (of vertex indices). It may be a jagged array due to the freedom of the .vtk file format. Faces may not be triangulised.
- set_nodes()¶
Set xnodes, ynodes, and znodes
- set_pix_type(pix_type)¶
Set pixel type :Param pix_type: string, ‘pixel’ or ‘atom’
- set_pixel_symbols(symbol='pixel')¶
Set pixel :Params pixel: str; pixel or atomic symbol, or array of strings
- set_pixel_volumes(vol)¶
Set pixel volumes :Params pixel: str; pixel or atomic symbol, or array of strings
- set_sldms(sld_mx, sld_my, sld_mz)¶
Sets mx, my, mz and abs(m).
- set_sldn(sld_n, non_zero_mag_only=True)¶
Sets neutron SLD.
Warning: if sld_n is a scalar and attribute is_data is True, then only pixels with non-zero magnetism will be set by default. Use the argument non_zero_mag_only=False to change this
- set_stepsize()¶
Set xtepsize, ystepsize, and zstepsize
- sld_mx = None¶
- sld_my = None¶
- sld_mz = None¶
- sld_n = None¶
- class sas.sascalc.calculator.sas_gen.OMF2SLD¶
Bases:
object
Convert OMFData to MAgData
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.sas_gen', '__doc__': '\n Convert OMFData to MAgData\n ', '__init__': <function OMF2SLD.__init__>, 'set_data': <function OMF2SLD.set_data>, 'get_omfdata': <function OMF2SLD.get_omfdata>, 'get_output': <function OMF2SLD.get_output>, '_check_data_length': <function OMF2SLD._check_data_length>, 'remove_null_points': <function OMF2SLD.remove_null_points>, '__dict__': <attribute '__dict__' of 'OMF2SLD' objects>, '__weakref__': <attribute '__weakref__' of 'OMF2SLD' objects>, '__annotations__': {}})¶
- __doc__ = '\n Convert OMFData to MAgData\n '¶
- __init__()¶
Init
- __module__ = 'sas.sascalc.calculator.sas_gen'¶
- __weakref__¶
list of weak references to the object
- _check_data_length(length)¶
Check if the data lengths are consistent :Params length: data length
- get_omfdata()¶
Return all data
- get_output()¶
Return output
- remove_null_points(remove=False, recenter=False)¶
Removes any mx, my, and mz = 0 points
- set_data(omfdata, shape='rectangular')¶
Set all data
- class sas.sascalc.calculator.sas_gen.OMFData¶
Bases:
object
OMF Data.
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.sas_gen', '__doc__': '\n OMF Data.\n ', '_meshunit': 'A', '_valueunit': 'A^(-2)', '__init__': <function OMFData.__init__>, '__str__': <function OMFData.__str__>, 'set_m': <function OMFData.set_m>, '__dict__': <attribute '__dict__' of 'OMFData' objects>, '__weakref__': <attribute '__weakref__' of 'OMFData' objects>, '__annotations__': {}})¶
- __doc__ = '\n OMF Data.\n '¶
- __init__()¶
Init for mag SLD
- __module__ = 'sas.sascalc.calculator.sas_gen'¶
- __str__()¶
doc strings
- __weakref__¶
list of weak references to the object
- _meshunit = 'A'¶
- _valueunit = 'A^(-2)'¶
- set_m(mx, my, mz)¶
Set the Mx, My, Mz values
- class sas.sascalc.calculator.sas_gen.OMFReader¶
Bases:
object
Class to load omf/ascii files (3 columns w/header).
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.sas_gen', '__doc__': '\n Class to load omf/ascii files (3 columns w/header).\n ', 'type_name': 'OMF ASCII', 'type': ['OMF files (*.OMF, *.omf)|*.omf'], 'ext': ['.omf', '.OMF'], 'read': <function OMFReader.read>, '__dict__': <attribute '__dict__' of 'OMFReader' objects>, '__weakref__': <attribute '__weakref__' of 'OMFReader' objects>, '__annotations__': {}})¶
- __doc__ = '\n Class to load omf/ascii files (3 columns w/header).\n '¶
- __module__ = 'sas.sascalc.calculator.sas_gen'¶
- __weakref__¶
list of weak references to the object
- ext = ['.omf', '.OMF']¶
- read(path)¶
Load data file :param path: file path :return: x, y, z, sld_n, sld_mx, sld_my, sld_mz
- type = ['OMF files (*.OMF, *.omf)|*.omf']¶
- type_name = 'OMF ASCII'¶
- class sas.sascalc.calculator.sas_gen.PDBReader¶
Bases:
object
PDB reader class: limited for reading the lines starting with ‘ATOM’
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.sas_gen', '__doc__': "\n PDB reader class: limited for reading the lines starting with 'ATOM'\n ", 'logger': <Logger sas_gen.PDBReader (WARNING)>, 'type_name': 'PDB', 'type': ['pdb files (*.PDB, *.pdb)|*.pdb'], 'ext': ['.pdb', '.PDB'], 'read': <function PDBReader.read>, 'write': <function PDBReader.write>, '__dict__': <attribute '__dict__' of 'PDBReader' objects>, '__weakref__': <attribute '__weakref__' of 'PDBReader' objects>, '__annotations__': {}})¶
- __doc__ = "\n PDB reader class: limited for reading the lines starting with 'ATOM'\n "¶
- __module__ = 'sas.sascalc.calculator.sas_gen'¶
- __weakref__¶
list of weak references to the object
- ext = ['.pdb', '.PDB']¶
- logger = <Logger sas_gen.PDBReader (WARNING)>¶
- read(path)¶
Load data file
- Parameters:
path – file path
- Returns:
MagSLD
- Raises:
RuntimeError – when the file can’t be opened
- type = ['pdb files (*.PDB, *.pdb)|*.pdb']¶
- type_name = 'PDB'¶
- write(path, data)¶
Write
- class sas.sascalc.calculator.sas_gen.SLDReader¶
Bases:
object
SLD reader for text files.
format: 1 line of header - may give any information n lines of data points of the form:
4 columns: x y z sld 6 columns: x y z mx my mz 7 columns: x y z sld mx my mz 8 columns: x y z sld mx my mz volume
where all n lines have the same format.
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.sas_gen', '__doc__': 'SLD reader for text files.\n\n format:\n 1 line of header - may give any information\n n lines of data points of the form:\n\n 4 columns: x y z sld\n 6 columns: x y z mx my mz\n 7 columns: x y z sld mx my mz\n 8 columns: x y z sld mx my mz volume\n \n where all n lines have the same format.\n ', 'type_name': 'SLD ASCII', 'type': ['sld files (*.SLD, *.sld)|*.sld', 'txt files (*.TXT, *.txt)|*.txt', 'all files (*.*)|*.*'], 'ext': ['.sld', '.SLD', '.txt', '.TXT', '.*'], 'read': <function SLDReader.read>, 'write': <function SLDReader.write>, '__dict__': <attribute '__dict__' of 'SLDReader' objects>, '__weakref__': <attribute '__weakref__' of 'SLDReader' objects>, '__annotations__': {}})¶
- __doc__ = 'SLD reader for text files.\n\n format:\n 1 line of header - may give any information\n n lines of data points of the form:\n\n 4 columns: x y z sld\n 6 columns: x y z mx my mz\n 7 columns: x y z sld mx my mz\n 8 columns: x y z sld mx my mz volume\n \n where all n lines have the same format.\n '¶
- __module__ = 'sas.sascalc.calculator.sas_gen'¶
- __weakref__¶
list of weak references to the object
- ext = ['.sld', '.SLD', '.txt', '.TXT', '.*']¶
- read(path)¶
Load data file :param path: file path :return MagSLD: x, y, z, sld_n, sld_mx, sld_my, sld_mz :raise RuntimeError: when the file can’t be loaded
- type = ['sld files (*.SLD, *.sld)|*.sld', 'txt files (*.TXT, *.txt)|*.txt', 'all files (*.*)|*.*']¶
- type_name = 'SLD ASCII'¶
- write(path, data)¶
Write sld file :Param path: file path :Param data: MagSLD data object
- class sas.sascalc.calculator.sas_gen.VTKReader¶
Bases:
object
Class to read and process .vtk files
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.sas_gen', '__doc__': '\n Class to read and process .vtk files\n ', 'type_name': 'VTK', 'type': ['vtk files (*.VTK, *.vtk)|*.vtk'], 'ext': ['.vtk', '.VTK'], 'read': <function VTKReader.read>, 'unstructured_grid_read': <function VTKReader.unstructured_grid_read>, 'load_data_attributes': <function VTKReader.load_data_attributes>, 'load_attribute': <function VTKReader.load_attribute>, 'get_faces': <function VTKReader.get_faces>, 'get_vols': <function VTKReader.get_vols>, '__dict__': <attribute '__dict__' of 'VTKReader' objects>, '__weakref__': <attribute '__weakref__' of 'VTKReader' objects>, '__annotations__': {}})¶
- __doc__ = '\n Class to read and process .vtk files\n '¶
- __module__ = 'sas.sascalc.calculator.sas_gen'¶
- __weakref__¶
list of weak references to the object
- ext = ['.vtk', '.VTK']¶
- get_faces(e, element_type)¶
Returns the faces of the elements
This function takes in the vertices and element type of an element and returns a list of faces - the orientation of the vertices in each face does not appear to be guaranteed in the vtk file format.
- Parameters:
e (list of int) – The vertices (as indices) of the element in the order as given in the .vtk file specification.
element_type (int) – The element_type (as given in the file specification).
- Returns:
A list of faces which is in turn a list of vertex indices, None if the element type is not supported
- Return type:
list of list of int or None
- get_vols(e, element_type, v)¶
Returns the volumes of the elements
This function takes in the vertices and element type of an element and returns the real space volume of each element.
- Parameters:
e (list of int) – the vertices (as indexes) of the element in the order as given in the .vtk file specification.
element_type (int) – The element_type (as given in the file specification).
v (list) – A list of real space positions which are indexed by e.
- Returns:
The volume of the element.
- Return type:
float
- load_attribute(lines, size)¶
Returns a single set of data - either point data or element data
- Parameters:
lines (iterator) – The lines of the file - with the next lines being the first after the descriptor POINT_DATA or CELL_DATA.
size (int) – The expected length of each attribute - either the number of points or number of elements.
- Returns:
a tuple containg both the data loaded - and the next lines in the file - which is None if the file is ended.
- Return type:
2-tuple
- load_data_attributes(lines, num_points, num_elements)¶
Extract the data attributes from the file
In the vtk file format the data attributes (POINT_DATA and CELL_DATA) are the last part of the file. This function processes that data and returns it.
- Parameters:
lines (iterator) – The lines from the file - with the next line being either POINT_DATA or CELL_DATA.
num_points (int) – The number of points in the loaded file.
num_elements (int) – The number of elements in the loaded file.
- Returns:
Either the loaded data attributes of None if loading failed. The data is a 2-tuple of lists of attributes - each attribute being a list of length 3 containing: the data as a list, the name of the attribute and the number of components of the attribute. The first list in the tuple is data associated with points, and the second is data associated with elements.
- Return type:
2-tuple
- read(path)¶
This function reads in a vtk file
- Parameters:
path (string) – The filepath to be loaded
- Returns:
A MagSLD instance containing the loaded data or None if loading failed
- Return type:
MagSLD or None
- type = ['vtk files (*.VTK, *.vtk)|*.vtk']¶
- type_name = 'VTK'¶
- unstructured_grid_read(lines, path)¶
Processes .vtk files in ASCII unstructured_grid format
- Parameters:
lines (iterator) – an iterator with the (non-empty) lines of the file, starting one line after the DATASET marker
path (string) – The filepath to be loaded
- Returns:
A MagSLD instance containing the loaded data or None if loading failed
- Return type:
MagSLD or None
- sas.sascalc.calculator.sas_gen._get_data_path(*path_parts)¶
- sas.sascalc.calculator.sas_gen._setup_realspace_path()¶
Put sasmodels/explore on path so realspace
- sas.sascalc.calculator.sas_gen._vec(v)¶
- sas.sascalc.calculator.sas_gen.compare(obj, qx, qy=None, plot_points=False, theory=None)¶
Compare GenSAS calculator obj to old C and sasmodels versions.
theory is the I(q) value for the shape, if known.
- sas.sascalc.calculator.sas_gen.decode(s)¶
- sas.sascalc.calculator.sas_gen.demo()¶
Run a GenSAS operation demo.
- sas.sascalc.calculator.sas_gen.demo_load()¶
Check loading of coordinate data.
- sas.sascalc.calculator.sas_gen.demo_oommf()¶
Calculate theory from saved OOMMF magnetic data.
- sas.sascalc.calculator.sas_gen.demo_pdb(is_avg=False)¶
Calculation I(q) for object in pdb file.
- sas.sascalc.calculator.sas_gen.demo_save()¶
Check saving of coordinate data.
- sas.sascalc.calculator.sas_gen.demo_shape(shape='ellip', samples=2000, nq=100, view=(60, 30, 0), qmax=0.5, use_2d=False, **kw)¶
Sample from shape with analytic model.
shape is one of the shapes from sasmodels/explore/realspace.py
samples is the number of sample points
view is the rotation angle for the shape
qmax is the max q value
use_2d produces a 2D shape rather
Remaining keywords are specific to the shape. See def build_SHAPE(…) in realspace.py for details.
- sas.sascalc.calculator.sas_gen.mag2sld(mag, v_unit=None)¶
Convert magnetization to magnatic SLD sldm = Dm * mag where Dm = gamma * classical elec. radius/(2*Bohr magneton) Dm ~ 2.90636E8 [(A m)^(-1)]= 2.90636E-12 [to Ang^(-2)]
- sas.sascalc.calculator.sas_gen.realspace_Iq(self, qx, qy)¶
Compute Iq for GenSAS object using sasmodels/explore/realspace.py
- sas.sascalc.calculator.sas_gen.sas_gen_c(self, qx, qy=None)¶
C interface to sas_gen, for comparison to new python interface.
Note: this requires the old C implementation which may have already been removed from the repository.
- sas.sascalc.calculator.sas_gen.set_axis_equal_3D(ax)¶
Set equal axes on a 3D plot.
- sas.sascalc.calculator.sas_gen.test()¶
Check that the GenSAS can load coordinates and compute I(q).
- sas.sascalc.calculator.sas_gen.transform_center(pos_x, pos_y, pos_z)¶
re-center :return: posx, posy, posz [arrays]
sas.sascalc.calculator.slit_length_calculator module¶
This module is a small tool to allow user to quickly determine the slit length value of data.
- class sas.sascalc.calculator.slit_length_calculator.SlitlengthCalculator¶
Bases:
object
compute slit length from SAXSess beam profile (1st col. Q , 2nd col. I , and 3rd col. dI.: don’t need the 3rd)
- __dict__ = mappingproxy({'__module__': 'sas.sascalc.calculator.slit_length_calculator', '__doc__': "\n compute slit length from SAXSess beam profile (1st col. Q , 2nd col. I ,\n and 3rd col. dI.: don't need the 3rd)\n ", '__init__': <function SlitlengthCalculator.__init__>, 'set_data': <function SlitlengthCalculator.set_data>, 'calculate_slit_length': <function SlitlengthCalculator.calculate_slit_length>, 'get_slit_length_unit': <function SlitlengthCalculator.get_slit_length_unit>, '__dict__': <attribute '__dict__' of 'SlitlengthCalculator' objects>, '__weakref__': <attribute '__weakref__' of 'SlitlengthCalculator' objects>, '__annotations__': {}})¶
- __doc__ = "\n compute slit length from SAXSess beam profile (1st col. Q , 2nd col. I ,\n and 3rd col. dI.: don't need the 3rd)\n "¶
- __init__()¶
- __module__ = 'sas.sascalc.calculator.slit_length_calculator'¶
- __weakref__¶
list of weak references to the object
- calculate_slit_length()¶
Calculate slit length.
- Returns:
the slit length calculated value.
- get_slit_length_unit()¶
- Returns:
the slit length unit.
- set_data(x=None, y=None)¶
Receive two vector x, y and prepare the slit calculator for computation.
- Parameters:
x – array
y – array