tmp dir auto-del, removed default in pulse shape

This commit is contained in:
Benoît Sierro
2021-08-23 11:26:00 +02:00
parent 2f01577480
commit 0bcbe00110
3 changed files with 12 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
__version__ = "0.1.0"
__version__ = "0.1.1"
from typing import Any

View File

@@ -7,6 +7,7 @@ from typing import Any, Callable, Dict, Generator, List, Sequence, Tuple
import numpy as np
import pkg_resources as pkg
import toml
from send2trash import send2trash
from . import env, utils
from .const import PARAM_FN, PARAM_SEPARATOR, SPEC1_FN, SPECN_FN, Z_FN, __version__
@@ -424,7 +425,7 @@ def merge_spectra(
yield z, np.atleast_2d(spectra)
def merge(destination: os.PathLike, path_trees: List[PathTree] = None):
def merge(destination: os.PathLike, path_trees: List[PathTree] = None, delete_tmp: bool = True):
destination = ensure_folder(Path(destination))
@@ -447,6 +448,13 @@ def merge(destination: os.PathLike, path_trees: List[PathTree] = None):
pbars.reset(1)
iden = PARAM_SEPARATOR.join(path_tree[-1][0].name.split()[2:-2])
merge_path_tree(path_tree, destination / iden, z_callback=lambda i: pbars.update(1))
if delete_tmp:
for branch in path_tree:
for path in branch:
try:
send2trash(path.parent)
except OSError:
continue
def sim_dirs(path_trees: List[PathTree]) -> Generator[Path, None, None]:

View File

@@ -338,12 +338,12 @@ def correct_wavelength(init_wavelength: float, w_c: np.ndarray, field_0: np.ndar
return units.m.inv(units.m(init_wavelength) - delta_w)
def E0_to_P0(E0, t0, shape="gaussian"):
def E0_to_P0(E0, t0, shape):
"""convert an initial total pulse energy to a pulse peak peak_power"""
return E0 / (t0 * P0T0_to_E0_fac[shape])
def P0_to_E0(P0, t0, shape="gaussian"):
def P0_to_E0(P0, t0, shape):
"""converts initial peak peak_power to pulse energy"""
return P0 * t0 * P0T0_to_E0_fac[shape]