Skip to content

Commit

Permalink
Improve Giese LISA figure
Browse files Browse the repository at this point in the history
  • Loading branch information
AgenttiX committed Nov 22, 2024
1 parent 926cbaa commit d2918a6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pow_*.txt
pylint.txt
test-output.txt
*.dot
*.eps
*.hdf5
*.html
*.lprof
Expand Down
16 changes: 11 additions & 5 deletions examples/giese_lisa_fig2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
from pttools.bubble import Bubble, Phase
from pttools.models import Model, ConstCSModel

logger = logging.getLogger(__name__)

try:
logger.info("Giese code imported successfully.")
from giese.lisa import kappaNuMuModel
except ImportError:
logger.info("Giese could not be imported.")
kappaNuMuModel: tp.Optional[callable] = None

logger = logging.getLogger(__name__)


def get_kappa(bubble: Bubble) -> float:
if not bubble.solved:
Expand Down Expand Up @@ -86,14 +88,17 @@ def create_figure(
except ValueError:
print(f"Could not produce bubbles with alpha_n={alpha_ns[j]} for {model.label_unicode}")
continue
ax.plot(v_walls, kappas[j], ls=ls, color=color, alpha=0.5)
kwargs = {}
if ls == "-":
kwargs["label"] = rf"$\alpha={alpha_ns[j]}$"
ax.plot(v_walls, kappas[j], ls=ls, color=color, alpha=0.5, **kwargs)
print(
f"alpha_n={alpha_ns[j]}, kappa_max={kappas[j, i_max]}, i_max={i_max}, "
f"v_wall={v_walls[i_max]}, color={color}, ls={ls}, {model.label_unicode}"
)

ax.set_xlabel(r"$\xi_w$")
ax.set_ylabel(r"$\kappa$")
ax.set_ylabel(r"$\kappa_{\bar{\theta}_n}$")
ax.set_yscale("log")
ax.set_ylim(bottom=10**-2.5, top=1)

Expand All @@ -108,6 +113,7 @@ def create_figure(
else:
title += r"$\alpha_n$"
ax.set_title(title)
# ax.legend()


def main():
Expand Down Expand Up @@ -146,4 +152,4 @@ def main():

if __name__ == "__main__":
fig = main()
save_and_show(fig, "giese_lisa_fig2.png")
save_and_show(fig, "giese_lisa_fig2")
12 changes: 8 additions & 4 deletions examples/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@


def save(fig: plt.Figure, path: str):
if os.path.isabs(path):
fig.savefig(path)
else:
fig.savefig(os.path.join(FIG_DIR, path))
has_extension = "." in path
if not os.path.isabs(path):
path = os.path.join(FIG_DIR, path)
if has_extension:
fig.savefig(path)
else:
fig.savefig(f"{path}.eps")
fig.savefig(f"{path}.png")


def save_and_show(fig: plt.Figure, path: str):
Expand Down

0 comments on commit d2918a6

Please sign in to comment.