/[ascend]/trunk/models/johnpye/datareader/timestudy.py
ViewVC logotype

Contents of /trunk/models/johnpye/datareader/timestudy.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2071 - (show annotations) (download) (as text)
Fri Aug 28 02:42:47 2009 UTC (10 years, 6 months ago) by jose
File MIME type: text/x-python
File size: 1780 byte(s)
MERGE Jose's branch [2274]:[2584] into trunk
1 # -*- coding: utf8 -*-
2 import extpy;
3
4 from pylab import *
5 from solverreporter import *
6
7 def timestudy(self):
8
9 # following is an unfortunate necessity in the current system architecture:
10 browser = extpy.getbrowser()
11
12 # just check that all is ok
13 browser.do_solve()
14
15 # set up figure
16 ioff()
17 figure()
18
19 # calculate time points in advance
20 tvalue = float(self.t);
21 tincr = 1800 # seconds
22 tt = []
23 for i in range(1*24*3600/tincr):
24 tt.append(tvalue);
25 tvalue += tincr
26
27 series = [unicode('G [W/m²]'), unicode('Gbn [W/m²]'), unicode('Gd [W/m²]'),'T [K]', 'v_wind [m/s]']
28 xdata = []
29 ydata = [[], [], [], [], []]
30
31 for t in tt:
32 self.t.setRealValueWithUnits(t,"s")
33 try:
34 browser.sim.solve(browser.solver,SimpleSolverReporter(browser,"t = %f"%(t)))
35 except:
36 browser.reporter.reportError('Failed to solve for t = %f' % t)
37 continue
38
39 xdata.append(t / 3600.)
40 # ydata[0].append(self.G.as("W/m^2"))
41 # ydata[1].append(self.Gbn.as("W/m^2"))
42 # ydata[2].append(self.Gd.as("W/m^2"))
43 # ydata[3].append(self.T.as("K") - 273.15)
44 # ydata[4].append(self.v_wind.as("m/s"))
45
46 ydata[0].append(self.G("W/m^2"))
47 ydata[1].append(self.Gbn("W/m^2"))
48 ydata[2].append(self.Gd("W/m^2"))
49 ydata[3].append(self.T("K") - 273.15)
50 ydata[4].append(self.v_wind("m/s"))
51
52
53 subplot(311)
54 plot(xdata,ydata[0])
55 title("Weather data vs Time")
56 ylabel(unicode("Radiation / [W/m²]"))
57 hold(1)
58 plot(xdata,ydata[1])
59 plot(xdata,ydata[2])
60 legend(series[0:3])
61 grid(1)
62
63 subplot(312)
64 plot(xdata,ydata[3])
65 ylabel('Temperature [K]')
66 grid(1)
67
68 subplot(313)
69 plot(xdata,ydata[4])
70 ylabel('Wind speed [m/s]')
71 grid(1)
72 xlabel("Time / [h]")
73
74 ion()
75 show()
76
77 extpy.registermethod(timestudy)
78 #the above method can be called using "EXTERNAL timestudy(SELF)" in ASCEND.
79

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22