public DeltaTsOperatorTest() { m_Delta = new DeltaTsOperator(); m_t0 = new DateTime(2015, 01, 01, 0, 0, 0, 0); m_t1 = new DateTime(2015, 02, 01, 0, 0, 0, 0); m_t2 = new DateTime(2015, 02, 02, 0, 0, 0, 0); m_Tvq5 = new Tvq(m_t0, 5, Quality.Ok); m_Tvq7 = new Tvq(m_t1, 7, Quality.Ok); m_Tvq11 = new Tvq(m_t2, 11, Quality.Ok); }
/// <summary> /// Calculates monthly consumption from meter values. /// Handles roll over and meter change. /// </summary> /// <param name="ts">A time series with meter values, possibly with roll over and meter change.</param> /// <returns> /// a time series with one entry per month where the /// time is the first second of the month /// and the value is the consumption for that month. /// </returns> public Timeseries MonthlyAverage(Timeseries ts) { if (ts == null || !ts.Any()) { return(new Timeseries()); } var deltaOperator = new DeltaTsOperator(); var consumptionTs = deltaOperator.Apply(ts); var result = Periodize(new Average(), consumptionTs, Interval.Month); return(result); }
public static Timeseries GetMonthlyAverages(string registerId) { var storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); var repo = new RegistryEntryRepo(storageAccount); var sortedTvqs = repo.GetRegistryEntries().OrderBy(x => x.Time); var tsWithRegisterEntries = new Timeseries(); tsWithRegisterEntries.AddRange(sortedTvqs.ToList()); var periodizer = new Periodizer(); var monthlyRegisterEntries = periodizer.MonthlyAverage(tsWithRegisterEntries); var deltaOperator = new DeltaTsOperator(); var monthlyAverages = deltaOperator.Apply(monthlyRegisterEntries); return(monthlyAverages); }