Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Solar Eclipse 2017

Project: Earth Science
Views: 1067
1
% generated by smc-sagews2pdf -- 2019-05-17 19:01:13.300124
2
\documentclass[
3
paper=A4,
4
pagesize,
5
fontsize=11pt,
6
%headings=small,
7
titlepage=false,
8
fleqn,
9
toc=flat,
10
bibliography=totoc, %totocnumbered,
11
index=totoc,
12
listof=flat]{scrartcl}
13
\usepackage{scrhack}
14
\setuptoc{toc}{leveldown}
15
16
\usepackage[utf8x]{inputenc}
17
\usepackage[T1]{fontenc}
18
\usepackage{xltxtra} % xelatex
19
20
\usepackage[
21
left=3cm,
22
right=2cm,
23
top=2cm,
24
bottom=2cm,
25
includeheadfoot]{geometry}
26
\usepackage[automark,headsepline,ilines,komastyle]{scrpage2}
27
\pagestyle{scrheadings}
28
29
\usepackage{fixltx2e}
30
31
\raggedbottom
32
33
% font tweaks
34
\usepackage{ellipsis,ragged2e,marginnote}
35
\usepackage{inconsolata}
36
\renewcommand{\familydefault}{\sfdefault}
37
\setkomafont{sectioning}{\normalcolor\bfseries}
38
\setkomafont{disposition}{\normalcolor\bfseries}
39
40
\usepackage{mathtools}
41
\mathtoolsset{showonlyrefs=true}
42
\usepackage{amssymb}
43
\usepackage{sfmath}
44
45
\usepackage[USenglish]{babel}
46
\usepackage{etoolbox}
47
\usepackage{url}
48
\usepackage{hyperref}
49
50
% use includegraphics directly, but beware, that this is actually ...
51
\usepackage{graphicx}
52
% ... adjust box! http://latex-alive.tumblr.com/post/81481408449
53
\usepackage[Export]{adjustbox}
54
\adjustboxset{max size={\textwidth}{0.7\textheight}}
55
56
\usepackage{textcomp}
57
\def\leftqquote{``}\def\rightqqoute{''}
58
\catcode`\"=13
59
\def"{\bgroup\def"{\rightqqoute\egroup}\leftqquote}
60
61
\makeatletter
62
\preto{\@verbatim}{\topsep=0pt \partopsep=0pt }
63
\makeatother
64
65
\usepackage{color}
66
\definecolor{midgray}{rgb}{0.5,0.5,0.5}
67
\definecolor{lightyellow}{rgb}{1,1,.92}
68
\definecolor{dblackcolor}{rgb}{0.0,0.0,0.0}
69
\definecolor{dbluecolor}{rgb}{.01,.02,0.7}
70
\definecolor{dredcolor}{rgb}{1,0,0}
71
\definecolor{dbrowncolor}{rgb}{0.625,0.3125,0}
72
\definecolor{dgraycolor}{rgb}{0.30,0.3,0.30}
73
\definecolor{graycolor}{rgb}{0.35,0.35,0.35}
74
75
\usepackage{listings}
76
\lstdefinelanguage{Sage}[]{Python}
77
{morekeywords={True,False,sage,singular},
78
sensitive=true}
79
\lstset{
80
showtabs=False,
81
showspaces=False,
82
showstringspaces=False,
83
commentstyle={\ttfamily\color{dbrowncolor}},
84
keywordstyle={\ttfamily\color{dbluecolor}\bfseries},
85
stringstyle ={\ttfamily\color{dgraycolor}\bfseries},
86
numberstyle ={\tiny\color{midgray}},
87
backgroundcolor=\color{lightyellow},
88
language = Sage,
89
basicstyle={\ttfamily},
90
extendedchars=true,
91
keepspaces=true,
92
aboveskip=1em,
93
belowskip=0.1em,
94
breaklines=true,
95
prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\backslash}},
96
%frame=single
97
}
98
99
% sagemath macros
100
\newcommand{\Bold}[1]{\mathbb{#1}}
101
\newcommand{\ZZ}{\Bold{Z}}
102
\newcommand{\NN}{\Bold{N}}
103
\newcommand{\RR}{\Bold{R}}
104
\newcommand{\CC}{\Bold{C}}
105
\newcommand{\FF}{\Bold{F}}
106
\newcommand{\QQ}{\Bold{Q}}
107
\newcommand{\QQbar}{\overline{\QQ}}
108
\newcommand{\CDF}{\Bold{C}}
109
\newcommand{\CIF}{\Bold{C}}
110
\newcommand{\CLF}{\Bold{C}}
111
\newcommand{\RDF}{\Bold{R}}
112
\newcommand{\RIF}{\Bold{I} \Bold{R}}
113
\newcommand{\RLF}{\Bold{R}}
114
\newcommand{\CFF}{\Bold{CFF}}
115
\newcommand{\GF}[1]{\Bold{F}_{#1}}
116
\newcommand{\Zp}[1]{\ZZ_{#1}}
117
\newcommand{\Qp}[1]{\QQ_{#1}}
118
\newcommand{\Zmod}[1]{\ZZ/#1\ZZ}
119
120
% mathjax has \lt and \gt
121
\newcommand{\lt}{<}
122
\newcommand{\gt}{>}
123
% also support HTML's &le; and &ge;
124
\newcommand{\lequal}{}
125
\newcommand{\gequal}{}
126
\newcommand{\notequal}{}
127
128
% defining utf8 characters for listings
129
\lstset{literate=
130
{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
131
{Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
132
{à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
133
{À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
134
{ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
135
{Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
136
{â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
137
{Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
138
{œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
139
{ã}{{\~a}}1 {Ã}{{\~A}}1 {õ}{{\~o}}1 {Õ}{{\~O}}1
140
{ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
141
{}{{\EUR}}1 {£}{{\pounds}}1
142
}
143
144
\title{Eclipse}
145
\author{Hal Snyder}
146
\date{5/17/2019}
147
\begin{document}
148
\maketitle
149
\begin{lstlisting}
150
\end{lstlisting}\section{Solar Eclipse 2017}
151
152
\subsection{Purpose}
153
154
155
156
{Compute eclipse start, peak, and end times for observer at a selected location. Also compute maximum obscuration.}
157
158
159
160
{See how close we come to NASA posted times.}
161
162
163
164
{I'm near the Palatine Public Library in Illinois. Here's what NASA shows for my location. Times are UTC:}
165
166
167
168
{\includegraphics[resolution=120]{5e0c11196e77a3851eeed983d090219fa2cdbe86.png}}
169
170
\subsection{References}
171
172
173
174
{NASA reference for eclipse path and timing.
175
- https://eclipse2017.nasa.gov/sites/default/files/interactive\_map/index.html}
176
177
178
179
{This US Navy site explains the difference between magnitude and obscuration for an eclipse.
180
- http://aa.usno.navy.mil/data/docs/Eclipse2017.php}
181
182
183
184
{Most of the math for this is taken from the following blog posting and source code.
185
- https://www.chromosphere.co.uk/2015/03/18/eclipse-calculations-using-python/}
186
187
\begin{lstlisting}
188
%auto
189
%default_mode python3
190
\end{lstlisting}
191
\begin{lstlisting}
192
# verify we're using python3
193
# version should be 3.x.y
194
import sys
195
print(sys.version)
196
\end{lstlisting}\begin{verbatim}3.5.4 | packaged by conda-forge | (default, Aug 10 2017, 01:38:41)
197
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)]\end{verbatim}
198
\begin{lstlisting}
199
# Get longitude and latitude for a given location
200
# You could change this for some other place
201
locname = "Palatine Public Library, Palatine, US"
202
\end{lstlisting}
203
\begin{lstlisting}
204
# geopy gets street address and county for the library as well as long/lat. Cool.
205
import geopy
206
from geopy.geocoders import Nominatim
207
geolocator = Nominatim()
208
location = geolocator.geocode("Palatine Public Library, Palatine, IL, US")
209
print(location.address)
210
print((location.longitude, location.latitude))
211
# save long/lat as strings for next step
212
my_longitude_str = str(location.longitude)
213
my_latitude_str = str(location.latitude)
214
\end{lstlisting}\begin{verbatim}Palatine Public Library, 700, North Court, Palatine, Cook County, Illinois, 60067, United
215
States of America
216
(-88.0366723932833, 42.12225845)\end{verbatim}
217
\begin{lstlisting}
218
# Choose a starting date and time to look for eclipse stats.
219
# Format is year, month, day, hour, minutes, seconds
220
# I am starting the search for eclipse coverage at 16:50 UTC on August 21.
221
# Store that as year, month, day, hour, minute, second.
222
start_dt = (2017, 8, 21, 16, 50, 0)
223
224
\end{lstlisting}
225
\begin{lstlisting}
226
import ephem
227
import math
228
from operator import itemgetter
229
230
def check_non_zero(x):
231
return x > 0
232
233
# Date
234
timetuple = start_dt
235
236
# Location
237
myloc = ephem.Observer()
238
myloc.lon, myloc.lat = my_longitude_str, my_latitude_str
239
myloc.date=timetuple
240
241
# Objects
242
sun, moon = ephem.Sun(), ephem.Moon()
243
244
# Output list
245
results=[]
246
247
for x in range(0,11000):
248
myloc.date= (ephem.date(ephem.date(timetuple)+x*ephem.second))
249
sun.compute(myloc)
250
moon.compute(myloc)
251
r_sun=sun.size/2
252
r_moon=moon.size/2
253
s=math.degrees(ephem.separation((sun.az, sun.alt), (moon.az, moon.alt)))*60*60
254
255
## Calculate the size of the lune (http://mathworld.wolfram.com/Lune.html) in arcsec^2
256
if s<(r_moon+r_sun):
257
lunedelta=0.25*math.sqrt((r_sun+r_moon+s)*(r_moon+s-r_sun)*(s+r_sun-r_moon)*(r_sun+r_moon-s))
258
else: ### If s>r_moon+r_sun there is no eclipse taking place
259
lunedelta=None
260
percent_eclipse=0
261
if lunedelta:
262
lune_area=2*lunedelta + r_sun*r_sun*(math.acos(((r_moon*r_moon)-(r_sun*r_sun)-(s*s))/(2*r_sun*s))) - r_moon*r_moon*(math.acos(((r_moon*r_moon)+(s*s)-(r_sun*r_sun))/(2*r_moon*s)))
263
# Calculate percentage of sun's disc eclipsed using lune area and sun size
264
percent_eclipse=(1-(lune_area/(math.pi*r_sun*r_sun)))*100
265
### Append to list of lists
266
results.append([myloc.date.datetime(),s,sun.size,moon.size,lune_area if lunedelta else 0, percent_eclipse])
267
268
### Find maximum obscuration of eclipse...
269
gen=(x for x in results)
270
maximum_obscuration=max(gen, key=itemgetter(5))
271
maximum_obscuration_dt = maximum_obscuration[0]
272
max_percent = maximum_obscuration[5]
273
274
### find first and last contact
275
gen=(x for x in results)
276
first_contact_dt = next(x for x in gen if check_non_zero(x[5]))[0]
277
last_contact_dt = next(x for x in gen if x[5]==0)[0]
278
279
\end{lstlisting}
280
\begin{lstlisting}
281
# choose a timezone by name
282
tzn = 'US/Central'
283
284
# convert UTC to Chicago time
285
# Note US/Central is not local time on this computer
286
import pytz
287
from pytz import timezone
288
local_tz = timezone('US/Central')
289
290
def utc_to_local(utc_dt):
291
local_dt = utc_dt.replace(tzinfo=pytz.utc).astimezone(local_tz)
292
return local_tz.normalize(local_dt)
293
\end{lstlisting}
294
\begin{lstlisting}
295
# pandas to_datetime for convenience
296
297
import pandas as pd
298
299
me_tstamp = utc_to_local(pd.to_datetime(maximum_obscuration_dt).round('s'))
300
fc_tstamp = utc_to_local(pd.to_datetime(first_contact_dt).round('s'))
301
lc_tstamp = utc_to_local(pd.to_datetime(last_contact_dt).round('s'))
302
303
\end{lstlisting}
304
\begin{lstlisting}
305
l = location[0].split(',')
306
print("2017 solar eclipse {} times for:\n {}\n {}\n {}\n {}".format(tzn,l[0],l[1]+l[2],l[3]+l[5]+l[6],l[7]))
307
print("First contact : {} {}".format(fc_tstamp.date(), fc_tstamp.time()))
308
print("Max obscuration: {} {}".format(me_tstamp.date(), me_tstamp.time()))
309
print("Max percent : {0:.2f}".format(max_percent))
310
print("Last contact : {} {}".format(lc_tstamp.date(), lc_tstamp.time()))
311
\end{lstlisting}\begin{verbatim}2017 solar eclipse US/Central times for:
312
Palatine Public Library
313
700 North Court
314
Palatine Illinois 60067
315
United States of America
316
First contact : 2017-08-21 11:53:23
317
Max obscuration: 2017-08-21 13:18:46
318
Max percent : 86.55
319
Last contact : 2017-08-21 14:41:42\end{verbatim}
320
\begin{lstlisting}
321
\end{lstlisting}\subsection{Results}
322
323
324
325
{NASA posted times have been converted from UTC to US/Central.}
326
327
328
329
{| value | NASA | calculations in this worksheet |
330
||||
331
| First contact time |11:54:00|11:53:23|
332
| Maximum obscuration time |13:19.41|13:18:46|
333
| Maximum obscuration |87.42\%|86.55\%|
334
| Last contact time |14:42:44|14:41:42|}
335
336
\end{document}
337
%configuration={"latex_command":"xelatex -synctex=1 -interact=nonstopmode 'tmp.tex'"}
338
339