postpic.particles package

class postpic.particles.ScalarProperty(expr, name=None, unit=None, symbol=None)[source]

Bases: object

evaluate(vars)[source]

vars must be a dictionary containing variables used within the expression “expr”.

expr
input_names

The list of variables used within this expression.

name
symbol
unit
class postpic.particles.MultiSpecies(dumpreader, *speciess, **kwargs)[source]

Bases: object

The MultiSpecies class. Different MultiSpecies can be added together to create a combined collection.

ignore_missing_species = False
set to true to ignore missing species.

The MultiSpecies class will return a list of values for every particle property.

Ekin()[source]

Deprecated since version unknown: The function Ekin is deprecated. Use self(“Ekin”) instead.

Ekin_MeV()[source]

Deprecated since version unknown: The function Ekin_MeV is deprecated. Use self(“Ekin_MeV”) instead.

Ekin_MeV_amu()[source]

Deprecated since version unknown: The function Ekin_MeV_amu is deprecated. Use self(“Ekin_MeV_amu”) instead.

Ekin_MeV_qm()[source]

Deprecated since version unknown: The function Ekin_MeV_qm is deprecated. Use self(“Ekin_MeV_qm”) instead.

Ekin_keV()[source]

Deprecated since version unknown: The function Ekin_keV is deprecated. Use self(“Ekin_keV”) instead.

Ekin_keV_amu()[source]

Deprecated since version unknown: The function Ekin_keV_amu is deprecated. Use self(“Ekin_keV_amu”) instead.

Ekin_keV_qm()[source]

Deprecated since version unknown: The function Ekin_keV_qm is deprecated. Use self(“Ekin_keV_qm”) instead.

Eruhe()[source]

Deprecated since version unknown: The function Eruhe is deprecated. Use self(“Eruhe”) instead.

ID()[source]

Deprecated since version unknown: The function ID is deprecated. Use self(“id”) instead.

P()[source]

Deprecated since version unknown: The function P is deprecated. Use self(“p”) instead.

Px()[source]

Deprecated since version unknown: The function Px is deprecated. Use self(“px”) instead.

Py()[source]

Deprecated since version unknown: The function Py is deprecated. Use self(“py”) instead.

Pz()[source]

Deprecated since version unknown: The function Pz is deprecated. Use self(“pz”) instead.

V()[source]

Deprecated since version unknown: The function V is deprecated. Use self(“v”) instead.

Vx()[source]

Deprecated since version unknown: The function Vx is deprecated. Use self(“vx”) instead.

Vy()[source]

Deprecated since version unknown: The function Vy is deprecated. Use self(“vy”) instead.

Vz()[source]

Deprecated since version unknown: The function Vz is deprecated. Use self(“vz”) instead.

X()[source]

Deprecated since version unknown: The function X is deprecated. Use self(“x”) instead.

X_um()[source]

Deprecated since version unknown: The function X_um is deprecated. Use self(“x_um”) instead.

Y()[source]

Deprecated since version unknown: The function Y is deprecated. Use self(“y”) instead.

Y_um()[source]

Deprecated since version unknown: The function Y_um is deprecated. Use self(“Y_mu”) instead.

Z()[source]

Deprecated since version unknown: The function Z is deprecated. Use self(“z”) instead.

Z_um()[source]

Deprecated since version unknown: The function Z_um is deprecated. Use self(“z_um”) instead.

add(dumpreader, species, ignore_missing_species=False)[source]

adds a species to this MultiSpecies. This function modifies the current Object and always returns None.

species can be a single species name

or a reserved name for collection of species, such as ions adds all available particles that are ions nonions adds all available particles that are not ions ejected noejected all

Optional arguments
--------
ignore_missing_species = False

set to True to ignore if the species is missing.

angle_xaxis()[source]

Deprecated since version unknown: The function angle_xaxis is deprecated. Use self(“angle_xaxis”) instead.

angle_xy()[source]

