Converting TRANSP output to IDSs using the transp2imas tool

TRANSP run output CDF file or its symlink is required to be present in the current directory. Only one CDF file is converted at a time. The input <runid>.CDF file and corresponding namelist <runid>TR.DAT (if available) are used in some data structures. An IDS is written out only if relevant input is present as valid CDF file; otherwise a message is added in a log.out file.

Python virtual environment with numpy, scipy, netcdf_class, and imass_class or system installations of these are required. Here the <python_venv> is the name of the virtual environment directory. The machine name (eg. ITER, D3D) and shot number are retrieved from the input CDF file, in order to avoid errors of passing in mismatched arguments.

If python virtual environment is set, skip this this section (of 6 lines). Please note that this is tested using only Python 3.10.7 and 3.11.4. cd ~/ python3 -m venv python_venv (Now we can cd to anywhere we want) source ~/python_venv/bin/activate pip install --upgrade pip pip install flake8 matplotlib netCDF4 f90nml numpy PyYAML scipy #for imas3.39, need this too pip install pyqt5 To run convert script, git clone transp2imas from github (git@github.com:PrincetonUniversity/transp2imas.git). cd transp2imas dir=`pwd` #Add the repo path to PYTHONPATH. export PYTHONPATH=$PYTHONPATH:$dir cd <work_directory> source <python_venv>/bin/activate . env_gcc.txt (or . env_intel.txt) python convert.py -i <runid> [ -b MDS/HDF -r <ids_run_num> -new ] # runid is TRANSP runid; MDS/HDF for backend # <runid>.CDF is the CDF file required. # Also used if available <runid>TR.DAT # machine name (eg. ITER, D3D) is retrieved from CDF file. All options: convert.py [-h] [-i INPUT_CDF] [-d INPUT_DIR] [-b {MDS,MDSPLUS,HDF,HDF5}] [-r RUN] [-new] [-o OCCUR] [-u USER] [-v] [-l {debug,info,warn,error,critical}] options: -h, --help show this help message and exit -i INPUT_CDF, --input-cdf INPUT_CDF CDF TRANSP output file, with or without .CDF -d INPUT_DIR, --input-dir INPUT_DIR input directory (file can be in its subdir), if file not in pwd -b {MDS,MDSPLUS,HDF,HDF5}, --backend {MDS,MDSPLUS,HDF,HDF5} IMAS backend -r RUN, --run RUN run number of o/p IDS (overrides default converted number: eg: Z10 -> 2610) -new, --new-db create new database -o OCCUR, --occur OCCUR occurrence -u USER, --user USER username or path of database -v, --verbose increase output verbosity -l {debug,info,warn,error,critical}, --log {debug,info,warn,error,critical} Provide logging level To convert a CDF file in a different directory : $ python convert.py -i </path/CDFname> or, $ python convert.py -i -d To convert all CDF files in a directory and its subdirectories: $ python convert.py -i all -d Examples $ python convert.py -i 38530P87 -d <path>/ $ python convert.py -i 38530P87_<text>.CDF -d <path>/ The option -u can be used as -u `pwd` or -u ~/work or -u <absolute_path>. If this is not used the default path ~/public/imasdb/<machine>/version/ is used. The CDF file (extension is optional) can be a renamed one seperated by non-digit, e.g, an underscore.

The namelists in corresponding directories will be used if available, in all cases.

The above steps will create MDS+ backend if HDF is not opted for. A log file log.out is written including which variables were not found in the input CDF file, for each IDS written out. In the above command line arguments, the run number is the end part of MDS output file names, while occurrence can be selected only when the ids is accessed, or from VIZ. If an existing database is appended, the size of MDS+ ids_...datafile increases with the current run.