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: Path | str, full_project: bool = False, z_min: float | None = None, z_max: float | None = None, definition: Literal['naive', 'running_mean', 'meter_per_meter'] = 'running_mean', **kwargs) None
Compute the lost power per meter for all given file(s).
- Parameters:
path (pathlib.Path | str) – Path to a single
partran1.outfile, or to a full LightWin project.full_project (bool, optional) – Indicate if the given path is a full project. If True, we take all the LightWin out folders in
pathwith a name like000000_refor000032(we look for folders with 6 digits in it). In each one, we treat1_TraceWin/partran1.outfile. If False, we try to findpatran1.outinpath/,path/1_TraceWin(ifpathis not already a file). The default is False.z_min (float | None, optional) – 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, optional) – If provided, points outside of this range will be filtered out. The default is None, in which case all points are kept.
definitions (definitions_t) – How the lost power should be calculated.
- _treat_single(path: Path, z_min: float | None, z_max: float | None, **kwargs: Any) Series
Load the given filepath and compute lost power in W/m.
- _add_linear_losses(df: DataFrame, definition: Literal['naive', 'running_mean', 'meter_per_meter'], **kwargs: Any) None
Add a column holding linear losses in W/m.
- _remove_doublons(df: DataFrame, file: Path | str | None = None) None
Remove positions that are represented twice.
- _filter_in_range_only(df: DataFrame, z_min: float | None, z_max: float | None) None
Remove the points before
z_minor afterz_max.
- _running_mean(position: Series, quantity: Series, window: float = 1.0, sigma: float = 0.5) list[float]
Provide running_mean of
quantityover a length ofwindow.
- _meter_per_meter(position: Series, quantity: Series, window: float = 1.0) list[float]
Sum lost power between 0 and 1m, between 1 and 2m, etc.
- _treat_full_project(paths: dict[str, Path], z_min: float | None, z_max: float | None, save_folder: Path | None = None, **kwargs: Any) DataFrame
Load several files and concatenate the lost powers.
- get_partran1_paths(folderpath: Path, full_project: Literal[True], verbose: bool = False, **kwargs: Any) dict[str, Path]
- get_partran1_paths(folderpath: Path, full_project: Literal[False], verbose: bool = False, **kwargs: Any) Path
Gather the file(s) to treat.
- _plot_single(df: DataFrame, info: str | None, path: Path | None = None) Figure
Plot the data for validity checking.
- main()