forked from rodegerdts/Pyalmanac
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuntables.py
More file actions
executable file
·158 lines (125 loc) · 4.98 KB
/
suntables.py
File metadata and controls
executable file
·158 lines (125 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#! /usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2014 Enno Rodegerdts
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#import ephem
#import math
from alma_ephem import *
def sunmoontab(date):
"""generates LaTeX table for sun and moon
"""
tab = r'''\noindent
\begin{tabular*}{0.2\textwidth}[t]{@{\extracolsep{\fill}}|c|rr|}
'''
d = 0
while d < 3:
tab = tab + r'''\hline
\hline
\multicolumn{1}{|c|}{\textbf{%s}} &\multicolumn{1}{c}{\textbf{GHA}} &\multicolumn{1}{c|}{\textbf{Dec}}\\
\hline
''' %(ephem.date(date+d).datetime().strftime("%d"))
da = date+d
h = 0
while h < 24:
eph = sunmoon(da)
line = "%s & %s & %s \\\ \n" %(h,eph[0],eph[1])
tab = tab + line
h += 1
da = da+ephem.hour
vd = vdmean(date+d)
tab = tab + r"""\hline
& \multicolumn{1}{c}{SD.=%s} & \multicolumn{1}{c|}{d=%s} \\
\hline
""" %(vd[1],vd[0])
d = d + 1
tab = tab+r"""\end{tabular*}"""
return tab
def page(date):
"""creates a page(15 days) of the Sun almanac
"""
page = r"""\sffamily
\noindent
\begin{flushright}
\textbf{%s to %s}
\end{flushright}
\begin{scriptsize}
""" %(ephem.date(date).datetime().strftime("%Y %B %d"),ephem.date(date+14).datetime().strftime("%b. %d"))
page = page + sunmoontab(date)
page = page + sunmoontab(date+3)
page = page + sunmoontab(date+6)
page = page + sunmoontab(date+9)
page = page + sunmoontab(date+12)
page = page + r"""\end{scriptsize}
\newpage
"""
return page
def pages(date,p):
"""make i pages beginning with date"""
d = ephem.date(date)
out = ''
for i in range(p):
out = out + page(d)
d = d +15
return out
def almanac(year):
"""make almanak from date til date"""
alm = r"""\documentclass[10pt, twoside, a4paper]{report}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
\usepackage{fontenc}
\usepackage[ top=25mm, bottom=25mm, left=18mm, right=8mm]{geometry}
\setlength{\parindent}{0pt}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\usepackage[pdftex]{graphicx}
\usepackage{multicol}
\begin{document}
\begin{titlepage}
\begin{center}
\textsc{\Large Generated by PyAlmanac-st599}\\[1.5cm]
\includegraphics[width=0.4\textwidth]{./images/Ra}\\[1cm]
\textsc{\huge The Nautical Almanac for the Sun}\\[0.7cm]
\HRule \\[0.6cm]
{ \Huge \bfseries %s}\\[0.4cm]
\HRule \\[1.5cm]
\vfill
{\large Generated: \today}
\HRule \\[0.6cm]
\end{center}
\begin{description}\tiny
\item[Disclaimer:] These are computer generated tables. Use at your own risk.
The software and the tables generated by the software are without any warranty
whatsoever, please see the GNU Public Licence v.2 for more information.
\end{description}
\end{titlepage}
\vfill
Generated using PyAlmanac-st599 which is available via Github: https://github.com/st599/Pyalmanac
Pyalmanac-st599 is a Python script that creates the daily pages of the Nautical Almanac. These are tables that are needed for celestial navigation with a Sextant.
This fork of the original code (which can be found at: https://github.com/rodegerdts/Pyalmanac) aims to include a brief guide to celestial navigation and tables of other numbers required to take a sextant measurement and produce a line of position.
\section*{WARNING}
These tables are generated without warranty or guarantee and should be used with caution. The original author states on his web page (https://sv-inua.net/the-nautical-almanac) that he has tested the code against a 2009 Nautical Almanac (which is published by the UK and US) and could not find any errors over 0.3'.
Requirements
Most of the heavy computing is done by the free Pyephem library. Typesetting is done by TeX/LaTeX So before you can use this program you need to install:
\begin{itemize}
\item Python v2.x (2.6 or later ) python 3 will not work out of the box
\item PyEphem
\item TeX/LaTeX
\end{itemize}
\include{./additional_pages/navigational_maths}
\newpage
""" %(year)
y = ephem.date(str(year))
alm = alm + pages(y,25)
alm = alm + '\end{document}'
return alm