public void SingleEnsemble() { var fn = @"c:\temp\ensemble-single.h5"; File.Delete(fn); string fileName = Path.Combine(EnsembleTester.CacheDir, "test.csv"); RfcCsvFile csv = new RfcCsvFile(fileName); float[,] data = csv.GetEnsemble("SCRN2"); Watershed ws = new Watershed("simple"); DateTime t = DateTime.Now.Date.AddHours(12); ws.AddForecast("scrn2", t, data, new DateTime[] { t }); H5Assist.H5Writer h5 = new H5Assist.H5Writer(fn); HDF5Ensemble.Write(h5, ws); var w = HDF5Ensemble.Read(h5, "simple"); Assert.AreEqual(1, w.Locations.Count); var ensemble = w.Locations[0].Forecasts[0].Ensemble; Assert.AreEqual(337, ensemble.GetLength(1)); Assert.AreEqual(59, ensemble.GetLength(0)); Assert.AreEqual(-59.0f, ensemble[58, 0]); Assert.AreEqual(-59.1f, ensemble[58, 1]); }
public void ProfileTesting() { var fn = @"C:\temp\dss7_profile_ensemble.dss"; File.Delete(fn); string csvFilename = Path.Combine(EnsembleTester.CacheDir, "test.csv"); RfcCsvFile csv = new RfcCsvFile(csvFilename); float[,] ensemble = null; csv.GetEnsemble("SCRN2", ref ensemble); Watershed ws = new Watershed("test"); DateTime issueDate = new DateTime(2001, 11, 15, 12, 0, 0); ws.AddForecast("SCRN2", issueDate, ensemble, csv.TimeStamps); DssEnsemble.WriteToTimeSeriesProfiles(fn, ws); var ws2 = DssEnsemble.ReadTimeSeriesProfiles("test", issueDate, issueDate, fn); Assert.AreEqual(1, ws2.Locations.Count); var data = ws2.Locations[0].Forecasts[0].Ensemble; Assert.AreEqual(-1.0f, data[0, 0]); Assert.AreEqual(-2.1f, data[0, 1]); Assert.AreEqual(-3.1f, data[0, 2]); Assert.AreEqual(-59.0f, data[58, 0]); Assert.AreEqual(-59.1f, data[58, 1]); Assert.AreEqual(-59.2f, data[58, 2]); }
private static Watershed ReadTestWaterShed(DateTime t) { string fileName = Path.Combine(EnsembleTester.CacheDir, "test.csv"); RfcCsvFile csv = new RfcCsvFile(fileName); float[,] scrn2 = csv.GetEnsemble("SCRN2"); var rval = new Watershed("simple"); rval.AddForecast("scrn2", t, scrn2, new DateTime[] { t }); return(rval); }
public void TimeSeriesTesting() { var fn = @"C:\temp\dss7_ensemble.dss"; File.Delete(fn); string fileName = Path.Combine(EnsembleTester.CacheDir, "test.csv"); RfcCsvFile csv = new RfcCsvFile(fileName); float[,] ensemble = null; csv.GetEnsemble("SCRN2", ref ensemble); Watershed w = new Watershed("test"); w.AddForecast("SCRN2", DateTime.Parse("2001-11-15"), ensemble, csv.TimeStamps); DssEnsemble.Write(fn, w); using (DssReader r = new DssReader(fn)) { var catalog = r.GetCatalog(); Assert.AreEqual(59, catalog.Count); string path = "/test/SCRN2/Flow/01Nov2013/1Hour/C:000059|T:3192001/"; var ts = r.GetTimeSeries(new DssPath(path)); Assert.AreEqual(-59.0, ts[0].Value); } DateTime t1 = new DateTime(1900, 1, 1); DateTime t2 = DateTime.Now.Date; w = DssEnsemble.Read("test", t1, t2, fn); Assert.AreEqual(1, w.Locations.Count); ensemble = w.Locations[0].Forecasts[0].Ensemble; Assert.AreEqual(337, ensemble.GetLength(1)); Assert.AreEqual(59, ensemble.GetLength(0)); Assert.AreEqual(-59.0f, ensemble[58, 0]); Assert.AreEqual(-59.1f, ensemble[58, 1]); }