2024-07-10 07:43:50 +02:00
|
|
|
import os
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import numpy as np
|
|
|
|
import math
|
|
|
|
import scipy as scp
|
|
|
|
|
|
|
|
outdir = "../img/"
|
|
|
|
filetype = ".pdf"
|
|
|
|
skipasserts = False
|
|
|
|
|
|
|
|
full = 8
|
|
|
|
size_half_half = (full/2, full/2)
|
|
|
|
size_third_half = (full/3, full/2)
|
|
|
|
size_half_third = (full/2, full/3)
|
|
|
|
|
|
|
|
def texvar(var, val, math=True):
|
|
|
|
s = "$" if math else ""
|
|
|
|
s += f"\\{var} = {val}"
|
|
|
|
if math: s += "$"
|
|
|
|
return s
|
|
|
|
|
2024-07-14 16:04:46 +02:00
|
|
|
def export(fig, name, notightlayout=False):
|
2024-07-10 07:43:50 +02:00
|
|
|
if not skipasserts:
|
|
|
|
assert os.path.abspath(".").endswith("scripts"), "Please run from the `scripts` directory"
|
|
|
|
filename = os.path.join(outdir, name + filetype)
|
2024-07-14 16:04:46 +02:00
|
|
|
if not notightlayout:
|
|
|
|
fig.tight_layout()
|
|
|
|
fig.savefig(filename) #, bbox_inches="tight")
|
2024-07-10 07:43:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
@np.vectorize
|
|
|
|
def smooth_step(x: float, left_edge: float, right_edge: float):
|
|
|
|
x = (x - left_edge) / (right_edge - left_edge)
|
|
|
|
if x <= 0: return 0.
|
|
|
|
elif x >= 1: return 1.
|
|
|
|
else: return 3*(x**2) - 2*(x**3)
|