oI started working on the gauge and I think this seemed a lot more difficult than it is. It is still a in progress project but my goal was to make a gauge in python that will operate on live info(5-10 second intervals) on electricity info. I started with the plotly library. This library wasn't very clear when I went through the documentation. Me being a PyCharm professional user spend about an hour trying to figure out why I cant run any of the demo programs that were demoed on the documentation. I took me a while but then I found out that all those commands are made specially for ipython notebook and then I found another section for users of other ide's. Learning this I went forward and found a Gauge template after making a few changes to this template and playing around I think I had the grasp of the library. So for the library you wrote all your code in libraries and it made the graphical interface by converting your code to html and made an html file that you could open in you browser. After this I had a though on how I would be updating this html file. Me never having worked with html was not sure how but after spending some time on w3school I learnt a command with which I can make the html page force refresh it self every 5 seconds and when it refreshes the html page would have the new live data. I implemented this command after plotly produced the html file. Python would open it delete the first line and then retype it with the command to refresh every 5 seconds(update-I am still in the process of writing this blog but I just came across something called ajax that might be worth giving a look at in the next blog). Next I started working on moving the pointer of the gauge. I learnt about this my learning of the command M for move, L for line to, and Z to end. This is how the shape would be made in css and html and if I got python to update the html file every 5 seconds by changing the location or coordinates of the pointer it would update on the webpage to have a moving pointer. After learning that I went on to figure how what value would correspond to how much movement. To do this I tried breaking it between percentage and the coordinates on the circle. This took a look of math(geometry, trignometry, and algebra). I figured out how to scale percent to how much this meant on the scale by doing the math on paper. I am yet to write the algorithm for this on python. When I do I will blog about it and hopefully by success with AJAX. I believe I may use the math library SymPy to simplify my work.
_____________________________________________________________________
0 Comments
For the first half we just worked on improving our pandas knowledge by coding small programs that would filter through csv files with many data points(million) and try making different kinds of filters as we explored many of the issues and interesting things in pandas like the data types the library has and the different functions for the different ones and how it has its own format and way to do things like the format of a date or such. Later we had a presentation by Janet Nicosia and I found this presentation very interesting she gave us a small sneak peak or just a few things about the solar business and how it functioned. The bills she gave us showed really high profits(70% interest) and I also found how AHS is actually a fully clean energy powered school yet I have never heard any talk or brag about this. The net metering system seems something very cool and complicated at the same time and I just never though it would be possible to turn a solar plant into a largely profitable source of income.
We all went over the Carbon Dioxide Emission diagrams and how 60 Quads is Rejected Energy. I found this very surprising and 21 quads were from transportation and I found this very surprising as that seems like a very large amount considering only 5 quads are go under actual energy service. We then moved on to heat or natural gas and how the unit is therms and such. We also went over gas bills and national grid bills
Now to just add on to our knowledge of Pandas we practiced using them a little more by making a more logical code with single script with input/output.
I think this was more focussed on object oriented programming in python. I learnt more about this as I never knew about this before and I learnt how this was different from languages like java where here we have variables like self or commands like __init__ and such. This is my code: import pandas as pd class EnergyAnalysis: def __init__(self, csv, column, column2): self.csv = pd.read_csv(csv) self.csvName = csv self.column = column self.column2 = column2 def setCsv(self, csv): self.csv = pd.read_csv(csv) def setColumn(self, column): self.column = column def setColumn2(self, column2): self.column2 = column2 def getCsv(self): return self.csvName def getColumn(self): return self.column def getColumn2(self): return self.column2 def sumCompare(self): column1sum = self.csv[self.column].sum() column2sum = self.csv[self.column2].sum() result="" if column1sum > column2sum: columnDifference = column1sum-column2sum result="Sum of all values in " + self.column + " is " + str(column1sum) +". Sum of all values in " + \ self.column2 + " is " + str(column2sum) + ". Sum of all values in " + self.column + \ " is greater than the sum of all values in " + self.column2 + ". " + self.column + \ " is greater than sum of " + self.column2 + " by " + str(columnDifference) elif column2sum > column1sum: columnDifference = column2sum-column1sum result="Sum of all values in " + self.column + " is " + str(column1sum) + ". Sum of all values in " +\ self.column2 + " is " + str(column2sum) + ". Sum of all values in " + self.column2 + \ " is greater than the sum of all values in " + self.column + ". " + self.column2 + \ "is greater than sum of " + self.column + " by " + str(columnDifference) elif column1sum == column2sum: result="Sum of all values in " + self.column + " is " + str(column1sum) +". Sum of all values in " + \ self.column2 + " is " + str(column2sum) + ". Sum of all values in " + self.column + \ " is equal to the sum of all values in " + self.column2 + "." return result def avgCompare(self): column1avg = self.csv[self.column].mean() column2avg = self.csv[self.column2].mean() if column1avg > column2avg: columnDifference = column1avg-column2avg return "Average of " + self.column + " is " + str(column1avg) + " and average of " + self.column2 + \ " is " + str(column2avg) + ". Average of " + self.column + " is greater than " + self.column2 + \ " by " + str(columnDifference) elif column2avg > column1avg: columnDifference = column2avg - column1avg return "Average of " + self.column + " is " + str(column1avg) + " and average of " + self.column2 + \ " is " + str(column2avg) + ". Average of " + self.column2 + " is greater than " + self.column + \ " by " + str(columnDifference) elif column2avg == column1avg: return "Average of " + self.column + " is " + str(column1avg) + " and average of " + self.column2 + \ " is " + str(column2avg) + ". Average of " + self.column2 + " is equal to " + self.column def totalCompare(self, filename): file = open((filename+".txt"),"w") file.write(self.sumCompare()) file.write("") file.write(self.avgCompare()) file.close() print("Exiting totalCompare") test = EnergyAnalysis("2016 Q1Q4 - Electrical.csv", "HS-Kitchen Emergency (kWh)", "HS Main (kWh)") test.totalCompare("test1") print("Done") The output is in a .txt file where it compares the two columns Samar and I got back and started to work on the .CSV files that Mr. Navkal sent us and the one at the library.
Our Goal was to:
import pandas as pd # 2016 EnergyUsage2016 = pd.read_csv("2016 Q1Q4 - Electrical.csv") print("2016") sumOfEnergyUsage2016 = EnergyUsage2016.sum() print(sumOfEnergyUsage2016) print() print() HS2016kWh = EnergyUsage2016['HS Main (kWh)'].sum() + EnergyUsage2016['HS DHB Plugload (kWh)'].sum() + \ EnergyUsage2016['HS DL Lighting (kWh)'].sum() + EnergyUsage2016['HS-Kitchen Emergency (kWh)'].sum() + \ EnergyUsage2016['HS DG Gym (kWh)'].sum() + EnergyUsage2016['HS M1 Chillers (kWh)'].sum() + \ EnergyUsage2016['HS CC (kWh)'].sum() CollinsCenter2016 = EnergyUsage2016['HS CC (kWh)'].sum() PercentUsage2016 = CollinsCenter2016/HS2016kWh * 100 print("Energy used in 2016 by AHS was " + str(HS2016kWh) + " kWh.") print("Energy used in 2016 by the Collins center was " + str(CollinsCenter2016) + " kWh.") print("The Collins Center contributed " + str(PercentUsage2016) + "% of AHS's total energy consumption in 2016.") print() print() print() print() # 2017 EnergyUsage2017 = pd.read_csv("2017 Q1Q4 - Electrical Energy Daily.csv") print("2017") sumOfEnergyUsage2017 = EnergyUsage2017.sum() print(sumOfEnergyUsage2017) print() print() HS2017kWh = EnergyUsage2017['HS Main (kWh)'].sum() + EnergyUsage2017['HS DHB Plugload (kWh)'].sum() + \ EnergyUsage2017['HS DL Lighting (kWh)'].sum() + EnergyUsage2017['HS-Kitchen Emergency (kWh)'].sum() + \ EnergyUsage2017['HS DG Gym (kWh)'].sum() + EnergyUsage2017['HS PBA AHU1- 4 (KWh)'].sum() + \ EnergyUsage2017['HS M1 Chillers (kWh)'].sum() + EnergyUsage2017['HS CC (kWh)'].sum() + \ EnergyUsage2017['HS Gas (100 Cu Ft)'].sum() * 29 CollinsCenter2017 = EnergyUsage2017['HS CC (kWh)'].sum() PercentUsage2017 = CollinsCenter2017/HS2017kWh * 100 print("The amount of energy used in 2017 by AHS was " + str(HS2017kWh) + " kWh.") print("The amount of energy used in 2017 by the Collins center was " + str(CollinsCenter2017) + " kWh.") print("The Collins Center contributed " + str(float(PercentUsage2017)) + "% of AHS's total energy consumption in 2017.") This was the output /Users/ayushzenith/PycharmProjects/Energize1/venv/bin/python /Users/ayushzenith/PycharmProjects/Energize1/venv/playground.py 2016 HS Main (kWh) 1705498.00 HS DL Lighting (kWh) 425014.40 HS-Kitchen Emergency (kWh) 384582.40 HS DHB Plugload (kWh) 146111.61 HS DG Gym (kWh) 377604.80 HS M1 Chillers (kWh) 37243.27 HS CC (kWh) 309461.50 dtype: float64 Energy used in 2016 by AHS was 3385515.98 kWh. Energy used in 2016 by the Collins center was 309461.5 kWh. The Collins Center contributed 9.14074846576267% of AHS's total energy consumption in 2016. 2017 HS Main (kWh) 1573257.000 HS DHB Plugload (kWh) 142503.700 HS DL Lighting (kWh) 382167.700 HS-Kitchen Emergency (kWh) 387982.600 HS DG Gym (kWh) 343008.500 HS PBA AHU1- 4 (KWh) 10360.216 HS M1 Chillers (kWh) 36628.880 HS CC (kWh) 276071.900 HS Gas (100 Cu Ft) 7546.000 dtype: float64 The amount of energy used in 2017 by AHS was 3370814.496 kWh. The amount of energy used in 2017 by the Collins center was 276071.9 kWh. The Collins Center contributed 8.190065051862174% of AHS's total energy consumption in 2017. Process finished with exit code 0 |
AuthorHi! My name is Ayush Zenith! I am currently a senior at Andover High School. I have been part of the Energize Andover Program since June, 2017 (8th grade). I have since been working on improving my knowledge in programming and working on writing better applications in order to save and conserve resources in buildings... Archives
November 2020
Categories |