Python tool for converting an EFIT g-file to a (fixed-boundary) DESC Equilibrium
In order to use the scripts in this repo, one must have DESC installed and omfit-classes (the full OMFIT is not needed, just the subset contained in the package omfit-classes). The requirements.txt file contains all of the needed packages for installing omfit-classes as well as DESC, so you should be able to do:
# first create your environment, using conda here as an example
conda create --name efit2desc python=3.9
# activate the environemnt
conda activate efit2desc
# install the requirements
# the --prefer-binary flag was found to be necessary when installing on a mac
pip install -r requirements.txt --prefer-binary- because of limitations of the packages used from omfit, I have to use python 3.9. That limits the corresponding DESC version I can use to only v0.13.0, which is quite old. Would be great if I could use omfit-classes without dealing with those constraints, perhaps in the future I will take just the code I need from omfit-classes and put in this repo and update so that I can use newer packages, but for now be aware of this.
For the coil and free-boundary functions in this repo, one must also have the ability to fetch data from PTDATA. The way it is done here involves using the PtDataFetcher class. To be able to use this, one must do the following (these are the steps followed at least on the Omega cluster.)
Make sure you have d3lib directory in your home directory (#TODO where does this come from?)
Then
mamba create --name efit2desc python=3.9 -y
# go to efit2desc directory
pip install -r requirements.txt --prefer-binary
# then navigate to inside d3lib directory
# make sure numpy<=1.26.4 in the environment.yml so it does not ruin the environment
mamba env update --name efit2desc --file environment.yml
pip install . # -e does not seem to work
Add the folder containing efit2desc to your path, like
PATH="$PATH:/path/to/efit2desc"Then, from a Python process you can import the function convert_EFIT_to_DESC and use it, like
from efit2desc import convert_EFIT_to_DESC
gfile = "g200245.1100"
eq, efit = convert_EFIT_to_DESC(gfile)