Skip to content
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

load_earth_relief: Add the support of data source "GEBCO" #1818

Merged
merged 39 commits into from
Oct 14, 2022

Conversation

willschlitzer
Copy link
Contributor

This pull request adds the GEBCO data source to load_earth_relief

Addresses #1786

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@willschlitzer
Copy link
Contributor Author

I'm running into an error when my machine is trying to find the cached version of the GEBCO files. When I run both grid = load_earth_relief(data_source="gebco", region = [0, 5, 10, 12]) and grid = pygmt.grdcut(grid="@earth_gebco_01d", region = [0, 5, 10, 12]) I get the following:

GMTCLibError: Module 'grdcut' failed with status code 16:
grdcut [ERROR]: Libcurl Error: HTTP response code said error
grdcut [ERROR]: File /home/will/.gmt/cache/earth_gebco_01d.grd was not found
grdcut [ERROR]: Cannot find file /home/will/.gmt/cache/earth_gebco_01d.grd
grdcut [ERROR]: File /home/will/.gmt/cache/earth_gebco_01d.grd was not found
grdcut [ERROR]: Cannot find file /home/will/.gmt/cache/earth_gebco_01d.grd
grdcut [ERROR]: File /home/will/.gmt/cache/earth_gebco_01d.grd not found

My guess is the issue is that the Earth GEBCO files are stored under .gmt/server/earth/earth_gebco rather than .gmt/cache. Is this a GMT error for how it finds the cached files?

@seisman
Copy link
Member

seisman commented Mar 15, 2022

What's the output if you run the following GMT command?

gmt grdcut @earth_gebco_01d -R0/5/10/20 -Gout.nc -Vd

@willschlitzer
Copy link
Contributor Author

willschlitzer commented Mar 15, 2022

gmt grdcut @earth_gebco_01d -R0/5/10/20 -Gout.nc -Vd

Same issue. Does it work for you?

Here is the output:

grdcut [NOTICE]:   -> Download grid file [105K]: earth_gebco_01d_g.grd
grdcut [INFORMATION]: Downloading file http://oceania.generic-mapping-tools.org/cache/earth_gebco_01d.grd ...
grdcut [ERROR]: Libcurl Error: HTTP response code said error
grdcut [WARNING]: You can turn remote file download off by setting GMT_DATA_UPDATE_INTERVAL to "off"
grdcut [DEBUG]: Delete /tmp/earth_gebco_01d.grd.download
grdcut [DEBUG]: Replace file @earth_gebco_01d.grd with /home/will/.gmt/cache/earth_gebco_01d.grd
grdcut [INFORMATION]: Processing input grid
grdcut [ERROR]: File /home/will/.gmt/cache/earth_gebco_01d.grd was not found
grdcut [ERROR]: Cannot find file /home/will/.gmt/cache/earth_gebco_01d.grd
grdcut [ERROR]: File /home/will/.gmt/cache/earth_gebco_01d.grd was not found
grdcut [ERROR]: Cannot find file /home/will/.gmt/cache/earth_gebco_01d.grd
grdcut [ERROR]: File /home/will/.gmt/cache/earth_gebco_01d.grd not found
[Session gmt (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16)

The file earth_gebco_01d_g.grd is in .gmt/server/earth/earth_gebco, so my guess is that GMT is looking in the wrong folder for the .grd file?

@weiji14
Copy link
Member

weiji14 commented Mar 15, 2022

I've got the same GMT_FILE_NOT_FOUND error when using grdcut, but using gmt which -Ga @earth_gebco_01d_g works:

gmt [INFORMATION]: Downloading file http://oceania.generic-mapping-tools.org/gmt_data_server.txt ...
gmt [INFORMATION]: Downloading file http://oceania.generic-mapping-tools.org/gmt_hash_server.txt ...
gmtwhich [INFORMATION]: Writing Data Table to Standard Output stream
gmtwhich [NOTICE]: Remote data courtesy of GMT data server oceania [http://oceania.generic-mapping-tools.org]

gmtwhich [NOTICE]: GEBCO Earth Relief at 1x1 arc degrees reduced by Gaussian Cartesian filtering (111.2 km fullwidth) [GEBCO Compilation Group, 2021 GEBCO 2021 Grid].
gmtwhich [NOTICE]:   -> Download grid file [105K]: earth_gebco_01d_g.grd
gmtwhich [INFORMATION]: Downloading file http://oceania.generic-mapping-tools.org/server/earth/earth_gebco/earth_gebco_01d_g.grd ...
/home/username/.gmt/server/earth/earth_gebco/earth_gebco_01d_g.grd

@willschlitzer
Copy link
Contributor Author

willschlitzer commented Mar 15, 2022

@weiji14 Does the use of which request a download from the remote server regardless or if it's cached, or will it use the cached version of the file if available? I was able to download the .grd and .nc files to .gmt/server/earth/earth_gebco.

@weiji14
Copy link
Member

weiji14 commented Mar 15, 2022

@weiji14 Does the use of which request a download from the remote server regardless or if it's cached, or will it use the cached version of the file if available? I was able to download the .grd and .nc files to .gmt/server/earth/earth_gebco.

It'll definitely take the local cached file. Looking at the verbose log though, which does seem to ping server network first to check for a new gmt_data_server.txt file and will pull an update if needed.

@maxrjones
Copy link
Member

These issues could be related to GenericMappingTools/gmt#6160. I would be curious if it works after deleting ~/.gmt/server/gmt_data_server.txt

@willschlitzer
Copy link
Contributor Author

These issues could be related to GenericMappingTools/gmt#6160. I would be curious if it works after deleting ~/.gmt/server/gmt_data_server.txt

Just deleted both gmt_data_server.txt and gmt_data_server,tx.old; same result

@seisman seisman added this to the 0.7.0 milestone Mar 18, 2022
@maxrjones
Copy link
Member

gmt grdcut @earth_gebco_01d -R0/5/10/20 -Gout.nc -Vd fails for me with GMT 6.3.0 but works with the main branch, due to the fix applied in GenericMappingTools/gmt#6160. We may want to wait until after the GMT 6.4.0 release to add support for earth_gebco and earth_geoid.

@seisman seisman modified the milestones: 0.7.0, 0.8.0 Jun 19, 2022
@willschlitzer willschlitzer marked this pull request as ready for review September 13, 2022 13:21
@willschlitzer willschlitzer marked this pull request as draft September 13, 2022 13:22
@willschlitzer willschlitzer marked this pull request as ready for review September 13, 2022 14:19
@willschlitzer
Copy link
Contributor Author

How extensively should this be testing load_earth_relief with data_source="gebco"? I don't want to duplicate all of the tests for Earth relief using SRTM data, as that seems excessive, so I just added tests using 1-degree resolution with and without setting region.

@seisman seisman added the enhancement Improving an existing feature label Sep 14, 2022
@seisman
Copy link
Member

seisman commented Sep 14, 2022

How extensively should this be testing load_earth_relief with data_source="gebco"? I don't want to duplicate all of the tests for Earth relief using SRTM data, as that seems excessive, so I just added tests using 1-degree resolution with and without setting region.

Yes, I agree.

pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
@@ -55,9 +61,19 @@ def load_earth_relief(resolution="01d", region=None, registration=None, use_srtm
use_srtm : bool
By default, the land-only SRTM tiles from NASA are used to generate the
``"03s"`` and ``"01s"`` grids, and the missing ocean values are filled
by up-sampling the SRTM15+ tiles which have a resolution of 15
by up-sampling the SRTM15+V2.1 tiles which have a resolution of 15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be v2.4 now according to https://web.archive.org/web/20220809113153/https://www.generic-mapping-tools.org/remote-datasets/earth-relief.html

Suggested change
by up-sampling the SRTM15+V2.1 tiles which have a resolution of 15
by up-sampling the SRTM15+V2.4 tiles which have a resolution of 15

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to update "Refer to https://www.generic-mapping-tools.org/remote-datasets/earth-relief.html for more details." above to "Refer to https://www.generic-mapping-tools.org/remote-datasets/index.html for more details about available datasets, including version information and references." so that we don't need to update this on each SRTM15+ release and the link provided is more generic.

pygmt/datasets/earth_relief.py Show resolved Hide resolved
pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
@weiji14
Copy link
Member

weiji14 commented Oct 7, 2022

Need to add @earth_gebco_01d to the cache too at pygmt/helpers/testing.py right?

@weiji14 weiji14 added feature Brand new feature and removed enhancement Improving an existing feature labels Oct 7, 2022
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Oct 10, 2022
@seisman
Copy link
Member

seisman commented Oct 12, 2022

@GenericMappingTools/pygmt-maintainers Can someone else give this PR a final review before we merge it?

pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
pygmt/helpers/testing.py Outdated Show resolved Hide resolved
pygmt/tests/test_datasets_earth_relief.py Outdated Show resolved Hide resolved
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks @willschlitzer!

@seisman seisman merged commit f1af459 into main Oct 14, 2022
@seisman seisman deleted the load-earth-relief/multiple-sources branch October 14, 2022 04:38
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Oct 14, 2022
@seisman seisman changed the title Add GEBCO data source to load_earth_relief load_earth_relief: Add the support of data source "GEBCO" Nov 30, 2022
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Brand new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants