Wolfram Blog
Jeffrey Bryant

Get Ready for the Total Solar Eclipse of 2017

August 8, 2017 — Jeffrey Bryant, Research Programmer, Wolfram|Alpha Scientific Content

Eclipse illustrations with the Wolfram Language

On August 21, 2017, an event will happen across parts of the Western Hemisphere that has not been seen by most people in their lifetimes. A total eclipse of the Sun will sweep across the face of the United States and nearby oceans. Although eclipses of this type are not uncommon across the world, the chance of one happening near you is quite small and is often a once-in-a-lifetime event unless you happen to travel the world regularly. This year, the total eclipse will be within driving distance of most people in the lower 48 states.

Total eclipses of the Sun are a result of the Moon moving in front of the Sun, from the point of view of an observer on the Earth. The Moon’s shadow is quite small and only makes contact with the Earth’s surface in a small region, as shown in the following illustration.

Lunar eclipse illustration

We can make use of 3D graphics in the Wolfram Language to create a more realistic visualization of this event. First, we will want to make use of a texture to make the Earth look more realistic.

texture =    ImageCrop[PlanetData["Earth", "CylindricalEquidistantTexture"]];

We can apply the texture to a rotated spherical surface as follows.

earthGraphic3D =    Rotate[ParametricPlot3D[{Cos[t] Cos[p], Sin[t] Cos[p], Sin[p]}, {t,        3/2 Pi, 7/2 Pi}, {p, -Pi/2, Pi/2}, Mesh -> None,       PlotStyle -> Texture[texture]][[1]], 23.5 \[Degree], {0, 1, 0}];

We represent the Earth’s shadow as a cone.

earthShadowCone = {GrayLevel[0, .5],     Cone[{{-0.3, 0, 0}, {-11, 0, 0}}, 1]};

The Moon can be represented by a simple Sphere that is offset from the center of the scene, while its orbit is a simple dashed 3D path. Both are parameterized since the Moon’s orbit will precess in time. It’s useful to be able to supply values to these functions to get the shadow to line up where we want.

moonGraphic3D[\[Phi]_, \[Theta]_] :=   With[{moonOrbitInclination = 5.16 \[Degree]}, {GrayLevel[.5],     Sphere[6 {Cos[\[Theta]] Cos[         moonOrbitInclination Cos[\[Theta] + \[Phi]]],        Sin[\[Theta]] Cos[moonOrbitInclination Cos[\[Theta] + \[Phi]]],        Sin[moonOrbitInclination Cos[\[Theta] + \[Phi]]]}, 0.4]}]

moonOrbit[\[Theta]_] :=   With[{moonOrbitInclination = 5.16 \[Degree]},    ParametricPlot3D[     6 {Cos[x] Cos[moonOrbitInclination Cos[x + \[Theta]]],        Sin[x] Cos[moonOrbitInclination Cos[x + \[Theta]]],        Sin[moonOrbitInclination Cos[x + \[Theta]]]}, {x, 0, 2 \[Pi]},      PlotStyle -> {Red, Dashed, AbsoluteThickness[1]},      PlotPoints -> 100][[1]]]

As with the Earth’s shadow, we represent the Moon’s shadow as a cone.

