public void ReadConnecticutGrids()
        {
            // This path doesn't have a  E part.....
            DssPath path = new DssPath("/SHG/CONNECTICUT/AIRTEMP/07MAY2019:1400//GAGEINTERP/");
            string  fn   = TestUtility.BasePath + "ConnecticutGrids.dss";

            DssReader r = new DssReader(fn);

            var catalog = r.GetCatalog();

            for (int i = 0; i < catalog.Count; i++)
            {
                var p = catalog[i].FullPath;
                if (p.IndexOf("GAGEINTERP") > 0)
                {
                    Console.WriteLine(p);
                }
            }

            Assert.IsTrue(r.ExactPathExists(path));

            Grid g1 = r.GetGrid(path, false);
            Grid g2 = r.GetGrid(path, true);

            Assert.IsNotNull(g1);
            Assert.IsNotNull(g2);

            string expected = Hec.Dss.Native.DSS.AlbersSRS();

            Console.WriteLine("expected:\n" + expected);
            Console.WriteLine(g2.SRSDefinition);
            Assert.IsTrue(expected.ToLower() == g2.SRSDefinition.ToLower());
            // Assert.IsTrue(g1.SRSDefinitionType == 1);
        }
        public void V7ReadSimpleAlbersUndefinedProjection()
        {
            string path = "/a/b/c/01jan2001:1200/01jan2001:1300/f/";
            string fn   = TestUtility.BasePath + "gridtest.dss";

            DssReader r = new DssReader(fn);

            Grid g1 = r.GetGrid(path, false);
            Grid g2 = r.GetGrid(path, true);

            Assert.IsNotNull(g1);
            Assert.IsNotNull(g2);

            var x = g2.Data;

            for (int i = 0; i < x.Length; i++)
            {
                float expected = i * 1.2f;
                Assert.AreEqual(expected, x[i], 0.0001);
            }
            Assert.AreEqual(0, g2.StorageDataType);
            float delta = 0.000001f;                                // tolarance for comparisons;

            Assert.AreEqual(DssDataType.PER_AVER, g2.DataType);     //  Data Type: PER-AVER
            Assert.AreEqual(50, g2.Data.Length);
            Assert.AreEqual(0, g2.LowerLeftCellX);                  //  Lower Left Cell: (0, 0)
            Assert.AreEqual(0, g2.LowerLeftCellY);
            Assert.AreEqual("mm", g2.DataUnits.ToLower());          // Data Units: mm
            Assert.AreEqual(5, g2.NumberOfCellsX);                  //Grid Extents: (5, 10)
            Assert.AreEqual(10, g2.NumberOfCellsY);
            Assert.AreEqual(5.0f, g2.CellSize, delta);              //Cell Size: 5.0

            Assert.AreEqual(60.0f, g2.MaxDataValue, delta);         // Max Data Value: 60.0
            Assert.AreEqual(0.001, g2.MinDataValue, delta);         //Min Data Value: 0.001
            Assert.AreEqual(30.0f, g2.MeanDataValue, delta);        // Mean Data Value: 30.0
            Assert.AreEqual(10.2f, g2.XCoordOfGridCellZero, delta); // XCoord Of Grid Cell Zero: 10.2
            Assert.AreEqual(20.3f, g2.YCoordOfGridCellZero, delta); //YCoord Of Grid Cell Zero: 20.3

            Assert.AreEqual(path.ToLower(), g2.PathName.ToLower());
            Assert.AreEqual(DssGridType.ALBERS, g2.GridType); //Grid Type: ALBERS
            Assert.AreEqual(12, g2.NumberOfRanges);

            /*
             *
             * Start Time(assumed UTC): 1 January 2001, 12:00
             * End Time(assumed UTC):   1 January 2001, 13:00
             * = = = AlbersInfo = = =
             * Projection Datum: UNDEFINED DATUM
             * Projection Units:
             * First Standard Parallel: 0.0
             * Second Standard Parallel: 0.0
             * Central Meridian: 0.0
             * Latitude Of ProjectionOrigin: 0.0
             * False Easting: 0.0
             * False Northing: 0.0
             */
        }
        public void ReadSpecifiedGrid(string filename)
        {
            string path = "/UTM16N/PISTOL/PRECIP/05MAY2003:1100/05MAY2003:1200/RADAR/";
            string fn   = TestUtility.BasePath + filename;

            using (DssReader r = new DssReader(fn))
            {
                Grid g1 = r.GetGrid(path, false);
                Grid g2 = r.GetGrid(path, true);

                string javaSRS = @"PROJCS[""UTM_ZONE_16N_WGS84"",
		GEOGCS[""WGS_84"",
			DATUM[""WGS_1984"",
				SPHEROID[""WGS84"",6378137.0,298.257223563]],
			PRIMEM[""Greenwich"",0],
			UNIT[""degree"",0.01745329251994328]],
		UNIT[""Meter"",1.0],
		PROJECTION[""Transverse_Mercator""],
		PARAMETER[""latitude_of_origin"",0],
		PARAMETER[""central_meridian"",-87],
		PARAMETER[""scale_factor"",0.9996],
		PARAMETER[""false_easting"",500000],
		PARAMETER[""false_northing"",0],
		AXIS[""Easting"",EAST],
		AXIS[""Northing"",NORTH]]"        ;
                javaSRS = Regex.Replace(javaSRS, @"\s+", "");

                Assert.AreEqual(javaSRS, g1.SRSDefinition);

                Assert.IsNotNull(g1);
                Assert.IsNotNull(g2);
                //    /UTM16N/PISTOL/PRECIP/05MAY2003:1100/05MAY2003:1200/RADAR/

                //  Grid Type: SPECIFIED SPATIAL REFERENCE SYSTEM
                float delta = 0.000001f; // tolarance for comparisons;
                Assert.AreEqual(DssDataType.PER_CUM, g2.DataType);
                Assert.AreEqual(48, g2.Data.Length);
                Assert.AreEqual(384, g2.LowerLeftCellX);
                Assert.AreEqual(1975, g2.LowerLeftCellY);
                Assert.AreEqual("mm", g2.DataUnits.ToLower());
                Assert.AreEqual(6, g2.NumberOfCellsX);
                Assert.AreEqual(8, g2.NumberOfCellsY);
                Assert.AreEqual(2000.0f, g2.CellSize, delta);

                Assert.AreEqual(2.6322386f, g2.MaxDataValue, delta);
                Assert.AreEqual(1.3286265f, g2.MinDataValue, delta);
                Assert.AreEqual(1.6439365f, g2.MeanDataValue, delta);
                Assert.AreEqual(0.0f, g2.XCoordOfGridCellZero, delta);
                Assert.AreEqual(0.0f, g2.YCoordOfGridCellZero, delta);
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            string fn            = @"C:\Users\q0hecngn\Downloads\precip.2018.09.dss";
            string pathname      = "/SHG/MARFC/PRECIP///NEXRAD/";
            var    targetDSSPath = new DssPath(pathname);

            double sum = 0;

            for (int j = 0; j < 4; j++)
            {
                using (var dssr = new DssReader(fn, DssReader.MethodID.MESS_METHOD_GENERAL_ID, DssReader.LevelID.MESS_LEVEL_CRITICAL))
                {
                    var cat   = dssr.GetCatalog(false);
                    var paths = cat.Paths.Select(dssPath => dssPath.FullPath).ToArray();

                    var filterPaths = PathAssist.FilterByPart(paths, targetDSSPath);

                    for (int i = 0; i < filterPaths.Count; i++)
                    {
                        string subpath = filterPaths[i];
                        var    dssPath = new DssPath(subpath);

                        var grd = dssr.GetGrid(dssPath, true);
                        sum += grd.MaxDataValue;
                    }

                    Console.WriteLine(sum.ToString());
                }
            }
        }
        public void ReadAllGrids()
        {
            string fn            = TestUtility.BasePath + "precip.2018.09.dss";
            string pathname      = "/SHG/MARFC/PRECIP///NEXRAD/";
            var    targetDSSPath = new DssPath(pathname);

            double sum = 0;

            using (var dssr = new DssReader(fn, DssReader.MethodID.MESS_METHOD_GENERAL_ID, DssReader.LevelID.MESS_LEVEL_CRITICAL))
            {
                var cat   = dssr.GetCatalog(false);
                var paths = cat.Paths.Select(dssPath => dssPath.FullPath).ToArray();

                var filterPaths = PathAssist.FilterByPart(paths, targetDSSPath);

                for (int i = 0; i < filterPaths.Count; i++)
                {
                    string subpath = filterPaths[i];
                    var    dssPath = new DssPath(subpath);

                    var grd = dssr.GetGrid(dssPath, true);
                    sum += grd.MaxDataValue;
                }

                Console.WriteLine(sum.ToString());
            }
        }
        public void V7ReadV6SHG()
        {
            string path = "/SHG/TRUCKEE RIVER/TEMP-AIR/31JAN2016:2400//INTERPOLATED-ROUNDED/";
            string fn   = TestUtility.BasePath + "version7AlbersGrid.dss";

            Console.WriteLine(Directory.GetCurrentDirectory());

            if (!File.Exists(fn))
            {
                Console.WriteLine("File does not exist " + fn);
            }
            DssReader r = new DssReader(fn);

            var  t1 = DateTime.Now;
            Grid g2 = r.GetGrid(path, true);

            for (int i = 0; i < g2.Data.Length; i++)
            {
                var f = g2.Data[i];
            }

            var      t2 = DateTime.Now;
            TimeSpan ts = t2.Subtract(t1);

            Console.WriteLine("grid read time " + ts.TotalSeconds);
            Assert.IsNotNull(g2);

            string s = g2.Info();
        }
        public void ReadBugUTM()
        {
            string fn   = TestUtility.BasePath + "BALDEAGLE.DSS";
            string path = "/UTM_18N/MARFC/PRECIP/23JUL2003:0000/23JUL2003:0100/NEXRAD (1000 M)/";

            using (DssReader r = new DssReader(fn))
            {
                Grid g1 = r.GetGrid(path, false);
                Console.WriteLine(g1.SRSDefinition);
            }
        }
