How to draw a day/night terminator

We will make a basemap and apply to it a terminator called date-time. The terminator is a division on the Earth's surface between day and night. Use the nightshade method that basemap provides and call utcnow, as shown here:

# Terminator 2: Judgement Datetime (nightshade)
from datetime import datetime
m = Basemap()
setup_map(m)
m.nightshade(datetime.utcnow())
plt.show()

We see that it is daytime in Europe and night time in Asia or Australia, and, hence, we can see the curve of the Earth's surface.

To use a different projection, we will use projection= 'ortho', lan_0=0, lon_0=0, as shown in the following code:

# Terminator 2: Judgement Datetime (nightshade)
from datetime import datetime
m = Basemap(projection='ortho', lat_0=0, lon_0=0)
setup_map(m)
m.nightshade(datetime.utcnow())
plt.show()

Hence, we see the terminator now around the edges, with the focus on the latitude at the middle of the day, as shown here:

Let's try setting latitude and longitude to 45 degrees:

# Terminator 2: Judgement Datetime (nightshade)
from datetime import datetime
m = Basemap(projection='ortho', lat_0=45, lon_0=45)
setup_map(m)
m.nightshade(datetime.utcnow())
plt.show()

From the output of the preceding code, we can see the edge of the day/night cycle for the earth:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset