forked from rodegerdts/Pyalmanac
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyalmanac.py
More file actions
executable file
·93 lines (79 loc) · 4.03 KB
/
pyalmanac.py
File metadata and controls
executable file
·93 lines (79 loc) · 4.03 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
#! /usr/bin/python
# -*- coding: UTF-8 -*-
# Copyright (C) Copyright for portions of project Foo are held by
# Enno Rodegerdts, 2014 as part of project PyAlmanac. All other copyright
# for project PyAlmanac-st599 are held by Simon Thompson, 2017.
# Updates Simon Thompson 2017
# 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.
"""
This module contains the main class for PyAlmanac. It uses PyEphem to generate
Sun Almanac or Nautical Almanac for a given year.
"""
__author__ = "Enno Rodegerdts and Simon Thompson"
__copyright__ = "Copyright for portions of project Foo are held by Enno Rodegerdts, 2014 as part of project PyAlmanac. All other copyright for project PyAlmanac-st599 are held by Simon Thompson, 2017."
__license__ = "GPL v2"
__version__ = "2.0.1"
__maintainer__ = "Simon Thompson"
__status__ = "Beta"
import tables
import suntables
import os
##Main###
if __name__ == '__main__':
## GPL Licence Condition
print "------------------------------------------------------------------------------"
print "PyAlmanac version %s - Generate Nautical Almanac for Astro-Navigation" %__version__
print "Released under %s" %__license__
print "Maintained by %s" %__maintainer__
print "-------------------------------------------------------------------------------"
print "Copyright for portions of project PyAlmanac-st599 are held by Enno Rodegerdts, 2014 as part of project PyAlmanac. All other copyright for project PyAlmanac-st599 are held by Simon Thompson, 2017.\n"
print "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.\n"
print "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.\n"
print "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.\n"
print "------------------------------------------------------------------------------"
print ""
year = raw_input("Please enter the year you want to create the nautical almanac for:\n ")
s = raw_input("""Do you want to create the full tables or just tables for the sun?:\n
1 Full nautical almanac
2 Just tables for the sun
""")
if s == "2":
print "Creating the sun tables only. \n The year %s" %year
print "Please wait this can take a while."
filename = "sunalmanac%s.tex" %year
outfile = open(filename, 'w')
outfile.write(suntables.almanac(year))
outfile.close()
command = 'pdflatex %s' %filename
os.system(command)
print "finished"
os.remove("sunalmanac%s.log" %year)
os.remove("sunalmanac%s.aux" %year)
os.remove(filename)
elif s == "1":
print "Creating the nautical almanac for the year %s" %year
print "Please wait this can take a while."
filename = "almanac%s.tex" %year
outfile = open(filename, 'w')
outfile.write(tables.almanac(year))
outfile.close()
command = 'pdflatex %s' %filename
os.system(command)
print "finished"
os.remove(filename)
os.remove("almanac%s.log" %year)
os.remove("almanac%s.aux" %year)
else:
print "Error! Choose either 1 or 2"