-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from FloraSauerbronn/new-doc-notebook
New notebook
- Loading branch information
Showing
5 changed files
with
164 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plotting Intro\n", | ||
"\n", | ||
"\n", | ||
"Gliderpy has a plotting interface for quick simple diagnostic figures they are: `plot_ track`, `plot_ctd`, and `plot_transect` for plotting the glider track, a vertical transect for a specific variable, or a single cast (glider dive). Let's take a look on how to use them. First we will load a glider dataset as a pandas DataFrame." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from gliderpy.fetchers import GliderDataFetcher\n", | ||
"\n", | ||
"glider_grab = GliderDataFetcher()\n", | ||
"\n", | ||
"glider_grab.fetcher.dataset_id = \"whoi_406-20160902T1700\"\n", | ||
"df = glider_grab.to_pandas()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### plot_track\n", | ||
"\n", | ||
"The `plot_track` method will returns a map with the glider's track." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig, ax = df.plot_track()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### plot_ctd\n", | ||
"\n", | ||
"This method groups all the casts by their position (latitude and longitude) giving the user access to each individual cast using the index (`profile_number`) of the grouped DataFrame." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig, ax = df.plot_ctd(profile_number=0, var=\"temperature\", color=\"blue\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"All the methods accept and `ax` argument and more complex figures can be create. For example, let's add a second variable to the cast above." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig, ax0 = df.plot_ctd(profile_number=0, var=\"temperature\", color=\"blue\")\n", | ||
"\n", | ||
"ax1 = ax0.twiny()\n", | ||
"df.plot_ctd(profile_number=0, var=\"salinity\", color=\"red\", ax=ax1)\n", | ||
"\n", | ||
"ax0.legend()\n", | ||
"ax1.legend()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"We can check a whole transec with the `plot_transect` method." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig, ax = df.plot_transect(var=\"temperature\", cmap=\"viridis\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Using a given matplotlib we can create a fancier version with two variables in a subplot." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\n", | ||
"\n", | ||
"fig, (ax0, ax1) = plt.subplots(\n", | ||
" figsize=(15, 9),\n", | ||
" nrows=2,\n", | ||
" sharex=True,\n", | ||
" sharey=True,\n", | ||
")\n", | ||
"\n", | ||
"df.plot_transect(var=\"temperature\", ax=ax0, cmap=\"viridis\")\n", | ||
"df.plot_transect(var=\"salinity\", ax=ax1, cmap=\"cividis\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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.12.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |