Skip to content

Removed title() from reference's to astropy's physical type. #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 89 additions & 89 deletions docs/notebooks/AutoPlot_template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,47 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The `auto_plot` function"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"hide_input"
]
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"from IPython.display import set_matplotlib_formats\n",
"\n",
"set_matplotlib_formats('retina')"
]
"#set_matplotlib_formats('retina')"
],
"outputs": [],
"metadata": {
"tags": [
"hide_input"
]
}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Overview"
]
],
"metadata": {}
},
{
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"The easiest way to plot stuff with :py:obj:`vplot` is using the :py:class:`vplot.auto_plot` function. Given a path to a directory containing a :py:obj:`vplanet` run, :py:class:`vplot.auto_plot` will parse the output and generate plots of all of the simulated quantities as a function of time for all of the bodies."
]
],
"metadata": {
"raw_mimetype": "text/restructuredtext"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"hide_input"
]
},
"outputs": [],
"source": [
"# Tar up the example folder\n",
"import glob\n",
Expand All @@ -58,121 +52,123 @@
"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))"
]
],
"outputs": [],
"metadata": {
"tags": [
"hide_input"
]
}
},
{
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"Let's run :py:class:`vplot.auto_plot` on the :download:`CircumbinaryOrbit <examples/CircumbinaryOrbit.tar.gz>` example."
]
],
"metadata": {
"raw_mimetype": "text/restructuredtext"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import vplot"
]
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"When we call :py:class:`vplot.auto_plot`, we pass the directory to the :py:obj:`vplanet` run:"
]
],
"metadata": {
"raw_mimetype": "text/restructuredtext"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\")"
},
"outputs": [],
"source": [
"from figure_grid import FigureGrid\n",
"\n",
"FigureGrid(\n",
" vplot.auto_plot(\"examples/CircumbinaryOrbit\", show=False, figsize=(5, 3), dpi=300)\n",
").display()"
]
],
"outputs": [],
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\")"
}
},
{
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
".. note::\n",
" You must actually run :py:obj:`vplanet` before calling :py:obj:`vplot`!"
]
],
"metadata": {
"raw_mimetype": "text/restructuredtext"
}
},
{
"cell_type": "markdown",
"metadata": {},
"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"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\", group=\"none\")"
},
"outputs": [],
"source": [
"FigureGrid(\n",
" vplot.auto_plot(\"examples/CircumbinaryOrbit\", show=False, figsize=(5, 3), dpi=300, group=\"none\")\n",
").display()"
]
],
"outputs": [],
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\", group=\"none\")"
}
},
{
"cell_type": "markdown",
"metadata": {},
"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)."
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\", group=\"type\")"
},
"outputs": [],
"source": [
"FigureGrid(\n",
" vplot.auto_plot(\"examples/CircumbinaryOrbit\", show=False, figsize=(5, 3), dpi=300, group=\"type\")\n",
").display()"
]
],
"outputs": [],
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\", group=\"type\")"
}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Useful options"
]
],
"metadata": {}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can plot only specific parameters:"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\", params=[\"eccentricity\", \"CBPR\"])"
},
"outputs": [],
"source": [
"FigureGrid(\n",
" vplot.auto_plot(\n",
Expand All @@ -183,22 +179,22 @@
" params=[\"eccentricity\", \"CBPR\"],\n",
" )\n",
").display()"
]
],
"outputs": [],
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\", params=[\"eccentricity\", \"CBPR\"])"
}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And we can plot only specific bodies:"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\", params=[\"eccentricity\", \"CBPR\"], bodies=\"earth\")"
},
"outputs": [],
"source": [
"FigureGrid(\n",
" vplot.auto_plot(\n",
Expand All @@ -210,35 +206,35 @@
" bodies=\"earth\",\n",
" ),\n",
").display()"
]
],
"outputs": [],
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\", params=[\"eccentricity\", \"CBPR\"], bodies=\"earth\")"
}
},
{
"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."
]
],
"metadata": {
"raw_mimetype": "text/restructuredtext"
}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also plot things logarithmically:"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\", params=[\"eccentricity\", \"CBPR\"], bodies=\"earth\", xlog=True, ylog=False)"
},
"outputs": [],
"source": [
"FigureGrid(\n",
" vplot.auto_plot(\n",
Expand All @@ -252,16 +248,20 @@
" ylog=False\n",
" ),\n",
").display()"
]
],
"outputs": [],
"metadata": {
"replace_input": "vpl.auto_plot(\"examples/CircumbinaryOrbit\", params=[\"eccentricity\", \"CBPR\"], bodies=\"earth\", xlog=True, ylog=False)"
}
},
{
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"Finally, note that :py:class:`vplot.auto_plot` also accepts any keyword arguments accepted by :py:class:`vplot.VPLOTFigure` and :py:class:`matplotlib.figure.Figure`, such as ``figsize`` and ``dpi``."
]
],
"metadata": {
"raw_mimetype": "text/restructuredtext"
}
}
],
"metadata": {
Expand All @@ -286,4 +286,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"setuptools_scm",
"numpy>=1.19.2",
"matplotlib>=3.3.4",
"astropy>=4.1",
"vplanet>=2.0.0",
"astropy>=6.0.0",
"vplanet>=2.4.24",
],
entry_points={
"console_scripts": ["vplot=vplot.command_line:_entry_point"]
Expand Down
4 changes: 2 additions & 2 deletions vplot/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _get_array_info(array, max_label_length=40):
unit = None
body = None
label = None
physical_type = array.unit.physical_type.title()
physical_type = array.unit.physical_type
if physical_type == "Dimensionless":
physical_type = None
else:
Expand All @@ -30,7 +30,7 @@ def _get_array_info(array, max_label_length=40):
label = array.tags.get("description", None)
if label is not None and len(label) > max_label_length:
label = array.tags.get("name", None)
physical_type = array.unit.physical_type.title()
physical_type = array.unit.physical_type
if physical_type == "Dimensionless":
physical_type = None
else:
Expand Down