Skip to content

Commit 3554aea

Browse files
deploy: 1c4d845
0 parents  commit 3554aea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+6416
-0
lines changed

.buildinfo

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: 0e9a6fcc67f2ddebd53c8efd65cafc2e
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7

.nojekyll

Whitespace-only changes.
35 KB
Loading
538 KB
Loading
93.6 KB
Loading
88.3 KB
Loading
76.5 KB
Loading
92.9 KB
Loading

_sources/contributing.rst.txt

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
Contributors Guide
2+
------------------
3+
4+
This is a community driven project and everyone is welcome to contribute. The
5+
project is hosted at the `gmt-examples GitHub repository <https://github.com/GenericMappingTools/gmt-examples>`_.
6+
7+
The goal is to maintain a diverse community that's pleasant for everyone.
8+
**Please be considerate and respectful of others**. Everyone must abide by our
9+
`Code of Conduct <https://github.com/GenericMappingTools/gmt-examples/blob/main/CODE_OF_CONDUCT.md>`_
10+
and we encourage all to read it carefully.
11+
12+
GMT Examples Overview
13+
~~~~~~~~~~~~~~~~~~~~~
14+
15+
There are two main components to GMT examples project:
16+
17+
* Gallery examples, with source material in the ``docs/gallery/`` folder.
18+
* Tutorial examples, with source material in the ``docs/tutorials/`` folder.
19+
20+
The gallery examples are designed to instruct users on how to complete a specific
21+
problem. For general recommendations on how to design effective gallery examples,
22+
see the `diataxis framework's section on how-to guides <https://diataxis.fr/how-to-guides/>`_.
23+
24+
The tutorials are learning orientated with the goal of teaching users GMT. For
25+
general recommendations on how to design effective tutorials, see the
26+
`diataxis framework's section on tutorials <https://diataxis.fr/tutorials/>`_.
27+
28+
The documentation are written primarily in
29+
`reStructuredText <https://docutils.sourceforge.io/rst.html>`_ and built by
30+
`Sphinx <http://www.sphinx-doc.org/>`_. Please refer to
31+
:gmt-module:`reStructuredText cheatsheet <devdocs/rst-cheatsheet.html>` if you are new to reStructuredText.
32+
33+
Setting up your environment
34+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
35+
36+
The following dependencies are required for building the GMT examples pages:
37+
38+
- `gmt <https://docs.generic-mapping-tools.org/latest/>`_ (GMT is required for executing example scripts)
39+
- `sphinx <http://www.sphinx-doc.org/>`_ (a Python documentation generator for creating the docs from source files)
40+
- `sphinx_gmt <https://www.generic-mapping-tools.org/sphinx_gmt/latest/>`_ (a Sphinx extension for creating GMT figures to accompany example scripts)
41+
- `sphinx_rtd_theme <https://sphinx-rtd-theme.readthedocs.io/en/stable/>`_ (a Sphinx theme used for consistent documentation appearance between GMT projects)
42+
43+
Two options for installing the dependencies are :ref:`pip <Pip Setup>` and :ref:`conda <Conda Setup>`.
44+
Since Sphinx is a Python documentation generator, you will need a working Python
45+
environment. For those who do not already have a working Python environment,
46+
one option is to use the minimal installer for Conda `Miniforge <https://github.com/conda-forge/miniforge>`_
47+
along with the :ref:`conda <Conda Setup>` instructions.
48+
49+
Pip Setup
50+
^^^^^^^^^
51+
52+
These instructions rely on the `pip <https://pip.pypa.io/en/stable/>`_ package
53+
installer, which can be used to install all dependencies except GMT.
54+
Follow the `GMT Install Guide <https://github.com/GenericMappingTools/gmt/blob/master/INSTALL.md>`_
55+
to install GMT. The Python dependencies can be installed using the
56+
``requirements.txt`` from the base of the repository (you may wish to setup a
57+
`virtual environment <https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment>`_ first):
58+
59+
Unix/macOS::
60+
61+
python -m pip install -r requirements.txt
62+
63+
Windows::
64+
65+
py -m pip install -r requirements.txt
66+
67+
Conda Setup
68+
^^^^^^^^^^^
69+
70+
These instructions rely on the `conda <https://docs.conda.io/en/latest/>`_ package
71+
manager. Run the following from the base of the repository to create a new conda
72+
environment from the ``environment.yml`` file::
73+
74+
conda env create
75+
76+
Before building the documentation, you have to activate the environment
77+
(you'll need to do this every time you start a new terminal)::
78+
79+
conda activate gmt-examples
80+
81+
Building the documentation
82+
~~~~~~~~~~~~~~~~~~~~~~~~~~
83+
84+
Once you have :ref:`setup your environment <Setting up your environment>`, you can
85+
build the documentation using::
86+
87+
cd docs
88+
make html
89+
90+
Contributing New Examples
91+
~~~~~~~~~~~~~~~~~~~~~~~~~
92+
93+
The source files for the gallery examples and tutorials are ``.rst`` files in
94+
``docs/`` that generate one or more figures using the
95+
`sphinx_gmt <https://www.generic-mapping-tools.org/sphinx_gmt/latest/)>`_
96+
extension. To add a new gallery example or tutorial:
97+
98+
* If necessary, create a new sub-directory under ``docs/gallery/`` for a
99+
gallery example section (e.g., ``basemaps/`` or ``plot_embellishments/``).
100+
* Create a new ``.rst`` file inside the appropriate sub-directory in
101+
``docs/gallery/`` or ``docs/tutorials/``.
102+
* Add a descriptive title and as much explanation as necessary.
103+
* Add hyperlinks to GMT modules using the ``gmt-module`` reStructuredText directive::
104+
105+
:gmt-module:`grdview`
106+
107+
* Add hyperlinks to GMT module options by appending lower-case ``#<option>`` to
108+
the ``gmt-module`` argument::
109+
110+
:gmt-module:`grdview#q`
111+
112+
* Add as many figures as needed using the ``gmtplot`` directive:
113+
114+
::
115+
116+
.. gmtplot::
117+
118+
gmt begin basemap png
119+
gmt basemap -B -Rg -JH5c
120+
gmt end show
121+
122+
The figures will be placed after the source code in the built documentation
123+
by the ``sphinx_gmt`` extension.
124+
125+
* Add the file to the appropriate section in ``docs/index.rst`` using the following
126+
template:
127+
128+
::
129+
130+
```bash
131+
- .. image:: _images/<file-name>-gmtplot-0.png
132+
:target: gallery/<section>/<file-name>.html
133+
:width: 80%
134+
:align: center
135+
136+
:doc:`gallery/<section>/<file-name>`
137+
```
138+
139+
Edit the number in the ``.. image:: ...`` line to show a different figure on the
140+
index page.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Plotting a surface
2+
------------------
3+
4+
:gmt-module:`grdview` can plot 3-D surfaces using the :gmt-module:`-Q <grdview#q>`
5+
parameter with the ``s`` directive. Here, we use :gmt-module:`grdmath` to create
6+
a netCDF file containing a grid for plotting.
7+
8+
Note that the **-p** parameter here controls the azimuth and elevation angle of
9+
the view.
10+
11+
We use the :gmt-module:`-B <grdview#b>` parameter twice - the first specifies
12+
the :math:`x`- and :math:`y`-axes frame attributes and the second specifies the
13+
:math:`z`-axis frame attributes using the ``z`` directive.
14+
15+
The :gmt-module:`-I <grdview#i>` parameter specifies the illumination; here we
16+
use an azimuth of 45° using the ``+a`` modifier.
17+
18+
.. gmtplot::
19+
20+
gmt grdmath -R-15/15/-15/15 -I0.3 X Y HYPOT DUP 2 MUL PI MUL 8 DIV COS EXCH NEG 10 DIV EXP MUL 0.001 SUB = example_grid.nc
21+
gmt begin grdview_surface png
22+
gmt grdview example_grid.nc -Ba5f1 -Bza5f1 -JX10C -JZ2c -Qs -Croma -p135/30 -I+a45
23+
gmt end show

_sources/index.rst.txt

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
GMT Tutorials and Examples
2+
==========================
3+
4+
A collection of tutorials and short guides demonstrating how to complete
5+
various tasks using GMT.
6+
7+
There are two main components to GMT examples project:
8+
9+
* Gallery examples.
10+
* Tutorial examples.
11+
12+
The gallery examples are designed to instruct users on how to complete a specific problem.
13+
They are how-to guides. It assumes you already know how to work with GMT.
14+
15+
The tutorials are learning orientated with the goal of teaching users GMT.
16+
They are designed to help beginners to understand how GMT works.
17+
If you want to learn GMT you should start here.
18+
19+
.. toctree::
20+
:hidden:
21+
:glob:
22+
:maxdepth: 2
23+
:caption: Gallery
24+
25+
gallery/*/*
26+
27+
.. toctree::
28+
:hidden:
29+
:glob:
30+
:maxdepth: 2
31+
:caption: Tutorials
32+
33+
tutorials/*/*
34+
35+
.. toctree::
36+
:hidden:
37+
:maxdepth: 2
38+
:caption: Development
39+
40+
contributing.rst
41+
42+
.. cssclass:: gmtgallery
43+
44+
45+
Gallery
46+
-------
47+
48+
Maps and map elements
49+
~~~~~~~~~~~~~~~~~~~~~
50+
51+
Lines
52+
~~~~~
53+
54+
Vectors
55+
~~~~~~~
56+
57+
58+
Symbols and markers
59+
~~~~~~~~~~~~~~~~~~~
60+
61+
Images, contours, and fields
62+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63+
64+
3d plots
65+
~~~~~~~~
66+
67+
.. cssclass:: gmtgallery
68+
69+
- .. image:: _images/4546e1b4bf691b3b38010ff66e835609.png
70+
:target: gallery/3d_plots/grdview_surface.html
71+
:width: 80%
72+
:align: center
73+
74+
:doc:`gallery/3d_plots/grdview_surface`
75+
76+
Seismology and geodesy
77+
~~~~~~~~~~~~~~~~~~~~~~
78+
79+
Basemaps
80+
~~~~~~~~
81+
82+
Histograms
83+
~~~~~~~~~~
84+
85+
Plot embellishments
86+
~~~~~~~~~~~~~~~~~~~
87+
88+
Tutorials
89+
---------
90+
91+
Basics
92+
~~~~~~
93+
94+
.. cssclass:: gmtgallery
95+
96+
- .. image:: _images/67b8930e41c80cad1a26bc81920b6abe.png
97+
:target: tutorials/basics/coastlines.html
98+
:width: 80%
99+
:align: center
100+
101+
:doc:`tutorials/basics/coastlines`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
Coastlines and boarders
2+
-----------------------
3+
4+
Plotting coastlines and boarders is handled by :gmt-module:`coast`.
5+
6+
Shorelines
7+
~~~~~~~~~~
8+
9+
Use the :gmt-module:`-W <coast#w>` parameter to plot only the shorelines:
10+
11+
.. gmtplot::
12+
13+
gmt begin shorelines png
14+
gmt coast -Rg -JW15c -B -W
15+
gmt end show
16+
17+
The shorelines are divided in 4 levels:
18+
19+
1. coastline
20+
2. lakeshore
21+
3. island-in-lake shore
22+
4. lake-in-island-in-lake shore
23+
24+
You can specify which level you want to plot by appending the level number and a
25+
GMT pen configuration to the :gmt-module:`-W <coast#w>` parameter. For example,
26+
to plot just the coastlines with 0.5 thickness and black lines:
27+
28+
.. gmtplot::
29+
30+
gmt begin shorelines_levels png
31+
gmt coast -Rg -JW15c -B -W1/0.5p,black
32+
gmt end show
33+
34+
You can specify multiple levels by using the :gmt-module:`-W <coast#w>`
35+
parameter more than once:
36+
37+
.. gmtplot::
38+
39+
gmt begin shorelines_levels png
40+
gmt coast -Rg -JW15c -B -W1/0.5p,black -W2/0.5,red
41+
gmt end show
42+
43+
Resolutions
44+
~~~~~~~~~~~
45+
46+
The coastline database comes with 5 resolutions, which can be set using the
47+
:gmt-module:`-D <coast#d>` parameter. The resolution drops by 80% between levels:
48+
49+
1. **c**: crude
50+
2. **l**: low
51+
3. **i**: intermediate
52+
4. **h**: high
53+
5. **f**: full
54+
55+
.. gmtplot::
56+
57+
oahu="-158.3/-157.6/21.2/21.8"
58+
gmt begin shorelines_resolutions png
59+
for res in c, l, i, h, f
60+
do
61+
gmt coast -R${oahu} -JM5c -W1p -D${res} -X5c
62+
done
63+
gmt end show
64+
65+
Land and water
66+
~~~~~~~~~~~~~~
67+
68+
Use the :gmt-module:`-G <coast#g>` and :gmt-module:`-S <coast#s>` parameters to
69+
specify a fill color for land and water bodies. The colors can be given by name
70+
or hex codes:
71+
72+
.. gmtplot::
73+
74+
gmt begin land_water png
75+
gmt coast -Rg -JW15c -B -G#666666 -Sskyblue
76+
gmt end show

0 commit comments

Comments
 (0)