Пример #1
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Creates a site variable with ecoregions.
        /// </summary>
        public ISiteVar <IEcoregion> CreateSiteVar(ILandscape landscape)
        {
            ISiteVar <IEcoregion> siteVar = landscape.NewSiteVar <IEcoregion>();
            IInputRaster <Pixel>  map     = Util.Raster.Open <Pixel>(path);

            foreach (Site site in landscape.AllSites)
            {
                Pixel pixel = map.ReadPixel();
                if (site.IsActive)
                {
                    ushort mapCode = pixel.Band0;
                    siteVar[site] = ecoregions.Find(mapCode);
                }
            }
            map.Close();
            return(siteVar);
        }
Пример #2
0
        public void Communities_Timestep10()
        {
            reader = OpenFile("Communities.txt");
            IDataset dataset = parser.Parse(reader);

            ICommunity community = dataset.Find(100);

            Assert.IsNotNull(community);
            ISpeciesCohorts <AgeCohort.ICohort> oakCohorts = community.Cohorts[oak];

            Assert.AreEqual(5, oakCohorts.Count);
            Assert.AreEqual(10, oakCohorts[0]);
            Assert.AreEqual(20, oakCohorts[1]);
            Assert.AreEqual(30, oakCohorts[2]);
            Assert.AreEqual(100, oakCohorts[3]);
            Assert.AreEqual(150, oakCohorts[4]);
        }
Пример #3
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Creates a site variable with ecoregions.
        /// </summary>
        public ISiteVar <IEcoregion> CreateSiteVar(ILandscape landscape)
        {
            ISiteVar <IEcoregion> siteVar = landscape.NewSiteVar <IEcoregion>();
            IInputRaster <Pixel>  map     = rasterFactory.OpenRaster <Pixel>(path);

            using (map) {
                foreach (Site site in landscape.AllSites)
                {
                    Pixel pixel = map.ReadPixel();
                    if (site.IsActive)
                    {
                        ushort mapCode = pixel.Band0;
                        siteVar[site] = ecoregions.Find(mapCode);
                    }
                }
            }
            return(siteVar);
        }
Пример #4
0
        //---------------------------------------------------------------------

        public bool ReadValue()
        {
            if (disposed)
            {
                throw new System.InvalidOperationException("Object has been disposed.");
            }
            Pixel pixel = raster.ReadPixel();

            pixelLocation = RowMajor.Next(pixelLocation, raster.Dimensions.Columns);
            ushort     mapCode   = pixel.Band0;
            IEcoregion ecoregion = ecoregions.Find(mapCode);

            if (ecoregion != null)
            {
                return(ecoregion.Active);
            }

            string mesg      = string.Format("Error at map site {0}", pixelLocation);
            string innerMesg = string.Format("Unknown map code for ecoregion: {0}", mapCode);

            throw new MultiLineException(mesg, innerMesg);
        }
        public void Communities_Timestep10()
        {
            reader = OpenFile("Communities.txt");
            IDataset dataset = parser.Parse(reader);

            ICommunity community = dataset.Find(100);

            Assert.IsNotNull(community);

            ISpeciesCohorts oakCohorts = community.Cohorts[oak];

            Assert.AreEqual(5, oakCohorts.Count);

            List <ushort> actualAges = new List <ushort>(oakCohorts.Count);

            foreach (ICohort cohort in oakCohorts)
            {
                actualAges.Add(cohort.Age);
            }
            ushort[] expectedAges = new ushort[] { 150, 100, 30, 20, 10 };
            AssertAreEqual(expectedAges, actualAges.ToArray());
        }