pnps.runfile#

Run files: a configuration and its scan, in TOML, for the command line and records.

A run file holds two tables:

  • [config]: the fields of pnps.setup.Config, with the beam as a table carrying its type ("HE11Beam", "GaussianBeam" or "UniformBeam"), the collection windows as an array of tables (pnps.extraction.WindowSpec fields), and an optional injected input pulse as a recipe ([config.input_pulse]: the source file, its keys, and the spectral window, centring and normalisation to apply, as pnps.input_pulse does them);

  • [scan]: the delay axis taus and the save positions zsave (lists in s and m, or {start, stop, num} tables for evenly spaced ones), the step h_target, the scan name, the output directory out_dir and the solprop backend.

Paths in a run file are relative to the file’s own directory. Fields left out take their defaults. dump_run() writes a run file load_run() reads back exactly.

Notes#

A small run file:

[config]
lam0 = 260e-9
tau_fwhm = 1e-15
energy = 1e-7
thickness = 40e-6
mask_diam = 1e-3
mask_spacing = 1e-3
lam_lims = [143e-9, 600e-9]
trange = 250e-15
r_max = 366e-6
n_transverse = 768

[config.beam]
type = "HE11Beam"
a = 125e-6
f_coll = 5.0
f_foc = 0.1

[[config.windows]]
holex = -1e-3
holey = -1e-3
holediam = 1e-3
zmask = 0.1

[scan]
name = "window_series"
taus = {start = -40e-15, stop = 40e-15, num = 161}
zsave = {start = 0.0, stop = 40e-6, num = 17}
h_target = 0.5e-6

Functions

dump_run(run, path)

Write a run file that load_run() reads back exactly.

load_run(path)

Read a run file.

Classes

PulseRecipe(file[, omega_key, e_omega_key, ...])

How to build an injected input pulse from its source file.

RunFile(config, scan[, input_pulse, base])

A configuration, its scan and the recipe of its input pulse.

ScanSpec(name, taus, zsave, h_target[, ...])

The scan a run file asks for.

class pnps.runfile.PulseRecipe(file, omega_key='ω', e_omega_key='Eω', window=None, wfrac_blue=0.05, wfrac_red=0.03, centre=True, normalise=True)[source]#

Bases: object

How to build an injected input pulse from its source file.

Attributes:
filestr

The source file, relative to the run file’s directory or absolute.

omega_key, e_omega_keystr

Its frequency and complex-spectrum datasets.

windowtuple of float or None

(lam_min, lam_max) in m for pnps.input_pulse.spectral_window(), or None for no window.

wfrac_blue, wfrac_redfloat

The window’s edge fractions.

centrebool

Centre the pulse in time (pnps.input_pulse.centre_pulse()).

normalisebool

Normalise its peak (pnps.input_pulse.normalise_peak()).

file: str#
omega_key: str = 'ω'#
e_omega_key: str = 'Eω'#
window: tuple[float, float] | None = None#
wfrac_blue: float = 0.05#
wfrac_red: float = 0.03#
centre: bool = True#
normalise: bool = True#
build(base)[source]#

Load the source and apply the recipe’s steps, in order.

Parameters:
basepathlib.Path

The directory a relative file is taken from.

Returns:
InputPulse

The prepared pulse.

class pnps.runfile.RunFile(config, scan, input_pulse=None, base=PosixPath('.'))[source]#

Bases: object

A configuration, its scan and the recipe of its input pulse.

Attributes:
configConfig

The configuration, with its input pulse built when there is a recipe.

scanScanSpec

The scan.

input_pulsePulseRecipe or None

How the input pulse was built, or None for the synthetic Gaussian.

basepathlib.Path

The directory relative paths are taken from.

config: Config#
scan: ScanSpec#
input_pulse: PulseRecipe | None = None#
base: Path = PosixPath('.')#
property out_dir: Path[source]#

Return the output directory, resolved against base.

Returns:
pathlib.Path

Where the scan files go.

class pnps.runfile.ScanSpec(name, taus, zsave, h_target, out_dir='.', backend='auto')[source]#

Bases: object

The scan a run file asks for.

Attributes:
namestr

The scan name; files are <out_dir>/<name>_collected[.shard<i>].h5.

tausnumpy.ndarray

The delay axis in s.

zsavenumpy.ndarray

The save positions in m.

h_targetfloat

The largest step of the replayed schedule, m.

out_dirstr

The output directory, relative to the run file’s directory or absolute.

backendstr

The solprop backend registry name.

name: str#
taus: Float[ndarray, 'n_delays']#
zsave: Float[ndarray, 'n_z']#
h_target: float#
out_dir: str = '.'#
backend: str = 'auto'#
pnps.runfile.dump_run(run, path)[source]#

Write a run file that load_run() reads back exactly.

Parameters:
runRunFile

The run; its configuration’s input pulse must come from its recipe.

pathstr or pathlib.Path

The TOML file to write.

Raises:
ConfigError

If the configuration carries an input pulse without a recipe (its arrays have no place in a run file).

pnps.runfile.load_run(path)[source]#

Read a run file.

Parameters:
pathstr or pathlib.Path

The TOML file.

Returns:
RunFile

The configuration (with its input pulse built), the scan and the recipe.

Raises:
ConfigError

If a table is missing, or holds an unknown key, a missing required field or an unreadable axis.