summaryrefslogtreecommitdiff
path: root/tools/solarmeter/solarmeter_plot.py
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2011-12-10 20:32:59 +0000
committerBernhard Tittelbach <xro@realraum.at>2011-12-10 20:32:59 +0000
commited4256fa10a1713a4afef868247948e3dbd53298 (patch)
tree40d013a1d51ce6fb67c459b801205bf3f43c607e /tools/solarmeter/solarmeter_plot.py
parentadded solar adc code (diff)
leistungsanpassungspunkt mit geglätteten widerstandswerten
git-svn-id: https://svn.spreadspace.org/mur.sat@220 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'tools/solarmeter/solarmeter_plot.py')
-rwxr-xr-xtools/solarmeter/solarmeter_plot.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/tools/solarmeter/solarmeter_plot.py b/tools/solarmeter/solarmeter_plot.py
index 856dd47..409e4f8 100755
--- a/tools/solarmeter/solarmeter_plot.py
+++ b/tools/solarmeter/solarmeter_plot.py
@@ -35,7 +35,30 @@ def getm_rp(panelid, limit_voltage=100):
@returns tuple of lists: (list(r values), list(p values))
"""
global measurements
- return zip(* sorted(list(set(map( lambda (u,i): (u/i, u*i), filter(lambda (u,i): i > 0.0 and u < limit_voltage, measurements[panelid]) )))))
+ return zip(* sorted(list(set(map( lambda (u,i): (int(u/i), u*i), filter(lambda (u,i): i > 0.0 and u < limit_voltage, measurements[panelid]) )))))
+
+def get_matched_impedance(panelids, limit_voltage=100):
+ """ get measurements load over power
+ @param subject name of solarpanelcells series
+ @returns tuple of lists: (list(r values), list(p values))
+ """
+ global measurements
+ r_panel_dict = {}
+ for id in panelids:
+ try:
+ (rl,pl) = getm_rp(id, limit_voltage)
+ except ValueError:
+ continue
+ for (r,p) in zip(rl, pl):
+ r = r / 5 * 5
+ if not r in r_panel_dict:
+ r_panel_dict[r] = {}
+ if id in r_panel_dict[r]:
+ r_panel_dict[r][id] = max(p, r_panel_dict[r][id])
+ else:
+ r_panel_dict[r][id] = p
+ return reduce(lambda (r1,p1),(r2,p2): (r1,p1) if p1 > p2 else (r2,p2) ,map(lambda (r,d): (r, sum(d.values())), r_panel_dict.items()))
+
lre = re.compile(r"(\d)\s+([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)")
#lre = re.compile(r"(\d)\s+([+-]?\d+.\d+)\s+([+-]?\d+\.\d+)")
@@ -54,7 +77,7 @@ pylab.xlabel('Spannung [V]')
pylab.ylabel('Strom [A]')
pylab.xscale('linear')
pylab.yscale('linear')
-pylab.title("U/I Plot")
+pylab.title("U/I Plot\nFile: %s" % sys.argv[1])
pylab.grid(True)
for id in panelids:
try:
@@ -68,9 +91,11 @@ pylab.legend()
pylab.figure(1)
pylab.xlabel('Widerstand [Ohm]')
pylab.ylabel('Leistung [W]')
+(r_mi, p_mi) = get_matched_impedance(panelids, limit_voltage=9)
pylab.xscale('log', basex=10)
pylab.yscale('log', basey=10)
-pylab.title("Leistungsanpassung")
+pylab.title("Leistungsanpassung: %.1f mW @ %d Ohm: \nFile: %s" % (p_mi*1e3, r_mi,sys.argv[1]))
+pylab.hold(True)
pylab.grid(True)
for id in panelids:
try:
@@ -79,6 +104,9 @@ for id in panelids:
continue
pylab.plot(r,p, label=str(id))
pylab.hold(True)
+pylab.stem([r_mi], [p_mi])
+(ymin, ymax) = pylab.ylim()
+pylab.axvline(r_mi, ymin, ymax)
pylab.legend()
pylab.show()