Skip to content

Commit

Permalink
Merge branch 'master' into contrib-guide
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrjones committed Jul 2, 2021
2 parents 8addf7a + d90b3fc commit f9e6acc
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 30 deletions.
2 changes: 1 addition & 1 deletion doc/maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ adjusted upward on every major and minor release, but never on a patch release.

## Backwards compatibility and deprecation policy

PyGMT is still undergoing rapid developement. All of the API is subject to change
PyGMT is still undergoing rapid development. All of the API is subject to change
until the v1.0.0 release.

Basic policy for backwards compatibility:
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/embellishments/solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---------------------------------------
Use :meth:`pygmt.Figure.solar` to show the different transition stages between daytime
and nightime. The parameter ``terminator`` is used to set the twilight stage, and can be
and nighttime. The parameter ``terminator`` is used to set the twilight stage, and can be
either 'day-night' (brightest), 'civil', 'nautical', or 'astronomical' (darkest). Refer
to https://en.wikipedia.org/wiki/Twilight for more information.
"""
Expand Down
47 changes: 47 additions & 0 deletions examples/gallery/symbols/custom_symbols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Custom symbols
--------------
The :meth:`pygmt.Figure.plot` method can plot individual custom symbols
by passing the corresponding symbol name together with the **k** shortcut to
the ``style`` parameter. In total 41 custom symbols are already included of
which the following plot shows five exemplary ones. The symbols are shown
underneath their corresponding names. For the remaining symbols see the GMT
cookbook :gmt-docs:`cookbook/custom-symbols.html`.
"""

import pygmt

fig = pygmt.Figure()
fig.basemap(region=[0, 8, 0, 3], projection="X12c/4c", frame=True)

# define pen and fontstlye for annotations
pen = "1p,black"
font = "15p,Helvetica-Bold"

# use the volcano symbol with a size of 1.5c,
# fill color is set to "seagreen"
fig.plot(x=1, y=1.25, style="kvolcano/1.5c", pen=pen, color="seagreen")
fig.text(x=1, y=2.5, text="volcano", font=font)

# use the astroid symbol with a size of 1.5c,
# fill color is set to "red3"
fig.plot(x=2.5, y=1.25, style="kastroid/1.5c", pen=pen, color="red3")
fig.text(x=2.5, y=2.5, text="astroid", font=font)

# use the flash symbol with a size of 1.5c,
# fill color is set to "darkorange"
fig.plot(x=4, y=1.25, style="kflash/1.5c", pen=pen, color="darkorange")
fig.text(x=4, y=2.5, text="flash", font=font)

# use the star4 symbol with a size of 1.5c,
# fill color is set to "dodgerblue4"
fig.plot(x=5.5, y=1.25, style="kstar4/1.5c", pen=pen, color="dodgerblue4")
fig.text(x=5.5, y=2.5, text="star4", font=font)

# use the hurricane symbol with a size of 1.5c,
# fill color is set to "magenta4"
fig.plot(x=7, y=1.25, style="khurricane/1.5c", pen=pen, color="magenta4")
fig.text(x=7, y=2.5, text="hurricane", font=font)

fig.show()
4 changes: 2 additions & 2 deletions examples/tutorials/date_time_charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
# data to the PyGMT figure.
# Specifically ``x`` contains 7 different :class:`pandas.DatetimeIndex` objects, with the
# number being manipulated by the ``periods`` parameter. Each period begins at the start
# of a business quarter as denoted by BQS when passed to the ``periods`` parameter. The inital
# of a business quarter as denoted by BQS when passed to the ``periods`` parameter. The initial
# date is the first argument that is passed to :func:`pandas.date_range` and it marks the first
# data point in the list ``x`` that will be plotted.

Expand Down Expand Up @@ -207,7 +207,7 @@
# -------------------------------
# In this example, instead of using a :func:`pd.date_range`, ``x`` is initialized
# as an ``np.array`` object. Similar to :class:`xarray.DataArray` this wraps the
# dataset before passing it as a paramater. However, ``np.array`` objects use less
# dataset before passing it as a parameter. However, ``np.array`` objects use less
# memory and allow developers to specify datatypes.

