Skip to content

Commit c8cc6fc

Browse files
Rephrase the documentation for dataset loading functions (#3838)
Co-authored-by: Yvonne Fröhlich <[email protected]>
1 parent 0d31234 commit c8cc6fc

19 files changed

+414
-347
lines changed

pygmt/datasets/earth_age.py

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,29 @@ def load_earth_age(
3030
3131
Earth seafloor crustal age dataset.
3232
33-
The grids are downloaded to a user data directory
34-
(usually ``~/.gmt/server/earth/earth_age/``) the first time you invoke
35-
this function. Afterwards, it will load the grid from the data directory.
36-
So you'll need an internet connection the first time around.
37-
38-
These grids can also be accessed by passing in the file name
39-
**@earth_age**\_\ *res*\[_\ *reg*] to any grid processing function or
40-
plotting method. *res* is the grid resolution (see below), and *reg* is
41-
the grid registration type (**p** for pixel registration or **g** for
42-
the gridline registration).
43-
44-
The default color palette table (CPT) for this dataset is *@earth_age.cpt*.
45-
It's implicitly used when passing in the file name of the dataset to any
46-
grid plotting method if no CPT is explicitly specified. When the dataset
47-
is loaded and plotted as an :class:`xarray.DataArray` object, the default
48-
CPT is ignored, and GMT's default CPT (*turbo*) is used. To use the
49-
dataset-specific CPT, you need to explicitly set ``cmap="@earth_age.cpt"``.
50-
51-
Refer to :gmt-datasets:`earth-age.html` for more details about available
52-
datasets, including version information and references.
33+
This function downloads the dataset from the GMT data server, caches it in a user
34+
data directory (usually ``~/.gmt/server/earth/earth_age/``), and load the dataset as
35+
an :class:`xarray.DataArray`. An internet connection is required the first time
36+
around, but subsequent calls will load the dataset from the local data directory.
37+
38+
The dataset can also be accessed by specifying a file name in any grid processing
39+
function or plotting method, using the following file name format:
40+
**@earth_age**\_\ *res*\_\ *reg*. *res* is the grid resolution; *reg* is the grid
41+
registration type (**p** for pixel registration, **g** for gridline registration).
42+
If *reg* is omitted (e.g., ``@earth_age_01d``), the gridline-registered grid will be
43+
loaded for grid proccessing functions and the pixel-registered grid will be loaded
44+
for plotting functions. If *res* is also omitted (i.e., ``@earth_age``), GMT
45+
automatically selects a suitable resolution based on the current region and
46+
projection settings.
47+
48+
This dataset comes with a color palette table (CPT) file, ``@earth_age.cpt``. To use
49+
the dataset-specific CPT when plotting the dataset, explicitly set
50+
``cmap="@earth_age.cpt"``, otherwise GMT's default CPT (*turbo*) will be used. If
51+
the dataset is referenced by the file name in a grid plotting method, the
52+
dataset-specific CPT file is used automatically unless another CPT is specified.
53+
54+
Refer to :gmt-datasets:`earth-age.html` for more details about available datasets,
55+
including version information and references.
5356
5457
Parameters
5558
----------
@@ -67,29 +70,28 @@ def load_earth_age(
6770
Returns
6871
-------
6972
grid
70-
The Earth seafloor crustal age grid. Coordinates are latitude and
71-
longitude in degrees. Age is in millions of years (Myr).
73+
The Earth seafloor crustal age grid. Coordinates are latitude and longitude in
74+
degrees. Age is in millions of years (Myr).
7275
7376
Note
7477
----
7578
The registration and coordinate system type of the returned
76-
:class:`xarray.DataArray` grid can be accessed via the GMT accessors
77-
(i.e., ``grid.gmt.registration`` and ``grid.gmt.gtype`` respectively).
78-
However, these properties may be lost after specific grid operations (such
79-
as slicing) and will need to be manually set before passing the grid to any
80-
PyGMT data processing or plotting functions. Refer to
81-
:class:`pygmt.GMTDataArrayAccessor` for detailed explanations and
82-
workarounds.
79+
:class:`xarray.DataArray` grid can be accessed via the GMT accessors (i.e.,
80+
``grid.gmt.registration`` and ``grid.gmt.gtype`` respectively). However, these
81+
properties may be lost after specific grid operations (such as slicing) and will
82+
need to be manually set before passing the grid to any PyGMT data processing or
83+
plotting functions. Refer to :class:`pygmt.GMTDataArrayAccessor` for detailed
84+
explanations and workarounds.
8385
8486
Examples
8587
--------
8688
8789
>>> from pygmt.datasets import load_earth_age
88-
>>> # load the default grid (gridline-registered 1 arc-degree grid)
90+
>>> # Load the default grid (gridline-registered 1 arc-degree grid)
8991
>>> grid = load_earth_age()
90-
>>> # load the 30 arc-minutes grid with "gridline" registration
92+
>>> # Load the 30 arc-minutes grid with "gridline" registration
9193
>>> grid = load_earth_age(resolution="30m", registration="gridline")
92-
>>> # load high-resolution (5 arc-minutes) grid for a specific region
94+
>>> # Load high-resolution (5 arc-minutes) grid for a specific region
9395
>>> grid = load_earth_age(
9496
... resolution="05m",
9597
... region=[120, 160, 30, 60],

pygmt/datasets/earth_day.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,17 @@ def load_blue_marble(
4545
4646
Earth day/night dataset.
4747
48-
The images are downloaded to a user data directory (usually
49-
``~/.gmt/server/earth/earth_day/``) the first time you invoke this function.
50-
Afterwards, it will load the image from the data directory. So you'll need an
51-
internet connection the first time around.
5248
53-
These images can also be accessed by passing in the file name
54-
**@earth_day**\_\ *res* to any image processing function or plotting method. *res*
55-
is the image resolution (see below).
49+
This function downloads the dataset from the GMT data server, caches it in a user
50+
data directory (usually ``~/.gmt/server/earth/earth_day/``), and load the dataset as
51+
an :class:`xarray.DataArray`. An internet connection is required the first time
52+
around, but subsequent calls will load the dataset from the local data directory.
53+
54+
The dataset can also be accessed by specifying a file name in any image processing
55+
function or plotting method, using the following file name format:
56+
**@earth_day**\_\ *res*. *res* is the image resolution. If *res* is omitted (i.e.,
57+
``@earth_day``), GMT automatically selects a suitable resolution based on the
58+
current region and projection settings.
5659
5760
Refer to :gmt-datasets:`earth-daynight.html` for more details about available
5861
datasets, including version information and references.
@@ -85,7 +88,7 @@ def load_blue_marble(
8588
--------
8689
8790
>>> from pygmt.datasets import load_blue_marble
88-
>>> # load the default image (pixel-registered 1 arc-degree image)
91+
>>> # Load the default image (pixel-registered 1 arc-degree image)
8992
>>> image = load_blue_marble()
9093
"""
9194
image = _load_remote_dataset(

pygmt/datasets/earth_deflection.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,29 @@ def load_earth_deflection(
3535
* - .. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_edefl.jpg
3636
- .. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_ndefl.jpg
3737
38-
The grids are downloaded to a user data directory (usually
39-
``~/.gmt/server/earth/earth_edefl/`` and ``~/.gmt/server/earth/earth_ndefl/`` the
40-
first time you invoke this function. Afterwards, it will load the grid from the
41-
data directory. So you'll need an internet connection the first time around.
42-
43-
These grids can also be accessed by passing in the file name
44-
**@**\ *earth_defl_type*\_\ *res*\[_\ *reg*] to any grid processing function or
45-
plotting method. *earth_defl_type* is the GMT name for the dataset. The available
46-
options are **earth_edefl** and **earth_ndefl**. *res* is the grid resolution (see
47-
below), and *reg* is the grid registration type (**p** for pixel registration or
48-
**g** for gridline registration).
49-
50-
The default color palette table (CPTs) for this dataset is *@earth_defl.cpt*. It's
51-
implicitly used when passing in the file name of the dataset to any grid plotting
52-
method if no CPT is explicitly specified. When the dataset is loaded and plotted as
53-
an :class:`xarray.DataArray` object, the default CPT is ignored, and GMT's default
54-
CPT (*turbo*) is used. To use the dataset-specific CPT, you need to explicitly set
55-
``cmap="@earth_defl.cpt"``.
38+
39+
This function downloads the dataset from the GMT data server, caches it in a user
40+
data directory (usually ``~/.gmt/server/earth/earth_edefl/`` and
41+
``~/.gmt/server/earth/earth_ndefl/``), and load the dataset as an
42+
:class:`xarray.DataArray`. An internet connection is required the first time around,
43+
but subsequent calls will load the dataset from the local data directory.
44+
45+
The datasets can also be accessed by specifying a file name in any grid processing
46+
function or plotting method, using the following file name format:
47+
**@**\ *earth_defl_type*\_\ *res*\_\ *reg*. *earth_defl_type* is the GMT name for
48+
the dataset. The available options are **earth_edefl** and **earth_ndefl**; *res* is
49+
the grid resolution; *reg* is the grid registration type (**p** for pixel
50+
registration, **g** for gridline registration). If *reg* is omitted (e.g.,
51+
``@earth_edefl_01d``), the gridline-registered grid will be loaded for grid
52+
proccessing functions and the pixel-registered grid will be loaded for plotting
53+
functions. If *res* is also omitted (i.e., ``@earth_edefl``), GMT automatically
54+
selects a suitable resolution based on the current region and projection settings.
55+
56+
This dataset comes with a color palette table (CPT) file, ``@earth_defl.cpt``. To
57+
use the dataset-specific CPT when plotting the dataset, explicitly set
58+
``cmap="@earth_defl.cpt"``, otherwise GMT's default CPT (*turbo*) will be used. If
59+
the dataset is referenced by the file name in a grid plotting method, the
60+
dataset-specific CPT file is used automatically unless another CPT is specified.
5661
5762
Refer to :gmt-datasets:`earth-edefl.html` and :gmt-datasets:`earth-ndefl.html` for
5863
more details about available datasets, including version information and references.
@@ -96,14 +101,14 @@ def load_earth_deflection(
96101
--------
97102
98103
>>> from pygmt.datasets import load_earth_deflection
99-
>>> # load the default grid for east-west deflection (gridline-registered
104+
>>> # Load the default grid for east-west deflection (gridline-registered
100105
>>> # 1 arc-degree grid)
101106
>>> grid = load_earth_deflection()
102-
>>> # load the default grid for north-south deflection
107+
>>> # Load the default grid for north-south deflection
103108
>>> grid = load_earth_deflection(component="north")
104-
>>> # load the 30 arc-minutes grid with "gridline" registration
109+
>>> # Load the 30 arc-minutes grid with "gridline" registration
105110
>>> grid = load_earth_deflection(resolution="30m", registration="gridline")
106-
>>> # load high-resolution (5 arc-minutes) grid for a specific region
111+
>>> # Load high-resolution (5 arc-minutes) grid for a specific region
107112
>>> grid = load_earth_deflection(
108113
... resolution="05m", region=[120, 160, 30, 60], registration="gridline"
109114
... )

pygmt/datasets/earth_dist.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,26 @@ def load_earth_dist(
3030
3131
GSHHG Earth distance to shoreline dataset.
3232
33-
The grids are downloaded to a user data directory (usually
34-
``~/.gmt/server/earth/earth_dist/``) the first time you invoke this function.
35-
Afterwards, it will load the grid from the data directory. So you'll need an
36-
internet connection the first time around.
37-
38-
These grids can also be accessed by passing in the file name
39-
**@earth_dist**\_\ *res*\[_\ *reg*] to any grid processing function or plotting
40-
method. *res* is the grid resolution (see below), and *reg* is the grid registration
41-
type (**p** for pixel registration or **g** for gridline registration).
42-
43-
The default color palette table (CPT) for this dataset is *@earth_dist.cpt*. It's
44-
implicitly used when passing in the file name of the dataset to any grid plotting
45-
method if no CPT is explicitly specified. When the dataset is loaded and plotted
46-
as an :class:`xarray.DataArray` object, the default CPT is ignored, and GMT's
47-
default CPT (*turbo*) is used. To use the dataset-specific CPT, you need to
48-
explicitly set ``cmap="@earth_dist.cpt"``.
33+
This function downloads the dataset from the GMT data server, caches it in a user
34+
data directory (usually ``~/.gmt/server/earth/earth_dist/``), and load the dataset
35+
as an :class:`xarray.DataArray`. An internet connection is required the first time
36+
around, but subsequent calls will load the dataset from the local data directory.
37+
38+
The dataset can also be accessed by specifying a file name in any grid processing
39+
function or plotting method, using the following file name format:
40+
**@earth_dist**\_\ *res*\_\ *reg*. *res* is the grid resolution; *reg* is the grid
41+
registration type (**p** for pixel registration, **g** for gridline registration).
42+
If *reg* is omitted (e.g., ``@earth_dist_01d``), the gridline-registered grid will
43+
be loaded for grid proccessing functions and the pixel-registered grid will be
44+
loaded for plotting functions. If *res* is also omitted (i.e., ``@earth_dist``), GMT
45+
automatically selects a suitable resolution based on the current region and
46+
projection settings.
47+
48+
This dataset comes with a color palette table (CPT) file, ``@earth_dist.cpt``. To
49+
use the dataset-specific CPT when plotting the dataset, explicitly set
50+
``cmap="@earth_dist.cpt"``, otherwise GMT's default CPT (*turbo*) will be used. If
51+
the dataset is referenced by the file name in a grid plotting method, the
52+
dataset-specific CPT file is used automatically unless another CPT is specified.
4953
5054
Refer to :gmt-datasets:`earth-dist.html` for more details about available datasets,
5155
including version information and references.
@@ -84,11 +88,11 @@ def load_earth_dist(
8488
--------
8589
8690
>>> from pygmt.datasets import load_earth_dist
87-
>>> # load the default grid (gridline-registered 1 arc-degree grid)
91+
>>> # Load the default grid (gridline-registered 1 arc-degree grid)
8892
>>> grid = load_earth_dist()
89-
>>> # load the 30 arc-minutes grid with "gridline" registration
93+
>>> # Load the 30 arc-minutes grid with "gridline" registration
9094
>>> grid = load_earth_dist(resolution="30m", registration="gridline")
91-
>>> # load high-resolution (5 arc-minutes) grid for a specific region
95+
>>> # Load high-resolution (5 arc-minutes) grid for a specific region
9296
>>> grid = load_earth_dist(
9397
... resolution="05m",
9498
... region=[120, 160, 30, 60],

pygmt/datasets/earth_free_air_anomaly.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,30 @@ def load_earth_free_air_anomaly(
3535
* - .. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_faa.jpg
3636
- .. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_faaerror.jpg
3737
38-
The grids are downloaded to a user data directory (usually
39-
``~/.gmt/server/earth/earth_faa/`` or ``~/.gmt/server/earth/earth_faaerror/``) the
40-
first time you invoke this function. Afterwards, it will load the grid from data
41-
directory. So you'll need an internet connection the first time around.
42-
43-
These grids can also be accessed by passing in the file name
44-
**@earth_faa_type**\_\ *res*\[_\ *reg*] to any grid processing function or
45-
plotting method. *earth_faa_type* is the GMT name for the dataset. The available
46-
options are **earth_faa** and **earth_faaerror**. *res* is the grid resolution (see
47-
below), and *reg* is the grid registration type (**p** for pixel registration or
48-
**g** for gridline registration).
49-
50-
The default color palette tables (CPTs) for these datasets are *@earth_faa.cpt* and
51-
*@earth_faaerror.cpt*. The dataset-specific CPT is implicitly used when passing in
52-
the file name of the dataset to any grid plotting method if no CPT is explicitly
53-
specified. When the dataset is loaded and plotted as an :class:`xarray.DataArray`
54-
object, the default CPT is ignored, and GMT's default CPT (*turbo*) is used. To use
55-
the dataset-specific CPT, you need to explicitly set ``cmap="@earth_faa.cpt"`` or
56-
``cmap="@earth_faaerror.cpt"``.
38+
39+
This function downloads the dataset from the GMT data server, caches it in a user
40+
data directory (usually ``~/.gmt/server/earth/earth_faa/`` or
41+
``~/.gmt/server/earth/earth_faaerror/``), and load the dataset as an
42+
:class:`xarray.DataArray`. An internet connection is required the first time around,
43+
but subsequent calls will load the dataset from the local data directory.
44+
45+
The dataset can also be accessed by specifying a file name in any grid processing
46+
function or plotting method, using the following file name format:
47+
**@**\ *earth_faa_type*\_\ *res*\_\ *reg*. *earth_faa_type* is the GMT name for the
48+
dataset. The available options are **earth_faa** and **earth_faaerror**. *res* is
49+
the grid resolution; *reg* is the grid registration type (**p** for pixel
50+
registration, **g** for gridline registration). If *reg* is omitted (e.g.,
51+
``@earth_faa_01d``), the gridline-registered grid will be loaded for grid
52+
proccessing functions and the pixel-registered grid will be loaded for plotting
53+
functions. If *res* is also omitted (i.e., ``@earth_faa``), GMT automatically
54+
selects a suitable resolution based on the current region and projection settings.
55+
56+
This dataset comes with two color palette table (CPT) files, ``@earth_faa.cpt`` and
57+
``@earth_faaerror.cpt``. To use the dataset-specific CPT when plotting the dataset,
58+
explicitly set ``cmap="@earth_faa.cpt"`` or ``cmap="@earth_faaerror.cpt"``,
59+
otherwise GMT's default CPT (*turbo*) will be used. If the dataset is referenced by
60+
the file name in a grid plotting method, the dataset-specific CPT file is used
61+
automatically unless another CPT is specified.
5762
5863
Refer to :gmt-datasets:`earth-faa.html` and :gmt-datasets:`earth-faaerror.html` for
5964
more details about available datasets, including version information and references.
@@ -96,13 +101,13 @@ def load_earth_free_air_anomaly(
96101
--------
97102
98103
>>> from pygmt.datasets import load_earth_free_air_anomaly
99-
>>> # load the default grid (gridline-registered 1 arc-degree grid)
104+
>>> # Load the default grid (gridline-registered 1 arc-degree grid)
100105
>>> grid = load_earth_free_air_anomaly()
101-
>>> # load the uncertainties related to the default grid
106+
>>> # Load the uncertainties related to the default grid
102107
>>> grid = load_earth_free_air_anomaly(uncertainty=True)
103-
>>> # load the 30 arc-minutes grid with "gridline" registration
108+
>>> # Load the 30 arc-minutes grid with "gridline" registration
104109
>>> grid = load_earth_free_air_anomaly(resolution="30m", registration="gridline")
105-
>>> # load high-resolution (5 arc-minutes) grid for a specific region
110+
>>> # Load high-resolution (5 arc-minutes) grid for a specific region
106111
>>> grid = load_earth_free_air_anomaly(
107112
... resolution="05m", region=[120, 160, 30, 60], registration="gridline"
108113
... )

0 commit comments

Comments
 (0)