public void ReadPairedData3()
 {
     using (DssReader r = new DssReader(TestUtility.BasePath + "indexedPairedData1.dss"))
     {
         var p = r.GetPairedData("/excel/import/plugin//e/pairedData3CR/");
     }
 }
        private static void Run(Options opts)
        {
            VerifyExportArgs(opts);

            using (DssReader r = new DssReader(opts.DssFile))
            {
                object      record;
                ExcelWriter ew = new ExcelWriter(opts.ExcelFile);

                for (int i = 0; i < opts.Paths.ToList <string>().Count; i++)
                {
                    string sheet;
                    while (true)
                    {
                        sheet = "dssvue_import_" + ExcelTools.RandomString(5);
                        if (!ew.SheetExists(sheet))
                        {
                            break;
                        }
                    }
                    DssPath p    = new DssPath(opts.Paths.ElementAt(i));
                    var     type = r.GetRecordType(p);
                    if (type is RecordType.RegularTimeSeries || type is RecordType.IrregularTimeSeries)
                    {
                        record = r.GetTimeSeries(p);
                        ew.Write(record as TimeSeries, sheet);
                    }
                    else if (type is RecordType.PairedData)
                    {
                        record = r.GetPairedData(p.FullPath);
                        ew.Write(record as PairedData, sheet);
                    }
                }
            }
        }
        public void ReadPairedDataWithXY()
        {
            var path = "/FISHKILL CREEK/BEACON NY/FREQ-FLOW///USGS/";

            using (DssReader r = new DssReader(TestUtility.BasePath + "sample7_units_xyz.dss"))
            {
                var pd = r.GetPairedData(path);
                Assert.AreEqual(123, pd.LocationInformation.XOrdinate);
                Assert.AreEqual(456, pd.LocationInformation.YOrdinate);
            }
        }
        public void GetPairedDataV6()
        {
            var path = "/A/B/STAGE-FLOW//E/F/";

            using (DssReader r = new DssReader(TestUtility.BasePath + "spd6.dss"))
            {
                var pd = r.GetPairedData(path);

                Assert.AreEqual("FEET", pd.UnitsIndependent);
                Assert.AreEqual("UNT", pd.TypeDependent);

                Assert.AreEqual("CFS", pd.UnitsDependent);
                Assert.AreEqual("UNT", pd.TypeDependent);

                Assert.IsNotNull(pd);
            }
        }
