public bool UseSingularSpectrumAnalyzer() { bool result = true; try { foreach (KeyValuePair <string, List <double> > entry in Dal.dicListFpi) { // do something with entry.Value or entry.Key SingularSpectrumAnalyzer SsaFpi = new SingularSpectrumAnalyzer(); SsaFpi.SetAddSequences(entry.Value.ToArray()); SsaFpi.SetWindow(3); SsaFpi.SetAlgoTopKDirect(1); SsaFpi.AnalyzeSequence(out double[] trendFpiArr, out double[] noiseFpiArr); Dic_trendFpiArr.TryAdd(entry.Key, trendFpiArr); Dic_noiseFpiArr.TryAdd(entry.Key, noiseFpiArr); StoreArrayAsMetaCsv(Dal.dicListDate[entry.Key].ToArray(), trendFpiArr, "trendFpi_" + entry.Key.ToString()); //StoreArrayAsResultCsv(Dal.dicListDate[entry.Key].ToArray(), trendFpiArr, "Trend\\" + "trendFpi_" + entry.Key.ToString()); //StoreArrayAsResultCsv(Dal.dicListDate[entry.Key].ToArray(), noiseFpiArr, "Noise\\" + "noiseFpi_" + entry.Key.ToString()); } Efa_Dic_StringList_DoubleArray_EuroStat Ea = new Efa_Dic_StringList_DoubleArray_EuroStat(); Ea.dicListDate = Dal.dicListDate; Ea.FilePath = AppDomain.CurrentDomain.BaseDirectory + "Result\\Result_Summary\\" + "Result_Auto_Data_Trend" + ".xlsx"; Ea.SheetName = "Trend"; Ea.dicArrData = Dic_trendFpiArr; Ea.CreateExcel(); Ea.FilePath = AppDomain.CurrentDomain.BaseDirectory + "Result\\Result_Summary\\" + "Result_Auto_Data_Noise" + ".xlsx"; Ea.SheetName = "Noise"; Ea.dicArrData = Dic_noiseFpiArr; Ea.CreateExcel(); } catch { result = false; } return(result); }
private void ReadMetaAndOutputAnIntegratedAutoDataCSV() { foreach (KeyValuePair <string, double[]> entry in Dic_trendFpiArr) { // Use key name to generate meta filename to read string CpaMetaFilePath = AppDomain.CurrentDomain.BaseDirectory + @"Meta\DACF_EuroStat\" + @"Cpa\" + "ChangePointsFpi_" + entry.Key + ".csv"; bool res = true; int LineIndex = 0; string Line = ""; char[] Delimiters = new char[] { '\t' }; List <double> temp = new List <double>(); GetExcelFigureMax(entry.Value.Max(), entry.Value.Min(), out double Ymax, out double Ymin, out double Yscale); try { using (FileStream fs = File.Open(CpaMetaFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (BufferedStream bs = new BufferedStream(fs)) using (StreamReader sr = new StreamReader(bs)) { //if (Cfs.FooterLinesCount > 0) // FileTotalLinesCount = File.ReadLines(FilePath).Count(); while ((Line = sr.ReadLine()) != null) { // Skip First Line LineIndex++; if (LineIndex == 1) { continue; } // if (Column["Alert"] == 1), insert Max*1.2 string[] Splits = Line.Split(Delimiters, StringSplitOptions.RemoveEmptyEntries); if (Splits[0] == "1") { temp.Add(Ymax); } else { temp.Add(0); } } } } catch (Exception e) { Console.WriteLine("entry.Key: " + entry.Key + "\tLineIndex: " + LineIndex.ToString() + "\tLine: " + Line.ToString()); res = false; } finally { // Do nothing } Dic_CpaFpiArr.TryAdd(entry.Key, temp.ToArray()); } Efa_Dic_StringList_DoubleArray_EuroStat Efa = new Efa_Dic_StringList_DoubleArray_EuroStat(); Efa.FilePath = AppDomain.CurrentDomain.BaseDirectory + "Result\\Result_Summary\\" + "Result_Auto_Data_Cpa" + ".xlsx"; Efa.SheetName = "Cpa"; Efa.dicListDate = Dal.dicListDate; Efa.dicArrData = Dic_CpaFpiArr; Efa.CreateExcel(); // Save as CSV also (for Integrated Analysis metadata) string FilePath = AppDomain.CurrentDomain.BaseDirectory + "Result\\Result_Summary\\" + "Result_Auto_Data_Cpa" + ".csv"; StoreArrayAsResultCsv(Dal.dicListDate, Dic_CpaFpiArr, FilePath); }