Skip to main content

Write G-EQDSK files directly from a single TRANSP CDF file.

Project description

eqdsk-from-cdf

Convert a single TRANSP CDF equilibrium slice into a G-EQDSK file from the command line.

The package is intended for quick local conversion workflows: install the command, point it at a TRANSP CDF file, choose the target time and sign convention explicitly, and write a GEQDSK file that can be checked with the bundled validation sample.

Install

Install from PyPI:

python -m pip install eqdsk-from-cdf

For command-line-only use, pipx is also a good option because it keeps the application and its dependencies isolated:

pipx install eqdsk-from-cdf

If eqdsk-from-cdf is not found after install, make sure ~/.local/bin is on your PATH.

The package requires Python 3.9 or newer.

Cluster Or HPC Environments

On shared systems, preloaded modules, PYTHONPATH, or user-site packages can make pip mix packages from different Python versions. If installation behaves strangely, create a clean environment first:

deactivate 2>/dev/null || true
unset PYTHONPATH PYTHONHOME
python3.9 -m venv --clear ~/venvs/eqdsk39
source ~/venvs/eqdsk39/bin/activate
python -m pip install --upgrade pip
python -m pip install --upgrade --no-cache-dir eqdsk-from-cdf
eqdsk-from-cdf validate

If your cluster uses environment modules, also unload unrelated Python/scientific modules before creating the venv. The key point is to avoid mixing a Python 3.9 venv with packages from older system Python paths.

Quick Start

Convert one TRANSP CDF time slice:

eqdsk-from-cdf run.CDF --time 17.5 --bt-sign 1 --ip-sign 1 --out out.geq

If --out is omitted, the output is written next to the input with a .geq suffix:

eqdsk-from-cdf run.CDF --time 17.5 --bt-sign 1 --ip-sign 1

Check the install with the public bundled sample:

eqdsk-from-cdf validate

validate regenerates a GEQDSK from the bundled sample CDF and compares it against the bundled sample GEQ reference. It does not depend on private reference files.

Main Options

CDF_PATH is the input TRANSP CDF file.

--time SECONDS selects the requested TRANSP time slice in seconds.

--bt-sign {-1,1} sets the toroidal magnetic field sign.

--ip-sign {-1,1} sets the plasma current sign.

--out PATH sets the output GEQDSK path. Without it, run.CDF becomes run.geq.

--nr N and --nz N set the output GEQDSK R and Z grid sizes. The defaults are 129 and 129. Larger grids preserve more spatial detail but produce larger files and take longer to generate. Common choices are 129x129, 257x257, or rectangular grids such as 128x192.

--plot PATH saves a conversion diagnostic plot.

--show displays the diagnostic plot interactively.

Run the built-in help for the full command reference:

eqdsk-from-cdf --help

Sign Convention

Viewed from above the machine, looking along +Z, +1 means counter-clockwise and -1 means clockwise.

Both --bt-sign and --ip-sign are required. This is intentional: the converter does not guess sign conventions silently.

Resolution Examples

Default grid:

eqdsk-from-cdf run.CDF --time 17.5 --bt-sign 1 --ip-sign 1 --out out.geq

Higher resolution square grid:

eqdsk-from-cdf run.CDF --time 17.5 --bt-sign 1 --ip-sign 1 --nr 257 --nz 257 --out out_257.geq

Rectangular grid:

eqdsk-from-cdf run.CDF --time 17.5 --bt-sign 1 --ip-sign 1 --nr 128 --nz 192 --out out_128x192.geq

Diagnostic Plots

Save a plot while converting:

eqdsk-from-cdf run.CDF --time 17.5 --bt-sign 1 --ip-sign 1 --out out.geq --plot conversion.png

Show the same plot interactively:

eqdsk-from-cdf run.CDF --time 17.5 --bt-sign 1 --ip-sign 1 --show

The plot overlays reconstructed moment surfaces, generated Psi(R,Z) contours, boundary, limiter, magnetic axis, and profile curves.

Bundled Sample

Print the installed sample CDF path:

eqdsk-from-cdf sample-path --kind cdf

Print the installed sample GEQ reference path:

eqdsk-from-cdf sample-path --kind geq

Convert the bundled public sample manually:

sample="$(eqdsk-from-cdf sample-path --kind cdf)"
eqdsk-from-cdf "$sample" --time 17.50435 --bt-sign 1 --ip-sign 1 --out sample.geq

Compare GEQDSK Files

Print scalar/profile differences and save a visual comparison:

reference="$(eqdsk-from-cdf sample-path --kind geq)"
eqdsk-from-cdf compare sample.geq "$reference" --output compare.png

If --output is omitted, the comparison plot is shown interactively.

Contour Extraction

Computational contour extraction uses contourpy directly. Matplotlib contour calls are used only for diagnostic plotting.

Development

Install from a local checkout:

./install.sh

Validate an existing command on PATH from a checkout:

./install.sh --check

Run checks before committing:

uv run --extra dev ruff check .
uv run pytest -q
uv build

Test the built wheel like a fresh user before publishing:

uv run --isolated --with dist/eqdsk_from_cdf-0.1.2-py3-none-any.whl eqdsk-from-cdf validate

Release Notes For Maintainers

Work from pypi-main; it is the clean public-history branch. Use feature branches from pypi-main for larger changes.

Before releasing, bump version in pyproject.toml, run the checks above, commit, tag, push, and publish:

git switch pypi-main
uv run --extra dev ruff check .
uv run pytest -q
uv build
git add -A
git commit -m "Release 0.1.2"
git tag v0.1.2
git push
git push origin v0.1.2
uv publish

uv publish needs PyPI credentials. One option is to export a PyPI API token as UV_PUBLISH_TOKEN before publishing:

export UV_PUBLISH_TOKEN="pypi-..."
uv publish

For interactive use, avoid leaving the token in shell history:

read -s UV_PUBLISH_TOKEN
export UV_PUBLISH_TOKEN
uv publish

For long-term use, store the token in a password manager or another secure secret store. If a token is exposed accidentally, revoke it on PyPI and create a new one.

Each PyPI release should have an immutable Git tag, for example v0.1.0, v0.1.1, or v0.2.0.

The public package carries only the bundled sample CDF and bundled sample GEQ used by eqdsk-from-cdf validate. Private reference checks, portability scripts, and scratch generated files should stay local or ignored.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eqdsk_from_cdf-0.1.2.tar.gz (268.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eqdsk_from_cdf-0.1.2-py3-none-any.whl (145.7 kB view details)

Uploaded Python 3

File details

Details for the file eqdsk_from_cdf-0.1.2.tar.gz.

File metadata

  • Download URL: eqdsk_from_cdf-0.1.2.tar.gz
  • Upload date:
  • Size: 268.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for eqdsk_from_cdf-0.1.2.tar.gz
Algorithm Hash digest
SHA256 886fe414232465be15f7027ca8da03702ba25051342e127c3c07c65545063691
MD5 84cd354143dddc86957765f8dd62a064
BLAKE2b-256 5712e16106aad76b35de8793097b676d97b458adb5fcea60c67ec91312e46c74

See more details on using hashes here.

File details

Details for the file eqdsk_from_cdf-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: eqdsk_from_cdf-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 145.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for eqdsk_from_cdf-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7070f7d5e4e4e2297b012fa1cb4d9b6ba4cc520acb57254b264042102d3e0c91
MD5 d8c274f6ad8e47547e60188fc934bfa0
BLAKE2b-256 cf3b43c5f5fe74cef26a75083c9a05cd1526390524462b79b69a481eefa632e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page