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 request: Shading on Orthographic projection #2357

Open
ledm opened this issue Mar 20, 2024 · 10 comments
Open

Feature request: Shading on Orthographic projection #2357

ledm opened this issue Mar 20, 2024 · 10 comments

Comments

@ledm
Copy link

ledm commented Mar 20, 2024

Thanks for making such a great tool. I've been using cartopy for years for all sorts of scientific work, including ESMValTool development, monitoring UKESM development, and several other NERC, UKRI and EU projects.

I've recently started to use Cartopy for artistic purposed. (I'm claiming that this is the first Cartopy based music video. Here's the first 20 seconds: https://twitter.com/LeedeMora/status/1769756546232147988, final video will be published later this week.)

One limiting factor that reduces the visual impact of cartopy is the shading. At the moment, the entire surface of the globe is the same brightness, so it looks quite flat. I'd like to darken the outer edges of the globe such that we can emphasise certain regions.

Even simple shading could make this figure far more striking and eye catching: https://www.youtube.com/watch?v=ErOMbspikNg

I wouldn't know where to start with adding it though. Perhaps providing the coordinates for the brightest spot and a reducing the RGB values of the colours outwards from there would be a starting point?

@reinderien
Copy link

@ledm
Copy link
Author

ledm commented Mar 20, 2024

Thanks for the quick reply @reinderien. I hadn't seen that function, and it looks like it does some of what I want, but it is quite binary. The projection is either lit or not. Is there some way of making it layered, so that it's increasingly dark away from the noon at the equator?

@reinderien
Copy link

The simplest way to do that (depending on performance constraints) is to apply several nightshades at increasing refractions, all with low alpha.

@ledm
Copy link
Author

ledm commented Mar 20, 2024

Thanks for the help. This worked:

thumbnail_ts_4K_199961

import numpy as np
from cartopy.feature.nightshade import Nightshade

def add_shading(ax):
    """
    Add Nightshade to light up the Atlantic.
    """
    for month in np.arange(5, 11, 2):
        for hour in np.arange(12, 17, 1):
            for minute in np.arange(0, 60, 5):
                date = datetime(1999, month, 1, hour, minute) 
                ax.add_feature(Nightshade(date, alpha=0.01), zorder=70)

You can still see the individual time sections, but smaller time steps really add to the performance costs.

I'm also getting some strange bright pixels around the edges. Not sure how or why.

@ledm
Copy link
Author

ledm commented Mar 20, 2024

Now that I've got this, I think the zero tilt makes it look strange. Is there any way to set the Axial tilt to 23degrees? There doesn't seem to be an option to do it in the API documentation. https://scitools.org.uk/cartopy/docs/latest/reference/projections.html#orthographic

@rcomer
Copy link
Member

rcomer commented Mar 20, 2024

Much as I love that you've done this with Cartopy, I wonder if geovista is the better tool for this job. Paging @bjlittle.

@ledm
Copy link
Author

ledm commented Mar 20, 2024

At this stage, the full video is basically finished and ready to go. Maybe, if I do another one, geovista (https://github.com/bjlittle/geovista) will be the way to go. The documentation is a little too Lorem ipsumy at the moment.

@ledm
Copy link
Author

ledm commented Mar 22, 2024

The final music-video is now published. I still claim that this is likely to be the first Cartopy based music video:

https://www.youtube.com/watch?v=zUPc3CmMpiY

@rcomer
Copy link
Member

rcomer commented Mar 22, 2024

That is astonishing 🙇‍♀️

@ledm
Copy link
Author

ledm commented Mar 22, 2024

Thanks - I've open sourced the code, it's all here:
Video: https://github.com/ledm/MarineHeatwaves
Audio: https://github.com/ledm/earthsystemmusic2

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

No branches or pull requests

3 participants