def _collect_and_plot(files): TS = [] location = [] for f in files: temperatures = [ section[1] for section in parse.parse_file(f)[1:-1] if section[1]['Plant'] == ['tmp'] ] for t in temperatures: if t['Step'][0] != '0000-00-00.01:00:00': print 'Not hourly readings of temperature. Abort.' break dates = ts.date_array(start_date=ts.Date('H', t['Start'][0]), length=len(t['Value'])) data = [ float(value.rsplit('/')[0]) for value in t['Value'] ] TS.append(ts.TimeSeries(data=data, dates=dates)) if location and t['Installation'][0] != location: print 'Location changed during reading of gs2 files. Probably some bad grouping of gs2 files.' location = t['Installation'][0] if TS: path = '/Users/tidemann/Documents/NTNU/devel/data/eklima/Telemark/' for file in os.listdir(path): try: series = xml.parse(path + file) sg.utils.plot_time_series([ts.concatenate((TS)), series], ['b-','r-'], [location, file]) except: print file, 'had no data.' else: print 'No temperature data.'
def test_append_timeseries(self): "Test appending to a MaskedTable" table = self.h5file.root.tseries tseries = self.tseries newdata = ts.time_series(zip(np.random.rand(3), np.arange(3)+10), mask=[(0,0),(1,0),(0,1)], dtype=tseries.dtype, start_date=tseries.dates[-1]+1) table.append(newdata) test = table.read() self.failUnless(isinstance(test, TimeSeries)) assert_equal_records(test, ts.concatenate((tseries,newdata)))
def test_append_timeseries(self): "Test appending to a MaskedTable" table = self.h5file.root.tseries tseries = self.tseries newdata = ts.time_series(zip(np.random.rand(3), np.arange(3) + 10), mask=[(0, 0), (1, 0), (0, 1)], dtype=tseries.dtype, start_date=tseries.dates[-1] + 1) table.append(newdata) test = table.read() self.failUnless(isinstance(test, TimeSeries)) assert_equal_records(test, ts.concatenate((tseries, newdata)))
def join(self,*args): """ TSJ = JOIN(SER1,SER2,"SER3") """ logger.debug('{JOIN}') series = [] S = [ args[0] ] S.extend(args[1]) for s in S: logger.debug('Selecting Series %s - %s',s,type(s)) if type(s) in (str,unicode): series.append(IS.select(s)) elif type(s) in (ets.Timeseries,): series.append(s) S = [ v._data for v in series ] _res = ets.Timeseries(data= ts.concatenate(S) ) return _res