private void SplitYearlyClick(object sender, RoutedEventArgs e) { try { var ts = TsParser.ParseTimeseries(tbSource.Text); var tsWithInserts = new Periodizer().InsertPoints(ts, Interval.Year); var splitPerYear = new Splitter().SplitPerYear(tsWithInserts); string result = string.Empty; var maxEntries = splitPerYear.Max(x => x.Count); for (var i = 0; i < maxEntries; i++) { string line = string.Empty; foreach (var series in splitPerYear) { if (series.Count > i) { line += series[i]; line += ColumnSeparator; } } result += line + "\r\n"; } tbResult.Text = result; } catch (Exception ex) { tbResult.Text = ex.ToString(); } }
/// <summary> /// Periodizes a timeseries /// </summary> /// <param name="id">a tab-separated list of times and values</param> /// <returns></returns> /// <remarks>It seems that the parameter must be named id for this /// method to be hit. Otherwise the parameterless Get is called.</remarks> public string Get(string id) { //var id = 12345; var ts = TsParser.ParseTimeseries(id); // Problem: A tab in the request is not accepted by the browser var periodizer = new Periodizer(); return periodizer.InsertPoints(ts, Interval.Year).ToString(); //return $"the value of {id} is {id * id}"; }
private void InsertPointsClick(object sender, RoutedEventArgs e) { try { var ts = TsParser.ParseTimeseries(tbSource.Text); var result = new Periodizer().InsertPoints(ts, Interval.Year); tbResult.Text = result.ToString(); } catch (Exception ex) { tbResult.Text = ex.ToString(); } }
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; }
private void SplitMonthlyClick(object sender, RoutedEventArgs e) { try { var ts = TsParser.ParseTimeseries(tbSource.Text); var tsMonthly = new Periodizer().MonthlyAverage(ts); var splitPerYear = new Splitter().SplitPerYear(tsMonthly); var writer = new StringWriter(); var renderer = new MonthlyValueTextRenderer(CultureInfo.CurrentCulture, ColumnSeparator); renderer.Render(splitPerYear, writer); tbResult.Text = writer.ToString(); } catch (Exception ex) { tbResult.Text = ex.ToString(); } }
public static Timeseries GetMonthlyAverages() { var repo = new RegistryEntryRepoFactory().GetRegistryEntryRepo(); var sortedTvqs = repo.GetRegistryEntries(Thread.CurrentPrincipal).OrderBy(x => x.Time); var tsWithRegisterEntries = new Timeseries(); tsWithRegisterEntries.AddRange(sortedTvqs.ToList()); var periodizer = new Periodizer(); var monthlyRegisterEntries = periodizer.MonthlyAverage(tsWithRegisterEntries); const int minMonths = 2; var tooFewEntries = monthlyRegisterEntries.Count < minMonths; var areTooFewEntries = tooFewEntries; if (areTooFewEntries) { throw new TooFewEntriesException(minMonths); } var deltaOperator = new DeltaTsOperator(); var monthlyAverages = deltaOperator.Apply(monthlyRegisterEntries); return monthlyAverages; }
public PeriodizerTest() { m_Tvqs = new Tvqs(); m_Periodizer = new Periodizer(); }