-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
107 lines (95 loc) · 2.73 KB
/
main.py
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
print("""Photopollution Calculator Copyright (C) 2019 Conor Casey
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. For further details, type `license'.
Don't know how to use the program? Type "help" for support.
To get a history of the updates released for this program, type "updates"
To exit the program, type 'quit'.
Current Edition: v4.0.0""")
def main():
import pandas as pd
import math
place_town = input("""
Is the name of the town being entered: """).lower()
#Updates
if place_town == "updates":
updates = open('UPDATES.md', 'r')
updates_read = updates.read()
print (updates_read)
updates.close()
main()
#Licensing Agreement
if place_town == "license":
license = open('LICENSE','r')
license_read = license.read()
print(license_read)
license.close()
main()
#Help Section
elif place_town == "help":
text = open('README.md','r')
text_read = text.read()
print(text_read)
text.close()
main()
#Force Closes Application
elif place_town == "quit":
quit()
#Population Density or Town Input
elif place_town == "no":
place = input("""
Enter the Population Density: """)
if place.isdigit() == False:
print("It appears you have entered words instead of numbers, please try again.")
main()
else:
print(place)
user_input = float(place)
#If A Town Is Entered
elif place_town == "yes":
pd_filename = 'Data/Population_Density/population_density_combined.csv'
pd_data = pd.read_csv(pd_filename)
towns = input("""
Please input the name of the town: """).title()
town = pd_data[pd_data.Towns.isin([towns])]
town.reset_index(inplace = True, drop = True)
if not town.empty:
print (town)
user_input = float(town.PD)
else:
print ("No population density data for the town of "), (towns), (" is available.")
main()
else:
print("Invalid Entry")
main()
#Calculation of Light Pollution
sqm = -2.51632097e-03 * user_input + 2.07271443e+01
#Understanding LUX Values
def conditions():
if sqm > 21:
return " Excellent Stargazing Conditions"
elif sqm > 20:
return " Great Stargazing Conditions"
elif sqm > 19:
return " Good Stargazing Conditions"
elif sqm > 18:
return " Fair Stargazing Conditions"
elif sqm > 17:
return " Poor Stargazing Conditions"
elif sqm < 17:
return " Terrible Stargazing Conditions"
#Result/Output
print("""
Photopollution in this location is approximately """ + str(round(sqm, 2)) + " mags / arcsec^2, this" + """
should correlate to""" + conditions())
#Restarts Program
restart = input("""
Do You Want to Restart the Program: """).lower()
if restart == "yes":
print("""
Restarting...""")
main()
else:
quit()
main()
#End of Code