Loading an interpolation table¶
Now that you have made an interpolation table (see the tutorial on constructing an inteprolationg table), let's try to load it.
import modules¶
In [1]:
Copied!
from glworia.amp.load_interp import load_interpolators, F_interp
import json
import numpy as np
import matplotlib.pyplot as plt
from glworia.amp.load_interp import load_interpolators, F_interp
import json
import numpy as np
import matplotlib.pyplot as plt
Load the interpolators¶
In [2]:
Copied!
# replace the paths with the correct ones
interpolation_dir_path = '../../interpolation'
settings_file_path = '../../settings/NFW_prod1.json'
with open(settings_file_path, 'r') as f:
settings = json.load(f)
interpolators = load_interpolators(interpolation_dir_path, **settings)
# replace the paths with the correct ones
interpolation_dir_path = '../../interpolation'
settings_file_path = '../../settings/NFW_prod1.json'
with open(settings_file_path, 'r') as f:
settings = json.load(f)
interpolators = load_interpolators(interpolation_dir_path, **settings)
Interpolate¶
note that you can use numpy
instead of jax.numpy
here.
In [3]:
Copied!
w_interp = np.linspace(0.001, 1e4, 10**6)
y_interp = 0.23456
lp_interp = 5.01234
F = F_interp(w_interp, y_interp, lp_interp, interpolators, settings)
w_interp = np.linspace(0.001, 1e4, 10**6)
y_interp = 0.23456
lp_interp = 5.01234
F = F_interp(w_interp, y_interp, lp_interp, interpolators, settings)
In [4]:
Copied!
fig, axs = plt.subplots(1, 2, figsize = (12, 5))
axs[0].semilogx(w_interp, np.abs(F))
axs[1].semilogx(w_interp, np.angle(F))
axs[0].set_xlabel('$w$')
axs[0].set_ylabel('$|F|$')
axs[1].set_xlabel('$w$')
axs[1].set_ylabel(r'$\arg(F)$')
fig, axs = plt.subplots(1, 2, figsize = (12, 5))
axs[0].semilogx(w_interp, np.abs(F))
axs[1].semilogx(w_interp, np.angle(F))
axs[0].set_xlabel('$w$')
axs[0].set_ylabel('$|F|$')
axs[1].set_xlabel('$w$')
axs[1].set_ylabel(r'$\arg(F)$')
Out[4]:
Text(0, 0.5, '$\\arg(F)$')