Ejemplo n.º 8
0
        public void GetHeaderInformationGrid()
        {
            string dssFile = @".\tempdssfile.dss";
            string srcFile = TestUtility.BasePath + @"containsGrids7.dss";

            File.Delete(dssFile);
            CopyAsReadWrite(srcFile, dssFile);
            string path = @"/SHG/LAKE WINNEBAGO/PRECIP/01JUN2016:0600/01JUN2016:1200/WPC-QPF/";

            using (DssReader dss = new DssReader(dssFile))
            {
                DssPathCollection paths = dss.GetCatalog();
                var dsspath             = paths.FindExactPath(path);
                var grid = dss.GetGrid(dsspath, false);
                Console.WriteLine("");
                Assert.IsTrue(grid.DataUnits == "mm");
                Assert.IsTrue(grid.DataType.ToString() == "PER_CUM");
            }
        }
        public void ReadMetVueHRAP()
        {
            string path = "/HRAP/MARFC/PRECIP/23JUL2003:1800/23JUL2003:1900/NEXRAD/";

            string fn = TestUtility.BasePath + "BALDEAGLE.DSS";

            using (DssReader r = new DssReader(fn))
            {
                Grid g1 = r.GetGrid(path, false);
                Console.WriteLine(g1.SRSDefinition);

                string hrap_wkt = @"PROJCS[""Stereographic_CONUS_HRAP"",
GEOGCS[""GCS_Sphere_LFM"",DATUM[""D_Sphere_LFM"",
SPHEROID[""Shpere_LFM"",6371200.0,0.0]],PRIMEM[""Greenwich"",0.0],
UNIT[""Degree"",0.0174532925199433]],
PROJECTION[""Stereographic_North_Pole""],
PARAMETER[""False_Easting"",1909762.5],PARAMETER[""False_Northing"",7624762.5],
PARAMETER[""Central_Meridian"",-105.0],PARAMETER[""Standard_Parallel_1"",60.0],
UNIT[""Meter"",1.0]]";
                hrap_wkt = Regex.Replace(hrap_wkt, @"\s+", "");
                Console.WriteLine(g1.SRSDefinition);
                Assert.AreEqual(hrap_wkt, g1.SRSDefinition);
            }
        }