Skip to content

LCODE backend§

Available file types§

At the moment, the following LCODE 2D file types can be read by ozzy:

  • plasma density profile along propagation (plzshape.dat)
  • particle information at a single timestep (tb?????.swp,beamfile.bin)
  • local/absolute extrema of on-axis longitudinal field or on-axis potential (emaxf.dat, gmaxf.dat, elocf.dat, glocf.dat)
  • grid density data
  • lineouts along longitudinal coordinate (xi_*.swp)
  • particle data for selected particles (partic.swp)
  • lost particle data (beamlost.dat)
  • key between exact times of diagnostic outputs and their 5-digit representations (times.dat)
  • trapped particle data (captured.pls)
  • plasma particle data (pl?????.swp, plasma.bin)
  • full grid information for fields and currents (fl?????.swp, fields.bin)

  • histogram of particle data

  • plasma particle data (?????.pls, s?????.pls)
  • substepped lineouts along longitudinal coordinate (u?????.det, v?????.det)
  • real and imaginary components of laser envelope (ls??????.???.swp)

Default metadata§

The variable metadata, such as the mathematical symbol and units, is inferred from the file name and file type. Since this translation is mostly hard-coded, some quantities have not yet been included and will therefore not be displayed as properly formatted metadata.

The default metadata for each foreseen quantity can be inspected with:

import ozzy as oz
for k, v in oz.backends.lcode_backend.quant_info.items():
    print(k)
    for k1, v1 in v.items():
        print(f' {k1}:')
        print(f'    label: {v1[0]}')
        print(f'    units: {v1[1]}')

Entry-point read function§

read §

read(files, axes_lims=None, axisym=True, abs_q=1.0)

Read one or more LCODE data files and create a Dataset.

Parameters:

Name Type Description Default

files §

list[str]

A list of file paths to be read.

required

axes_lims §

dict[str, tuple[float, float]] | None

A dictionary specifying the limits for each axis in the data. Keys are axis names, and values are tuples of (min, max) values.

None

axisym §

bool

Whether the data is in 2D axisymmetric/cylindrical geometry.

True

abs_q §

float

Absolute value of the charge of the bunch particles, in units of the elementary charge \(e\).

This argument is used to normalize the particle momenta to \(m_\mathrm{sp} c\) instead of LCODE's default of \(m_e c\).

1.0

Returns:

Type Description
Dataset

A Dataset containing the data from the input files.

Examples:

Warning

Note that you would not usually call this function directly, except in advanced use cases such as debugging. The examples below are included for completeness.

In general, please use ozzy's file-reading functions along with the backend specification instead, for example:

data = oz.open('lcode', 'path/to/file.swp')

Reading grid files with axis limits
from ozzy.backends.lcode_backend import read

files = ['grid_file1.swp', 'grid_file2.swp']
axes_lims = {'x1': (0, 10), 'x2': (-5, 5)}
ds = read(files, axes_lims)
# Returns Dataset with grid data and axis coordinates
Reading particle data with custom charge

The abs_q keyword argument is used to normalize the particle momenta to \(m_\mathrm{sp} c\) (instead of LCODE's default of \(m_e c\)).

from ozzy.backends.lcode_backend import read
files = ['tb00200.swp']
ds = read(files, axisym=True, abs_q=2.0)
# Returns Dataset with particle momenta normalized to the species mass times the speed of light