/// <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); }
public void Apply_WhenTsIsNull_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => m_Delta.Apply(null)); }