Jscatter’s documentation

The aim of Jscatter is treatment of experimental data and models:

Jscatter Logo
  • Reading and analyzing experimental data with associated attributes as temperature, wavevector, comment, ….

  • Multidimensional fitting taking attributes into account.

  • Providing useful models for neutron and X-ray scattering form factors, structure factors and dynamic models (quasi elastic neutron scattering) and other topics.

  • Simplified plotting with paper ready quality.

  • Easy model building for non programmers.

  • Python scripts/Jupyter Notebooks to document data evaluation and modelling.

Binder citation install license pyversion Read the Docs Beginners Guide

Main concept

Exemplary functions:

Physical equations and useful formulas as quadrature of vector functions
  • scatteringLengthDensityCalc() -> Electron density, coh and inc neutron scattering length, mass.

  • smear() -> Smearing enabling simultaneous fits of differently smeared SANS/SAXS data.

  • desmear() -> Desmearing according to the Lake algorithm for the above.

See formel and smallanglescattering (sas)

Particle Formfactors

See formfactor (ff)

Particle Structurefactors
  • RMSA() -> Rescaled MSA structure factor for dilute charged colloidal dispersions.

  • twoYukawa() -> Structure factor for a two Yukawa potential in mean spherical approximation.

  • OrnsteinZernikeSolver -> Numerical Solution of the Ornstein-Zernike Equation for user-defined potentials

  • hydrodynamicFunct() -> Hydrodynamic function from hydrodynamic pair interaction.

See structurefactor (sf)

Dynamics

See dynamic

biomacromoleules

See Biomacromolecules (bio)

For help with an AI coding assistant such as Codex, see Using AI assistants for Jscatter analysis for a simple prompt and project setup.

How to use Jscatter

see Examples and Beginners Guide / Help or try Jscatter live at Binder .

# import jscatter and numpy
import numpy as np
import jscatter as js

# read the data (16 dataArrays) 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, wavevector, e=0: A*np.exp(-wavevector**2*D*t) + e

# do the fit
# single valued start parameters are the same for all 16 dataArrays
# list start parameters [...] indicate independent fitting for dataArrays
# the command line shows progress and the final result, which is found in i5.lastfit
i5.fit(model=diffusion,                         # the fit function
       freepar={'D': [0.08], 'A': 0.98},        # free start parameters
       fixpar={'e': 0.0},                       # fixed parameters
       mapNames={'t': 'X', 'wavevector': 'q'})  # map names from model to data

# open plot with results and residuals
i5.showlastErrPlot(yscale='l')

# open a plot with fixed size and plot data and fit result
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])
# extend to longer times by changing a model parameter (points)
p.plot(i5.modelValues(t=np.r_[10:120:5]), symbol=0, line=[2, 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)

Picture about diffusion fit

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 in XmGrace
p=js.mplot()                  # create plot in matplotlib
p.plot(exampledL)             # plot the read dataList

jscatter.usempl(*args)

Switch between using mpl and grace in dataArray/dataList fitting.

jscatter.headless(*args)

Switch to headless mode (NO-GUI) to work on a cluster.

jscatter.version

Jscatter version is changed in pyproject.toml


If not otherwise stated in the files:

written by Ralf Biehl at the Forschungszentrum Jülich ,
Jülich Center for Neutron Science (JCNS-1)
Jscatter is a program to read, analyse and plot data
Copyright (C) 2015-2026 Ralf Biehl

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

Jscatter package contents

Indices and tables