Skip to content

Commit

Permalink
Sky Quality Update
Browse files Browse the repository at this point in the history
  • Loading branch information
conorcaseyc committed Mar 26, 2019
1 parent c74ebd2 commit 3a329a0
Show file tree
Hide file tree
Showing 10 changed files with 361 additions and 155 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added Data/.DS_Store
Binary file not shown.
155 changes: 155 additions & 0 deletions Data/.ipynb_checkpoints/scatterplot-checkpoint.ipynb

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions Data/SQM.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from numpy import *
from scipy.interpolate import *
from matplotlib.pyplot import *
from scipy.stats import *

#The Data
population_density = array([1901, 1292, 1423.6, 1069.2, 731.9, 2163.9, 1467.7, 327.6, 768.5, 2.4])
population = array ([94192, 1129, 6619, 2023, 2486, 23691, 14504, 172, 2376, 146])
sqm = array([16.15, 17.17, 16.88, 17.44, 19.11, 15.87, 16.89, 19.79, 18.57, 21.35])
print(population_density)
print(population)
print(sqm)

#Finds the formula to describe the correlation between population density and photopollution
p1 = polyfit(population_density,sqm,1)
print(p1)
#Finds the correlation coefficient in the case of population density
slope,intercept,r_value,p_value,std_err = linregress(population_density,sqm)
correlation = (pow(r_value,2))
print(correlation)
#Finds the formula to describe the correlation between population and photopollution (Normalization of Walker's Law.)
p2 = polyfit(population,sqm,1)
print(p2)
#Finds the correlation coefficient in the case of population
slope,intercept2,r_value2,p_value2,std_err2 = linregress(population,sqm)
correlation2 = (pow(r_value2,2))
print (correlation2)
#Calculate Standard Deviation
stddev = std(sqm)
print(stddev)
Binary file added Data/__pycache__/SQM.cpython-37.pyc
Binary file not shown.
155 changes: 155 additions & 0 deletions Data/scatterplot.ipynb

Large diffs are not rendered by default.

118 changes: 0 additions & 118 deletions Program.py

This file was deleted.

13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,19 @@ Welcome to the Photopollution Calculator. This program is based on the mathemati
To run this program you will need:

* Python (Preferably Python 2.7)
* Python 3
* Pandas
* Scipy
* Numpy
* Mathplotlib

All the necessary tools needed to run this program are available through [Anaconda](https://www.anaconda.com/download/).
Choose the operating system you are using, download the Python 2.7 version, and follow the Installation instructions available on their website.
Choose the operating system you are using, download the Python 3 version, and follow the Installation instructions available on their website.

To install and run this program, open a command line and type the following:

``` bash
$ git clone https://www.github.com/conorcaseyc/Photopollution-Calculator
$ cd Photopollution-Calculator
$ python2 Program.py
```
If you are using Python 3, use the following command instead of the final command previously mentioned:

```bash
$ python3 Program_3.py
$ python main.py
```

If you have any problems, please [email me.](mailto:[email protected])
Expand Down
1 change: 1 addition & 0 deletions UPDATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ v1.5.1: Emergency Bug Fix Update
v1.5.2: Small Changes and Fixes
v1.6.0: Errer Update
v2.0.0: BTYSTE Update
v3.0.0: Sky Quality Update
44 changes: 17 additions & 27 deletions Program_3.py → main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
print("""Photopollution Calculator Copyright (C) 2018 Conor Casey
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'.
Expand All @@ -7,7 +7,7 @@
To get a history of the updates released for this program, type "updates"
To exit the program, type 'quit'.
Current Edition: v2.0.0""")
Current Edition: v3.0.0""")

def main():
#Imports Population Density Data from the Central Statistics Office
Expand Down Expand Up @@ -72,37 +72,27 @@ def main():
main()

#Calculation of Light Pollution
lux = 0.03510566 * user_input - 14.32414198

#Get Limerick's Population Density In Order to Understand what the LUX Values Mean
limerick = pd_data[pd_data.Towns.isin(["Limerick City"])]
limerick.reset_index(inplace = True, drop = True)
limerick_pd = float(limerick.PD)
limerick_lux = 0.03510566 * (limerick_pd) - 14.32414198
sqm = -2.51632097e-03 * user_input + 2.07271443e+01

#Understanding LUX Values
calculations = (lux) / (limerick_lux) * 100
def conditions():
if calculations >= 80:
return " Terrible Stargazing Conditions"
elif calculations >= 60:
return " Poor Stargazing Conditions"
elif calculations >= 40:
return " Fair Stargazing Conditions"
elif calculations >= 20:
if sqm > 21:
return " Excellent Stargazing Conditions"
elif sqm > 20:
return " Great Stargazing Conditions"
elif sqm > 19:
return " Good Stargazing Conditions"
elif calculations >= 0:
return " Excellent 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
if calculations >= 0:
print("""
Photopollution in this location is approximately """ + str(int(math.ceil(lux))) + " LUX, this should" + """
print("""
Photopollution in this location is approximately """ + str(round(sqm, 2)) + " mags / arcsec^2, this should" + """
correlate to""" + conditions())
elif calculations < 0:
print("""
Oops, it appears we are getting a negative LUX value. Your population density
is extremely low, therefore, this correlates to Excellent Stargazing Conditions.""")

#Restarts Program
restart = input("""
Expand All @@ -115,4 +105,4 @@ def conditions():
quit()
main()

#End of Code
#End of Code

0 comments on commit 3a329a0

Please sign in to comment.