Skip to content

Commit

Permalink
Reduce log spam
Browse files Browse the repository at this point in the history
  • Loading branch information
AgenttiX committed Dec 9, 2024
1 parent 8054ca3 commit 454120e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/giese_lisa_fig2.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def kappas_giese(
multiple_params=True,
# output_dtypes=(float, ),
# max_workers=max_workers,
log_progress_percentage=True,
log_progress_percentage=20,
kwargs={"model": model}
)
return kappas
Expand Down
2 changes: 1 addition & 1 deletion pttools/analysis/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def create_bubbles(
v_walls: np.ndarray,
alpha_ns: np.ndarray,
func: callable = None,
log_progress_percentage: float = 5,
log_progress_percentage: float = 10,
max_workers: int = options.MAX_WORKERS_DEFAULT,
allow_bubble_failure: bool = False,
kwargs: tp.Dict[str, any] = None,
Expand Down
2 changes: 1 addition & 1 deletion pttools/bubble/fluid_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def create(
multiple_params=True,
unpack_params=True,
output_dtypes=(np.int_, np.float64, np.float64, np.float64, np.float64, np.float64, np.float64),
log_progress_percentage=5
log_progress_percentage=10
)
file.create_dataset("v_wall", data=v_walls)
file.create_dataset("alpha_n", data=alpha_ns)
Expand Down
9 changes: 5 additions & 4 deletions pttools/models/analytic.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ def __init__(
gen_cs2: bool = True,
gen_cs2_neg: bool = True,
allow_invalid: bool = False,
auto_potential: bool = False):
if V_b != 0:
auto_potential: bool = False,
log_info: bool = True):
if log_info and V_b != 0:
logger.warning(
"Got V_b = %s != 0. This may result in inaccurate results with the GW spectrum computation, "
"as the GW spectrum equations presume V_b = 0.", V_b)
Expand Down Expand Up @@ -75,9 +76,9 @@ def __init__(
T_min=T_min, T_max=T_max, T_crit_guess=T_crit_guess,
name=name, label_latex=label_latex, label_unicode=label_unicode,
gen_critical=gen_critical, gen_cs2=gen_cs2, gen_cs2_neg=gen_cs2_neg,
allow_invalid=allow_invalid
allow_invalid=allow_invalid, log_info=log_info
)
if self.a_s <= self.a_b:
if log_info and self.a_s <= self.a_b:
logger.warning(
f"The model \"{self.name}\" does not satisfy a_s > a_b. "
"Please check that the critical temperature is non-negative. "
Expand Down
15 changes: 9 additions & 6 deletions pttools/models/const_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def __init__(
name: str = None,
label_latex: str = None,
label_unicode: str = None,
allow_invalid: bool = False):
allow_invalid: bool = False,
log_info: bool = True):
# Ensure that these descriptions correspond to those in the base class
r"""
:param a_s: prefactor of $p$ in the symmetric phase. The convention is as in :notes:`\ ` eq. 7.33.
Expand All @@ -72,7 +73,8 @@ def __init__(
:param T_ref: reference temperature, usually 1 * unit of choice, e,g. 1 GeV
:param name: custom name for the model
"""
logger.debug(f"Initialising ConstCSModel with css2={css2}, csb2={csb2}.")
if log_info:
logger.debug(f"Initialising ConstCSModel with css2={css2}, csb2={csb2}.")
css2_flt, css2_label = cs2_to_float_and_label(css2)
csb2_flt, csb2_label = cs2_to_float_and_label(csb2)
self.css2 = self.validate_cs2(css2_flt, "css2")
Expand All @@ -83,7 +85,7 @@ def __init__(
"c_{s,s}^2 and c_{s,b}^2 have to be 0 < c_s <= 1."
f"Got: c_{{s,s}}^2={css2}, c_{{s,b}}^2={csb2}."
)
if css2_flt > 1/3 or csb2_flt > 1/3:
if log_info and css2_flt > 1/3 or csb2_flt > 1/3:
logger.warning(
"c_{s,s}^2 > 1/3 or c_{s,b}^2 > 1/3. "
"Please ensure that g_eff is monotonic in your model. "
Expand Down Expand Up @@ -122,7 +124,8 @@ def __init__(
g_s=g_s, g_b=g_b,
T_min=T_min, T_max=T_max, T_crit_guess=T_crit_guess,
name=name, label_latex=label_latex, label_unicode=label_unicode,
allow_invalid=allow_invalid
allow_invalid=allow_invalid,
log_info=log_info
)
# This can only be set after self.a_s and self.a_b are set.
# This seems to contain invalid assumptions and approximations.
Expand Down Expand Up @@ -304,7 +307,7 @@ def alpha_n_min_find_params(
# ---
# Solve numerically
# ---
model = ConstCSModel(css2=self.css2, csb2=self.csb2, a_s=a_s_default, a_b=a_b, V_s=V_s_default)
model = ConstCSModel(css2=self.css2, csb2=self.csb2, a_s=a_s_default, a_b=a_b, V_s=V_s_default, log_info=False)
# If we are already below the target
if model.alpha_n_min < alpha_n_min_target:
return a_s_default, a_b, V_s_default, V_b
Expand Down Expand Up @@ -380,7 +383,7 @@ def alpha_n_min_find_params_solvable(
css2: float, csb2: float,
alpha_n_target: float):
try:
model = ConstCSModel(css2=css2, csb2=csb2, a_s=a_s, a_b=a_b, V_s=V_s, V_b=V_b)
model = ConstCSModel(css2=css2, csb2=csb2, a_s=a_s, a_b=a_b, V_s=V_s, V_b=V_b, log_info=False)
except (ValueError, RuntimeError):
return np.nan
diff = model.alpha_n_min - alpha_n_target
Expand Down
20 changes: 11 additions & 9 deletions pttools/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ def __init__(
gen_cs2_neg: bool = True,
implicit_V: bool = False,
temperature_is_physical: bool = None,
allow_invalid: bool = False):
allow_invalid: bool = False,
log_info: bool = True):

if implicit_V:
if log_info and implicit_V:
if V_s != 0 or V_b != 0:
logger.warning(
"Potentials have been specified for the implicit model: %s. "
Expand Down Expand Up @@ -98,7 +99,7 @@ def __init__(

if gen_critical:
# w_crit = wn_max
self.T_crit, self.w_crit = self.criticals(T_crit_guess, allow_invalid)
self.T_crit, self.w_crit = self.criticals(T_crit_guess, allow_fail=allow_invalid, log_info=log_info)
self.w_at_alpha_n_min, self.alpha_n_min = self.alpha_n_min_find()

# Concrete methods
Expand Down Expand Up @@ -451,12 +452,13 @@ def criticals(self, t_crit_guess: float, allow_fail: bool = False, log_info: boo
wn_min = self.w(t_crit, Phase.SYMMETRIC)
alpha_n_at_wn_min = self.alpha_n(wn_min)

logger.info(
f"Initialized model with name={self.name}, T_crit={t_crit}, alpha_n_at_wn_min={alpha_n_at_wn_min}. "
f"At T_crit: w_s={wn_min}, w_b={self.w(t_crit, Phase.BROKEN)}, "
f"e_s={self.e_temp(t_crit, Phase.SYMMETRIC)}, e_b={self.e_temp(t_crit, Phase.BROKEN)}, "
f"p_s={self.p_temp(t_crit, Phase.SYMMETRIC)}, p_b={self.p_temp(t_crit, Phase.BROKEN)}"
)
if log_info:
logger.info(
f"Initialised model with name={self.name}, T_crit={t_crit}, alpha_n_at_wn_min={alpha_n_at_wn_min}. "
f"At T_crit: w_s={wn_min}, w_b={self.w(t_crit, Phase.BROKEN)}, "
f"e_s={self.e_temp(t_crit, Phase.SYMMETRIC)}, e_b={self.e_temp(t_crit, Phase.BROKEN)}, "
f"p_s={self.p_temp(t_crit, Phase.SYMMETRIC)}, p_b={self.p_temp(t_crit, Phase.BROKEN)}"
)
return t_crit, wn_min

def critical_temp(
Expand Down
4 changes: 2 additions & 2 deletions pttools/speedup/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def run(self, param, index: int = None, multi_index: tp.Iterable = None):
np.floor(percentage / self.log_progress_percentage) != np.floor(
percentage_prev / self.log_progress_percentage)):
if multi_index is None:
logger.debug("Processed item %s/%s, %s %%", index, self.arr_size, percentage)
logger.debug("Processed item %d/%d, %.2f %%", index, self.arr_size, percentage)
else:
logger.debug("Processed item %s, %s/%s, %s %%", multi_index, index, self.arr_size, percentage)
logger.debug("Processed item %s, %d/%d, %.2f %%", multi_index, index, self.arr_size, percentage)

return ret

Expand Down

0 comments on commit 454120e

Please sign in to comment.