Skip to content

Commit

Permalink
Merge branch 'main' into doc/bullet
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Jan 8, 2025
2 parents ed2e0b7 + a9d26a8 commit e174fff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v2.1.0
uses: lycheeverse/lychee-action@v2.2.0
with:
fail: false # Don't fail action on broken links
output: /tmp/lychee-out.md
Expand Down
36 changes: 31 additions & 5 deletions pygmt/datasets/load_remote_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class GMTRemoteDataset(NamedTuple):
Attributes
----------
description
The name assigned as an attribute to the DataArray.
The name assigned as an attribute to the DataArray.
kind
The kind of the dataset source. Valid values are ``"grid"`` and ``"image"``.
units
The units of the values in the DataArray.
resolutions
Expand All @@ -49,6 +51,7 @@ class GMTRemoteDataset(NamedTuple):
"""

description: str
kind: Literal["grid", "image"]
units: str | None
resolutions: dict[str, Resolution]
extra_attributes: dict[str, Any]
Expand All @@ -57,6 +60,7 @@ class GMTRemoteDataset(NamedTuple):
datasets = {
"earth_age": GMTRemoteDataset(
description="EarthByte Earth seafloor crustal age",
kind="grid",
units="Myr",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -75,6 +79,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_day": GMTRemoteDataset(
description="NASA Day Images",
kind="image",
units=None,
extra_attributes={"long_name": "blue_marble", "horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -94,6 +99,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_dist": GMTRemoteDataset(
description="GSHHG Earth distance to shoreline",
kind="grid",
units="kilometers",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -112,6 +118,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_edefl": GMTRemoteDataset(
description="IGPP Earth east-west deflection",
kind="grid",
units="micro-radians",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -130,6 +137,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_faa": GMTRemoteDataset(
description="IGPP Earth free-air anomaly",
kind="grid",
units="mGal",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -148,6 +156,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_faaerror": GMTRemoteDataset(
description="IGPP Earth free-air anomaly errors",
kind="grid",
units="mGal",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -166,6 +175,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_gebco": GMTRemoteDataset(
description="GEBCO Earth relief",
kind="grid",
units="meters",
extra_attributes={"vertical_datum": "EGM96", "horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -188,6 +198,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_geoid": GMTRemoteDataset(
description="EGM2008 Earth geoid",
kind="grid",
units="meters",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -206,6 +217,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_igpp": GMTRemoteDataset(
description="IGPP Earth relief",
kind="grid",
units="meters",
extra_attributes={"vertical_datum": "EGM96", "horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -228,6 +240,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_mag": GMTRemoteDataset(
description="EMAG2 Earth Magnetic Anomaly Model",
kind="grid",
units="nT",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -245,6 +258,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_mask": GMTRemoteDataset(
description="GSHHG Earth mask",
kind="grid",
units=None,
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -265,6 +279,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_mss": GMTRemoteDataset(
description="CNES Earth mean sea surface",
kind="grid",
units="meters",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -283,6 +298,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_night": GMTRemoteDataset(
description="NASA Night Images",
kind="image",
units=None,
extra_attributes={"long_name": "black_marble", "horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -302,6 +318,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_mdt": GMTRemoteDataset(
description="CNES Earth mean dynamic topography",
kind="grid",
units="meters",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -315,6 +332,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_ndefl": GMTRemoteDataset(
description="IGPP Earth north-south deflection",
kind="grid",
units="micro-radians",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -333,6 +351,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_vgg": GMTRemoteDataset(
description="IGPP Earth vertical gravity gradient",
kind="grid",
units="Eotvos",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -351,6 +370,7 @@ class GMTRemoteDataset(NamedTuple):
),
"earth_wdmam": GMTRemoteDataset(
description="WDMAM World Digital Magnetic Anomaly Map",
kind="grid",
units="nT",
extra_attributes={"horizontal_datum": "WGS84"},
resolutions={
Expand All @@ -367,6 +387,7 @@ class GMTRemoteDataset(NamedTuple):
),
"mars_relief": GMTRemoteDataset(
description="NASA Mars (MOLA) relief",
kind="grid",
units="meters",
extra_attributes={},
resolutions={
Expand All @@ -388,6 +409,7 @@ class GMTRemoteDataset(NamedTuple):
),
"moon_relief": GMTRemoteDataset(
description="USGS Moon (LOLA) relief",
kind="grid",
units="meters",
extra_attributes={},
resolutions={
Expand All @@ -409,6 +431,7 @@ class GMTRemoteDataset(NamedTuple):
),
"mercury_relief": GMTRemoteDataset(
description="USGS Mercury relief",
kind="grid",
units="meters",
extra_attributes={},
resolutions={
Expand All @@ -428,6 +451,7 @@ class GMTRemoteDataset(NamedTuple):
),
"pluto_relief": GMTRemoteDataset(
description="USGS Pluto relief",
kind="grid",
units="meters",
extra_attributes={},
resolutions={
Expand All @@ -447,6 +471,7 @@ class GMTRemoteDataset(NamedTuple):
),
"venus_relief": GMTRemoteDataset(
description="NASA Magellan Venus relief",
kind="grid",
units="meters",
extra_attributes={},
resolutions={
Expand Down Expand Up @@ -545,15 +570,16 @@ def _load_remote_dataset(
raise GMTInvalidInput(msg)

fname = f"@{prefix}_{resolution}_{reg}"
kind = "image" if name in {"earth_day", "earth_night"} else "grid"
kwdict = {"R": region, "T": {"grid": "g", "image": "i"}[kind]}
kwdict = {"R": region, "T": {"grid": "g", "image": "i"}[dataset.kind]}
with Session() as lib:
with lib.virtualfile_out(kind=kind) as voutgrd:
with lib.virtualfile_out(kind=dataset.kind) as voutgrd:
lib.call_module(
module="read",
args=[fname, voutgrd, *build_arg_list(kwdict)],
)
grid = lib.virtualfile_to_raster(kind=kind, outgrid=None, vfname=voutgrd)
grid = lib.virtualfile_to_raster(
kind=dataset.kind, outgrid=None, vfname=voutgrd
)

# Full path to the grid if not tiled grids.
source = which(fname, download="a") if not resinfo.tiled else None
Expand Down

0 comments on commit e174fff

Please sign in to comment.