jscatter’s documentation¶
The aim of jscatter is handling of experimental data and models:

- Reading and analyzing experimental data with associated attributes as temperature, wavevector, comment, ….
- Multidimensional fitting taking the attributes (as fixed parameters) into account.
- Providing useful models (mainly for neutron and xray scattering), but there is no limitation.
- Simplified plotting with paper ready quality (preferred in xmgrace).
- Easy model building for non programmers.
- Python scripts to document data evaluation and modelling.
Main concept
- Data organisation
dataList
(subclass of list) containing dataArray
´s.- Read/Write data
- Fitting
fit()
for detailed description.- Plotting
- Models
some special functions:
scatteringLengthDensityCalc()
-> electron density, coh and inc neutron scattering length, masswaterdensity()
-> temperature dependent density of water (H2O/D2O) with inorganic subtstancessedimentationProfile()
-> approximate solution to the Lamm equation of sedimenting particlesRMSA()
-> rescaled MSA structure factor for dilute charged colloidal dispersionshydrodynamicFunct()
-> hydrodynamic function from hydrodynamic pair interactionmultiShellSphere()
-> formfactor of multi shell spherical particlesmultiShellCylinder()
-> formfactor of multi shell cylinder particles with capsorientedCloudScattering()
-> 2D scattering of an oriented cloud of scatterersfiniteZimm()
-> Zimm model with internal friction -> intermediate scattering functiondiffusionHarmonicPotential()
-> diffusion in harmonic potential-> intermediate scattering functionsmear()
-> smearing for SANS (Pedersen), SAXS (line collimation) or by explicit Gaussiandesmear()
-> desmearing according to the Lake algorithm for the abovewaterXrayScattering()
-> Absolute scattering of water with components (salt, buffer)
Example see example_simple_diffusion.py and other Examples
# import jscatter and numpy
import numpy as np
import jscatter as js
# read the data (16 sets) with attributes as q, Dtrans .... into dataList
i5=js.dL(js.examples.datapath+'/iqt_1hho.dat')
# define a model for the fit
diffusion=lambda A,D,t,elastic,wavevector=0:A*np.exp(-wavevector**2*D*t)+elastic
# do the fit
i5.fit(model=diffusion, # the fit function
freepar={'D':[0.08],'A':0.98}, # start parameters, "[]" -> independent fit
fixpar={'elastic':0.0}, # fixed parameters
mapNames={'t':'X','wavevector':'q'}) # map names from the model to names from the data
# single valued start parameters are the same for all dataArrays
# list start parameters indicate independent fitting for datasets
# the command line shows progress and the final result, which is found in .lastfit
i5.showlastErrPlot(yscale='l') # opens plot with residuals
# open a plot with fixed size and plot
p=js.grace(1.2,0.8)
# plot the data with Q values in legend as symbols
p.plot(i5,symbol=[-1,0.4,-1],legend='Q=$q')
# plot fit results in lastfit as lines without symbol or legend
p.plot(i5.lastfit,symbol=0,line=[1,1,-1])
# pretty up if needed
p.yaxis(min=0.02,max=1.1,scale='log',charsize=1.5,label='I(Q,t)/I(Q,0)')
p.xaxis(min=0,max=130,charsize=1.5,label='t / ns')
p.legend(x=110,y=0.9,charsize=1)
p.title('I(Q,t) as measured by Neutron Spinecho Spectroscopy',size=1.3)
p.text('for diffusion a single exp. decay',x=60,y=0.35,rot=360-20,color=4)
p.text(r'f(t)=A*e\S-Q\S2\N\SDt',x=100,y=0.025,rot=0,charsize=1.5)
if 0: # optional; save in different formats
p.save('DiffusionFit.agr')
p.save('DiffusionFit.jpg')

Shortcuts:
import jscatter as js
js.showDoc() # Show html documentation in browser
exampledA=js.dA('test.dat') # shortcut to create dataArray from file
exampledL=js.dL('test.dat') # shortcut to create dataList from file
p=js.grace() # create plot
p.plot(exampledL) # plot the read dataList
jscatter package contents¶
- 1. Beginners Guide / Help
- 2. dataArray
- 3. dataList
- 4. formel
- 5. smallanglescattering (sas)
- 6. formfactor (ff)
- 7. structurefactor (sf)
- 8. dynamic
- 9. dls
- 10. parallel
- 11. Plotting in XmGrace
- 12. mpl
- 13. Examples
- 13.1. In a hurry and short
- 13.2. How to build simple models
- 13.3. How to build a more complex model
- 13.4. Some Sinusoidial fits with different kinds to use data atrributes
- 13.5. Simple diffusion fit of not so simple diffusion case
- 13.6. How to smooth Xray data and make an inset in the plot
- 13.7. How to fit SANS data including the resolution for different detector distances
- 13.8. Smearing and desmearing of SAX and SANS data
- 13.9. A long example for diffusion and how to analyze step by step
- 13.10. Sedimentation of two particle sizes and resulting scattering: a Simulation
- 13.11. Create a stacked chart of some curves
- 13.12. A comparison of different dynamic models in frequency domain
- 13.13. Protein incoherent scattering in frequency domain
- 13.14. Fitting a multiShellcylinder in various ways
- 13.15. Hydrodynamic function
- 13.16. 2D oriented scattering
- 13.17. Multilamellar Vesicles
- 13.18. A nano cube build of different lattices
- 14. Extending/Contributing/Fortran
- 15. Tips
- 16. Intention and Remarks
- 17. Installation
Installation¶
Dependencies
numpy, scipy (automatically installed by pip)
gfortran, without some functions dont work:
sudo apt-get install gfortran
recommended:
xmgrace for plotting in Linux (Ubuntu, Debian)
sudo apt-get install grace
xmgrace for plotting in MacOs (install XQuartz and Homebrew):
brew tap homebrew/x11 brew install grace
Ipython for convenience
matplotlib (needed for 3D plots):
pip install ipython matplotlib
Installation (maybe use pip2 or pip3 dependent what you want to use)
pip install jscatter
as user in home directory:
pip install jscatter --user
from a local repository (development versions):
pip install jscatter --user --upgrade --pre --find-links /where/the/file/is/saved options --user : Install in user directory (folder defined by PYTHONUSERBASE or the default is used) --find-links : look in the given path for package links e.g development releases --upgrade : to install upgrades --pre : to install also development versions
Anaconda is a python distribution as easy alternative for MacOs and Windows (also working on Linux) with numpy, scipy, matplotlib, Ipython preinstalled.
pip install jscatter # install xmgrace (only Linux/OSX) conda install -c uvcdat xmgrace
CONTIN in DLS module
See DLS module documentation for details how to get and compile the original fortran code. Only if needed.
Testing
You can test basic functionality of jscatter after installation:
import jscatter as js js.test.doTest()
During development:
python setup.py test