{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# The command line interface" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2023-08-23T23:27:52.425412Z", "iopub.status.busy": "2023-08-23T23:27:52.425063Z", "iopub.status.idle": "2023-08-23T23:27:52.810531Z", "shell.execute_reply": "2023-08-23T23:27:52.809157Z" }, "tags": [ "hide_input" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_5371/1180289843.py:5: DeprecationWarning: `set_matplotlib_formats` is deprecated since IPython 7.23, directly use `matplotlib_inline.backend_inline.set_matplotlib_formats()`\n", " set_matplotlib_formats('retina')\n" ] } ], "source": [ "%matplotlib inline\n", "\n", "from IPython.display import set_matplotlib_formats\n", "\n", "set_matplotlib_formats('retina')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Overview" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "If you are in the directory of a completed :py:obj:`vplanet` simulation, you can use the command-line function :py:obj:`vplot` to generate plots of any/all of the simulated quantities as a function of time." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2023-08-23T23:27:52.813614Z", "iopub.status.busy": "2023-08-23T23:27:52.813089Z", "iopub.status.idle": "2023-08-23T23:27:52.820152Z", "shell.execute_reply": "2023-08-23T23:27:52.819617Z" }, "tags": [ "hide_input" ] }, "outputs": [], "source": [ "# Tar up the example folder\n", "import glob\n", "import tarfile\n", "import os\n", "\n", "with tarfile.open(\"examples/CircumbinaryOrbit.tar.gz\", \"w:gz\") as tar:\n", " for file in glob.glob(\"examples/CircumbinaryOrbit/*.in\"):\n", " tar.add(file, arcname=os.path.basename(file))" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Let's run :py:obj:`vplot` on the :download:`CircumbinaryOrbit ` example. If we are in that directory, we can simply run\n", "\n", ".. code-block:: bash\n", "\n", " vplot\n", " \n", "This should cause the following figures to pop up:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2023-08-23T23:27:52.822649Z", "iopub.status.busy": "2023-08-23T23:27:52.822445Z", "iopub.status.idle": "2023-08-23T23:27:55.243858Z", "shell.execute_reply": "2023-08-23T23:27:55.242839Z" }, "tags": [ "hide_input" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: AstropyDeprecationWarning: support for accessing str attributes such as 'title' from PhysicalType instances is deprecated since 4.3 and will be removed in a subsequent release. [astropy.units.physical]\n" ] }, { "data": { "text/html": [ "\n", " \n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from figure_grid import FigureGrid\n", "import vplot\n", "\n", "FigureGrid(\n", " vplot.auto_plot(\"examples/CircumbinaryOrbit\", show=False, figsize=(5, 3), dpi=300)\n", ").display()" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ ".. note::\n", " You must actually run :py:obj:`vplanet` before calling :py:obj:`vplot`!" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "By default, parameters are grouped by *parameter name*. This means that if there are multiple bodies with the same parameter, they will all show up in the same plot, with labels indicating the body they correspond to. We can disable grouping by running\n", "\n", ".. code-block:: bash\n", "\n", " vplot -g none" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2023-08-23T23:27:55.260598Z", "iopub.status.busy": "2023-08-23T23:27:55.259883Z", "iopub.status.idle": "2023-08-23T23:27:57.580759Z", "shell.execute_reply": "2023-08-23T23:27:57.580199Z" }, "tags": [ "hide_input" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: AstropyDeprecationWarning: support for accessing str attributes such as 'title' from PhysicalType instances is deprecated since 4.3 and will be removed in a subsequent release. [astropy.units.physical]\n" ] }, { "data": { "text/html": [ "\n", " \n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "FigureGrid(\n", " vplot.auto_plot(\"examples/CircumbinaryOrbit\", show=False, figsize=(5, 3), dpi=300, group=\"none\")\n", ").display()" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Alternatively, we can group by *physical type*. This means that everything that is an angle will be grouped into one plot, everything that has units of distance will be grouped into a different plot, and so forth. It isn't always useful, particularly if you have *lots* of parameters of the same physical type (as is the case here).\n", "\n", ".. code-block:: bash\n", "\n", " vplot -g type" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2023-08-23T23:27:57.605824Z", "iopub.status.busy": "2023-08-23T23:27:57.605198Z", "iopub.status.idle": "2023-08-23T23:27:58.576679Z", "shell.execute_reply": "2023-08-23T23:27:58.576025Z" }, "tags": [ "hide_input" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: AstropyDeprecationWarning: support for accessing str attributes such as 'title' from PhysicalType instances is deprecated since 4.3 and will be removed in a subsequent release. [astropy.units.physical]\n" ] }, { "data": { "text/html": [ "\n", " \n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "FigureGrid(\n", " vplot.auto_plot(\"examples/CircumbinaryOrbit\", show=False, figsize=(5, 3), dpi=300, group=\"type\")\n", ").display()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Useful options" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "We can plot only specific parameters:\n", "\n", ".. code-block:: bash\n", "\n", " vplot -p eccentricity cbpr" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "execution": { "iopub.execute_input": "2023-08-23T23:27:58.587129Z", "iopub.status.busy": "2023-08-23T23:27:58.586488Z", "iopub.status.idle": "2023-08-23T23:27:59.144423Z", "shell.execute_reply": "2023-08-23T23:27:59.143890Z" }, "tags": [ "hide_input" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: AstropyDeprecationWarning: support for accessing str attributes such as 'title' from PhysicalType instances is deprecated since 4.3 and will be removed in a subsequent release. [astropy.units.physical]\n" ] }, { "data": { "text/html": [ "\n", " \n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "FigureGrid(\n", " vplot.auto_plot(\n", " \"examples/CircumbinaryOrbit\",\n", " show=False,\n", " figsize=(5, 3),\n", " dpi=300,\n", " params=[\"eccentricity\", \"CBPR\"],\n", " )\n", ").display()" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "And we can plot only specific bodies:\n", "\n", ".. code-block:: bash\n", "\n", " vplot -p eccentricity cbpr -b earth" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "execution": { "iopub.execute_input": "2023-08-23T23:27:59.149686Z", "iopub.status.busy": "2023-08-23T23:27:59.149158Z", "iopub.status.idle": "2023-08-23T23:27:59.648426Z", "shell.execute_reply": "2023-08-23T23:27:59.647894Z" }, "tags": [ "hide_input" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: AstropyDeprecationWarning: support for accessing str attributes such as 'title' from PhysicalType instances is deprecated since 4.3 and will be removed in a subsequent release. [astropy.units.physical]\n" ] }, { "data": { "text/html": [ "\n", " \n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "FigureGrid(\n", " vplot.auto_plot(\n", " \"examples/CircumbinaryOrbit\",\n", " show=False,\n", " figsize=(5, 3),\n", " dpi=300,\n", " params=[\"eccentricity\", \"CBPR\"],\n", " bodies=\"earth\",\n", " ),\n", ").display()" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ ".. note::\n", " Body and parameter names are case-insensitive, but otherwise \n", " they must match the values in the ``.in`` files exactly.\n", " Note that the parameter names are those specified in the\n", " ``saOutputOrder`` line of the ``.in`` files." ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "We can also plot things logarithmically:\n", "\n", ".. code-block:: bash\n", "\n", " vplot -p eccentricity cbpr -b earth --xlog" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "execution": { "iopub.execute_input": "2023-08-23T23:27:59.651388Z", "iopub.status.busy": "2023-08-23T23:27:59.650849Z", "iopub.status.idle": "2023-08-23T23:28:00.396605Z", "shell.execute_reply": "2023-08-23T23:28:00.396064Z" }, "tags": [ "hide_input" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: AstropyDeprecationWarning: support for accessing str attributes such as 'title' from PhysicalType instances is deprecated since 4.3 and will be removed in a subsequent release. [astropy.units.physical]\n" ] }, { "data": { "text/html": [ "\n", " \n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "FigureGrid(\n", " vplot.auto_plot(\n", " \"examples/CircumbinaryOrbit\",\n", " show=False,\n", " figsize=(5, 3),\n", " dpi=300,\n", " params=[\"eccentricity\", \"CBPR\"],\n", " bodies=\"earth\",\n", " xlog=True,\n", " ylog=False\n", " ),\n", ").display()" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Finally, you can run\n", "\n", ".. code-block:: bash\n", "\n", " vplot --help\n", " \n", "to view all available options:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "execution": { "iopub.execute_input": "2023-08-23T23:28:00.399885Z", "iopub.status.busy": "2023-08-23T23:28:00.399254Z", "iopub.status.idle": "2023-08-23T23:28:01.051530Z", "shell.execute_reply": "2023-08-23T23:28:01.050675Z" }, "tags": [ "hide_input" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "usage: vplot [-h] [-g GROUP] [-b [BODIES [BODIES ...]]]\n", " [-p [PARAMS [PARAMS ...]]] [--xlog] [--ylog]\n", " [--figsize FIGSIZE FIGSIZE]\n", "\n", "optional arguments:\n", " -h, --help show this help message and exit\n", " -g GROUP, --group GROUP\n", " What to group plots by (param | type | none)\n", " -b [BODIES [BODIES ...]], --bodies [BODIES [BODIES ...]]\n", " Which bodies to plot\n", " -p [PARAMS [PARAMS ...]], --params [PARAMS [PARAMS ...]]\n", " Which parameters to plot\n", " --xlog Logarithmic x axes?\n", " --ylog Logarithmic y axes?\n", " --figsize FIGSIZE FIGSIZE\n", " Figure size in inches\n" ] } ], "source": [ "import subprocess\n", "print(subprocess.getoutput(\"vplot --help\"))" ] } ], "metadata": { "celltoolbar": "Tags", "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.8.17" } }, "nbformat": 4, "nbformat_minor": 2 }