moonShadowCone[\[Phi]_, \[Theta]_] :=   With[{moonOrbitInclination = 5.16 \[Degree]}, {GrayLevel[0, .7],     Cone[{#, # - {7, 0, 0}}, .4] &[     6 { Cos[\[Theta]] Cos[#], Sin[\[Theta]] Cos[#], Sin[#]} &[      moonOrbitInclination Cos[\[Theta] + \[Phi]]]]}]

Finally, we create some additional scene elements for use as annotations.

sunArrow = {Hue[0.2, 0.5, 1], Arrowheads -> Small,     Arrow[{{2, 0, 0}, {8, 0, 0}}]};

labels = {Text[Style["To Sun", Hue[0.2, 0.5, 1]], {8.5, -0.7, 0}],     Text[Style["Moon's Orbit", Hue[1, 0, 0.92]], {-2, -8, 1}]};

Now we just need to assemble the scene. We want the Moon to be directly in line with the Sun, so we use 0° as one of the parameters to achieve that. To precess the orbit in such a way that the shadow falls on North America, we use 70°. The rest is just styling information.

Graphics3D[{moonOrbit[70 \[Degree]],    moonGraphic3D[70 \[Degree], 0 \[Degree]],    moonShadowCone[70 \[Degree], 0 \[Degree]], earthShadowCone,    earthGraphic3D, sunArrow, labels}, Axes -> False,   PlotRange -> {{-13, 8}, {-6.5, 6.5}, {-3, 3}},   Background -> GrayLevel[0.2],   Lighting -> {{"Ambient", GrayLevel[.7]}, {"Point",      Hue[0.2, 0.5, 1], {28, 0, 0}}}, Boxed -> False, ViewAngle -> 0.14,   ViewCenter -> {{0.5, 0.52, 0.5}, {0.2326, 0.6112}},   ViewPoint -> {1.1, -2.5, 2.0}, ViewVertical -> {-0.02, -0.01, 0.99},   ImageSize -> {500, 312}]

Entity["PlanetaryMoon", "Moon"][{"Eccentricity", "Inclination"}]

This means that due to the eccentric orbit, sometimes the Moon is further away from Earth than at other times; it also means that, due to the orbital inclination, it may be above or below the plane of the Earth-Sun orbit. Usually when the Moon passes “between” the Earth and the Sun, it is either “above” or “below” the Sun from the point of view of an observer on the Earth’s surface. The geometry is affected by other effects but, from time to time, the geometry is just right, and the Moon actually blocks part or all of the Sun’s disk. On August 21, 2017, the geometry will be “just right,” and from some places on Earth the Moon will cover at least part of the Sun.

Besides illustrating eclipse geometry, we can also make use of the Wolfram Language via GeoGraphics to create various maps showing where the eclipse is visible. With very little code, you can get elaborate results. For example, we can combine the functionality of SolarEclipse with GeoGraphics to show where the path of the 2017 total solar eclipse can be seen. Totality will be visible in a narrow strip that cuts right across the central United States.

GeoGraphics[{GeoStyling[Directive[EdgeForm[], Opacity[.15]]],    SolarEclipse[DateObject[{2017, 8, 21}], "GraphicsData",     EclipseType -> "Total"]},   GeoRange -> Entity["GeographicRegion", "NorthAmerica"],   GeoProjection -> "Orthographic", GeoBackground -> "Satellite"]

So which states are going to able to see the total solar eclipse? The following example can be used to determine that. First, we retrieve the polygon corresponding to the total phase for the upcoming eclipse.

polygondata =    SolarEclipse[DateObject[{2017, 8, 21}], "TotalPhasePolygon",     EclipseType -> "Total"];

states = GeoEntities[polygondata, "AdministrativeDivision1"]

GeoGraphics[{Orange, Polygon /@ states}]

Suppose you want to zoom in on a particular state to see a bit more detail. At this level, we are only interested in the path of totality and the center line. Once again, we use SolarEclipse to obtain the necessary elements.

totalityCenterLine =    SolarEclipse[DateObject[{2017, 8, 21}], "TotalPhaseCenterLine",     EclipseType -> "Total"];

totalityPolygon =    SolarEclipse[DateObject[{2017, 8, 21}], "TotalPhasePolygon",     EclipseType -> "Total"];

Then we just use GeoGraphics to easily generate a map of the state in question—Wyoming, in this case.

GeoGraphics[{totalityPolygon, Red, totalityCenterLine},   GeoRange ->    Entity["AdministrativeDivision", {"Wyoming", "UnitedStates"}]]

We can make use of the Wolfram Data Repository to obtain additional eclipse information, such as timing of the eclipse at various locations.

pathData =    ResourceData[    "Path of the Total Solar Eclipse of August 21st, 2017"];

timeLocationData =    DeleteMissing[    pathData[[     All, {"UT1", "NorthernLimit", "CentralLine", "SouthernLimit"}]],     1, 2];

We can use that data to construct annotated time marks for various points along the eclipse path.

timeMarks = {Thickness[.0025], GrayLevel[1, .5],    Table[{      Line[{timeLocationData[[i, 2]], timeLocationData[[i, 3]],         timeLocationData[[i, 4]]}], {GrayLevel[1, 1], Text[        Style[         DateString[          DateObject[timeLocationData[[i, 1]],            TimeZone ->             Entity["TimeZone", "America/Denver"]], {"Hour12", ":",            "Minute", "AMPM"}],         12, Bold], timeLocationData[[i, 4]], {0, -1},         Background -> GrayLevel[.5]]}}, {i, 1,       Length[timeLocationData], 1}]};

Then we just combine the elements.

GeoGraphics[{   Thickness[.005], {Red, totalityCenterLine,     GeoStyling[GrayLevel[0, .2]], totalityPolygon},   timeMarks   }, GeoRange ->    Entity["AdministrativeDivision", {"Wyoming", "UnitedStates"}]]

Of course, even if the eclipse is happening, there is no guarantee that you will be able to witness it. If the weather doesn’t cooperate, you will simply notice that it will get dark in the middle of the day. Using WeatherData, we can try to predict which areas are likely to have cloud cover on August 21. The following example is based on a similar Wolfram Community post.

The following retrieves all of the counties that intersect with the eclipse’s polygon bounds.

usco = GeoEntities[polygondata, "AdministrativeDivision2"];

Most of the work is involved in looking at the "CloudCoverFraction" values for each county on August 21 for each year from 2001 to 2016 and finding the mean value for each county.

countydata[county_] :=   Switch[#, {}, Missing["NotAvailable"], _, Mean[#]] &[   Cases[Flatten[     Table[Normal@       WeatherData[county["Position"],         "CloudCoverFraction", {2000 + y, 8, 21}], {y, 16}],      1], {_, n_?NumberQ} :> n]]

avcc = Map[countydata, usco] /. _Mean -> Missing["NotAvailable"];

I can then use GeoRegionValuePlot to plot these values. In general, it appears that most areas along this path have relatively low cloud cover on August 21, based on historical data.

GeoRegionValuePlot[Thread[usco -> avcc], ColorFunction -> "Rainbow",   GeoBackground -> "ReliefMap", PlotStyle -> Opacity[.75],   PlotRange -> All]

The total solar eclipse on August 21, 2017, is a big deal due to the fact that the path carries it across a large area of the United States. Make every effort to see it! Take the necessary safety precautions and wear eclipse-viewing glasses. If your kids are in school already, see if they are planning any viewing events. Just make sure to plan ahead, since traffic may be very heavy in areas near totality. Enjoy it!

Download this post as a Computable Document Format (CDF) file. New to CDF? Get your copy for free with this one-time download.

Leave a Comment

One Comment

Barrie Stokes

Hi Jeffrey

What a beautiful illustration of the power and flexibility of the integration of the Mathematica system! From Australia I’ll have travel further than most Americans to see this solar eclipse. I hope the skies are clear for everyone on the path on August 21.


Posted by Barrie Stokes    August 8, 2017 at 7:44 pm

Leave a comment


Or continue as a guest (your comment will be held for moderation):