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

Feature: add etopo plotting to stock_img #1747

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

smartlixx
Copy link
Contributor

@smartlixx smartlixx commented Mar 13, 2021

Rationale

Close #1734

Implications

None as far as I can see.

Example

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

fig = plt.figure(figsize=[4, 6])
ax1 = fig.add_subplot(2, 1, 1, projection=ccrs.PlateCarree())
ax2 = fig.add_subplot(2, 1, 2, projection=ccrs.Orthographic())

ax1.stock_img(name='etopo')
ax1.coastlines()
ax2.stock_img(name='etopo')
ax2.coastlines()

plt.show()

The output is
Cartopy_etopo1

lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
@dopplershift
Copy link
Contributor

Currently the PR is showing an empty etopo1.jpg committed? Any reason that needs to be included?

@smartlixx
Copy link
Contributor Author

The file etopo1.jpg is not empty. its size is 1.28M (64 dpi). it is the picture of the bathymetry data to plot. I took it from Basemao repo, because the original file downloaded from NOAA is about 2M (96 dpi). This file definitely will increase the size of cartopy. Alternatively, we can download it on the fly from NOAA website. Please let me know your opinion.

@greglucas
Copy link
Contributor

I think grabbing it from the source is better whenever possible, that way we get any updates they have. It also looks like there are multiple "versions" of etopo, focusing on ice, or other features too? It looks like the original data is 300+MB! I didn't see the downsampled version immediately on NOAA's site, do you have a link to that?

@smartlixx
Copy link
Contributor Author

I think grabbing it from the source is better whenever possible, that way we get any updates they have. It also looks like there are multiple "versions" of etopo, focusing on ice, or other features too? It looks like the original data is 300+MB! I didn't see the downsampled version immediately on NOAA's site, do you have a link to that?

When you click on the thumbnail on https://www.ngdc.noaa.gov/mgg/global/, you will get to the downsampled version of etopo1: https://www.ngdc.noaa.gov/mgg/image/color_etopo1_ice_low.jpg.

Yes, there are several versions of this dataset, depending on using the ice top or the ice bottom for altitude. The above link should suffice for our purpose. If we choose to grab it on the fly, its size is about 2M.

lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
@smartlixx
Copy link
Contributor Author

Now I have modified the code to download the etopo1 image from NOAA website, and delete the etopo1.jpg file from the commit.

@smartlixx smartlixx force-pushed the FEAT_add_etopo1 branch 2 times, most recently from 8a0abd2 to 8617bc2 Compare March 29, 2021 09:16
@smartlixx smartlixx changed the title Feature: add etopo1 plotting to stock_img Feature: add etopo plotting to stock_img Mar 29, 2021
@dopplershift
Copy link
Contributor

Can you rebase your commits to "squash" together the original commit adding the file and the one deleting it? Otherwise, there will be a copy of the 1.3MB file sitting in the history for this repo.

@smartlixx
Copy link
Contributor Author

Can you rebase your commits to "squash" together the original commit adding the file and the one deleting it? Otherwise, there will be a copy of the 1.3MB file sitting in the history for this repo.

Thanks. I squashed all the commits into one.

The test failure message below seems not to be related with this PR.

FAILED lib/cartopy/tests/mpl/test_ticks.py::test_set_xticks_no_transform - Fi...

@marqh
Copy link
Member

marqh commented Oct 14, 2021

this PR appears to be reviwed and have passing tests, but there are conflicts between it and master

@smartlixx please may i suggest that you rebase this PR branch with respect to upstream/master

i would hope that reviewers would then be able to re-assess and potentially merge this onto master

@dopplershift @QuLogic is this reasonable from your points of view?

lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
lib/cartopy/tests/mpl/test_images.py Outdated Show resolved Hide resolved
lib/cartopy/tests/mpl/test_images.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
lib/cartopy/tests/mpl/test_images.py Show resolved Hide resolved
lib/cartopy/tests/mpl/test_images.py Show resolved Hide resolved
@smartlixx smartlixx force-pushed the FEAT_add_etopo1 branch 3 times, most recently from 55b5595 to a867704 Compare October 15, 2021 10:39
@smartlixx
Copy link
Contributor Author

this PR appears to be reviwed and have passing tests, but there are conflicts between it and master

@smartlixx please may i suggest that you rebase this PR branch with respect to upstream/master

i would hope that reviewers would then be able to re-assess and potentially merge this onto master

@dopplershift @QuLogic is this reasonable from your points of view?

Yes, it is done. Please review and let me know your thoughts. @QuLogic @dopplershift

lib/cartopy/mpl/geoaxes.py Show resolved Hide resolved
lib/cartopy/mpl/geoaxes.py Show resolved Hide resolved
@greglucas greglucas added this to the 0.21 milestone Nov 13, 2021
lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Looks good to me, just one minor suggestion.

As a side comment/follow-up PR, would this make sense to have as a RasterSource feature artist? So, make it usable outside of the stock_img function, and have stock_img add the RasterSource features instead.

lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
@QuLogic QuLogic modified the milestones: 0.21, 0.22 Sep 11, 2022
@dopplershift dopplershift modified the milestones: 0.22, Next Release Aug 4, 2023
@smartlixx smartlixx force-pushed the FEAT_add_etopo1 branch 3 times, most recently from 772a697 to c88e2a4 Compare August 6, 2023 08:49
@smartlixx
Copy link
Contributor Author

smartlixx commented Aug 6, 2023

Looks good to me, just one minor suggestion.

Thanks for your comments. I have updated the PR to incorporate the new changes since my last commit, and the PR has passed all the test. Hopefully it can be accepted (quite a long time has passed). Or if it is OK, I can also combine this PR with #2230.

As a side comment/follow-up PR, would this make sense to have as a RasterSource feature artist? So, make it usable outside of the stock_img function, and have stock_img add the RasterSource features instead.

I can see there is a RasterSource class in io/__init__.py

class RasterSource:
"""
Define the cartopy raster fetching interface.
A :class:`RasterSource` instance is able to supply images and
associated extents (as a sequence of :class:`LocatedImage` instances)
through its :meth:`~RasterSource.fetch_raster` method.
As a result, further interfacing classes, such as
:class:`cartopy.mpl.slippy_image_artist.SlippyImageArtist`, can then
make use of the interface for functionality such as interactive image
retrieval with pan and zoom functionality.
.. _raster-source-interface:
"""
def validate_projection(self, projection):
"""
Raise an error if this raster source cannot provide images in the
specified projection.
Parameters
----------
projection: :class:`cartopy.crs.Projection`
The desired projection of the image.
"""
raise NotImplementedError()
def fetch_raster(self, projection, extent, target_resolution):
"""
Return a sequence of images with extents given some constraining
information.
Parameters
----------
projection: :class:`cartopy.crs.Projection`
The desired projection of the image.
extent: iterable of length 4
The extent of the requested image in projected coordinates.
The resulting image may not be defined exactly by these extents,
and so the extent of the resulting image is also returned. The
extents must be defined in the form
``(min_x, max_x, min_y, max_y)``.
target_resolution: iterable of length 2
The desired resolution of the image as ``(width, height)`` in
pixels.
Returns
-------
images
A sequence of :class:`LocatedImage` instances.
"""
raise NotImplementedError()

This may be a good starting point, but it's beyond my hands at this moment.

@rcomer
Copy link
Member

rcomer commented Feb 19, 2024

Hi, I’m just checking on the status of this one. It looks like it was ready to go but unfortunately now has conflicts with the main branch again. @smartlixx do you have the bandwidth to rebase this again?

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plot etopo
8 participants