Skip to content

Commit

Permalink
Merge branch 'main' into refactor/virtualfile-to-data
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Oct 15, 2023
2 parents 78c28cd + 55c058a commit f849e5a
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pygmt/datasets/earth_age.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def load_earth_age(resolution="01d", region=None, registration=None):
r"""
Load the Earth seafloor crustal age dataset in various resolutions.
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_age.png # noqa: W505
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_age.png # noqa: W505
:width: 80 %
:align: center
Expand Down
2 changes: 1 addition & 1 deletion pygmt/datasets/earth_free_air_anomaly.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def load_earth_free_air_anomaly(resolution="01d", region=None, registration=None
Load the IGPP Global Earth Free-Air Anomaly datatset in various
resolutions.
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_faa.jpg # noqa: W505
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_faa.jpg # noqa: W505
:width: 80 %
:align: center
Expand Down
2 changes: 1 addition & 1 deletion pygmt/datasets/earth_geoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def load_earth_geoid(resolution="01d", region=None, registration=None):
r"""
Load the EGM2008 Global Earth Geoid dataset in various resolutions.
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_geoid.jpg # noqa: W505
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_geoid.jpg # noqa: W505
:width: 80 %
:align: center
Expand Down
4 changes: 2 additions & 2 deletions pygmt/datasets/earth_magnetic_anomaly.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def load_earth_magnetic_anomaly(
* - Global Earth Magnetic Anomaly Model (EMAG2)
- World Digital Magnetic Anomaly Map (WDMAM)
* - .. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_mag.jpg # noqa: W505
- .. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_wdmam.jpg # noqa: W505
* - .. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_mag4km.jpg # noqa: W505
- .. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_wdmam.jpg # noqa: W505
The grids are downloaded to a user data directory
(usually ``~/.gmt/server/earth/earth_mag/``,
Expand Down
2 changes: 1 addition & 1 deletion pygmt/datasets/earth_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def load_earth_mask(resolution="01d", region=None, registration=None):
r"""
Load the GSHHG Global Earth Mask dataset in various resolutions.
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earthmask.png # noqa: W505
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_mask.png # noqa: W505
:width: 80 %
:align: center
Expand Down
2 changes: 1 addition & 1 deletion pygmt/datasets/earth_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def load_earth_relief(
Load the Earth relief datasets (topography and bathymetry) in various
resolutions.
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_gebcosi.jpg # noqa: W505
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_gebcosi.jpg # noqa: W505
:width: 80 %
:align: center
Expand Down
2 changes: 1 addition & 1 deletion pygmt/datasets/earth_vertical_gravity_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def load_earth_vertical_gravity_gradient(
Load the IGPP Global Earth Vertical Gravity Gradient dataset in various
resolutions.
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_vgg.jpg # noqa: W505
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_vgg.jpg # noqa: W505
:width: 80 %
:align: center
Expand Down
6 changes: 4 additions & 2 deletions pygmt/src/which.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
GMTTempFile,
build_arg_string,
fmt_docstring,
kwargs_to_strings,
is_nonstr_iter,
use_alias,
)


@fmt_docstring
@use_alias(G="download", V="verbose")
@kwargs_to_strings(fname="sequence_space")
def which(fname, **kwargs):
r"""
Find the full path to specified files.
Expand Down Expand Up @@ -63,6 +62,9 @@ def which(fname, **kwargs):
FileNotFoundError
If the file is not found.
"""
if is_nonstr_iter(fname): # Got a list of files
fname = " ".join(fname)

with GMTTempFile() as tmpfile:
with Session() as lib:
lib.call_module(
Expand Down
14 changes: 7 additions & 7 deletions pygmt/tests/test_which.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Test pygmt.which.
"""
import os
from pathlib import Path

import pytest
from pygmt import which
Expand All @@ -13,20 +13,20 @@ def test_which():
Make sure `which` returns file paths for @files correctly without errors.
"""
for fname in ["tut_quakes.ngdc", "tut_bathy.nc"]:
cached_file = which(f"@{fname}", download="c")
assert os.path.exists(cached_file)
assert os.path.basename(cached_file) == fname
cached_file = which(fname=f"@{fname}", download="c")
assert Path(cached_file).exists()
assert Path(cached_file).name == fname


def test_which_multiple():
"""
Make sure `which` returns file paths for multiple @files correctly.
"""
filenames = ["ridge.txt", "tut_ship.xyz"]
cached_files = which(fname=[f"@{fname}" for fname in filenames], download="c")
cached_files = which([f"@{fname}" for fname in filenames], download="c")
for cached_file in cached_files:
assert os.path.exists(cached_file)
assert os.path.basename(cached_file) in filenames
assert Path(cached_file).exists()
assert Path(cached_file).name in filenames


def test_which_fails():
Expand Down

0 comments on commit f849e5a

Please sign in to comment.