Skip to content

GENE plugin

TODO: Short description of GENE software as introduction. Parser/runner are descibed within their own docstrings.

GeneParser

GeneParser(*args, **kwargs)

spare_files_list instance-attribute

spare_files_list = get('spare_ciles_list', None)

args: precision: int: number of decimal places the inputs will be rounded to. This reduces the chance of gene changing them when making the effective parameters file which can lear to quasineutrality errors for example.

clear_directory

clear_directory(path, spare=None)

Delete all files and subdirectories inside path but keep the directory itself. Any names listed in spare will be preserved.

Parameters

path : str Directory to clear. spare : list of str, optional Filenames or directory names to keep.

fd_d1_o4

fd_d1_o4(var, grid, mat=False)

Centered finite difference, first derivative, 4th order. var: quantity to be differentiated. grid: grid for var mat: matrix for the finite-differencing operator. if mat=False then it is created

parse_gene_wallclock_time

parse_gene_wallclock_time(run_dir)

Parse 'Total wallclock time for GENE:' from a file by reading it all at once. Returns the time in seconds as a float, or None if not found.

parse_iterdb

parse_iterdb(file_path)

Parses an iterdb file and extracts profiles, specifically looking for VROT. Returns a dictionary: {quantity_name: (x_data, y_data, x_label)}

plot_iterdb_comparison

plot_iterdb_comparison(file_paths, output_dir=None)

Plots profiles from multiple iterdb files for comparison and saves to PNG.

read_nrg

read_nrg(run_dir, suffix='.dat', time='all')

returns a dict of dataframes, one for each spiecies and one for time e.g. {electron: electron_df, ion: ion_df}

where electron_df has columns ['n1','u1_par','T1_par','T1_perp','Gamma_es','Gamma_em','Q_es','Q_em','PI_es','PI_em'] taken from gene docs for nrg file.

VrotIterdbPlotter

parse_vrot_only

parse_vrot_only(file_path)

Parses an iterdb file but ONLY extracts the VROT profile.

plot_vrot_comparison

plot_vrot_comparison(
    file_paths, output_name="vrot_comparison.png"
)

Plots only the VROT profiles from a list of files for comparison.

safe_read_namelist

safe_read_namelist(path)

Reads a Fortran namelist safely: - Sanitizes problematic lines - Writes to a temporary directory - Automatically deletes all temp files afterward

sanitize_lines_fast

sanitize_lines_fast(path)

Returns a list of sanitized lines: - Only quotes values containing parentheses - Leaves everything else untouched