Deprecated since version unknown: The function angle_xy is deprecated. Use self(“angle_xy”) instead.

angle_xz()[source]

Deprecated since version unknown: The function angle_xz is deprecated. Use self(“angle_xz”) instead.

angle_yx()[source]

Deprecated since version unknown: The function angle_yx is deprecated. Use self(“angle_yx”) instead.

angle_yz()[source]

Deprecated since version unknown: The function angle_yz is deprecated. Use self(“angle_yz”) instead.

angle_zx()[source]

Deprecated since version unknown: The function angle_zx is deprecated. Use self(“angle_zx”) instead.

angle_zy()[source]

Deprecated since version unknown: The function angle_zy is deprecated. Use self(“angle_zy”) instead.

beta()[source]

Deprecated since version unknown: The function beta is deprecated. Use self(“beta”) instead.

betax()[source]

Deprecated since version unknown: The function betax is deprecated. Use self(“betax”) instead.

betay()[source]

Deprecated since version unknown: The function betay is deprecated. Use self(“betay”) instead.

betaz()[source]

Deprecated since version unknown: The function betaz is deprecated. Use self(“betaz”) instead.

charge()[source]

Deprecated since version unknown: The function charge is deprecated. Use self(“charge”) instead.

charge_e()[source]

Deprecated since version unknown: The function charge_e is deprecated. Use self(“charge_e”) instead.

compress(condition, name='unknown condition')[source]

works like numpy.compress. Returns a new MultiSpecies instance.

Additionaly you can specify a name, that gets saved in the compresslog.

condition has to be one out of: 1) condition = [True, False, True, True, … , True, False] condition is a list of length N, specifing which particles to keep. Example: cfintospectrometer = lambda x: x.angle_offaxis() < 30e-3 cfintospectrometer.name = ‘< 30mrad offaxis’ pa.compress(cfintospectrometer(pa), name=cfintospectrometer.name) 2) condition = [1, 2, 4, 5, 9, … , 805, 809] condition can be a list of arbitraty length, so only the particles with the ids listed here are kept.

name – name the condition. This can later be reviewed by calling ‘self.compresslog()’

compressfn(conditionf, name='unknown condition')[source]

like “compress”, but accepts a function.

Returns a new MultiSpecies instance.

name – name the condition.

createField(*sps, **kwargs)[source]

Creates an n-d Histogram enclosed in a Field object.

Parameters:
  • *sps – list of scalarfunctions/strings/scalar-properties, that will be evaluated to data for each axis. the number of args given determins the dimensionality of the field returned by this function (maximum 3)
  • name (string, optional) – addes a name. usually used for generating savenames. Defaults to “distfn”.
  • title (string, options) – overrides the title. Autocreated if title==None. Defaults to None.
  • rangex (list of two values, optional) – the xrange to include into the histogram. Defaults to None, determins the range by the range of scalars given.
  • rangey (list of two values, optional) – the yrange to include into the histogram. Defaults to None, determins the range by the range of scalars given.
  • rangez (list of two values, optional) – the zrange to include into the histogram. Defaults to None, determins the range by the range of scalars given.
dumpreader

returns the dumpreader if the dumpreader of all species are pointing to the same dump. This should be mostly the case.

Otherwise returns None.

filter(condition, name=None)[source]

like compress, but takes a ScalarProperty or a str, which are required to evaluate to a boolean list to filter particles. This is the preferred method to filter particles by a value of their property.

Returns a new MultiSpecies instance.

gamma()[source]

Deprecated since version unknown: The function gamma is deprecated. Use self(“gamma”) instead.

gamma_m1()[source]

Deprecated since version unknown: The function gamma_m1 is deprecated. Use self(“gamma_m1”) instead.

getcompresslog()[source]
initial_npart

Original number of particles (before the use of compression or filter).

mass()[source]

Deprecated since version unknown: The function mass is deprecated. Use self(“mass”) instead.

