|
7 | 7 | from typing import Any, Literal, NamedTuple |
8 | 8 |
|
9 | 9 | import xarray as xr |
10 | | -from pygmt.clib import Session |
11 | 10 | from pygmt.exceptions import GMTInvalidInput |
12 | | -from pygmt.helpers import build_arg_list, kwargs_to_strings |
13 | | -from pygmt.src import which |
14 | 11 |
|
15 | 12 | with contextlib.suppress(ImportError): |
16 | 13 | # rioxarray is needed to register the rio accessor |
@@ -502,7 +499,6 @@ class GMTRemoteDataset(NamedTuple): |
502 | 499 | } |
503 | 500 |
|
504 | 501 |
|
505 | | -@kwargs_to_strings(region="sequence") |
506 | 502 | def _load_remote_dataset( |
507 | 503 | name: str, |
508 | 504 | prefix: str, |
@@ -581,22 +577,9 @@ def _load_remote_dataset( |
581 | 577 | raise GMTInvalidInput(msg) |
582 | 578 |
|
583 | 579 | fname = f"@{prefix}_{resolution}_{reg}" |
584 | | - kwdict = {"R": region, "T": {"grid": "g", "image": "i"}[dataset.kind]} |
585 | | - with Session() as lib: |
586 | | - with lib.virtualfile_out(kind=dataset.kind) as voutgrd: |
587 | | - lib.call_module( |
588 | | - module="read", |
589 | | - args=[fname, voutgrd, *build_arg_list(kwdict)], |
590 | | - ) |
591 | | - grid = lib.virtualfile_to_raster( |
592 | | - kind=dataset.kind, outgrid=None, vfname=voutgrd |
593 | | - ) |
594 | | - |
595 | | - # Full path to the grid if not tiled grids. |
596 | | - source = which(fname, download="a") if not resinfo.tiled else None |
597 | | - # Manually add source to xarray.DataArray encoding to make the GMT accessors work. |
598 | | - if source: |
599 | | - grid.encoding["source"] = source |
| 580 | + grid = xr.load_dataarray( |
| 581 | + fname, engine="gmt", raster_kind=dataset.kind, region=region |
| 582 | + ) |
600 | 583 |
|
601 | 584 | # Add some metadata to the grid |
602 | 585 | grid.attrs["description"] = dataset.description |
|
0 commit comments