public TestUofIDisaggregation() { string zipFile = Path.Combine(TestData.DataPath, "UofIDisaggregationTest.zip"); path = FileUtility.GetTempPath() + @"\UofIDisaggregationTest.pdb"; ZipFileUtility.UnzipFile(zipFile, path); }
public void InterpolateWithStyle() { string zipFile = Path.Combine(TestData.DataPath, "UofIDisaggregationTest.zip"); var path = FileUtility.GetTempPath() + @"\UofIDisaggregationTest.pdb"; ZipFileUtility.UnzipFile(zipFile, path); Reclamation.Core.SQLiteServer pDB = new Reclamation.Core.SQLiteServer(path); TimeSeriesDatabase DB = new TimeSeriesDatabase(pDB, false); Series sReal = DB.GetSeriesFromName("SS_Day_Mean"); sReal.Read(); Series sEst = DB.GetSeriesFromName("TS_Mon_Mean"); sEst.Read(); Series sOut = Reclamation.TimeSeries.Math.InterpolateWithStyle(sReal, sEst, "2001-3-1", "2003-12-1"); // Can't get the Series.Values.Sum() extension... workaround below. double sum1 = 0, sum2 = 0; for (int i = 0; i < sEst.Count; i++) { sum1 = sum1 + sEst[i].Value; sum2 = sum2 + sOut[i].Value; } sum1 = System.Math.Round(sum1, 2); sum2 = System.Math.Round(sum2, 2); Assert.AreEqual(sum1, sum2); }
private static string DownloadAndUnzip(string url) { var zip = FileUtility.GetTempFileName(".zip"); Console.WriteLine("Downloading: " + url); Web.GetFile(url, zip); var csv = FileUtility.GetTempFileName(".csv"); Console.WriteLine("Unzipping to-> " + csv); ZipFileUtility.UnzipFile(zip, csv); return(csv); }
public static int BuildZip(string path, string pattern, string zippath, string unzipfolder, int index) { long totalSize = 1024 * 1024 * 4; if (!Directory.Exists(zippath)) { Directory.CreateDirectory(zippath); } List <string> files = new List <string>(Directory.GetFiles(path, "*" + pattern)); List <string> sourceList = new List <string>(); long curSize = 0; files.Sort(SortByFileSize); foreach (string file in files) { FileInfo info = new FileInfo(file); if (!(sourceList.Count <= 0 || curSize + info.Length <= totalSize)) { string targetFile = string.Format("{0}data_{1}.zip", zippath, index); ZipFileUtility.ZipFile(sourceList, targetFile, unzipfolder); sourceList.Clear(); index++; curSize = 0; } curSize += info.Length; sourceList.Add(file); } if (sourceList.Count > 0) { string targetFile = string.Format("{0}data_{1}.zip", zippath, index); ZipFileUtility.ZipFile(sourceList, targetFile, unzipfolder); index++; } List <string> directories = new List <string>(Directory.GetDirectories(path)); foreach (string directory in directories) { string subpath = directory.Replace(path, ""); index = BuildZip(path + subpath, pattern, zippath, unzipfolder + subpath, index); } return(index); }
private static string DownloadAndUnzip(DateTime t) { //http://www.noaa.inel.gov/mvp/data/2014/02/x28.zip string url = System.Configuration.ConfigurationManager.AppSettings["INEL_URL"]; url += t.Year + "/" + t.Month.ToString().PadLeft(2, '0') + "/x" + t.Day.ToString().PadLeft(2, '0') + ".zip"; var zip = FileUtility.GetTempFileName(".zip"); Console.WriteLine("Downloading: " + url); Web.GetFile(url, zip); var xmlFileName = FileUtility.GetTempFileName(".xml"); Console.WriteLine("Unzipping to-> " + xmlFileName); ZipFileUtility.UnzipFile(zip, xmlFileName); return(xmlFileName); }
public virtual void ConfigureSetting() { var i = 0; for (; i > -15; i--) { if (File.Exists(string.Format(ZipFileName, Date.AddDays(i)))) { break; } else { Console.Error.WriteLine("Daily File Not Found: {0}", string.Format(OldFileName, Date.AddDays(i))); } } ZipFileUtility.ExtractZipFile(string.Format(ZipFileName, Date.AddDays(i)), FileDirectory); File.Delete(NewFileName); File.Move(Directory.GetFiles(FileDirectory, string.Format(oldFileName, Date.AddDays(i)))[0], NewFileName); }