mass_u()[source]

Deprecated since version unknown: The function mass_u is deprecated. Use self(“mass_u”) instead.

mean(expr, weights='1')[source]

the mean of a value given by the function func. The particle weight of the individual particles will be included in the calculation. An additional weight can be given as well.

median(expr, weights='1')[source]

The median

name

an alias to self.species

npart

Number of Particles.

nspecies

Number of species.

quantile(expr, q, weights='1')[source]

The qth-quantile of the distribution.

r_xy()[source]

Deprecated since version unknown: The function r_xy is deprecated. Use self(“r_xy”) instead.

r_xyz()[source]

Deprecated since version unknown: The function r_xyz is deprecated. Use self(“r_xyz”) instead.

r_yz()[source]

Deprecated since version unknown: The function r_yz is deprecated. Use self(“r_yz”) instead.

r_zx()[source]

Deprecated since version unknown: The function r_zx is deprecated. Use self(“r_zx”) instead.

simextent(axis)[source]

the combined simextent for all species and dumps included in this MultiSpecies object.

simgridpoints(axis)[source]

this function is for convenience only and is likely to be removed in the future. Particlarly it is impossible to define the grid of the simulation if the MultiSpecies object consists of multiple dumps from different simulations.

species

returns an string name for the species involved. Basically only returns unique names from all species (used for plotting and labeling purposes – not for completeness). May be overwritten.

speciess

a complete list of all species involved.

time()[source]

Deprecated since version unknown: The function time is deprecated. Use self(“time”) instead.

uncompress()[source]

Returns a new MultiSpecies instance, with all previous calls of “compress” or “filter” undone.

var(expr, weights='1')[source]

variance

weight()[source]

Deprecated since version unknown: The function weight is deprecated. Use self(“weight”) instead.

class postpic.particles.ParticleHistory(sr, speciess, ids=None)[source]

Bases: object

Represents a list of particles including their history that can be found in all the dumps defined by the simulation reader sr.

Parameters:
  • sr (iterable of datareader) – a collection of datareader to use. Usually a Simulationreader object
  • speciess (string or iterable of strings) – a species name or a list of species names. Those particles can be included into the history.
  • ids (iterable of int) – list of ids to use (default: None). If this is None all particles in speciess will be tracked. If a list of ids is given, these ids will be serached in speciess only.
collect(*scalarfs)[source]

Collects the given particle properties for all particles for all times.

*scalarfs: the scalarfunction(s) defining the particle property

numpy.ndarray holding the different particles in the same order as the list of self.ids, meaning the particle on position particle_idx has the ID self.ids[particle_idx]. every array element holds the history for a single particle. Indexorder of returned array: [particle_idx][scalarf_idx, collection_idx]

skip(n)[source]

takes only everth (n+1)-th particle

postpic.particles.histogramdd(data, **kwargs_in)[source]

Creates a histogram of the data. This function has the similar signature and return values as numpy.histogramdd. In addition this function supports the shape keyword argument to choose the particle shape used. If used with shape=0 the results of this function and the numpy.histogramdd are identical, however, this function is approx. factor 2 or 3 faster.

Parameters:
  • data (sequence of ndarray or ndarray (1D or 2D)) –
    The input (particle) data for the histogram.
    • A 1D numpy array (for 1D histogram).
    • A sequence providing the data for the different axis, i.e. (datax, datay, dataz) (preferred).
    • A (N, D)-array, i.e. [[x1, y1, z1], [x2, y2, z2]] – must be a numpy array!
  • bins (sequence or int) – The number of bins to use for each dimension
  • range (sequence, optional) – A sequence of lower and upper bin edges to be used if the edges are not given explicitly in bins. Defaults to the minimum and maximum values along each dimension.
  • weights (1D numpy array) – The weights to be used for each data point
  • shape (int) –
    possible choices are:
    • 0 - use nearest grid point (NGP)
    • 1 - use tophat shape of width 1 bin
    • 2 - triangular shape (default)
    • 3 - spline 3 shape
