Skip to content

gk-nodes script mode#181

Merged
JunoRavin merged 5 commits intomainfrom
gk_nodes_script_mode
Feb 23, 2026
Merged

gk-nodes script mode#181
JunoRavin merged 5 commits intomainfrom
gk_nodes_script_mode

Conversation

@manauref
Copy link
Copy Markdown
Collaborator

@manauref manauref commented Feb 20, 2026

This commit improves the storage of data and plot handles so that when gk-nodes is used from a python script one has greater control over the plot, allowing the python script to manipulate the data or the plot.

For example, here's an example where we extract the nodes data and separately resize the figure

  #[ Create a click context (needed to call pgkyl command).
  ctx = click.core.Context(cli)
  ctx.obj = {}
  ctx.obj["data"] = pg.commands.DataSpace()
  ctx.obj["verbose"] = False

  ctx.invoke(pg.commands.gk_nodes, name=sim_name, path=data_dir, wall_file=wall_coords,
    psi_file=psi_pol, contour=psi_contour, cnlevels=psi_contour_num_levels, no_show=True)

  #[ Nodes data.
  nodes = ctx.obj["data"].get_dataset(tag="nodes",idx=0)
  nodes_majorR = nodes.get_grid()
  nodes_vertZ = nodes.get_values()

  #[ Resize figure:
  plot_h = ctx.obj["plot_handles"]
  fig_h = plot_h["figure"]
  fig_width, fig_height = fig_h.get_size_inches() #[ In inches.
  fig_h.set_size_inches(fig_width*0.85, fig_height*0.9)

We also fixed:

  • the y label from R (z) to Z (m).
  • an error in collect due to the way we checked for the key period in the context. Also made that change elsewhere.

@JunoRavin JunoRavin merged commit 6f522df into main Feb 23, 2026
3 checks passed
@JunoRavin JunoRavin deleted the gk_nodes_script_mode branch February 23, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants