def _make_ssa_ts_from_shyft_ts(name, shyft_ts): ''' Geturns a SSaTimeSeries from shyft_ts ''' t = np.array([shyft_ts.time(i) for i in range(shyft_ts.size())]) v = np.array([shyft_ts.value(i) for i in range(shyft_ts.size())]) q = np.zeros_like(t, dtype=np.int) numPoints = shyft_ts.size() tsv = TsAsVector(numPoints, TimeSystemReference.Unix1970Utc) p = Period(UtcTime.CreateFromUnixTime(t[0]), UtcTime.CreateFromUnixTime(t[-1] + 3600)) tsv.SetVectors(p, t, v, q) tsv.Name = name return SsaTimeSeries(tsv)
def _make_ssa_tsps_from_shyft_ts(ts_id, shyft_ts): ''' returns a TimeSeriesPointSegments from shyft_ts ''' ts_size = shyft_ts.size(); t = np.array([shyft_ts.time(i) for i in range(ts_size)]) v = np.array([shyft_ts.value(i) for i in range(ts_size)]) q = np.zeros_like(t, dtype=np.int) tsv = TsAsVector(ts_size, TimeSystemReference.Unix1970Utc) p = Period(UtcTime.CreateFromUnixTime(t[0]), UtcTime.CreateFromUnixTime(t[-1] + 3600)) tsv.SetVectors(p, t, v, q) ts_ps = TimeSeriesPointSegments() ts_ps.Identity = ts_id psList = List[IPointSegment]([]) psList.Add(PointSegment(p, tsv.Points)) ts_ps.PointSegments = psList return ts_ps
def _make_ssa_Period_from_shyft_period(shyft_period): if not shyft_period.valid(): raise SmgDataError("shyft_period must be of type api.UtcPeriod") return Period(UtcTime.CreateFromUnixTime(shyft_period.start), UtcTime.CreateFromUnixTime(shyft_period.end))