-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote datasets: Add "uncertainty" parameter to "load_earth_free_air_anomaly" to load the "free-air anomaly uncertainty" dataset #3727
Changes from 11 commits
a6ca401
fcd3a3d
0a96819
a2c2116
b45d24c
ca94508
8dfa23c
3ba3b8a
b220050
b167338
f9cbab6
c880fcf
0e85bf6
6154ede
552f761
8245f6d
1532541
9898ec5
d6cfac4
e4ee230
945a301
2e24b2d
6e366e3
523e108
f44bf48
e8b1b81
189cb3a
5d8c606
4665c61
50d928e
a1bb505
4b93a73
0c84b68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,6 +10,7 @@ | |||||
|
||||||
import xarray as xr | ||||||
from pygmt.datasets.load_remote_dataset import _load_remote_dataset | ||||||
from pygmt.exceptions import GMTInvalidInput | ||||||
|
||||||
__doctest_skip__ = ["load_earth_free_air_anomaly"] | ||||||
|
||||||
|
@@ -20,36 +21,42 @@ | |||||
] = "01d", | ||||||
region: Sequence[float] | str | None = None, | ||||||
registration: Literal["gridline", "pixel", None] = None, | ||||||
data_source: Literal["faa", "faaerror"] = "faa", | ||||||
) -> xr.DataArray: | ||||||
r""" | ||||||
Load the IGPP Earth free-air anomaly dataset in various resolutions. | ||||||
yvonnefroehlich marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
.. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_faa.jpg | ||||||
:width: 80 % | ||||||
:align: center | ||||||
.. list-table:: | ||||||
:widths: 50 50 | ||||||
:header-rows: 1 | ||||||
|
||||||
IGPP Earth free-air anomaly dataset. | ||||||
* - IGPP Earth Free-Air Anomaly | ||||||
- IGPP Earth Free-Air Anomaly Errors | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm. I used the name for the upstream docs at https://www.generic-mapping-tools.org/remote-datasets/earth-faaerror.html. But I was wondering, if "uncertainty" is better, as it is used in the docstrings. Maybe we should also update the upstream docs; I can include this in PR GenericMappingTools/remote-datasets#128 if approved. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The GMT remote-dataset docs is inconsistenly using "error" and "uncertainty", while the officiail README file (https://topex.ucsd.edu/pub/global_grav_1min/README_V32.txt) uses "uncertainty":
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made commit GenericMappingTools/remote-datasets@5aa5e58 for changing this in the GMT remote-dataset docs. But we stick to "error" in the GMT dataset name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think faaerror is fine. |
||||||
* - .. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_faa.jpg | ||||||
- .. figure:: https://www.generic-mapping-tools.org/remote-datasets/_images/GMT_earth_faaerror.jpg | ||||||
|
||||||
The grids are downloaded to a user data directory | ||||||
(usually ``~/.gmt/server/earth/earth_faa/``) the first time you invoke | ||||||
this function. Afterwards, it will load the grid from the data directory. | ||||||
So you'll need an internet connection the first time around. | ||||||
The grids are downloaded to a user data directory (usually | ||||||
``~/.gmt/server/earth/earth_faa/`` or ``~/.gmt/server/earth/earth_faaerror/``) the | ||||||
first time you invoke this function. Afterwards, it will load the grid from data | ||||||
directory. So you'll need an internet connection the first time around. | ||||||
|
||||||
These grids can also be accessed by passing in the file name | ||||||
**@earth_faa**\_\ *res*\[_\ *reg*] to any grid processing function or | ||||||
plotting method. *res* is the grid resolution (see below), and *reg* is | ||||||
the grid registration type (**p** for pixel registration or **g** for | ||||||
gridline registration). | ||||||
|
||||||
The default color palette table (CPT) for this dataset is *@earth_faa.cpt*. | ||||||
It's implicitly used when passing in the file name of the dataset to any | ||||||
grid plotting method if no CPT is explicitly specified. When the dataset | ||||||
is loaded and plotted as an :class:`xarray.DataArray` object, the default | ||||||
CPT is ignored, and GMT's default CPT (*turbo*) is used. To use the | ||||||
dataset-specific CPT, you need to explicitly set ``cmap="@earth_faa.cpt"``. | ||||||
|
||||||
Refer to :gmt-datasets:`earth-faa.html` for more details about available | ||||||
datasets, including version information and references. | ||||||
**@earth_faa_type**\_\ *res*\[_\ *reg*] to any grid processing function or | ||||||
plotting method. *earth_faa_type* is the GMT name for the dataset. The available | ||||||
options are **earth_faa** and **earth_faaerror**. *res* is the grid resolution | ||||||
(see below), and *reg* is the grid registration type (**p** for pixel registration | ||||||
or **g** for gridline registration). | ||||||
|
||||||
The default color palette tables (CPTs) for these datasets are *@earth_faa.cpt* and | ||||||
*@earth_faaerror.cpt*. The dataset-specific CPT is implicitly used when passing in | ||||||
the file name of the dataset to any grid plotting method if no CPT is explicitly | ||||||
specified. When the dataset is loaded and plotted as an :class:`xarray.DataArray` | ||||||
object, the default CPT is ignored, and GMT's default CPT (*turbo*) is used. To use | ||||||
the dataset-specific CPT, you need to explicitly set ``cmap="@earth_faa.cpt"`` or | ||||||
``cmap="@earth_faaerror.cpt"``. | ||||||
|
||||||
Refer to :gmt-datasets:`earth-faa.html` and :gmt-datasets:`earth-faaerror.html` for | ||||||
more details about available datasets, including version information and references. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
|
@@ -63,8 +70,12 @@ | |||||
registration | ||||||
Grid registration type. Either ``"pixel"`` for pixel registration or | ||||||
``"gridline"`` for gridline registration. Default is ``None``, means | ||||||
``"gridline"`` for all resolutions except ``"01m"`` which is | ||||||
``"pixel"`` only. | ||||||
``"gridline"`` for all resolutions except ``"01m"`` which is ``"pixel"`` only. | ||||||
data_source | ||||||
Select the free air anomaly data. Available options are: | ||||||
|
||||||
- ``"faa"``: Altimetry-based marine free-air anomaly values. | ||||||
- ``"faaerror"``: Uncertainties to the free-air anomaly values. | ||||||
|
||||||
Returns | ||||||
------- | ||||||
|
@@ -75,13 +86,12 @@ | |||||
Note | ||||||
---- | ||||||
The registration and coordinate system type of the returned | ||||||
:class:`xarray.DataArray` grid can be accessed via the GMT accessors | ||||||
(i.e., ``grid.gmt.registration`` and ``grid.gmt.gtype`` respectively). | ||||||
However, these properties may be lost after specific grid operations (such | ||||||
as slicing) and will need to be manually set before passing the grid to any | ||||||
PyGMT data processing or plotting functions. Refer to | ||||||
:class:`pygmt.GMTDataArrayAccessor` for detailed explanations and | ||||||
workarounds. | ||||||
:class:`xarray.DataArray` grid can be accessed via the GMT accessors (i.e., | ||||||
``grid.gmt.registration`` and ``grid.gmt.gtype`` respectively). However, these | ||||||
properties may be lost after specific grid operations (such as slicing) and will | ||||||
need to be manually set before passing the grid to any PyGMT data processing or | ||||||
plotting functions. Refer to :class:`pygmt.GMTDataArrayAccessor` for detailed | ||||||
explanations and workarounds. | ||||||
|
||||||
Examples | ||||||
-------- | ||||||
|
@@ -93,14 +103,23 @@ | |||||
>>> grid = load_earth_free_air_anomaly(resolution="30m", registration="gridline") | ||||||
>>> # load high-resolution (5 arc-minutes) grid for a specific region | ||||||
>>> grid = load_earth_free_air_anomaly( | ||||||
... resolution="05m", | ||||||
... region=[120, 160, 30, 60], | ||||||
... registration="gridline", | ||||||
... resolution="05m", region=[120, 160, 30, 60], registration="gridline" | ||||||
... ) | ||||||
""" | ||||||
# Map data source to prefix | ||||||
prefix = { | ||||||
"faa": "earth_faa", | ||||||
"faaerror": "earth_faaerror", | ||||||
}.get(data_source) | ||||||
if prefix is None: | ||||||
msg = ( | ||||||
f"Invalid earth free air anomaly data source '{data_source}'. " | ||||||
"Valid values are 'faa' and 'faaerror'." | ||||||
) | ||||||
raise GMTInvalidInput(msg) | ||||||
grid = _load_remote_dataset( | ||||||
name="earth_faa", | ||||||
prefix="earth_faa", | ||||||
name=prefix, | ||||||
prefix=prefix, | ||||||
resolution=resolution, | ||||||
region=region, | ||||||
registration=registration, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the parameter name
data_source
here, since these two datasets acutally comes from the same source.Maybe
uncertainty=True
to use thefaaerror
data?