x = np.array(["2010-06-01", "2011-06-01T12", "2012-01-01T12:34:56"], dtype="datetime64")
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
# start and end points of the geographic vector.
# The geographical vector is going from Idaho to
# Chicago. To style geographic
# vectors, use ``=`` at the begining of the ``style`` parameter.
# vectors, use ``=`` at the beginning of the ``style`` parameter.
# Other styling features such as vector stem thickness and head color
# can be passed into the ``pen`` and ``color`` parameters.
#
Expand Down
2 changes: 2 additions & 0 deletions pygmt/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def region(self):
I="icc_gray",
T="fmt",
Q="anti_aliasing",
V="verbose",
)
@kwargs_to_strings()
def psconvert(self, **kwargs):
Expand Down Expand Up @@ -185,6 +186,7 @@ def psconvert(self, **kwargs):
both an EPS and a PDF file. Using **F** creates a multi-page PDF
file from the list of input PS or PDF files. It requires the
``prefix`` parameter.
{V}
"""
kwargs = self._preprocess(**kwargs)
# Default cropping the figure to True
Expand Down
2 changes: 2 additions & 0 deletions pygmt/src/grdlandmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
G="outgrid",
I="spacing",
R="region",
V="verbose",
r="registration",
)
@kwargs_to_strings(R="sequence")
Expand All @@ -44,6 +45,7 @@ def grdlandmask(**kwargs):
in.
{I}
{R}
{V}
{r}
Returns
Expand Down
2 changes: 1 addition & 1 deletion pygmt/src/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def histogram(self, table, **kwargs):
Draws a stairs-step diagram which does not include the internal bars
of the default histogram.
horizontal : bool
Plot the histogram using horizonal bars instead of the
Plot the histogram using horizontal bars instead of the
default vertical bars.
series : int or str or list
[*min*\ /*max*\ /]\ *inc*\ [**+n**\ ].
Expand Down
56 changes: 32 additions & 24 deletions pygmt/tests/test_grdtrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,35 @@ def fixture_dataarray():
)


def test_grdtrack_input_dataframe_and_dataarray(dataarray):
@pytest.fixture(scope="module", name="dataframe")
def fixture_dataframe():
"""
Load the ocean ridge file.
"""
return load_ocean_ridge_points()


@pytest.fixture(scope="module", name="csvfile")
def fixture_csvfile():
"""
Load the csvfile.
"""
return which("@ridge.txt", download="c")


@pytest.fixture(scope="module", name="ncfile")
def fixture_ncfile():
"""
Load the ncfile.
"""
return which("@earth_relief_01d", download="a")


def test_grdtrack_input_dataframe_and_dataarray(dataarray, dataframe):
"""
Run grdtrack by passing in a pandas.DataFrame and xarray.DataArray as
inputs.
"""
dataframe = load_ocean_ridge_points()

output = grdtrack(points=dataframe, grid=dataarray, newcolname="bathymetry")
assert isinstance(output, pd.DataFrame)
assert output.columns.to_list() == ["longitude", "latitude", "bathymetry"]
Expand All @@ -40,12 +62,10 @@ def test_grdtrack_input_dataframe_and_dataarray(dataarray):
return output


def test_grdtrack_input_csvfile_and_dataarray(dataarray):
def test_grdtrack_input_csvfile_and_dataarray(dataarray, csvfile):
"""
Run grdtrack by passing in a csvfile and xarray.DataArray as inputs.
"""
csvfile = which("@ridge.txt", download="c")

try:
output = grdtrack(points=csvfile, grid=dataarray, outfile=TEMP_TRACK)
assert output is None # check that output is None since outfile is set
Expand All @@ -59,12 +79,10 @@ def test_grdtrack_input_csvfile_and_dataarray(dataarray):
return output


def test_grdtrack_input_dataframe_and_ncfile():
def test_grdtrack_input_dataframe_and_ncfile(dataframe, ncfile):
"""
Run grdtrack by passing in a pandas.DataFrame and netcdf file as inputs.
"""
dataframe = load_ocean_ridge_points()
ncfile = which("@earth_relief_01d", download="a")

output = grdtrack(points=dataframe, grid=ncfile, newcolname="bathymetry")
assert isinstance(output, pd.DataFrame)
Expand All @@ -74,13 +92,10 @@ def test_grdtrack_input_dataframe_and_ncfile():
return output


def test_grdtrack_input_csvfile_and_ncfile():
def test_grdtrack_input_csvfile_and_ncfile(csvfile, ncfile):
"""
Run grdtrack by passing in a csvfile and netcdf file as inputs.
"""
csvfile = which("@ridge.txt", download="c")
ncfile = which("@earth_relief_01d", download="a")

try:
output = grdtrack(points=csvfile, grid=ncfile, outfile=TEMP_TRACK)
assert output is None # check that output is None since outfile is set
Expand All @@ -94,49 +109,42 @@ def test_grdtrack_input_csvfile_and_ncfile():
return output


def test_grdtrack_wrong_kind_of_points_input(dataarray):
def test_grdtrack_wrong_kind_of_points_input(dataarray, dataframe):
"""
Run grdtrack using points input that is not a pandas.DataFrame (matrix) or
file.
"""
dataframe = load_ocean_ridge_points()
invalid_points = dataframe.longitude.to_xarray()

assert data_kind(invalid_points) == "grid"
with pytest.raises(GMTInvalidInput):
grdtrack(points=invalid_points, grid=dataarray, newcolname="bathymetry")


def test_grdtrack_wrong_kind_of_grid_input(dataarray):
def test_grdtrack_wrong_kind_of_grid_input(dataarray, dataframe):
"""
Run grdtrack using grid input that is not as xarray.DataArray (grid) or
file.
"""
dataframe = load_ocean_ridge_points()
invalid_grid = dataarray.to_dataset()

assert data_kind(invalid_grid) == "matrix"
with pytest.raises(GMTInvalidInput):
grdtrack(points=dataframe, grid=invalid_grid, newcolname="bathymetry")


def test_grdtrack_without_newcolname_setting(dataarray):
def test_grdtrack_without_newcolname_setting(dataarray, dataframe):
"""
Run grdtrack by not passing in newcolname parameter setting.
"""
dataframe = load_ocean_ridge_points()

with pytest.raises(GMTInvalidInput):
grdtrack(points=dataframe, grid=dataarray)


def test_grdtrack_without_outfile_setting():
def test_grdtrack_without_outfile_setting(csvfile, ncfile):
"""
Run grdtrack by not passing in outfile parameter setting.
"""
csvfile = which("@ridge.txt", download="c")
ncfile = which("@earth_relief_01d", download="a")

output = grdtrack(points=csvfile, grid=ncfile)
npt.assert_allclose(output.iloc[0], [-32.2971, 37.4118, -1939.748245])

Expand Down

0 comments on commit f9e6acc

Please sign in to comment.