{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Plotting radial slices\n\nThis example shows how to plot slices of constant radial distance from a MAS model\noutput.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "First, load the required modules.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from psipy.model import MASOutput\nimport matplotlib.pyplot as plt"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Next, load a set of MAS output files. You will need to change this line to\npoint to a folder with MAS files in them.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mas_path = '/Users/dstansby/github/psipy/data/helio'\nmodel = MASOutput(mas_path)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Each MAS model contains a number of variables. The variable names can be\naccessed using the ``.variables`` attribute.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "print(model.variables)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Set parameters for plotting. The first line will give us a horizontal\nerrorbar underneath the plots. The second line is the index to select for the\nradial slice.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "cbar_kwargs = {'orientation': 'horizontal'}\nr_idx = 139"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Plot the slices\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig, axs = plt.subplots(nrows=2, ncols=3)\n\nax = axs[0, 0]\nmodel['vr'].plot_radial_cut(r_idx, ax=ax, cbar_kwargs=cbar_kwargs)\nmodel['br'].contour_radial_cut(r_idx, levels=[0], ax=ax, colors='white')\nax = axs[0, 1]\nmodel['vp'].plot_radial_cut(r_idx, ax=ax, cbar_kwargs=cbar_kwargs)\nmodel['br'].contour_radial_cut(r_idx, levels=[0], ax=ax, colors='black')\nax = axs[0, 2]\nmodel['vt'].plot_radial_cut(r_idx, ax=ax, cbar_kwargs=cbar_kwargs)\nmodel['br'].contour_radial_cut(r_idx, levels=[0], ax=ax, colors='black')\n\nax = axs[1, 0]\nmodel['rho'].plot_radial_cut(r_idx, ax=ax, cbar_kwargs=cbar_kwargs)\nmodel['br'].contour_radial_cut(r_idx, levels=[0], ax=ax, colors='white')\nax = axs[1, 1]\nmodel['p'].plot_radial_cut(r_idx, ax=ax, cbar_kwargs=cbar_kwargs)\nmodel['br'].contour_radial_cut(r_idx, levels=[0], ax=ax, colors='white')\n\nplt.show()"
      ]
    }
  ],
  "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.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}