Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
henfrydls committed Oct 28, 2021
1 parent 90be4d2 commit 62fa078
Show file tree
Hide file tree
Showing 10 changed files with 700 additions and 0 deletions.
Binary file added Images/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/gmail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/logo.ico
Binary file not shown.
Binary file added Images/paypal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/stack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions PVOUT_multi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import urllib.request, urllib.parse, urllib.error
import ssl
import json
from bs4 import BeautifulSoup
from opencage.geocoder import OpenCageGeocode
from opencage.geocoder import InvalidInputError, RateLimitExceededError, UnknownError

class MTI:
def __init__(self, location, module_wp, monthly_energy, ratio=1.25, percent=100):
self.location = location
self.module_wp = module_wp
self.monthly_energy = monthly_energy
self.ratio = ratio
self.percent = percent/100
self.key = '5bcb65fdf736480b8ac6a0baf16f0bec'
self.geocoder = OpenCageGeocode(self.key)
self.location_data, self.pv_data = {}, {}
self.lat, self.long = map(float, self.location.split(","))

def error_handling(self, name, target, results):
try:
self.location_data[name] = (results[0] ['components'][target])
except KeyError:
pass

def location_name(self):
while True:
try:
results = self.geocoder.reverse_geocode(self.lat, self.long, language='es', no_annotations='1')
if results and len(results):
self.error_handling("Continent", 'continent', results)
self.error_handling("Country", 'country', results)
self.error_handling("State", 'state', results)
self.error_handling("County", 'county', results)
self.error_handling("Village", 'village', results)
self.error_handling("Town", 'town', results)
self.error_handling("Suburb", 'suburb', results)
self.error_handling("Hamlet", 'hamlet', results)
return(self.location_data)
except RateLimitExceededError as ex:
key = '08c837016a914d4a8b7db3f8d8ed1d90'
continue
except InvalidInputError as ex:
return(None)

def PVOUT_values(self):
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
try:
url = (f'https://api.globalsolaratlas.info/data/lta?loc={self.lat},{self.long}')
html = urllib.request.urlopen(url, context=ctx).read()
except:
return(None)
soup = BeautifulSoup(html, "html.parser")
soup = json.loads(soup.text)["annual"]["data"]
for key, value in soup.items():
self.pv_data[key] = round(float(value), 2)
modules = self.modules_needed()
return(self.pv_data, modules)


def modules_needed(self):
modules = ((self.monthly_energy*self.ratio)/
((self.pv_data['GHI']/12)*(self.module_wp/1000)))*self.percent;
return(round(modules))
52 changes: 52 additions & 0 deletions modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import pandas as pd
import math

class Mppt:
def __init__(self, n1, n2, modules):
self.n1 = n1
self.n2 = n2
self.modules = modules
self.numbers, self.posibles_combinations = {}, {}
self.Mo_1, self.string_1, self.Mo_2, self.string_2 = [], [], [], []
self.extrations()

def extrations(self):
for n in range(self.n1, (int(math.ceil(self.modules/2)) + 1)):
self.numbers[n] = (self.modules - n)

def combinations(self, key, values):
for mpp1 in range(1, (int(math.ceil(self.modules/self.n1)) + 1)):
for mpp2 in range(1, (int(math.ceil(self.modules/self.n1)) + 1)):
if ((key % mpp1 == 0) and (values % mpp2 == 0)) and (mpp1):
if (key/mpp1 >= self.n1 and key/mpp1 <= self.n2) and (values/mpp2 >= self.n1 and values/mpp2 <= self.n2):
if key/mpp1 == values/mpp2:
if round(key/mpp1) in self.Mo_1 and (mpp1 + mpp2) in self.string_1:
continue
self.Mo_1.append(round(key/mpp1))
self.string_1.append(mpp1 + mpp2)
self.Mo_2.append(0)
self.string_2.append(0)
#print(f"I Found one result: {key/mpp1} modules of {mpp1 + mpp2} strings")
else:
if key/mpp1 > values/mpp2:
self.Mo_1.append(round(key/mpp1))
self.string_1.append(mpp1)
self.Mo_2.append(round(values/mpp2))
self.string_2.append(mpp2)
else:
self.Mo_2.append(round(key/mpp1))
self.string_2.append(mpp1)
self.Mo_1.append(round(values/mpp2))
self.string_1.append(mpp2)
#print(f"I Found one result: {key/mpp1} modules of {mpp1} strings and {values/mpp2} modules of {mpp2} strings")

def sorting(self):
# assign data of lists.
data = {'Mo_1': self.Mo_1, 'string_1': self.string_1,
'Mo_2': self.Mo_2, 'string_2': self.string_2}

# Create DataFrame
df = pd.DataFrame(data)
df = df.drop_duplicates(subset=None, keep="first", inplace=False)
df = df.sort_values(by=['Mo_1', 'Mo_2', 'string_1', 'string_2'],ascending=False, ignore_index=True)
return(df)
Loading

0 comments on commit 62fa078

Please sign in to comment.