Skip to content

Commit

Permalink
Merge branch 'master' into test/central_meridians
Browse files Browse the repository at this point in the history
  • Loading branch information
weiji14 committed Sep 11, 2020
2 parents f228e5c + 23d2284 commit 406f847
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 183 deletions.
5 changes: 1 addition & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Disclaimer
All of the API (functions/classes/interfaces) is subject to change until we reach v1.0.0
as per the `semantic versioning specification <https://semver.org/spec/v2.0.0.html>`__.
There may be non-backward compatible changes as we experiment with new design ideas and
implement new features. **This is not a finished product, use with caution**
implement new features. **This is not a finished product, use with caution.**

We welcome any feedback and ideas!
Let us know by submitting
Expand Down Expand Up @@ -85,9 +85,6 @@ Contacting Us
open issue or pull request.
* We have a `Discourse forum <https://forum.generic-mapping-tools.org>`__
where you can ask questions and leave comments.
* This project is released with a `Contributor Code of Conduct
<https://github.com/GenericMappingTools/pygmt/blob/master/CODE_OF_CONDUCT.md>`__.
By participating in this project you agree to abide by its terms.


Contributing
Expand Down
3 changes: 1 addition & 2 deletions examples/tutorials/first-figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
#
# You’ll probably have noticed several things that are different from classic
# command-line GMT. Many of these changes reflect the new GMT modern execution mode that
# will be part of the future 6.0 release. A few are PyGMT exclusive (like the
# ``savefig`` method).
# are part of GMT 6. A few are PyGMT exclusive (like the ``savefig`` method).
#
# 1. The name of method is ``coast`` instead of ``pscoast``. As a general rule, all
# ``ps*`` modules had their ``ps`` prefix removed. The exceptions are:
Expand Down
45 changes: 33 additions & 12 deletions pygmt/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ def info(table, **kwargs):
"""
Get information about data tables.
Reads from files and finds the extreme values in each of the columns.
It recognizes NaNs and will print warnings if the number of columns vary
from record to record. As an option, it will find the extent of the first
n columns rounded up and down to the nearest multiple of the supplied
increments. By default, this output will be in the form *-Rw/e/s/n*,
or the output will be in column form for as many columns as there are
increments provided. The *nearest_multiple* option will provide a
*-Tzmin/zmax/dz* string for makecpt.
Reads from files and finds the extreme values in each of the columns
reported as min/max pairs. It recognizes NaNs and will print warnings if
the number of columns vary from record to record. As an option, it will
find the extent of the first two columns rounded up and down to the nearest
multiple of the supplied increments given by *spacing*. Such output will be
in a numpy.ndarray form ``[w, e, s, n]``, which can be used directly as the
*region* argument for other modules (hence only dx and dy are needed). If
the *per_column* option is combined with *spacing*, then the numpy.ndarray
output will be rounded up/down for as many columns as there are increments
provided in *spacing*. A similar option *nearest_multiple* option will
provide a numpy.ndarray in the form of ``[zmin, zmax, dz]`` for makecpt.
Full option list at :gmt-docs:`gmtinfo.html`
Expand All @@ -83,12 +86,21 @@ def info(table, **kwargs):
spacing : str
``'[b|p|f|s]dx[/dy[/dz...]]'``.
Report the min/max of the first n columns to the nearest multiple of
the provided increments and output results in the form *-Rw/e/s/n*
(unless *per_column* is set).
the provided increments and output results in the form
``[w, e, s, n]``.
nearest_multiple : str
``'dz[+ccol]'``
Report the min/max of the first (0'th) column to the nearest multiple
of dz and output this as the string *-Tzmin/zmax/dz*.
of dz and output this in the form ``[zmin, zmax, dz]``.
Returns
-------
output : np.ndarray or str
Return type depends on whether any of the 'per_column', 'spacing', or
'nearest_multiple' parameters are set.
- np.ndarray if either of the above parameters are used.
- str if none of the above parameters are used.
"""
kind = data_kind(table)
with Session() as lib:
Expand All @@ -108,7 +120,16 @@ def info(table, **kwargs):
[fname, build_arg_string(kwargs), "->" + tmpfile.name]
)
lib.call_module("info", arg_str)
return tmpfile.read()
result = tmpfile.read()

if any(arg in kwargs for arg in ["C", "I", "T"]):
# Converts certain output types into a numpy array
# instead of a raw string that is less useful.
if result.startswith(("-R", "-T")): # e.g. -R0/1/2/3 or -T0/9/1
result = result[2:].replace("/", " ")
result = np.loadtxt(result.splitlines())

return result


@fmt_docstring
Expand Down
21 changes: 21 additions & 0 deletions pygmt/tests/test_grdimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ def test_grdimage_file():
return fig


@pytest.mark.xfail(reason="Upstream bug in GMT 6.1.1")
@check_figures_equal()
def test_grdimage_xarray_shading(grid, fig_ref, fig_test):
"""
Test that shading works well for xarray.
See https://github.com/GenericMappingTools/pygmt/issues/364
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(
region=[-180, 180, -90, 90],
frame=True,
projection="Cyl_stere/6i",
cmap="geo",
shading=True,
)

fig_ref.grdimage("@earth_relief_01d_g", **kwargs)
fig_test.grdimage(grid, **kwargs)
return fig_ref, fig_test


def test_grdimage_fails():
"Should fail for unrecognized input"
fig = Figure()
Expand Down
Loading

0 comments on commit 406f847

Please sign in to comment.