Beispiel #5
0
        public void GetHeaderInformationPairedData()
        {
            string dssFile = @".\tempdssfile.dss";
            string srcFile = TestUtility.BasePath + @"benchmarks6\BaldEDmbrk.dss";

            File.Delete(dssFile);
            CopyAsReadWrite(srcFile, dssFile);
            string path = @"/BALD EAGLE LOC HAV//LOCATION-ELEV//19FEB1999 2055/DAMBRKSIMBRCH/";

            using (DssReader dss = new DssReader(dssFile))
            {
                DssPathCollection paths = dss.GetCatalog();
                var dsspath             = paths.FindExactPath(path);
                var pd = dss.GetPairedData(dsspath.FullPath);
                Assert.IsTrue(pd.UnitsDependent == "FEET");
                Assert.IsTrue(pd.TypeDependent == "UNT");
            }
        }
        public void GetPairedDataV7()
        {
            var path = "/a/b/stage-flow//e/f/";

            using (DssReader r = new DssReader(TestUtility.BasePath + "spd7.dss"))
            {
                var pd = r.GetPairedData(path);

                Assert.AreEqual("FEET", pd.UnitsIndependent);
                Assert.AreEqual("UNT", pd.TypeDependent);

                Assert.AreEqual("CFS", pd.UnitsDependent);
                Assert.AreEqual("UNT", pd.TypeDependent);

                var d = pd.Values[0][1];

                Assert.IsNotNull(pd);
            }
        }
        public void ReadPairedData()
        {
            var path = "/MY BASIN/DEER CREEK/STAGE-FLOW///USGS/";

            using (DssReader r = new DssReader(TestUtility.BasePath + "sample7.dss"))
            {
                var pd = r.GetPairedData(path);


                //Assert.AreEqual()
                Assert.AreEqual("FEET", pd.UnitsIndependent);
                Assert.AreEqual("UNT", pd.TypeDependent);

                Assert.AreEqual("CFS", pd.UnitsDependent);
                Assert.AreEqual("UNT", pd.TypeDependent);

                Assert.AreEqual(0, pd.LocationInformation.CoordinateID);
            }
        }
        public void ReadPairedDataWithMultipleCurves2()
        {
            var path = "/a/b/stage-flow//e/f/";

            using (DssReader r = new DssReader(TestUtility.BasePath + "pdTest1.dss"))
            {
                var pd = r.GetPairedData(path);

                Assert.AreEqual(2, pd.Values.Count);


                Assert.AreEqual(1, pd.Values[0][0]);
                Assert.AreEqual(11, pd.Values[0][1]);
                Assert.AreEqual(111, pd.Values[0][2]);
                Assert.AreEqual(1111, pd.Values[0][3]);
                Assert.AreEqual(11111, pd.Values[0][4]);

                Assert.AreEqual(2, pd.Values[1][0]);
                Assert.AreEqual(22, pd.Values[1][1]);
                Assert.AreEqual(222, pd.Values[1][2]);
                Assert.AreEqual(2222, pd.Values[1][3]);
                Assert.AreEqual(22222, pd.Values[1][4]);

                Assert.AreEqual("duck1", pd.Labels[0]);
                Assert.AreEqual("duck2", pd.Labels[1]);



                //Assert.AreEqual()
                Assert.AreEqual("ft", pd.UnitsIndependent);
                Assert.AreEqual("UNT", pd.TypeDependent);

                Assert.AreEqual("cfs", pd.UnitsDependent);
                Assert.AreEqual("UNT", pd.TypeDependent);

                Assert.AreEqual(0, pd.LocationInformation.CoordinateID);
            }
        }
        private static void Run(Options opts)
        {
            if (opts.Command == "import")
            {
                VerifyImportArgs(opts);

                ExcelReader er = new ExcelReader(opts.ExcelFile);
                using (DssWriter w = new DssWriter(opts.DssFile))
                {
                    if (opts.Sheets.ToList <string>().Count == 0)
                    {
                        for (int i = 0; i < er.WorksheetCount; i++)
                        {
                            var t = er.CheckType(i);
                            if (t is RecordType.RegularTimeSeries || t is RecordType.IrregularTimeSeries)
                            {
                                w.Write(er.Read(i) as TimeSeries);
                            }
                            else if (t is RecordType.PairedData)
                            {
                                w.Write(er.Read(i) as PairedData);
                            }
                        }
                    }
                    else
                    {
                        foreach (var sheet in opts.Sheets)
                        {
                            var t = er.CheckType(sheet);
                            if (t is RecordType.RegularTimeSeries || t is RecordType.IrregularTimeSeries)
                            {
                                w.Write(er.Read(sheet) as TimeSeries);
                            }
                            else if (t is RecordType.PairedData)
                            {
                                w.Write(er.Read(sheet) as PairedData);
                            }
                        }
                    }
                }
            }
            else if (opts.Command == "export")
            {
                VerifyExportArgs(opts);

                using (DssReader r = new DssReader(opts.DssFile))
                {
                    object      record;
                    ExcelWriter ew = new ExcelWriter(opts.ExcelFile);
                    if (opts.Sheets.ToList().Count == 0)
                    {
                        for (int i = 0; i < opts.Paths.ToList <string>().Count; i++)
                        {
                            string  sheet = "dssvue_import_" + ExcelTools.RandomString(5);
                            DssPath p     = new DssPath(opts.Paths.ElementAt(i));
                            var     type  = r.GetRecordType(p);
                            if (type is RecordType.RegularTimeSeries || type is RecordType.IrregularTimeSeries)
                            {
                                record = r.GetTimeSeries(p);
                                ew.Write(record as TimeSeries, sheet);
                            }
                            else if (type is RecordType.PairedData)
                            {
                                record = r.GetPairedData(p.FullPath);
                                ew.Write(record as PairedData, sheet);
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < opts.Sheets.ToList().Count; i++)
                        {
                            DssPath p    = new DssPath(opts.Paths.ElementAt(i));
                            var     type = r.GetRecordType(p);
                            if (type is RecordType.RegularTimeSeries || type is RecordType.IrregularTimeSeries)
                            {
                                record = r.GetTimeSeries(p);
                                ew.Write(record as TimeSeries, opts.Sheets.ElementAt(i));
                            }
                            else if (type is RecordType.PairedData)
                            {
                                record = r.GetPairedData(p.FullPath);
                                ew.Write(record as PairedData, opts.Sheets.ElementAt(i));
                            }
                        }
                    }
                }
            }
        }