""" Extract Conductor Coordinates ============================= Use the Output parser to extract conductor coordinates and forces Download Input files * :download:`dipole_2d.data <../../../../../examples/input_files/dipole_2d.data>` * :download:`dipole_2d.post.xml <../../../../../examples/input_files/dipole_2d.post.xml>` """ # %% # Setting up # ---------- # Standard Loading of input, Parsing and Initializing RoxiePlotOutputs object # import pandas as pd from roxieapi.output.parser import RoxieOutputParser parser = RoxieOutputParser("../input_files/dipole_2d.post.xml") # %% # Extract Geometry # ---------------- geom = parser.opt[1].coilGeometries columns = ["cond", "block", "layer", "x1", "y1", "x2", "y2", "x3", "y3", "x4", "y4"] data = [ (cond.nr, cond.block_id, cond.layer_id, *cond.geometry.flatten()) for cond in geom.values() ] df_geom = pd.DataFrame(data, columns=columns) df_geom # %% # Merge Geometry with forces # -------------------------- df_forces = parser.opt[1].step[1].conductorForces df_all = df_geom.merge(df_forces, on="cond") df_all # %%