Skip to main content

Particle Phase Space Analysis Toolkit

Project description

Particle Phase Space Analysis Toolkit

p2sat is an open-source, object-oriented python package created to simplify particle phase-space analysis.

Core features of the package are :

  • Automatic calculation of kinetic energy, divergence angle and gamma factor of the particles from phase space informations
  • Histogram making (1D, 2D, 3D) and data fits (1D)
  • Plotting (1D to 3D histograms, scatter and contour plots) with automatic normalizations and legend
  • Particle filtering with a given property (for example select all the particles at a given position)
  • Statistical tools (standard deviation, covariance, ...)
  • Import data from simulation files (Smilei, Geant4, text files, ...)
  • Low memory load

This allows to process complex operations in a very concise and clear way, as shown in the examples.

See objects documentation for more informations.

Notes :

  • This package was made for my personal use and then contains only few methods to import data from code results, but you can easily add your own (please, share !) and use it to perform your data analysis. See sub-object _Extract for more informations.
  • This tool can be usefull to physicists working with Particle-In-Cell or Monte Carlo codes

Installation

The most simple way to install p2sat is to use pip (https://pypi.org/project/p2sat/)

pip install p2sat

Otherwise, you can also download the source code from github and type the following commands

cd p2sat
python setup.py install

If it is not working, you can add the following lines at the beginning of your script

p2sat_path="/path/to/p2sat/"
import sys
if p2sat_path not in sys.path: sys.path.append(p2sat_path)

import p2sat

Examples

Here is one quick example of p2sat usage, with my Geant4 app results (see examples/ for more informations).

Import results from a simulation file

eps = p2sat.PhaseSpace(particle="electron")
eps.extract.txt("example.csv", sep=",")

1D histogram

Spectrum (Number/MeV) of all the electrons with time selection between 700 and 900 fs (bin width of 0.1 MeV)

ekin,spectrum = eps.hist.h1('ekin',bwidth=0.1,select={'t':[700.0,900.0]})

1D histogram plot and fit

Spectrum of electrons, and exponential fit for energy > 0.511 MeV (bin width of 0.1 MeV, log scale)

eps.plot.h1('ekin', log=True, bwidth=0.1)
eps.plot.f1('ekin', func_name="exp", log=True, bwidth=0.1, select={'ekin':[0.511,None]})

2D histogram plot

Transverse particle dispersion (y, z) at x = 300 µm, for electrons with kinetic energy > 0.511 MeV (log color scale, bin width of 5 µm each, between -300 and 300 µm each)

eps.plot.h2('y','z',log=True,
            bwidth1=5.0,bwidth2=5.0,
            brange1=[-300.,300.],brange2=[-300.,300.],
            select={'x':300,'ekin':[0.511,None]})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

p2sat-1.4.2.tar.gz (85.1 kB view details)

Uploaded Source

File details

Details for the file p2sat-1.4.2.tar.gz.

File metadata

  • Download URL: p2sat-1.4.2.tar.gz
  • Upload date:
  • Size: 85.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6

File hashes

Hashes for p2sat-1.4.2.tar.gz
Algorithm Hash digest
SHA256 82db32fcecc1f741a07cf7232742944a186dbd376bc809a881bd86e76acf07c9
MD5 f6a17c9a656de50781a7e9bda66400ab
BLAKE2b-256 d2f29db1a0d14ce3d961e07624a7304676f5d89c6c123ca19a184bbd1dd32c48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page