{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Custom plots in 2D\n\nCreate a new 2D plot based on output data.\n\nDownload Input files\n\n* :download:`dipole_2d.data <../../../../../examples/input_files/dipole_iron.data>`\n* :download:`dipole_2d.post.xml <../../../../../examples/input_files/dipole_iron.post.xml>`\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from roxieapi.commons.roxie_constants import PlotLabels\nfrom roxieapi.commons.types import Plot2D\nfrom roxieapi.output.plots import RoxiePlotOutputs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting up\nStandard Loading of input, Parsing and Initializing RoxiePlotOutputs object\n\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plots = RoxiePlotOutputs(\n \"../input_files/dipole_iron.post.xml\", \"../input_files/dipole_iron.data\"\n)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plots defined in Roxie\n\nPrint a list of Plots which are defined in Roxie\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "for pl in PlotLabels.plot2D_desc:\n lbl, desc = PlotLabels.lbl_desc_plot2D(pl)\n print(f\"Coil plot {pl}, Label: '{lbl}', Description: '{desc}'\")\n\nfor pl in PlotLabels.plotMesh2D_desc:\n lbl, desc = PlotLabels.lbl_desc_mesh2D(pl)\n print(f\"Mesh plot {pl}, Label: '{lbl}', Description: '{desc}'\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plots defined in Roxie\nPrint all plots available of an output\n\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "trans = plots.output.opt[1].step[1]\nprint(\"Coil Plots:\")\ndata_cols = trans.coilData.columns\nfor col in data_cols:\n if col in PlotLabels.plot2D_desc:\n lbl, desc = PlotLabels.lbl_desc_plot2D(col)\n print(f\" Plot {col}: {desc}\")\nfor hc_idx, hc in trans.harmonicCoils.items():\n data_cols = hc.strandData\n for col in data_cols:\n if col in PlotLabels.plot2D_desc:\n lbl, desc = PlotLabels.lbl_desc_plot2D(col)\n print(f\" Harmonic coil #{hc_idx}, Plot {col}: {desc}\")\n\nprint(\"Iron mesh plots:\")\ndata_cols = plots.output.opt[1].step[1].meshData.columns\nfor col in data_cols:\n if col in PlotLabels.plotMesh2D_desc:\n lbl, desc = PlotLabels.lbl_desc_mesh2D(col)\n print(f\" Plot {col}: {desc}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Define a new Plot and create it\nFrom the list of available plots, Select which fields to plot, and create the output\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plot_created = Plot2D.create(\"My Plot2D\")\nplot_created.add_coilPlot(\"52\", harm_coil=1)\n# pl.add_meshPlot(\"35\", legend=PlotLegend(\"e\", False, 0, 1))\n\nfigure = plots.plots2d.plot_xs(plot_created)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.19" } }, "nbformat": 4, "nbformat_minor": 0 }