cfs-energy / cfspopcon

POPCONs (Plasma OPerating CONtours)
https://cfspopcon.readthedocs.io/en/latest/
MIT License
22 stars 14 forks source link

Minimum finding algorithm seems to have a slight error #97

Open tbody-cfs opened 1 month ago

tbody-cfs commented 1 month ago

Exact minimum point is a bit off — what is going on here?

Screenshot 2024-09-06 at 3 36 59 PM
tbody-cfs commented 4 days ago

In the separatrix_operational_space.ipynb notebook, you can see what is causing this issue. Where there are multiple points fulfilling the mask condition with the same value, the code is returning the first value it finds.

from cfspopcon.shaping_and_selection import find_coords_of_minimum

dataset["SepOS_LH_transition"].T.plot(vmin=0.9, vmax=1.1)
dataset["SepOS_LH_transition"].T.plot.contour(levels=[1.0])

point = dataset.isel(find_coords_of_minimum(dataset["separatrix_electron_temp"], mask=dataset["SepOS_LH_transition"] > 1.0))

plt.scatter(point.separatrix_electron_density, point.separatrix_electron_temp, color="r")

plt.ylim(50, 70)

image

tbody-cfs commented 4 days ago

Increasing the resolution is a simple solution, i.e. 10x increase in both dimensions

image