libaditya 0.3.4__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- libaditya/__init__.py +46 -0
- libaditya/_version.py +29 -0
- libaditya/calc/__init__.py +9 -0
- libaditya/calc/api.py +30 -0
- libaditya/calc/avasthas.py +346 -0
- libaditya/calc/docs/jaimini-get-arch.md +95 -0
- libaditya/calc/hellenistic.py +37 -0
- libaditya/calc/jaimini.py +335 -0
- libaditya/calc/jaimini_get.py +240 -0
- libaditya/calc/kala.py +73 -0
- libaditya/calc/panchanga.py +422 -0
- libaditya/calc/rashi.py +612 -0
- libaditya/calc/returns.py +50 -0
- libaditya/calc/swe_functions.py +118 -0
- libaditya/calc/varga.py +287 -0
- libaditya/calc/vimshottari.py +431 -0
- libaditya/cards/__init__.py +5 -0
- libaditya/cards/card.py +90 -0
- libaditya/cards/cards_constants.py +115 -0
- libaditya/cards/cards_of_truth.py +323 -0
- libaditya/cards/cot.py +142 -0
- libaditya/cards/deck.py +52 -0
- libaditya/charts/__init__.py +6 -0
- libaditya/charts/api.py +36 -0
- libaditya/charts/bodygraph.py +80 -0
- libaditya/charts/chart.py +286 -0
- libaditya/charts/jaimini.py +83 -0
- libaditya/charts/tajika.py +36 -0
- libaditya/constants.py +1776 -0
- libaditya/draw/__init__.py +20 -0
- libaditya/draw/draw_bodygraph.py +489 -0
- libaditya/draw/draw_sbc.py +712 -0
- libaditya/draw/themes/default-theme.hd +53 -0
- libaditya/ephe/ast0/se00010s.se1 +0 -0
- libaditya/ephe/seas_00.se1 +0 -0
- libaditya/ephe/seas_06.se1 +0 -0
- libaditya/ephe/seas_12.se1 +0 -0
- libaditya/ephe/seas_18.se1 +0 -0
- libaditya/ephe/seas_24.se1 +0 -0
- libaditya/ephe/seas_30.se1 +0 -0
- libaditya/ephe/seas_36.se1 +0 -0
- libaditya/ephe/seas_42.se1 +0 -0
- libaditya/ephe/seas_48.se1 +0 -0
- libaditya/ephe/seasm06.se1 +0 -0
- libaditya/ephe/seasm12.se1 +0 -0
- libaditya/ephe/seasm18.se1 +0 -0
- libaditya/ephe/seasm24.se1 +0 -0
- libaditya/ephe/seasm30.se1 +0 -0
- libaditya/ephe/seasm36.se1 +0 -0
- libaditya/ephe/seasm42.se1 +0 -0
- libaditya/ephe/seasm48.se1 +0 -0
- libaditya/ephe/seasm54.se1 +0 -0
- libaditya/ephe/sefstars.txt +4245 -0
- libaditya/ephe/semo_00.se1 +0 -0
- libaditya/ephe/semo_06.se1 +0 -0
- libaditya/ephe/semo_12.se1 +0 -0
- libaditya/ephe/semo_18.se1 +0 -0
- libaditya/ephe/semo_24.se1 +0 -0
- libaditya/ephe/semo_30.se1 +0 -0
- libaditya/ephe/semo_36.se1 +0 -0
- libaditya/ephe/semo_42.se1 +0 -0
- libaditya/ephe/semo_48.se1 +0 -0
- libaditya/ephe/semom06.se1 +0 -0
- libaditya/ephe/semom12.se1 +0 -0
- libaditya/ephe/semom18.se1 +0 -0
- libaditya/ephe/semom24.se1 +0 -0
- libaditya/ephe/semom30.se1 +0 -0
- libaditya/ephe/semom36.se1 +0 -0
- libaditya/ephe/semom42.se1 +0 -0
- libaditya/ephe/semom48.se1 +0 -0
- libaditya/ephe/semom54.se1 +0 -0
- libaditya/ephe/sepl_00.se1 +0 -0
- libaditya/ephe/sepl_06.se1 +0 -0
- libaditya/ephe/sepl_12.se1 +0 -0
- libaditya/ephe/sepl_18.se1 +0 -0
- libaditya/ephe/sepl_24.se1 +0 -0
- libaditya/ephe/sepl_30.se1 +0 -0
- libaditya/ephe/sepl_36.se1 +0 -0
- libaditya/ephe/sepl_42.se1 +0 -0
- libaditya/ephe/sepl_48.se1 +0 -0
- libaditya/ephe/seplm06.se1 +0 -0
- libaditya/ephe/seplm12.se1 +0 -0
- libaditya/ephe/seplm18.se1 +0 -0
- libaditya/ephe/seplm24.se1 +0 -0
- libaditya/ephe/seplm30.se1 +0 -0
- libaditya/ephe/seplm36.se1 +0 -0
- libaditya/ephe/seplm42.se1 +0 -0
- libaditya/ephe/seplm48.se1 +0 -0
- libaditya/ephe/seplm54.se1 +0 -0
- libaditya/hd/__init__.py +8 -0
- libaditya/hd/calc.py +55 -0
- libaditya/hd/constants.py +127 -0
- libaditya/hd/longitude.py +271 -0
- libaditya/objects/__init__.py +19 -0
- libaditya/objects/celestial_object.py +206 -0
- libaditya/objects/context.py +133 -0
- libaditya/objects/cusps.py +259 -0
- libaditya/objects/julian_day.py +265 -0
- libaditya/objects/location.py +167 -0
- libaditya/objects/longitude.py +987 -0
- libaditya/objects/nakshatras.py +285 -0
- libaditya/objects/planets.py +2059 -0
- libaditya/objects/shadbala.py +398 -0
- libaditya/objects/signs.py +690 -0
- libaditya/objects/swe_functions.py +75 -0
- libaditya/print_functions.py +548 -0
- libaditya/read.py +665 -0
- libaditya/stars/__init__.py +4 -0
- libaditya/stars/fixed_star.py +216 -0
- libaditya/stars/make_swe_stars.py +407 -0
- libaditya/stars/star-sign-boundaries +44 -0
- libaditya/stars/stellarium/__init__.py +6 -0
- libaditya/stars/stellarium/remote_control/__init__.py +22 -0
- libaditya/stars/stellarium/remote_control/location.py +82 -0
- libaditya/stars/stellarium/remote_control/locationsearch.py +35 -0
- libaditya/stars/stellarium/remote_control/main.py +165 -0
- libaditya/stars/stellarium/remote_control/objects.py +63 -0
- libaditya/stars/stellarium/remote_control/scripts.py +81 -0
- libaditya/stars/stellarium/remote_control/simbad.py +20 -0
- libaditya/stars/stellarium/remote_control/stelaction.py +31 -0
- libaditya/stars/stellarium/remote_control/stelproperty.py +30 -0
- libaditya/stars/stellarium/remote_control/view.py +85 -0
- libaditya/stars/stellarium/stellarium.py +92 -0
- libaditya/stars/the_stars.py +522 -0
- libaditya/stars/utilities.py +539 -0
- libaditya/utils.py +431 -0
- libaditya/write.py +67 -0
- libaditya-0.3.4.dist-info/METADATA +588 -0
- libaditya-0.3.4.dist-info/RECORD +131 -0
- libaditya-0.3.4.dist-info/WHEEL +5 -0
- libaditya-0.3.4.dist-info/licenses/LICENSE +661 -0
libaditya/read.py
ADDED
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
# This file is part of libaditya.
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2025 Josh Harper <humanhaven@substack.com>
|
|
4
|
+
#
|
|
5
|
+
# libaditya is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# libaditya is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU Affero General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
# along with libaditya. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import codecs
|
|
19
|
+
import configparser
|
|
20
|
+
import toml
|
|
21
|
+
|
|
22
|
+
from libaditya import constants as const
|
|
23
|
+
from libaditya.objects import JulianDay, Location, EphContext, Circle
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def read_pyph(infile):
|
|
27
|
+
input = open(infile, "r")
|
|
28
|
+
for line in input:
|
|
29
|
+
if not "=" in line:
|
|
30
|
+
continue
|
|
31
|
+
field, value = line.split("=")
|
|
32
|
+
field = field.strip()
|
|
33
|
+
value = value.strip()
|
|
34
|
+
if field.startswith("Na") or field.startswith("na"):
|
|
35
|
+
name = value
|
|
36
|
+
if field.startswith("Pla") or field.startswith("pla"):
|
|
37
|
+
placename = value
|
|
38
|
+
if field.startswith("Da") or field.startswith("da"):
|
|
39
|
+
month, day, year = intize_date(value)
|
|
40
|
+
if field.startswith("Ti") or field.startswith("ti"):
|
|
41
|
+
ephclock = intize_time(value)
|
|
42
|
+
if field.startswith("La") or field.startswith("la"):
|
|
43
|
+
lat = float(value)
|
|
44
|
+
if field.startswith("Lo") or field.startswith("lo"):
|
|
45
|
+
long = float(value)
|
|
46
|
+
return name, placename, month, day, year, ephclock, lat, long
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def read_chtk(infile):
|
|
50
|
+
input = open(infile, "rb")
|
|
51
|
+
lines = input.readlines()
|
|
52
|
+
linenum = 0
|
|
53
|
+
for line in lines:
|
|
54
|
+
# print(f"{n}: {line.decode(errors='ignore')}")
|
|
55
|
+
match linenum:
|
|
56
|
+
case 0:
|
|
57
|
+
name = clean_line(line)
|
|
58
|
+
case 1:
|
|
59
|
+
year = intize_line(codecs.decode(line))
|
|
60
|
+
case 2:
|
|
61
|
+
month = intize_line(codecs.decode(line))
|
|
62
|
+
case 3:
|
|
63
|
+
day = intize_line(codecs.decode(line))
|
|
64
|
+
case 4:
|
|
65
|
+
hour = intize_line(codecs.decode(line))
|
|
66
|
+
case 5:
|
|
67
|
+
min = intize_line(codecs.decode(line))
|
|
68
|
+
case 6:
|
|
69
|
+
sec = intize_line(codecs.decode(line))
|
|
70
|
+
case 7:
|
|
71
|
+
sex = intize_line(codecs.decode(line))
|
|
72
|
+
case 8:
|
|
73
|
+
country = clean_line(line)
|
|
74
|
+
case 9:
|
|
75
|
+
city = clean_line(line)
|
|
76
|
+
case 10:
|
|
77
|
+
long = long_to_float(clean_line(line))
|
|
78
|
+
case 11:
|
|
79
|
+
lat = lat_to_float(clean_line(line))
|
|
80
|
+
case 12:
|
|
81
|
+
# this is the utc offset
|
|
82
|
+
# usually this line is HH:MM:SS
|
|
83
|
+
# someimtes it is just HH:MM
|
|
84
|
+
# sometimes it is just H, so deal with all of those
|
|
85
|
+
line = clean_line(line).split(":")
|
|
86
|
+
sign = 1
|
|
87
|
+
if line[0] == "UTC":
|
|
88
|
+
utcoff = 0
|
|
89
|
+
continue
|
|
90
|
+
elif len(line) == 1:
|
|
91
|
+
h = int(line[0])
|
|
92
|
+
m = s = 0
|
|
93
|
+
elif len(line) == 2:
|
|
94
|
+
h = int(line[0])
|
|
95
|
+
m = int(line[1])
|
|
96
|
+
s = 0
|
|
97
|
+
else:
|
|
98
|
+
h = int(line[0])
|
|
99
|
+
m = int(line[1])
|
|
100
|
+
s = int(line[2])
|
|
101
|
+
if h < 0:
|
|
102
|
+
sign = -1
|
|
103
|
+
h = abs(h)
|
|
104
|
+
utcoff = sign*(int(h) + (int(m) / 60) + (int(s) / 3600))
|
|
105
|
+
case 13: # dst value
|
|
106
|
+
dst = intize_line(codecs.decode(line))
|
|
107
|
+
linenum += 1
|
|
108
|
+
input.close()
|
|
109
|
+
placename = city + ", " + country
|
|
110
|
+
ephclock = hour + min / 60 + sec / 3600
|
|
111
|
+
return (
|
|
112
|
+
name,
|
|
113
|
+
placename,
|
|
114
|
+
month,
|
|
115
|
+
day,
|
|
116
|
+
year,
|
|
117
|
+
# below is the precise decimal hour needed to turn this into the proper JulianDay
|
|
118
|
+
ephclock + utcoff - dst,
|
|
119
|
+
lat,
|
|
120
|
+
long,
|
|
121
|
+
-(utcoff - dst),
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def read_chtk_location(infile):
|
|
126
|
+
_, placename, _, _, _, _, lat, long, utcoff = read_chtk(infile)
|
|
127
|
+
return placename, lat, long, utcoff
|
|
128
|
+
|
|
129
|
+
def chtk_to_Location(infile):
|
|
130
|
+
context=chtk_to_context(infile)
|
|
131
|
+
return context.location
|
|
132
|
+
|
|
133
|
+
def read_toml(infile):
|
|
134
|
+
con=toml_to_context(infile)
|
|
135
|
+
return con.name,con.location.placename(),con.timeJD.month(),con.timeJD.day(),con.timeJD.year(),con.timeJD.hour(tz="utc"),con.location.lat,con.location.long,con.location.utcoffset
|
|
136
|
+
|
|
137
|
+
def read_toml_location(infile):
|
|
138
|
+
con=toml_to_context(infile)
|
|
139
|
+
return con.location.placename, con.location.lat, con.location.long, con.timeJD.utcoffset
|
|
140
|
+
|
|
141
|
+
def toml_to_Location(infile):
|
|
142
|
+
context=toml_to_context(infile)
|
|
143
|
+
return context.location
|
|
144
|
+
|
|
145
|
+
# note: argument "toround" takes a tuple (bool,int) = (if toround; ifso, how much)
|
|
146
|
+
def chtk_to_context(infile, sysflg=const.TROP,ayanamsa=98,hsys='C',circle=Circle.ADITYA,signize=True,toround=(True,3),print_nakshatras=True,print_outer_planets=True,names_type="mixed",sign_names="adityas"):
|
|
147
|
+
name, placename, month, day,year, timedec, lat, long, utcoffset = read_chtk(infile)
|
|
148
|
+
timeJD = JulianDay((year,month,day,timedec),utcoffset)
|
|
149
|
+
location = Location(lat, long, 0, placename, timeJD.utcoffset)
|
|
150
|
+
return EphContext(name=name,timeJD=timeJD,location=location,sysflg=sysflg,amsha=1,ayanamsa=ayanamsa,hsys=hsys,circle=circle,toround=toround,print_nakshatras=print_nakshatras, print_outer_planets=print_outer_planets, names_type="mixed",sign_names="adityas")
|
|
151
|
+
|
|
152
|
+
def context_to_chtk(context=EphContext(),outfile=None):
|
|
153
|
+
"""
|
|
154
|
+
turn context into a list of strings
|
|
155
|
+
|
|
156
|
+
out = []
|
|
157
|
+
out.append(str(name)+"\n")
|
|
158
|
+
out.append(str(year)+"\n")
|
|
159
|
+
out.append(str(month)+"\n")
|
|
160
|
+
out.append(str(day)+"\n")
|
|
161
|
+
out.append(str(hour)+"\n")
|
|
162
|
+
out.append(str(min)+"\n")
|
|
163
|
+
out.append(str(sec)+"\n")
|
|
164
|
+
out.append(str(sex)+"\n")
|
|
165
|
+
out.append(str(country)+"\n")
|
|
166
|
+
out.append(str(city)+"\n")
|
|
167
|
+
out.append(float_to_long(long)+"\n")
|
|
168
|
+
out.append(float_to_lat(lat)+"\n")
|
|
169
|
+
out.append(f"{h:02d}:{m:02d}:{s:02d}\n")
|
|
170
|
+
out.append(str(dst)+"\n")
|
|
171
|
+
return out
|
|
172
|
+
# put below into a different function
|
|
173
|
+
# fout = open(foutname+"-test"+".chtk","w")
|
|
174
|
+
# fout.writelines(out)
|
|
175
|
+
# fout.close()
|
|
176
|
+
"""
|
|
177
|
+
out = []
|
|
178
|
+
out.append(str(context.name)+"\n")
|
|
179
|
+
out.append(str(context.timeJD.year())+"\n")
|
|
180
|
+
out.append(str(context.timeJD.month())+"\n")
|
|
181
|
+
out.append(str(context.timeJD.day())+"\n")
|
|
182
|
+
out.append(str(context.timeJD.hour())+"\n")
|
|
183
|
+
out.append(str(context.timeJD.min())+"\n")
|
|
184
|
+
out.append(str(context.timeJD.sec())+"\n")
|
|
185
|
+
|
|
186
|
+
def chtk_to_toml(infile):
|
|
187
|
+
"""
|
|
188
|
+
encodes with the least information needed
|
|
189
|
+
outputs into an equivalent file, replacing .chtk by .toml
|
|
190
|
+
|
|
191
|
+
[timeJD]
|
|
192
|
+
jd = float
|
|
193
|
+
utcoffset = float
|
|
194
|
+
|
|
195
|
+
[location]
|
|
196
|
+
# N,E are positive
|
|
197
|
+
lat = float
|
|
198
|
+
long = float
|
|
199
|
+
# alt in meters
|
|
200
|
+
alt = float
|
|
201
|
+
# optional placename
|
|
202
|
+
placename = ""
|
|
203
|
+
timezone = timeJD.mktimezone()
|
|
204
|
+
"""
|
|
205
|
+
name, placename, month, day,year, timedec, lat, long, utcoffset = read_chtk(infile)
|
|
206
|
+
timeJD = JulianDay((year,month,day,timedec),utcoffset)
|
|
207
|
+
location = Location(lat, long, 0, placename, utcoffset)
|
|
208
|
+
d=dict()
|
|
209
|
+
d["name"] = name
|
|
210
|
+
d["timeJD"] = dict()
|
|
211
|
+
d["timeJD"]["jd"]=timeJD.jd_number()
|
|
212
|
+
d["timeJD"]["utcoffset"]=timeJD.utcoffset
|
|
213
|
+
d["location"]=location.__dict__
|
|
214
|
+
with open(f"{infile.split('.')[0]}.toml", "w") as fd:
|
|
215
|
+
toml.dump(d,fd)
|
|
216
|
+
return
|
|
217
|
+
|
|
218
|
+
def toml_to_context(infile) -> EphContext:
|
|
219
|
+
with open(infile, "r") as fd:
|
|
220
|
+
d = toml.load(fd)
|
|
221
|
+
name = d["name"]
|
|
222
|
+
timeJD = JulianDay(d["timeJD"]["jd"],d["timeJD"]["utcoffset"])
|
|
223
|
+
# use unpacking of the dictionary values
|
|
224
|
+
location = Location(*d["location"].values())
|
|
225
|
+
# all other options are defaults
|
|
226
|
+
return EphContext(name=name,timeJD=timeJD,location=location)
|
|
227
|
+
|
|
228
|
+
def lat_to_float(lat):
|
|
229
|
+
"""
|
|
230
|
+
change kalas lat representation into a float
|
|
231
|
+
"""
|
|
232
|
+
# string is like this 030E44'00
|
|
233
|
+
if lat[2:3] == "N":
|
|
234
|
+
sign = 1
|
|
235
|
+
else:
|
|
236
|
+
sign = -1
|
|
237
|
+
degs = float(lat[:2])
|
|
238
|
+
mins = float(lat[3:5])
|
|
239
|
+
secs = float(lat[6:8])
|
|
240
|
+
return sign*(degs + (mins / 60) + (secs / 3600))
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def float_to_lat(lat):
|
|
244
|
+
if lat >= 0:
|
|
245
|
+
dir = "N"
|
|
246
|
+
else:
|
|
247
|
+
dir = "S"
|
|
248
|
+
|
|
249
|
+
latstr = dec2dms(lat)
|
|
250
|
+
d, m, s = latstr.split(":")
|
|
251
|
+
|
|
252
|
+
return d + dir + m + "'" + s
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def long_to_float(long):
|
|
256
|
+
"""
|
|
257
|
+
change kalas long representation into a float
|
|
258
|
+
"""
|
|
259
|
+
# string is usually like this 030E44'00
|
|
260
|
+
if long[3:4] == "E":
|
|
261
|
+
sign = 1
|
|
262
|
+
else:
|
|
263
|
+
sign = -1
|
|
264
|
+
try:
|
|
265
|
+
degs = float(long[:3])
|
|
266
|
+
mins = float(long[4:6])
|
|
267
|
+
secs = float(long[7:9])
|
|
268
|
+
except:
|
|
269
|
+
degs = float(long[:2])
|
|
270
|
+
mins = float(long[3:5])
|
|
271
|
+
secs = float(long[6:8])
|
|
272
|
+
return sign*(degs + (mins / 60) + (secs / 3600))
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def float_to_long(long):
|
|
276
|
+
if long >= 0:
|
|
277
|
+
dir = "E"
|
|
278
|
+
else:
|
|
279
|
+
dir = "W"
|
|
280
|
+
|
|
281
|
+
longstr = dec2dms(long)
|
|
282
|
+
d, m, s = longstr.split(":")
|
|
283
|
+
|
|
284
|
+
return "0" + d + dir + m + "'" + s
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def intize_line(line):
|
|
288
|
+
"""
|
|
289
|
+
line is a string (of decoded bytes)
|
|
290
|
+
we remove all the space, etc. characters, then
|
|
291
|
+
can return the integer of the string
|
|
292
|
+
"""
|
|
293
|
+
nochars = ["\x00", "\r", "\n"]
|
|
294
|
+
count = 0
|
|
295
|
+
line = list(line)
|
|
296
|
+
while count < len(line):
|
|
297
|
+
if line[count] in nochars:
|
|
298
|
+
del line[count]
|
|
299
|
+
continue
|
|
300
|
+
count += 1
|
|
301
|
+
return int("".join(line))
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def clean_line(line):
|
|
305
|
+
"""
|
|
306
|
+
line is a line of bytes
|
|
307
|
+
we remove all the space, carriage return, and newline characters, then
|
|
308
|
+
can return the string as only a string
|
|
309
|
+
"""
|
|
310
|
+
line = line.decode(errors="ignore")
|
|
311
|
+
nochars = ["\x00", "\r", "\n"]
|
|
312
|
+
count = 0
|
|
313
|
+
line = list(line)
|
|
314
|
+
while count < len(line):
|
|
315
|
+
if line[count] in nochars:
|
|
316
|
+
del line[count]
|
|
317
|
+
continue
|
|
318
|
+
count += 1
|
|
319
|
+
retval = "".join(line)
|
|
320
|
+
# print(retval)
|
|
321
|
+
return retval
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def dec2dms(dd):
|
|
325
|
+
"""
|
|
326
|
+
take a decimal dd and return the equivalent DD:MM:SS as a string
|
|
327
|
+
"""
|
|
328
|
+
dd = abs(dd)
|
|
329
|
+
minutes, seconds = divmod(dd * 3600, 60)
|
|
330
|
+
degrees, minutes = divmod(minutes, 60)
|
|
331
|
+
return f"{round(degrees):02d}:{round(minutes):02d}:{round(seconds):02d}"
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def dms2dec(dms):
|
|
335
|
+
"""
|
|
336
|
+
dms is a tuple (hour,minutes,seconds) that wants to be turned into a float
|
|
337
|
+
"""
|
|
338
|
+
return dms[0] + (dms[1] / 60) + (dms[2] / 3600)
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def intize_date(date):
|
|
342
|
+
"""
|
|
343
|
+
take a string 'MM/DD/YYYY'
|
|
344
|
+
and return a tuple of int (mm,dd,yyyy)
|
|
345
|
+
"""
|
|
346
|
+
date = date.split("/")
|
|
347
|
+
year = int(date[2])
|
|
348
|
+
month = int(date[0])
|
|
349
|
+
day = int(date[1])
|
|
350
|
+
|
|
351
|
+
return (month, day, year)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def intize_time(time):
|
|
355
|
+
"""
|
|
356
|
+
take a string 'HH:MM:SS'
|
|
357
|
+
and return a float of that time
|
|
358
|
+
"""
|
|
359
|
+
time = time.split(":")
|
|
360
|
+
if len(time) == 2:
|
|
361
|
+
# no seconds
|
|
362
|
+
return float(time[0]) + float(time[1]) / 60
|
|
363
|
+
else:
|
|
364
|
+
return float(time[0]) + float(time[1]) / 60 + float(time[2]) / 3600
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def parse_position_argument(position):
|
|
368
|
+
"""
|
|
369
|
+
i think this basically works now
|
|
370
|
+
|
|
371
|
+
parse command line position argument
|
|
372
|
+
position is one position, either latitude or longitude
|
|
373
|
+
either can be:
|
|
374
|
+
float
|
|
375
|
+
DD:MM(:SS)
|
|
376
|
+
(D)DD(N/E/S/W)MM('SS)
|
|
377
|
+
return a float
|
|
378
|
+
N and E are positive
|
|
379
|
+
S and W are negative
|
|
380
|
+
"""
|
|
381
|
+
|
|
382
|
+
# given as a decimal
|
|
383
|
+
if "." in position and not any(char.isalpha() for char in position):
|
|
384
|
+
return float(position)
|
|
385
|
+
|
|
386
|
+
# given in the form DD:MM(:SS)
|
|
387
|
+
if not isinstance(position, float):
|
|
388
|
+
if ":" in position:
|
|
389
|
+
positiontmp = position.split(":")
|
|
390
|
+
# if len == 2, HH:MM, otherwise, HH:MM:SS
|
|
391
|
+
sign = 1
|
|
392
|
+
if "-" in positiontmp[0]:
|
|
393
|
+
sign = -1
|
|
394
|
+
if len(positiontmp) == 2:
|
|
395
|
+
position = sign * (abs(float(positiontmp[0])) + float(positiontmp[1]) / 60)
|
|
396
|
+
else:
|
|
397
|
+
position = sign * (abs(float(positiontmp[0])) + float(positiontmp[1]) / 60 + float(positiontmp[2]) / 3600)
|
|
398
|
+
return position
|
|
399
|
+
|
|
400
|
+
# given in Kala format DDD(DIR)MM('SS)
|
|
401
|
+
# longtiude is DDD, latitude it DD
|
|
402
|
+
if not isinstance(position, float):
|
|
403
|
+
if "N" in position or "S" in position or "W" in position or "E" in position:
|
|
404
|
+
if "N" in position:
|
|
405
|
+
positionsign = 1
|
|
406
|
+
positiontmp = position.split("N")
|
|
407
|
+
elif "E" in position:
|
|
408
|
+
positionsign = 1
|
|
409
|
+
positiontmp = position.split("E")
|
|
410
|
+
elif "S" in position:
|
|
411
|
+
positionsign = -1
|
|
412
|
+
positiontmp = position.split("S")
|
|
413
|
+
elif "W" in position:
|
|
414
|
+
positionsign = -1
|
|
415
|
+
positiontmp = position.split("W")
|
|
416
|
+
if "'" in positiontmp[1]:
|
|
417
|
+
min, sec = positiontmp[1].split("'")
|
|
418
|
+
position = positionsign * (int(positiontmp[0]) + int(min) / 60 + float(sec) / 3600)
|
|
419
|
+
else:
|
|
420
|
+
position = positionsign * (int(positiontmp[0]) + int(positiontmp[1]) / 60)
|
|
421
|
+
return position
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
#def init_names(langfile=const.base_path + "/dict/dict.mixed"):
|
|
427
|
+
# names = configparser.ConfigParser()
|
|
428
|
+
# if "/" not in langfile:
|
|
429
|
+
# langfile = const.base_path + f"/dict/{langfile}"
|
|
430
|
+
# names.read(langfile)
|
|
431
|
+
#
|
|
432
|
+
# # because of importing and such things
|
|
433
|
+
# planets = []
|
|
434
|
+
# zodiac = []
|
|
435
|
+
# tithis = []
|
|
436
|
+
# karanas = []
|
|
437
|
+
# nakshatras = []
|
|
438
|
+
# nakshatraeq = []
|
|
439
|
+
# varas = []
|
|
440
|
+
# yogas = []
|
|
441
|
+
# adityas = []
|
|
442
|
+
#
|
|
443
|
+
# # because of needing these names in pyphclasses i called init_names()
|
|
444
|
+
# # there, which when i run the whole program thus initializes them twice
|
|
445
|
+
# # which causes the karana especially to not work right
|
|
446
|
+
# # so if planets is not an empty list, then we have already done the names
|
|
447
|
+
# # if planets != []:
|
|
448
|
+
# # return
|
|
449
|
+
#
|
|
450
|
+
# pnames = names["PLANETS"]
|
|
451
|
+
# znames = names["RASIS"]
|
|
452
|
+
# tnames = names["TITHI"]
|
|
453
|
+
# knames = names["KARANA"]
|
|
454
|
+
# nnames = names["NAKSHATRA"]
|
|
455
|
+
# neqnames = names["NAKSHATRAEQ"]
|
|
456
|
+
# vnames = names["VARA"]
|
|
457
|
+
# ynames = names["YOGAS"]
|
|
458
|
+
# anames = names["ADITYAS"]
|
|
459
|
+
#
|
|
460
|
+
# planets.append(pnames["Sun"])
|
|
461
|
+
# planets.append(pnames["Moon"])
|
|
462
|
+
# planets.append(pnames["Mercury"])
|
|
463
|
+
# planets.append(pnames["Venus"])
|
|
464
|
+
# planets.append(pnames["Mars"])
|
|
465
|
+
# planets.append(pnames["Jupiter"])
|
|
466
|
+
# planets.append(pnames["Saturn"])
|
|
467
|
+
# planets.append(pnames["Uranus"])
|
|
468
|
+
# planets.append(pnames["Neptune"])
|
|
469
|
+
# planets.append(pnames["Pluto"])
|
|
470
|
+
# planets.append(pnames["Rahu"]) # index 10
|
|
471
|
+
# planets.append(pnames["Ketu"]) # index 11
|
|
472
|
+
# planets.append([])
|
|
473
|
+
# planets.append([])
|
|
474
|
+
# planets.append(pnames["Earth"]) # so we can use swe.EARTH
|
|
475
|
+
# planets.append("Chiron")
|
|
476
|
+
#
|
|
477
|
+
# zodiac.append(znames["Aries"])
|
|
478
|
+
# zodiac.append(znames["Taurus"])
|
|
479
|
+
# zodiac.append(znames["Gemini"])
|
|
480
|
+
# zodiac.append(znames["Cancer"])
|
|
481
|
+
# zodiac.append(znames["Leo"])
|
|
482
|
+
# zodiac.append(znames["Virgo"])
|
|
483
|
+
# zodiac.append(znames["Libra"])
|
|
484
|
+
# zodiac.append(znames["Scorpio"])
|
|
485
|
+
# zodiac.append(znames["Sagittarius"])
|
|
486
|
+
# zodiac.append(znames["Capricorn"])
|
|
487
|
+
# zodiac.append(znames["Aquarius"])
|
|
488
|
+
# zodiac.append(znames["Pisces"])
|
|
489
|
+
#
|
|
490
|
+
# tithis.append(tnames["Nanda"])
|
|
491
|
+
# tithis.append(tnames["Bhadra"])
|
|
492
|
+
# tithis.append(tnames["Jaya"])
|
|
493
|
+
# tithis.append(tnames["Rkta"])
|
|
494
|
+
# tithis.append(tnames["Purna"])
|
|
495
|
+
#
|
|
496
|
+
# karanas.append(knames["Kimtughna"])
|
|
497
|
+
# karanas.append(knames["Bava"])
|
|
498
|
+
# karanas.append(knames["Balava"])
|
|
499
|
+
# karanas.append(knames["Kaulava"])
|
|
500
|
+
# karanas.append(knames["Taitula"])
|
|
501
|
+
# karanas.append(knames["Garija"])
|
|
502
|
+
# karanas.append(knames["Vanija"])
|
|
503
|
+
# karanas.append(knames["Vishti"])
|
|
504
|
+
# karanas.append(knames["Shakuni"])
|
|
505
|
+
# karanas.append(knames["Chatushpada"])
|
|
506
|
+
# karanas.append(knames["Naga"])
|
|
507
|
+
# karanas = organize_karana(karanas)
|
|
508
|
+
#
|
|
509
|
+
# nakshatras.append(nnames["Ashvini"])
|
|
510
|
+
# nakshatras.append(nnames["Bharani"])
|
|
511
|
+
# nakshatras.append(nnames["Krittika"])
|
|
512
|
+
# nakshatras.append(nnames["Rohini"])
|
|
513
|
+
# nakshatras.append(nnames["Mrigashira"])
|
|
514
|
+
# nakshatras.append(nnames["Ardra"])
|
|
515
|
+
# nakshatras.append(nnames["Punarvasu"])
|
|
516
|
+
# nakshatras.append(nnames["Pushya"])
|
|
517
|
+
# nakshatras.append(nnames["Ashlesha"])
|
|
518
|
+
# nakshatras.append(nnames["Magha"])
|
|
519
|
+
# nakshatras.append(nnames["Purva Phalguni"])
|
|
520
|
+
# nakshatras.append(nnames["Uttara Phalguni"])
|
|
521
|
+
# nakshatras.append(nnames["Hasta"])
|
|
522
|
+
# nakshatras.append(nnames["Chitra"])
|
|
523
|
+
# nakshatras.append(nnames["Svati"])
|
|
524
|
+
# nakshatras.append(nnames["Vishakha"])
|
|
525
|
+
# nakshatras.append(nnames["Anuradha"])
|
|
526
|
+
# nakshatras.append(nnames["Jyeshtha"])
|
|
527
|
+
# nakshatras.append(nnames["Mula"])
|
|
528
|
+
# nakshatras.append(nnames["Purva Ashadha"])
|
|
529
|
+
# nakshatras.append(nnames["Uttara Ashadha"])
|
|
530
|
+
# nakshatras.append(nnames["Shravana"])
|
|
531
|
+
# nakshatras.append(nnames["Danishtha"])
|
|
532
|
+
# nakshatras.append(nnames["Shatabhisha"])
|
|
533
|
+
# nakshatras.append(nnames["Purva Bhadrapada"])
|
|
534
|
+
# nakshatras.append(nnames["Uttara Bhadrapada"])
|
|
535
|
+
# nakshatras.append(nnames["Revati"])
|
|
536
|
+
#
|
|
537
|
+
# varas.append(vnames["Ravivara"])
|
|
538
|
+
# varas.append(vnames["Somavara"])
|
|
539
|
+
# varas.append(vnames["Mangalavara"])
|
|
540
|
+
# varas.append(vnames["Budhavara"])
|
|
541
|
+
# varas.append(vnames["Guruvara"])
|
|
542
|
+
# varas.append(vnames["Shukravara"])
|
|
543
|
+
# varas.append(vnames["Shanivara"])
|
|
544
|
+
#
|
|
545
|
+
# yogas.append(ynames["Vishkambha"])
|
|
546
|
+
# yogas.append(ynames["Priti"])
|
|
547
|
+
# yogas.append(ynames["Ayushman"])
|
|
548
|
+
# yogas.append(ynames["Saubhagya"])
|
|
549
|
+
# yogas.append(ynames["Shobana"])
|
|
550
|
+
# yogas.append(ynames["Atiganda"])
|
|
551
|
+
# yogas.append(ynames["Sukarma"])
|
|
552
|
+
# yogas.append(ynames["Dhriti"])
|
|
553
|
+
# yogas.append(ynames["Shoola"])
|
|
554
|
+
# yogas.append(ynames["Ganda"])
|
|
555
|
+
# yogas.append(ynames["Vriddhi"])
|
|
556
|
+
# yogas.append(ynames["Dhruva"])
|
|
557
|
+
# yogas.append(ynames["Vyaghata"])
|
|
558
|
+
# yogas.append(ynames["Harshana"])
|
|
559
|
+
# yogas.append(ynames["Vajra"])
|
|
560
|
+
# yogas.append(ynames["Siddhi"])
|
|
561
|
+
# yogas.append(ynames["Vyatipata"])
|
|
562
|
+
# yogas.append(ynames["Variyan"])
|
|
563
|
+
# yogas.append(ynames["Parigha"])
|
|
564
|
+
# yogas.append(ynames["Shiva"])
|
|
565
|
+
# yogas.append(ynames["Siddha"])
|
|
566
|
+
# yogas.append(ynames["Sadhya"])
|
|
567
|
+
# yogas.append(ynames["Shubha"])
|
|
568
|
+
# yogas.append(ynames["Shukla"])
|
|
569
|
+
# yogas.append(ynames["Brahma"])
|
|
570
|
+
# yogas.append(ynames["Indra"])
|
|
571
|
+
# yogas.append(ynames["Vaidhriti"])
|
|
572
|
+
#
|
|
573
|
+
# adityas.append(anames["Dhata"])
|
|
574
|
+
# adityas.append(anames["Aryama"])
|
|
575
|
+
# adityas.append(anames["Mitra"])
|
|
576
|
+
# adityas.append(anames["Varuna"])
|
|
577
|
+
# adityas.append(anames["Indra"])
|
|
578
|
+
# adityas.append(anames["Vivasvan"])
|
|
579
|
+
# adityas.append(anames["Tvashta"])
|
|
580
|
+
# adityas.append(anames["Vishnu"])
|
|
581
|
+
# adityas.append(anames["Amshu"])
|
|
582
|
+
# adityas.append(anames["Bhaga"])
|
|
583
|
+
# adityas.append(anames["Pusha"])
|
|
584
|
+
# adityas.append(anames["Parjanya"])
|
|
585
|
+
#
|
|
586
|
+
# # sidereal_adityas = [adityas[11]] + adityas[:11]
|
|
587
|
+
#
|
|
588
|
+
# nakshatraeq.append(neqnames["Krittika"])
|
|
589
|
+
# nakshatraeq.append(neqnames["Rohini"])
|
|
590
|
+
# nakshatraeq.append(neqnames["Mrigashira"])
|
|
591
|
+
# nakshatraeq.append(neqnames["Ardra"])
|
|
592
|
+
# nakshatraeq.append(neqnames["Punarvasu"])
|
|
593
|
+
# nakshatraeq.append(neqnames["Pushya"])
|
|
594
|
+
# nakshatraeq.append(neqnames["Ashlesha"])
|
|
595
|
+
# nakshatraeq.append(neqnames["Magha"])
|
|
596
|
+
# nakshatraeq.append(neqnames["Purva Phalguni"])
|
|
597
|
+
# nakshatraeq.append(neqnames["Uttara Phalguni"])
|
|
598
|
+
# nakshatraeq.append(neqnames["Hasta"])
|
|
599
|
+
# nakshatraeq.append(neqnames["Chitra"])
|
|
600
|
+
# nakshatraeq.append(neqnames["Svati"])
|
|
601
|
+
# nakshatraeq.append(neqnames["Vishakha"])
|
|
602
|
+
# nakshatraeq.append(neqnames["Anuradha"])
|
|
603
|
+
# nakshatraeq.append(neqnames["Jyeshtha"])
|
|
604
|
+
# nakshatraeq.append(neqnames["Mula"])
|
|
605
|
+
# nakshatraeq.append(neqnames["Purva Ashadha"])
|
|
606
|
+
# nakshatraeq.append(neqnames["Uttara Ashadha"])
|
|
607
|
+
# nakshatraeq.append(neqnames["Abhijit"])
|
|
608
|
+
# nakshatraeq.append(neqnames["Shravana"])
|
|
609
|
+
# nakshatraeq.append(neqnames["Danishtha"])
|
|
610
|
+
# nakshatraeq.append(neqnames["Shatabhisha"])
|
|
611
|
+
# nakshatraeq.append(neqnames["Purva Bhadrapada"])
|
|
612
|
+
# nakshatraeq.append(neqnames["Uttara Bhadrapada"])
|
|
613
|
+
# nakshatraeq.append(neqnames["Revati"])
|
|
614
|
+
# nakshatraeq.append(neqnames["Ashvini"])
|
|
615
|
+
# nakshatraeq.append(neqnames["Bharani"])
|
|
616
|
+
#
|
|
617
|
+
# return (
|
|
618
|
+
# planets,
|
|
619
|
+
# zodiac,
|
|
620
|
+
# tithis,
|
|
621
|
+
# karanas,
|
|
622
|
+
# nakshatras,
|
|
623
|
+
# varas,
|
|
624
|
+
# yogas,
|
|
625
|
+
# adityas,
|
|
626
|
+
# )
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
# there are 11 karanas
|
|
630
|
+
# 4 happen once a lunar month
|
|
631
|
+
# the other 7 happen 8 times each a lunar month,
|
|
632
|
+
# repeating in a fixed pattern
|
|
633
|
+
# so the config just has 11 names
|
|
634
|
+
# and the function below is to organize them as
|
|
635
|
+
# as list of pairs in order that can easily be indexed when we know the tithi
|
|
636
|
+
def organize_karana(karana):
|
|
637
|
+
# lets do them in order
|
|
638
|
+
ret = [] # our return list or organized karana
|
|
639
|
+
tmp = [] # build a list of two in tmp, then append to ret
|
|
640
|
+
# then the 7 repeat in order eight times
|
|
641
|
+
tmp.append(karana[0])
|
|
642
|
+
for i in range(8):
|
|
643
|
+
for n in range(7):
|
|
644
|
+
# n+1 because, e.g., bava is at [1]
|
|
645
|
+
if (
|
|
646
|
+
i % 2 == 1
|
|
647
|
+
): # i is odd, so we need to start a new pair first, if n is even
|
|
648
|
+
if n % 2 == 0:
|
|
649
|
+
tmp.append(karana[n + 1])
|
|
650
|
+
else:
|
|
651
|
+
tmp.append(karana[n + 1])
|
|
652
|
+
ret.append(tmp)
|
|
653
|
+
tmp = []
|
|
654
|
+
else:
|
|
655
|
+
if n % 2 == 0: # n is even; append this karana to its first of the pair
|
|
656
|
+
tmp.append(karana[n + 1])
|
|
657
|
+
# this pair is done, so it can be added to ret
|
|
658
|
+
ret.append(tmp)
|
|
659
|
+
tmp = []
|
|
660
|
+
else: # n is odd; start a new pair list
|
|
661
|
+
tmp.append(karana[n + 1])
|
|
662
|
+
tmp.append(karana[8])
|
|
663
|
+
ret.append(tmp)
|
|
664
|
+
ret.append([karana[9], karana[10]])
|
|
665
|
+
return ret
|