sas.calculator package

Submodules

sas.calculator.instrument module

This module is a small tool to allow user to control instrumental parameters

class sas.calculator.instrument.Aperture[source]

Bases: object

An object class that defines the aperture variables

set_sample_distance(distance=[])[source]

Set the sample aperture distance

set_sample_size(size=[])[source]

Set the sample aperture size

set_source_size(size=[])[source]

Set the source aperture size

class sas.calculator.instrument.Detector[source]

Bases: object

An object class that defines the detector variables

set_distance(distance=[])[source]

Set the detector distance

set_pix_size(size=[])[source]

Set the detector pix_size

set_size(size=[])[source]

Set the detector size

class sas.calculator.instrument.Neutron[source]

Bases: object

An object that defines the wavelength variables

get_band()[source]

To get the wavelength band

get_default_spectrum()[source]

get default spectrum

get_intensity()[source]

To get the value of intensity

get_mass()[source]

To get the neutron mass

get_ramdom_value()[source]

To get the value of wave length

get_spectrum()[source]

To get the wavelength spectrum

get_wavelength()[source]

To get the value of wavelength

get_wavelength_spread()[source]

To get the value of wavelength spread

plot_spectrum()[source]

To plot the wavelength spactrum : requirment: matplotlib.pyplot

set_band(band=[])[source]

To set the wavelength band

Parameters:band – array of [min, max]
set_full_band()[source]

set band to default value

set_intensity(intensity=368428)[source]

Sets the intensity in counts/sec

set_mass(mass=1.67492729e-24)[source]

Sets the wavelength

set_spectrum(spectrum)[source]

Set spectrum

Parameters:spectrum – numpy array
set_wavelength(wavelength=6.0)[source]

Sets the wavelength

set_wavelength_spread(spread=0.125)[source]

Sets the wavelength spread

setup_spectrum()[source]

To set the wavelength spectrum, and intensity, assumes wavelength is already within the spectrum

class sas.calculator.instrument.Sample[source]

Bases: object

An object class that defines the sample variables

set_distance(distance=[])[source]

Set the sample distance

set_size(size=[])[source]

Set the sample size

set_thickness(thickness=0.0)[source]

Set the sample thickness

class sas.calculator.instrument.TOF[source]

Bases: sas.calculator.instrument.Neutron

TOF: make list of wavelength and wave length spreads

get_intensity_list()[source]

get list of the intensity wrt wavelength_list

get_wave_list()[source]

Get wavelength and wavelength_spread list

set_wave_list(wavelength=[])[source]

Set wavelength list

Parameters:wavelength – list of wavelengths
set_wave_spread_list(wavelength_spread=[])[source]

Set wavelength_spread list

Parameters:wavelength_spread – list of wavelength spreads
sas.calculator.instrument.validate(value=None)[source]

Check if the value is folat > 0.0

Return value:True / False

sas.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.calculator.kiessig_calculator.KiessigThicknessCalculator[source]

Bases: object

compute thickness from the fringe width of data

compute_thickness()[source]

Calculate thickness.

Returns:the thickness.
get_deltaq()[source]

return deltaQ value in 1/A unit

get_thickness_unit()[source]
Returns:the thickness unit.
set_deltaq(dq=None)[source]

Receive deltaQ value

Parameters:dq – q fringe width in 1/A unit

sas.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.calculator.resolution_calculator.ResolutionCalculator[source]

Bases: object

compute resolution in 2D

compute(wavelength, wavelength_spread, qx_value, qy_value, coord='cartesian', tof=False)[source]

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')[source]

Compute the resolution : qx_value: x component of q : qy_value: y component of q

get_all_instrument_params()[source]

Get all instrumental parameters

get_default_spectrum()[source]

Get default_spectrum

get_detector_pix_size()[source]

Get detector pixel size

get_detector_qrange()[source]

get max detector q ranges

: return: qx_min, qx_max, qy_min, qy_max tuple

get_detector_size()[source]

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)[source]

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()[source]

Get intensity

get_intensity_list()[source]

Set wavelength spread

get_neutron_mass()[source]

Get Neutron mass

get_sample2detector_distance()[source]

Get detector sample2detector_distance

get_sample2sample_distance()[source]

Get detector sampleslitsample_distance

get_sample_aperture_size()[source]

Get sample aperture size

get_source2sample_distance()[source]

Get detector source2sample_distance

get_source_aperture_size()[source]

Get source aperture size

get_spectrum()[source]

Get _spectrum

get_variance(size=[], distance=0, phi=0, comp='radial')[source]

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')[source]

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')[source]

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()[source]

Set wavelength spread

get_wavelength()[source]

Get wavelength

get_wavelength_spread()[source]

Get wavelength spread

plot_image(image)[source]

Plot image using pyplot : image: 2d resolution image

: return plt: pylab object

reset_image()[source]

Reset image to default (=[])

set_detector_pix_size(size)[source]

Set detector pixel size

set_detector_size(size)[source]

Set detector size in number of pixels : param size: [pixel_nums] or [x_pix_num, yx_pix_num]

set_intensity(intensity)[source]

Set intensity

set_neutron_mass(mass)[source]

Set Neutron mass

set_sample2detector_distance(distance)[source]

Set detector sample2detector_distance

: param distance: [distance, x_offset]

set_sample2sample_distance(distance)[source]

Set detector sample_slit2sample_distance

: param distance: [distance, x_offset]

set_sample_aperture_size(size)[source]

Set sample aperture size

: param size: [dia_value] or [xheight_value, yheight_value]

set_source2sample_distance(distance)[source]

Set detector source2sample_distance

