compute_lost_power_per_meter module

Convert lost power of one or several patran1.out into lost power per meter.

Todo

Sometimes the lost power in first row is 1e-10 or something? Check this out when I see it appear again.

Todo

May be included to post-processing from within LightWin directly

compute(folderpath, full_project=False, z_min=None, z_max=None, definition='running_mean', **kwargs)[source]

Compute the lost power per meter for all given file(s).

Parameters:
  • path – Path to a single partran1.out file, or to a full LightWin project.

  • full_project (bool, default: False) – Indicate if the given path is a full project. If True, we take all the LightWin out folders in path with a name like 000000_ref or 000032 (we look for folders with 6 digits in it). In each one, we treat 1_TraceWin/partran1.out file. If False, we try to find patran1.out in path/, path/1_TraceWin (if path is not already a file).

  • z_min (float | None, default: None) – If provided, points outside of this range will be filtered out. The default is None, in which case all points are kept.

  • z_max (float | None, default: None) – If provided, points outside of this range will be filtered out. The default is None, in which case all points are kept.

  • definitions – How the lost power should be calculated.

  • folderpath (Path | str)

  • definition (Literal['naive', 'running_mean', 'meter_per_meter'], default: 'running_mean')

Return type:

None

_treat_single(path, z_min, z_max, **kwargs)[source]

Load the given filepath and compute lost power in W/m.

Parameters:
Return type:

Series

_add_linear_losses(df, definition, **kwargs)[source]

Add a column holding linear losses in W/m.

Parameters:
Return type:

None

_remove_doublons(df, file=None)[source]

Remove positions that are represented twice.

Parameters:
Return type:

None

_filter_in_range_only(df, z_min, z_max)[source]

Remove the points before z_min or after z_max.

Parameters:
Return type:

None

_running_mean(position, quantity, window=1.0, sigma=0.5)[source]

Provide running_mean of quantity over a length of window.

Parameters:
Return type:

list[float]

_meter_per_meter(position, quantity, window=1.0)[source]

Sum lost power between 0 and 1m, between 1 and 2m, etc.

Parameters:
Return type:

list[float]

_treat_full_project(paths, z_min, z_max, save_folder=None, **kwargs)[source]

Load several files and concatenate the lost powers.

Parameters:
Return type:

DataFrame

_get_partran1_filepath(folderpath)[source]

Look for partran1.out in folderpath and subfolders.

Parameters:

folderpath (Path)

Return type:

Path

get_partran1_paths(folderpath, full_project, verbose=False, **kwargs)[source]
Overloads:
  • folderpath (Path), full_project (Literal[True]), verbose (bool), kwargs (Any) → dict[str, Path]

  • folderpath (Path), full_project (Literal[False]), verbose (bool), kwargs (Any) → Path

Parameters:
Return type:

Path | dict[str, Path]

Gather the file(s) to treat.

Parameters:
  • folderpath (Path)

  • full_project (bool)

  • verbose (bool, default: False)

  • kwargs (Any)

Return type:

Path | dict[str, Path]

_check_validity(df)[source]

Print some info to ensure consistency.

Parameters:

df (DataFrame)

Return type:

Series

_plot_single(df, info, path=None)[source]

Plot the data for validity checking.

Parameters:
Return type:

Figure

_plot_several(df, path=None)[source]

Concatenate all plots.

Parameters:
Return type:

Figure

main()[source]