Returns:

  • H (ndarray) – the final histogram
  • edges (list) – A list of D arrays describing the edges for each dimension

class postpic.particles.SpeciesIdentifier[source]

Bases: postpic.helper.PhysicalConstants

This Class provides static methods for deriving particle properties from species Names. The only reason for this to be a class is that it can be used as a mixin.

classmethod identifyspecies(species)[source]

Returns a dictionary containing particle informations deduced from the species name. The following keys in the dictionary will always be present: name species name string mass kg (SI) charge C (SI) tracer boolean ejected boolean

Valid Examples: Periodic Table symbol + charge state: c6, F2, H1, C6b ionm#c# defining mass and charge: ionm12c2, ionc20m110 advanced examples: ejected_tracer_ionc5m20b, ejected_tracer_electronx, ejected_c6b, tracer_proton, protonb

static isejected(species)[source]
classmethod ision(species)[source]

Submodules

postpic.particles.particles module

Particle related routines.

class postpic.particles.particles.MultiSpecies(dumpreader, *speciess, **kwargs)[source]

Bases: object

The MultiSpecies class. Different MultiSpecies can be added together to create a combined collection.

ignore_missing_species = False
set to true to ignore missing species.

The MultiSpecies class will return a list of values for every particle property.

Ekin()[source]

Deprecated since version unknown: The function Ekin is deprecated. Use self(“Ekin”) instead.

Ekin_MeV()[source]

Deprecated since version unknown: The function Ekin_MeV is deprecated. Use self(“Ekin_MeV”) instead.

Ekin_MeV_amu()[source]

Deprecated since version unknown: The function Ekin_MeV_amu is deprecated. Use self(“Ekin_MeV_amu”) instead.

Ekin_MeV_qm()[source]

Deprecated since version unknown: The function Ekin_MeV_qm is deprecated. Use self(“Ekin_MeV_qm”) instead.

Ekin_keV()[source]

Deprecated since version unknown: The function Ekin_keV is deprecated. Use self(“Ekin_keV”) instead.

Ekin_keV_amu()[source]

Deprecated since version unknown: The function Ekin_keV_amu is deprecated. Use self(“Ekin_keV_amu”) instead.

Ekin_keV_qm()[source]

Deprecated since version unknown: The function Ekin_keV_qm is deprecated. Use self(“Ekin_keV_qm”) instead.

Eruhe()[source]

Deprecated since version unknown: The function Eruhe is deprecated. Use self(“Eruhe”) instead.

ID()[source]

Deprecated since version unknown: The function ID is deprecated. Use self(“id”) instead.

P()[source]

Deprecated since version unknown: The function P is deprecated. Use self(“p”) instead.

Px()[source]

Deprecated since version unknown: The function Px is deprecated. Use self(“px”) instead.

Py()[source]

Deprecated since version unknown: The function Py is deprecated. Use self(“py”) instead.

Pz()[source]

Deprecated since version unknown: The function Pz is deprecated. Use self(“pz”) instead.

V()[source]

Deprecated since version unknown: The function V is deprecated. Use self(“v”) instead.

Vx()[source]

Deprecated since version unknown: The function Vx is deprecated. Use self(“vx”) instead.

Vy()[source]

Deprecated since version unknown: The function Vy is deprecated. Use self(“vy”) instead.

Vz()[source]

Deprecated since version unknown: The function Vz is deprecated. Use self(“vz”) instead.

X()[source]

Deprecated since version unknown: The function X is deprecated. Use self(“x”) instead.

X_um()[source]

Deprecated since version unknown: The function X_um is deprecated. Use self(“x_um”) instead.

Y()[source]

Deprecated since version unknown: The function Y is deprecated. Use self(“y”) instead.

Y_um()[source]

Deprecated since version unknown: The function Y_um is deprecated. Use self(“Y_mu”) instead.

