Closed tbody-cfs closed 5 months ago
from cfspopcon.read_atomic_data import AtomicData, AtomicSpecies
atomic_data = AtomicData()
from cfspopcon.atomic_data import read_atomic_data
atomic_data_2 = read_atomic_data()
for species in [
"Helium",
"Lithium",
"Beryllium",
"Carbon",
"Nitrogen",
"Oxygen",
"Neon",
"Argon",
"Krypton",
"Xenon",
"Tungsten",
]:
kind = AtomicData.CoronalLz
dataset = atomic_data[species]
Ne = np.logspace(np.log10(dataset.dim_electron_density.min()), np.log10(dataset.dim_electron_density.max()), num=1000, endpoint=False)
Te = np.logspace(np.log10(dataset.dim_electron_temp.min()), np.log10(dataset.dim_electron_temp.max()), num=1000, endpoint=False)
atomic_data.eval_interpolator(Ne, Te, kind=kind, species=species, allow_extrapolation=True).sel(dim_electron_density=1e20, method="nearest").plot(xscale="log", yscale="log", label="new")
interpolator_2 = atomic_data_2[AtomicSpecies[species]].coronal_Lz_interpolator
xr.DataArray(np.power(10, interpolator_2(np.log10(Te), np.log10(Ne), grid=True)), coords=dict(dim_electron_temp=Te, dim_electron_density=Ne)).sel(dim_electron_density=1e20, method="nearest").plot(xscale="log", yscale="log", label="original", linestyle="--")
plt.title(f"{species} Lz ")
plt.legend()
plt.savefig(f"{species}_Lz.png")
plt.close()
Seems to be slower than the previous version. Why is this? Might want to try evaluate for the entire ne, Te grid at once. Alternatively, pick a single ne value (weak dependence for rates) and just use this single reference value.
Seems to be slower than the previous version. Why is this? Might want to try evaluate for the entire ne, Te grid at once. Alternatively, pick a single ne value (weak dependence for rates) and just use this single reference value.
Fixed this in latest commit. Seems to be significantly faster to precompute as much as possible.
python -m cProfile cfspopcon/cli.py example_cases/SPARC_PRD > profile.txt
Checking the comparison of the Krypton data, was getting an issue where the Lz curve was going to zero at a particular temperature. Have now added logic to drop invalid rows and columns from the atomic data.
atomic_data[AtomicSpecies.Krypton].sel(dim_electron_density=1e20, method="nearest").coronal_Lz.plot(xscale="log", yscale="log")
plt.title("Krypton")
Removes the radas submodule and replaces it with a pip-installed version.