public void ExportMonthyGridTestFor2Vars() { if (File.Exists("output_table.csv")) { File.Delete("output_table.csv"); } using (DataSet result1 = DataSet.Open("airt_10x10_monthly.csv"), result2 = DataSet.Open("relhum_10x10_monthly.csv"), result3 = DataSet.Open("prate_10x10_monthly.csv")) { using (var table = DataSet.Open("msds:memory")) { table.IsAutocommitEnabled = false; TableExportHelper.MergeTable(config, table, new Tuple <DataSet, string[]>[] { new Tuple <DataSet, string[]>(result1, null), new Tuple <DataSet, string[]>(result2, null), new Tuple <DataSet, string[]>(result3, null), }); Trace.WriteLine(table.ToString()); Assert.IsTrue(table.Dimensions["i"].Length == 9 * 9 * 12); Assert.IsTrue(((string[])table.Variables["relhum_provenance"].GetData())[100] == "GFDLRelHum"); Assert.IsTrue(table.Variables.Contains("airt_uncertainty")); Assert.IsTrue(table.Variables.Contains("relhum_uncertainty")); Assert.IsTrue(table.Variables.Contains("prate_uncertainty")); } } }
public void Export5dTest() { using (DataSet result1 = DataSet.Open("airt_5d.csv")) { using (var table = DataSet.Open("msds:memory")) { table.IsAutocommitEnabled = false; TableExportHelper.MergeTable(config, table, new Tuple <DataSet, string[]>[] { new Tuple <DataSet, string[]>(result1, new string[] { "Europe" }) }); Trace.WriteLine(table.ToString()); Assert.IsTrue(table.Dimensions["i"].Length == 4 * 4 * 6 * 4 * 12); } } }
public void ExportElevationTest() { using (DataSet result1 = DataSet.Open("elevation.csv")) { using (var table = DataSet.Open("msds:memory")) { table.IsAutocommitEnabled = false; TableExportHelper.MergeTable(config, table, new Tuple <DataSet, string[]>[] { new Tuple <DataSet, string[]>(result1, new string[] { "Europe" }) }); Trace.WriteLine(table.ToString()); } } // using (var ds = new AzureBlobDataSet(Uri.UnescapeDataString("msds%3Aab%3FAccountName%3Dfetchclimate2%26Container%3Drequests%26Blob%3Deac53851f2b91e94f804c7a054d78462d73d99b5"))) // ds.Clone("elev.csv"); }
public void ExportMonthyGridTest() { using (var result = DataSet.Open("airt_10x10_monthly.csv")) { using (var table = DataSet.Open("msds:memory")) { table.IsAutocommitEnabled = false; TableExportHelper.MergeTable(config, table, new Tuple <DataSet, string[]>[] { new Tuple <DataSet, string[]>(result, new string[] { "Region 1" }) }); Trace.WriteLine(table.ToString()); Assert.IsTrue(table.Dimensions["i"].Length == 9 * 9 * 12); Assert.IsTrue(((DateTime[])table.Variables["start"].GetData())[0] == new DateTime(2000, 1, 1)); Assert.IsTrue(((DateTime[])table.Variables["end"].GetData())[9 * 9 * 12 - 1] == new DateTime(2011, 1, 1)); Assert.IsTrue(((string[])table.Variables["airt_provenance"].GetData())[100] == "NCEP/NCAR Reanalysis 1 (regular grid)"); } } }
private void MergeCSV(DataSet dst, Tuple <string, string[]>[] requests) { var jobManager = WebApiApplication.GetSharedJobManager(Request); var dsr = requests.Select(r => new Tuple <DataSet, string[]>(DataSet.Open(jobManager.ResultDataSetUri(r.Item1, false)), r.Item2)).ToArray(); try { var config = WebApiApplication.GetFetchConfiguration(DateTime.MaxValue); TableExportHelper.MergeTable(config, dst, dsr); dst.Commit(); } finally { foreach (var r in dsr) { r.Item1.Dispose(); } } }
public void ExportGridsAndPointsTest() { using (DataSet result1 = DataSet.Open("prate_10x10.csv"), result2 = DataSet.Open("prate_5_points.csv")) { using (var table = DataSet.Open("msds:memory")) { table.IsAutocommitEnabled = false; TableExportHelper.MergeTable(config, table, new Tuple <DataSet, string[]>[] { new Tuple <DataSet, string[]>(result1, null), new Tuple <DataSet, string[]>(result2, new string[] { "P1", "P2", "P3", "P4", "P5" }) }); Trace.WriteLine(table.ToString()); Assert.IsTrue(table.Dimensions["i"].Length == 9 * 9 + 5); Assert.IsTrue(((string[])table.Variables["prate_provenance"].GetData())[9 * 9 + 4] == "WorldClim 1.4"); Assert.IsTrue(((string[])table.Variables["region"].GetData())[81] == "P1"); Assert.IsTrue(((string[])table.Variables["region"].GetData())[9 * 9 + 4] == "P5"); Assert.IsTrue(((string[])table.Variables["region"].GetData())[0] == null); } } }