Z()[source]

Deprecated since version unknown: The function Z is deprecated. Use self(“z”) instead.

Z_um()[source]

Deprecated since version unknown: The function Z_um is deprecated. Use self(“z_um”) instead.

add(dumpreader, species, ignore_missing_species=False)[source]

adds a species to this MultiSpecies. This function modifies the current Object and always returns None.

species can be a single species name

or a reserved name for collection of species, such as ions adds all available particles that are ions nonions adds all available particles that are not ions ejected noejected all

Optional arguments
--------
ignore_missing_species = False

set to True to ignore if the species is missing.

angle_xaxis()[source]

Deprecated since version unknown: The function angle_xaxis is deprecated. Use self(“angle_xaxis”) instead.

angle_xy()[source]

Deprecated since version unknown: The function angle_xy is deprecated. Use self(“angle_xy”) instead.

angle_xz()[source]

Deprecated since version unknown: The function angle_xz is deprecated. Use self(“angle_xz”) instead.

angle_yx()[source]

Deprecated since version unknown: The function angle_yx is deprecated. Use self(“angle_yx”) instead.

angle_yz()[source]

Deprecated since version unknown: The function angle_yz is deprecated. Use self(“angle_yz”) instead.

angle_zx()[source]

Deprecated since version unknown: The function angle_zx is deprecated. Use self(“angle_zx”) instead.

angle_zy()[source]

Deprecated since version unknown: The function angle_zy is deprecated. Use self(“angle_zy”) instead.

beta()[source]

Deprecated since version unknown: The function beta is deprecated. Use self(“beta”) instead.

betax()[source]

Deprecated since version unknown: The function betax is deprecated. Use self(“betax”) instead.

betay()[source]

Deprecated since version unknown: The function betay is deprecated. Use self(“betay”) instead.

betaz()[source]

Deprecated since version unknown: The function betaz is deprecated. Use self(“betaz”) instead.

charge()[source]

Deprecated since version unknown: The function charge is deprecated. Use self(“charge”) instead.

charge_e()[source]

Deprecated since version unknown: The function charge_e is deprecated. Use self(“charge_e”) instead.

compress(condition, name='unknown condition')[source]

works like numpy.compress. Returns a new MultiSpecies instance.

Additionaly you can specify a name, that gets saved in the compresslog.

condition has to be one out of: 1) condition = [True, False, True, True, … , True, False] condition is a list of length N, specifing which particles to keep. Example: cfintospectrometer = lambda x: x.angle_offaxis() < 30e-3 cfintospectrometer.name = ‘< 30mrad offaxis’ pa.compress(cfintospectrometer(pa), name=cfintospectrometer.name) 2) condition = [1, 2, 4, 5, 9, … , 805, 809] condition can be a list of arbitraty length, so only the particles with the ids listed here are kept.

name – name the condition. This can later be reviewed by calling ‘self.compresslog()’

compressfn(conditionf, name='unknown condition')[source]

like “compress”, but accepts a function.

Returns a new MultiSpecies instance.

name – name the condition.

createField(*sps, **kwargs)[source]

Creates an n-d Histogram enclosed in a Field object.

Parameters:
  • *sps – list of scalarfunctions/strings/scalar-properties, that will be evaluated to data for each axis. the number of args given determins the dimensionality of the field returned by this function (maximum 3)
  • name (string, optional) – addes a name. usually used for generating savenames. Defaults to “distfn”.
  • title (string, options) – overrides the title. Autocreated if title==None. Defaults to None.
  • rangex (list of two values, optional) – the xrange to include into the histogram. Defaults to None, determins the range by the range of scalars given.
  • rangey (list of two values, optional) – the yrange to include into the histogram. Defaults to None, determins the range by the range of scalars given.
  • rangez (list of two values, optional) – the zrange to include into the histogram. Defaults to None, determins the range by the range of scalars given.
