|
1 | 1 | __author__ = 'stephanie' |
2 | | -import sys |
3 | | -import os |
| 2 | + |
4 | 3 |
|
5 | 4 |
|
6 | 5 | import matplotlib.pyplot as plt |
7 | 6 | from matplotlib import dates |
8 | 7 |
|
9 | 8 |
|
10 | | -#this will be removed when we can installthe api |
11 | | -# this_file = os.path.realpath(__file__) |
12 | | -# directory = os.path.dirname(os.path.dirname(this_file)) |
13 | | -# print directory |
14 | | -# sys.path.insert(0, directory) |
15 | 9 |
|
16 | 10 | from odm2api.ODMconnection import dbconnection |
17 | 11 | from odm2api.ODM2.services.readService import * |
|
20 | 14 |
|
21 | 15 |
|
22 | 16 | #connect to database |
23 | | -#createconnection (dbtype, servername, dbname, username, password) |
| 17 | +# createconnection (dbtype, servername, dbname, username, password) |
| 18 | +# session_factory = dbconnection.createConnection('connection type: sqlite|mysql|mssql|postgresql', '/your/path/to/db/goes/here', 2.0)#sqlite |
24 | 19 | # session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')#mysql |
25 | | -#session_factory = dbconnection.createConnection('connection type: sqlite|mysql|mssql|postgresql', '/your/path/to/db/goes/here', 2.0)#sqlite |
26 | 20 | # session_factory= dbconnection.createConnection('mssql', "(local)", "LBRODM2", "ODM", "odm")#win MSSQL |
27 | 21 | session_factory= dbconnection.createConnection('mssql', "arroyoodm2", "", "ODM", "odm")#mac/linux MSSQL |
28 | 22 |
|
29 | 23 |
|
30 | 24 |
|
31 | 25 | #_session = session_factory.getSession() |
32 | | - |
33 | 26 | read = ReadODM2(session_factory) |
34 | 27 |
|
35 | 28 |
|
|
152 | 145 | # Print a few Time Series Values to the console |
153 | 146 | # tsValues.set_index('ValueDateTime', inplace=True) |
154 | 147 | try: |
| 148 | + print "tsValues " |
155 | 149 | print tsValues.head() |
156 | 150 | except Exception as e: |
157 | 151 | print e |
158 | 152 |
|
159 | 153 | # Plot the time series |
160 | 154 |
|
161 | 155 | try: |
162 | | - fig = plt.figure() |
163 | | - ax = fig.add_subplot(111) |
164 | | - tsValues.plot(x='ValueDateTime', y='DataValue', kind='line', |
165 | | - title=tsResult.ResultObj.VariableObj.VariableNameCV + " at " + tsResult.ResultObj.FeatureActionObj.SamplingFeatureObj.SamplingFeatureName, |
166 | | - ax=ax) |
167 | | - ax.set_ylabel(tsResult.ResultObj.VariableObj.VariableNameCV + " (" + tsResult.ResultObj.UnitsObj.UnitsAbbreviation + ")") |
168 | | - ax.set_xlabel("Date/Time") |
169 | | - ax.xaxis.set_minor_locator(dates.MonthLocator()) |
170 | | - ax.xaxis.set_minor_formatter(dates.DateFormatter('%b')) |
171 | | - ax.xaxis.set_major_locator(dates.YearLocator()) |
172 | | - ax.xaxis.set_major_formatter(dates.DateFormatter('\n%Y')) |
173 | | - ax.grid(True) |
| 156 | + plt.figure() |
| 157 | + ax=tsValues.plot(x='ValueDateTime', y='DataValue') |
| 158 | + |
174 | 159 | plt.show() |
175 | 160 | except Exception as e: |
176 | 161 | print "Unable to demo plotting of tsValues: ", e |
0 commit comments