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

Adding a nightshade/terminator feature #1135

Merged
merged 1 commit into from
Nov 13, 2018

Conversation

greglucas
Copy link
Contributor

@greglucas greglucas commented Sep 29, 2018

Rationale

Adding a nightshade() feature, with refraction to visualize the day/night terminator. This has been requested several times, and I've followed the Aurora example myself numerous times. I blended the Aurora example and old basemap features together for this. I have also implemented refraction/extra daylight hours to be a little more precise.

It addresses the following previous issues: #1038, fixes #1128, follows on from #737.

Implications

  • I've implemented a solar.py file similar to the one from mpl/basemap to calculate the sun's position in latitude longitude coordinates.

  • .nightshade() is callable from any geoaxes, let me know if somewhere else would be preferable.

lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/geoaxes.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/tests/mpl/test_nightshade.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
lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
0.019994643*np.sin(2*M_sun*deg2rad))

# obliquity of the ecliptic (epsilon in Vallado's notation)
epsilon = 23.439291 - 0.0130042*T_UT1
Copy link
Member

Choose a reason for hiding this comment

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

Use np.deg2rad here so you don't need to convert units twice below.

lib/cartopy/mpl/solar.py Outdated Show resolved Hide resolved
lib/cartopy/tests/mpl/test_nightshade.py Show resolved Hide resolved
lib/cartopy/tests/mpl/test_nightshade.py Outdated Show resolved Hide resolved
lib/cartopy/tests/mpl/test_nightshade.py Outdated Show resolved Hide resolved
lib/cartopy/tests/mpl/test_nightshade.py Outdated Show resolved Hide resolved
@greglucas
Copy link
Contributor Author

@QuLogic, thanks for the excellent review. I didn't know a lot of the test features and other standards you pointed out, so I learned something too! I've amended the commit with all of the changes, other than the deg/rad which I replied to above in my thinking.

@QuLogic QuLogic merged commit ff9655b into SciTools:master Nov 13, 2018
@QuLogic QuLogic added this to the 0.17 milestone Nov 13, 2018
@QuLogic
Copy link
Member

QuLogic commented Nov 13, 2018

Thanks @greglucas!

@pelson
Copy link
Member

pelson commented Nov 14, 2018

For the record, I followed this up in #1181 in order to reduce the impact on the GeoAxes namespace, and to keep a clean separation between cartopy functionality and cartopy's matplotlib interface.

An example of how to use the nightshade Feature is in that PR, and has been added to the gallery.

@greglucas
Copy link
Contributor Author

I think that is a great decision @pelson. It will definitely make it easier to deal with day/night terminators for me now. Thanks for the good suggestions/review @QuLogic!

@greglucas greglucas deleted the terminator_nightshade branch November 26, 2018 16:09
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

Successfully merging this pull request may close these issues.

nightshade feature implemented?
5 participants