: param distance: [distance, x_offset]

set_source_aperture_size(size)[source]

Set source aperture size

: param size: [dia_value] or [x_value, y_value]

set_spectrum(spectrum)[source]

Set spectrum

set_wave(wavelength)[source]

Set wavelength list or wavelength

set_wave_list(wavelength_list, wavelengthspread_list)[source]

Set wavelength and its spread list

set_wave_spread(wavelength_spread)[source]

Set wavelength spread or wavelength spread

set_wavelength(wavelength)[source]

Set wavelength

set_wavelength_spread(wavelength_spread)[source]

Set wavelength spread

setup_tof(wavelength, wavelength_spread)[source]

Setup all parameters in instrument

: param ind: index of lambda, etc

sas.calculator.sas_gen module

SAS generic computation and sld file readers

class sas.calculator.sas_gen.GenSAS[source]

Bases: sas.models.BaseComponent.BaseComponent

Generic SAS computation Model based on sld (n & m) arrays

evalDistribution(qdist)[source]

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. :param qdist: ndarray of scalar q-values or list [qx,qy] where qx,qy are 1D ndarrays

getProfile()[source]

Get SLD profile

: return: sld_data

run(x=0.0)[source]

Evaluate the model :param x: simple value :return: (I value)

runXY(x=0.0)[source]

Evaluate the model :param x: simple value :return: I value :Use this runXY() for the computation

set_is_avg(is_avg=False)[source]

Sets is_avg: [bool]

set_pixel_volumes(volume)[source]

Set the volume of a pixel in (A^3) unit :Param volume: pixel volume [float]

set_sld_data(sld_data=None)[source]

Sets sld_data

class sas.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)[source]

Magnetic SLD.

get_sld_m()[source]

Returns (sldm, sld_theta, sld_phi)

get_sld_mxyz()[source]

Returns (sld_mx, sldmy, sld_mz)

get_sldn()[source]

Returns nuclear sld

pos_x = None
pos_y = None
pos_z = None
set_conect_lines(line_x, line_y, line_z)[source]

Set bonding line data if taken from pdb

set_nodes()[source]

Set xnodes, ynodes, and znodes

set_pix_type(pix_type)[source]

Set pixel type :Param pix_type: string, ‘pixel’ or ‘atom’

set_pixel_symbols(symbol='pixel')[source]

Set pixel :Params pixel: str; pixel or atomic symbol, or array of strings

set_pixel_volumes(vol)[source]

Set pixel volumes :Params pixel: str; pixel or atomic symbol, or array of strings

set_sldms(sld_mx, sld_my, sld_mz)[source]

Sets (|m|, m_theta, m_phi)

set_sldn(sld_n)[source]

Sets neutron SLD

set_stepsize()[source]

Set xtepsize, ystepsize, and zstepsize

sld_mx = None
sld_my = None
sld_mz = None
sld_n = None
class sas.calculator.sas_gen.OMF2SLD[source]

Convert OMFData to MAgData

get_magsld()[source]

return MagSLD

get_omfdata()[source]

Return all data

get_output()[source]

Return output

remove_null_points(remove=False, recenter=False)[source]

Removes any mx, my, and mz = 0 points

set_data(omfdata, shape='rectangular')[source]

Set all data

class sas.calculator.sas_gen.OMFData[source]

OMF Data.

set_m(mx, my, mz)[source]

Set the Mx, My, Mz values

class sas.calculator.sas_gen.OMFReader[source]

Class to load omf/ascii files (3 columns w/header).

ext = ['.omf', '.OMF']
read(path)[source]

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.calculator.sas_gen.PDBReader[source]

PDB reader class: limited for reading the lines starting with ‘ATOM’

ext = ['.pdb', '.PDB']
read(path)[source]

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)[source]

Write

class sas.calculator.sas_gen.SLDReader[source]

Class to load ascii files (7 columns).

ext = ['.sld', '.SLD', '.txt', '.TXT', '.*']
read(path)[source]

Load data file

Parameters:

path – file path

Return MagSLD:

x, y, z, sld_n, sld_mx, sld_my, sld_mz

Raises:
  • RuntimeError – when the file can’t be opened
  • ValueError – when the length of the data vectors are inconsistent
type = ['sld files (*.SLD, *.sld)|*.sld', 'txt files (*.TXT, *.txt)|*.txt', 'all files (*.*)|*.*']
type_name = 'SLD ASCII'
write(path, data)[source]

Write sld file

Param path:file path
Param data:MagSLD data object
sas.calculator.sas_gen.mag2sld(mag, v_unit=None)[source]

Convert magnetization to magnatic SLD sldm = Dm * mag where Dm = gamma * classical elec. radius/(2*Bohr magneton) Dm ~ 2.853E-12 [A^(-2)] ==> Shouldn’t be 2.90636E-12 [A^(-2)]???

sas.calculator.sas_gen.test()[source]
sas.calculator.sas_gen.test_load()[source]
sas.calculator.sas_gen.transform_center(pos_x, pos_y, pos_z)[source]

re-center

Returns:posx, posy, posz [arrays]

sas.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.calculator.slit_length_calculator.SlitlengthCalculator[source]

Bases: object

compute slit length from SAXSess beam profile (1st col. Q , 2nd col. I , and 3rd col. dI.: don’t need the 3rd)

calculate_slit_length()[source]

Calculate slit length.

Returns:the slit length calculated value.
get_slit_length_unit()[source]
Returns:the slit length unit.
set_data(x=None, y=None)[source]
Receive two vector x, y and prepare the slit calculator for computation.
Parameters:
  • x – array
  • y – array

Module contents