dumpreader

returns the dumpreader if the dumpreader of all species are pointing to the same dump. This should be mostly the case.

Otherwise returns None.

filter(condition, name=None)[source]

like compress, but takes a ScalarProperty or a str, which are required to evaluate to a boolean list to filter particles. This is the preferred method to filter particles by a value of their property.

Returns a new MultiSpecies instance.

gamma()[source]

Deprecated since version unknown: The function gamma is deprecated. Use self(“gamma”) instead.

gamma_m1()[source]

Deprecated since version unknown: The function gamma_m1 is deprecated. Use self(“gamma_m1”) instead.

getcompresslog()[source]
initial_npart

Original number of particles (before the use of compression or filter).

mass()[source]

Deprecated since version unknown: The function mass is deprecated. Use self(“mass”) instead.

mass_u()[source]

Deprecated since version unknown: The function mass_u is deprecated. Use self(“mass_u”) instead.

mean(expr, weights='1')[source]

the mean of a value given by the function func. The particle weight of the individual particles will be included in the calculation. An additional weight can be given as well.

median(expr, weights='1')[source]

The median

name

an alias to self.species

npart

Number of Particles.

nspecies

Number of species.

quantile(expr, q, weights='1')[source]

The qth-quantile of the distribution.

r_xy()[source]

Deprecated since version unknown: The function r_xy is deprecated. Use self(“r_xy”) instead.

r_xyz()[source]

Deprecated since version unknown: The function r_xyz is deprecated. Use self(“r_xyz”) instead.

r_yz()[source]

Deprecated since version unknown: The function r_yz is deprecated. Use self(“r_yz”) instead.

r_zx()[source]

Deprecated since version unknown: The function r_zx is deprecated. Use self(“r_zx”) instead.

simextent(axis)[source]

the combined simextent for all species and dumps included in this MultiSpecies object.

simgridpoints(axis)[source]

this function is for convenience only and is likely to be removed in the future. Particlarly it is impossible to define the grid of the simulation if the MultiSpecies object consists of multiple dumps from different simulations.

species

returns an string name for the species involved. Basically only returns unique names from all species (used for plotting and labeling purposes – not for completeness). May be overwritten.

speciess

a complete list of all species involved.

time()[source]

Deprecated since version unknown: The function time is deprecated. Use self(“time”) instead.

uncompress()[source]

Returns a new MultiSpecies instance, with all previous calls of “compress” or “filter” undone.

var(expr, weights='1')[source]

variance

weight()[source]

Deprecated since version unknown: The function weight is deprecated. Use self(“weight”) instead.

class postpic.particles.particles.ParticleHistory(sr, speciess, ids=None)[source]

Bases: object

Represents a list of particles including their history that can be found in all the dumps defined by the simulation reader sr.

Parameters:
  • sr (iterable of datareader) – a collection of datareader to use. Usually a Simulationreader object
  • speciess (string or iterable of strings) – a species name or a list of species names. Those particles can be included into the history.
  • ids (iterable of int) – list of ids to use (default: None). If this is None all particles in speciess will be tracked. If a list of ids is given, these ids will be serached in speciess only.
collect(*scalarfs)[source]

Collects the given particle properties for all particles for all times.

*scalarfs: the scalarfunction(s) defining the particle property

numpy.ndarray holding the different particles in the same order as the list of self.ids, meaning the particle on position particle_idx has the ID self.ids[particle_idx]. every array element holds the history for a single particle. Indexorder of returned array: [particle_idx][scalarf_idx, collection_idx]

skip(n)[source]

takes only everth (n+1)-th particle

postpic.particles.scalarproperties module

class postpic.particles.scalarproperties.ScalarProperty(expr, name=None, unit=None, symbol=None)[source]

Bases: object

evaluate(vars)[source]

vars must be a dictionary containing variables used within the expression “expr”.

expr
input_names

The list of variables used within this expression.

name
symbol
unit