예제 #1
0
        //---------------------------------------------------------------------

        public InputParameters(ISpeciesDataset speciesDataset, int litterCnt, int functionalCnt)
        {
            this.speciesDataset = speciesDataset;

            functionalTypes        = new FunctionalTypeTable(functionalCnt);
            fireReductionsTable    = new FireReductions[6];
            harvestReductionsTable = new List <HarvestReductions>();

            sppFunctionalType = new Landis.Library.Parameters.Species.AuxParm <int>(speciesDataset);
            nFixer            = new Landis.Library.Parameters.Species.AuxParm <bool>(speciesDataset);
            gddMin            = new Landis.Library.Parameters.Species.AuxParm <int>(speciesDataset);
            gddMax            = new Landis.Library.Parameters.Species.AuxParm <int>(speciesDataset);
            minJanTemp        = new Landis.Library.Parameters.Species.AuxParm <int>(speciesDataset);
            maxDrought        = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            leafLongevity     = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            epicormic         = new Landis.Library.Parameters.Species.AuxParm <bool>(speciesDataset);
            leafLignin        = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            woodLignin        = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            coarseRootLignin  = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            fineRootLignin    = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            leafCN            = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            woodCN            = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            coarseRootCN      = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            foliageLitterCN   = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            fineRootCN        = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            maxANPP           = new Landis.Library.Parameters.Species.AuxParm <int>(speciesDataset);
            maxBiomass        = new Landis.Library.Parameters.Species.AuxParm <int>(speciesDataset);

            maximumShadeLAI = new double[6];
            sufficientLight = new List <ISufficientLight>();
        }
 //---------------------------------------------------------------------
 public static void Initialize(IInputParameters parameters)
 {
     LeafLignin           = parameters.LeafLignin;
     LeafLongevity        = parameters.LeafLongevity;
     MortCurveShapeParm   = parameters.MortCurveShapeParm;
     GrowthCurveShapeParm = parameters.GrowthCurveShapeParm;
     WoodyDebrisDecay     = parameters.WoodyDecayRate;
 }
 //---------------------------------------------------------------------
 public InputParameters()
 {
     drought_Y    = new Landis.Library.Parameters.Species.AuxParm <double>(PlugIn.ModelCore.Species);
     drought_YSE  = new Landis.Library.Parameters.Species.AuxParm <double>(PlugIn.ModelCore.Species);
     drought_B    = new Landis.Library.Parameters.Species.AuxParm <double>(PlugIn.ModelCore.Species);
     drought_BSE  = new Landis.Library.Parameters.Species.AuxParm <double>(PlugIn.ModelCore.Species);
     drought_Sens = new Landis.Library.Parameters.Species.AuxParm <int>(PlugIn.ModelCore.Species);
 }
예제 #4
0
 //---------------------------------------------------------------------
 public static void Initialize(IInputParameters parameters)
 {
     //ChangeParameters(parameters);
     Drought_Y    = parameters.Drought_Y;
     Drought_YSE  = parameters.Drought_YSE;
     Drought_B    = parameters.Drought_B;
     Drought_BSE  = parameters.Drought_BSE;
     Drought_Sens = parameters.Drought_Sens;
 }
 //---------------------------------------------------------------------
 public static void Initialize(IInputParameters parameters)
 {
     //ChangeParameters(parameters);
     Drought_Y = parameters.Drought_Y;
     Drought_YSE = parameters.Drought_YSE;
     Drought_B = parameters.Drought_B;
     Drought_BSE = parameters.Drought_BSE;
     Drought_Sens = parameters.Drought_Sens;
 }
예제 #6
0
 //---------------------------------------------------------------------
 public InputParameters(int ecoregionCount)
 {
     sbwHost       = new Library.Parameters.Species.AuxParm <bool>(PlugIn.ModelCore.Species);
     deciduous     = new Library.Parameters.Species.AuxParm <bool>(PlugIn.ModelCore.Species);
     EcoParameters = new IEcoParameters[ecoregionCount];
     for (int i = 0; i < ecoregionCount; i++)
     {
         EcoParameters[i] = new EcoParameters();
     }
 }
        //---------------------------------------------------------------------

        public InputParameters(ISpeciesDataset speciesDataset)
        {
            this.speciesDataset = speciesDataset;

            ladderFuelSpeciesList      = new List <ISpecies>();
            deadWoodList               = new List <IDeadWood>();
            suppressionFWI_Table       = new Dictionary <int, ISuppressionTable>();
            dynamicRxIgnitions         = new List <IDynamicIgnitionMap>();
            dynamicLightningIgnitions  = new List <IDynamicIgnitionMap>();
            dynamicAccidentalIgnitions = new List <IDynamicIgnitionMap>();
            dynamicSuppression         = new List <IDynamicSuppressionMap>();
            ageDBH = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
            maximumBarkThickness = new Landis.Library.Parameters.Species.AuxParm <double>(speciesDataset);
        }
        public WaterStressTable(InputParameters parameters)
        {
            H2 = parameters.GetSpeciesParameterValues<float>("H2", 0, float.MaxValue);
            H3 = parameters.GetSpeciesParameterValues<float>("H3", 0, float.MaxValue);
            H4 = parameters.GetSpeciesParameterValues<float>("H4", 0, float.MaxValue);

            foreach (ISpecies species in PlugIn.ModelCore.Species)
            {
                List<float> values = new List<float>();
                for (int ph = 0; ph <= H4[species]; ph++)
                {
                    values.Add(GetFWater(species, ph));
                }
                table[species] = values.ToArray();
                table2[species.Index] = values.ToArray();
            }
        }
예제 #9
0
        //---------------------------------------------------------------------

        public InputParameters()
        {
            sufficientLight      = new List <ISufficientLight>();
            leafLongevity        = new Landis.Library.Parameters.Species.AuxParm <double>(PlugIn.ModelCore.Species);
            woodyDecayRate       = new Landis.Library.Parameters.Species.AuxParm <double>(PlugIn.ModelCore.Species);
            mortCurveShapeParm   = new Landis.Library.Parameters.Species.AuxParm <double>(PlugIn.ModelCore.Species);
            growthCurveShapeParm = new Landis.Library.Parameters.Species.AuxParm <double>(PlugIn.ModelCore.Species);
            leafLignin           = new Landis.Library.Parameters.Species.AuxParm <double>(PlugIn.ModelCore.Species);
            //maxLAI = new Species.AuxParm<double>(PlugIn.ModelCore.Species);
            //lightExtinctionCoeff = new Species.AuxParm<double>(PlugIn.ModelCore.Species);
            //pctBioMaxLAI = new Species.AuxParm<double>(PlugIn.ModelCore.Species);
            aet = new Landis.Library.Parameters.Ecoregions.AuxParm <int>(PlugIn.ModelCore.Ecoregions);

            minRelativeBiomass = new Landis.Library.Parameters.Ecoregions.AuxParm <Percentage> [6];
            for (byte shadeClass = 1; shadeClass <= 5; shadeClass++)
            {
                minRelativeBiomass[shadeClass] = new Landis.Library.Parameters.Ecoregions.AuxParm <Percentage>(PlugIn.ModelCore.Ecoregions);
            }
        }
        //---------------------------------------------------------------------
        public InputParameters()
        {
            sufficientLight = new List<ISufficientLight>();
            leafLongevity = new Landis.Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
            woodyDecayRate = new Landis.Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
            mortCurveShapeParm = new Landis.Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
            growthCurveShapeParm = new Landis.Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
            leafLignin = new Landis.Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
            //maxLAI = new Species.AuxParm<double>(PlugIn.ModelCore.Species);
            //lightExtinctionCoeff = new Species.AuxParm<double>(PlugIn.ModelCore.Species);
            //pctBioMaxLAI = new Species.AuxParm<double>(PlugIn.ModelCore.Species);
            aet = new Landis.Library.Parameters.Ecoregions.AuxParm<int>(PlugIn.ModelCore.Ecoregions);

            minRelativeBiomass = new Landis.Library.Parameters.Ecoregions.AuxParm<Percentage>[6];
            for (byte shadeClass = 1; shadeClass <= 5; shadeClass++)
            {
                minRelativeBiomass[shadeClass] = new Landis.Library.Parameters.Ecoregions.AuxParm<Percentage>(PlugIn.ModelCore.Ecoregions);
            }
        }
예제 #11
0
        //---------------------------------------------------------------------
        public static void Initialize(IInputParameters parameters)
        {
            FuncType         = parameters.SppFunctionalType;
            NFixer           = parameters.NFixer;
            GDDmin           = parameters.GDDmin;
            GDDmax           = parameters.GDDmax;
            MinJanTemp       = parameters.MinJanTemp;
            MaxDrought       = parameters.MaxDrought;
            LeafLongevity    = parameters.LeafLongevity;
            Epicormic        = parameters.Epicormic;
            LeafLignin       = parameters.LeafLignin;
            WoodLignin       = parameters.WoodLignin;
            CoarseRootLignin = parameters.CoarseRootLignin;
            FineRootLignin   = parameters.FineRootLignin;
            LeafCN           = parameters.LeafCN;
            WoodCN           = parameters.WoodCN;
            CoarseRootCN     = parameters.CoarseRootCN;
            LeafLitterCN     = parameters.FoliageLitterCN;
            FineRootCN       = parameters.FineRootCN;
            Max_ANPP         = parameters.MaxANPP;
            Max_Biomass      = parameters.MaxBiomass;
            Grass            = parameters.Grass;

            foreach (ISpecies spp in PlugIn.ModelCore.Species)
            {
                try
                {
                    double maxLAI = FunctionalType.Table[SpeciesData.FuncType[spp]].MaxLAI;
                    //PlugIn.ModelCore.UI.WriteLine("Spp={0}, FT={1}", spp.Name, SpeciesData.FuncType[spp]);
                }
                catch (Exception)
                {
                    string mesg = string.Format("Species or Functional Type Missing: {0}", spp.Name);
                    throw new System.ApplicationException(mesg);
                }
            }
        }
        public override void Run()
        {
            System.Console.WriteLine("Updating output variable: BelowGround");

            if (LAI != null)
            {
                System.Console.WriteLine("Updating output variable: LAI");
                // Total LAI per site

                ISiteVar<byte> values = cohorts.GetIsiteVar(o => o.CanopyLAImax);

                string FileName = FileNames.ReplaceTemplateVars(LAI.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar<byte, byte>(FileName, values, o => o);

                // Values per species each time step
                LAI.output_table_ecoregions.WriteUpdate(PlugIn.ModelCore.CurrentTime, values);
            }

            if (Biomass != null)
            {
                System.Console.WriteLine("Updating output variable: Biomass");

                ISiteVar<Landis.Library.Parameters.Species.AuxParm<int>> Biom = cohorts.GetIsiteVar(o => o.BiomassPerSpecies);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar<int> Biom_spc = modelCore.Landscape.NewSiteVar<int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        Biom_spc[site] = Biom[site][spc];
                    }

                    new OutputMapSpecies(Biom_spc, spc, Biomass.MapNameTemplate);
                }

                OutputFilePerTStepPerSpecies.Write<int>(Biomass.MapNameTemplate, Biomass.units, PlugIn.ModelCore.CurrentTime, Biom);

                ISiteVar<float> Biomass_site = cohorts.GetIsiteVar(x => x.BiomassSum);

                Biomass.output_table_ecoregions.WriteUpdate<float>(PlugIn.ModelCore.CurrentTime, Biomass_site);
            }
            if (AbovegroundBiomass != null)
            {
                System.Console.WriteLine("Updating output variable: Aboveground Biomass");

                ISiteVar<Landis.Library.Parameters.Species.AuxParm<int>> AGBiom = cohorts.GetIsiteVar(o => o.AbovegroundBiomassPerSpecies);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar<int> AGBiom_spc = modelCore.Landscape.NewSiteVar<int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        AGBiom_spc[site] = AGBiom[site][spc];
                    }

                    new OutputMapSpecies(AGBiom_spc, spc, AbovegroundBiomass.MapNameTemplate);
                }

                OutputFilePerTStepPerSpecies.Write<int>(AbovegroundBiomass.MapNameTemplate, Biomass.units, PlugIn.ModelCore.CurrentTime, AGBiom);

                ISiteVar<float> AGBiomass_site = cohorts.GetIsiteVar(x => x.AbovegroundBiomassSum);

                AbovegroundBiomass.output_table_ecoregions.WriteUpdate<float>(PlugIn.ModelCore.CurrentTime, AGBiomass_site);
            }
            if (WoodySenescence != null)
            {
                System.Console.WriteLine("Updating output variable: Woody Senescence");

                ISiteVar<Landis.Library.Parameters.Species.AuxParm<int>> Senes = cohorts.GetIsiteVar(o => o.WoodySenescencePerSpecies);
                /*
                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar<int> Senes_spc = modelCore.Landscape.NewSiteVar<int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        Senes_spc[site] = Senes[site][spc];

                    }

                    new OutputMapSpecies(Senes_spc, spc, WoodySenescence.MapNameTemplate);
                }
                */
                OutputFilePerTStepPerSpecies.Write<int>(WoodySenescence.MapNameTemplate, WoodySenescence.units, PlugIn.ModelCore.CurrentTime, Senes);

                ISiteVar<float> Senescence_site = cohorts.GetIsiteVar(x => x.WoodySenescenceSum);

                WoodySenescence.output_table_ecoregions.WriteUpdate<float>(PlugIn.ModelCore.CurrentTime, Senescence_site);
            }
            if (FoliageSenescence != null)
            {
                System.Console.WriteLine("Updating output variable: Foliage Senescence");

                ISiteVar<Landis.Library.Parameters.Species.AuxParm<int>> Senes = cohorts.GetIsiteVar(o => o.FoliageSenescencePerSpecies);

                /*foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar<int> Senes_spc = modelCore.Landscape.NewSiteVar<int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        Senes_spc[site] = Senes[site][spc];
                    }

                    new OutputMapSpecies(Senes_spc, spc, FoliageSenescence.MapNameTemplate);
                }
                */
                OutputFilePerTStepPerSpecies.Write<int>(FoliageSenescence.MapNameTemplate, FoliageSenescence.units, PlugIn.ModelCore.CurrentTime, Senes);

                ISiteVar<float> Senescence_site = cohorts.GetIsiteVar(x => x.FoliageSenescenceSum);

                FoliageSenescence.output_table_ecoregions.WriteUpdate<float>(PlugIn.ModelCore.CurrentTime, Senescence_site);
            }
            if (MonthlyFolResp != null)
            {
                ISiteVar<int[]> monthlyFolResp = cohorts.GetIsiteVar(site => site.FolResp);

                WriteMonthlyOutput(monthlyFolResp, MonthlyFolResp.MapNameTemplate);
            }
            if (MonthlyGrossPsn != null)
            {
                ISiteVar<int[]> monthlyGrossPsn = cohorts.GetIsiteVar(site => site.GrossPsn);

                WriteMonthlyOutput(monthlyGrossPsn, MonthlyGrossPsn.MapNameTemplate);
            }
            if (MonthlyNetPsn != null)
            {
                ISiteVar<int[]> monthlyNetPsn = cohorts.GetIsiteVar(site => site.NetPsn);

                WriteMonthlyOutput(monthlyNetPsn, MonthlyNetPsn.MapNameTemplate);
            }
            if (MonthlyMaintResp != null)
            {
                ISiteVar<int[]> monthlyMaintResp = cohorts.GetIsiteVar(site => site.MaintResp);

                WriteMonthlyOutput(monthlyMaintResp, MonthlyMaintResp.MapNameTemplate);
            }

            if (BelowGround != null)
            {
                System.Console.WriteLine("Updating output variable: BelowGround");

                ISiteVar<uint> values = cohorts.GetIsiteVar(o => o.BelowGroundBiomass);

                string FileName = FileNames.ReplaceTemplateVars(BelowGround.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar<uint, uint>(FileName, values, o => o);

            }

            if (CohortsPerSpc != null)
            {
                System.Console.WriteLine("Updating output variable: CohortsPerSpc");
                // Nr of Cohorts per site and per species

                ISiteVar<Landis.Library.Parameters.Species.AuxParm<int>> cps =  cohorts.GetIsiteVar(x => x.CohortCountPerSpecies);

                new OutputHistogramCohort<int>(CohortsPerSpc.MapNameTemplate, "CohortsPerSpcPerSite", 10).WriteOutputHist(cps);

                foreach (ISpecies spc in PlugIn.modelCore.Species)
                {
                    string FileName = FileNames.ReplaceTemplateVars(CohortsPerSpc.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                    new OutputMapSiteVar<Landis.Library.Parameters.Species.AuxParm<int>, int>(FileName, cps, o => o[spc]);
                }

                OutputFilePerTStepPerSpecies.Write<int>(CohortsPerSpc.MapNameTemplate, CohortsPerSpc.units, PlugIn.ModelCore.CurrentTime, cps);
            }
            if (EstablishmentProbability != null)
            {
                System.Console.WriteLine("Updating output variable: EstablishmentProbability");

                ISiteVar<Landis.Library.Parameters.Species.AuxParm<byte>> pest = cohorts.GetIsiteVar(o => o.EstablishmentProbability.Probability);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar<int> _pest = modelCore.Landscape.NewSiteVar<int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        _pest[site] = pest[site][spc];
                    }

                    new OutputMapSpecies(_pest, spc, EstablishmentProbability.MapNameTemplate);
                }

            }
            if (SpeciesEstablishment != null)
            {
                System.Console.WriteLine("Updating output variable: SpeciesEstablishment");

                ISiteVar<Landis.Library.Parameters.Species.AuxParm<bool>> SpeciesIsThere = cohorts.GetIsiteVar(o => o.SpeciesPresent);

                if (SpeciesWasThere != null)
                {
                    foreach (ISpecies spc in PlugIn.modelCore.Species)
                    {
                        ISiteVar<int> comp = PlugIn.modelCore.Landscape.NewSiteVar<int>();

                        MapComparison m = new MapComparison();
                        foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                        {
                            if (SpeciesWasThere[site] == null)
                            {
                                SpeciesWasThere[site] = new Library.Parameters.Species.AuxParm<bool>(PlugIn.modelCore.Species);
                            }

                            comp[site] = m[SpeciesWasThere[site][spc], SpeciesIsThere[site][spc]];

                            SpeciesWasThere[site][spc] = SpeciesIsThere[site][spc];
                        }

                        OutputMapSpecies output_map =  new OutputMapSpecies(comp, spc, SpeciesEstablishment.MapNameTemplate);

                        // map label text
                        m.PrintLabels(SpeciesEstablishment.MapNameTemplate, spc);

                    }
                }
                else
                {
                    SpeciesWasThere = modelCore.Landscape.NewSiteVar<Landis.Library.Parameters.Species.AuxParm<bool>>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        SpeciesWasThere[site] = new Library.Parameters.Species.AuxParm<bool>(PlugIn.modelCore.Species);
                    }
                }

                ISiteVar<Landis.Library.Parameters.Species.AuxParm<bool>> Established_spc = cohorts.GetIsiteVar(x => x.SpeciesPresent);

                Landis.Library.Parameters.Species.AuxParm<int> Est_Sum = new Landis.Library.Parameters.Species.AuxParm<int>(PlugIn.modelCore.Species);

                foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
                {
                    foreach(ISpecies spc in PlugIn.modelCore.Species)
                    {
                        if(Established_spc[site][spc] ==true)
                        {
                            Est_Sum[spc]++;
                        }
                    }
                }

                OutputFilePerTStepPerSpecies.Write<int>(SpeciesEstablishment.MapNameTemplate, SpeciesEstablishment.units, PlugIn.ModelCore.CurrentTime, Est_Sum);

            }
            if (AnnualPsn != null)
            {
                System.Console.WriteLine("Updating output variable: AnnualPsn");

                ISiteVar<Landis.Library.Parameters.Species.AuxParm<int>> Biom = cohorts.GetIsiteVar(o => o.BiomassPerSpecies);

                if (LastBiom != null)
                {
                    foreach (ISpecies spc in PlugIn.modelCore.Species)
                    {
                        ISiteVar<int> comp = PlugIn.modelCore.Landscape.NewSiteVar<int>();

                        MapComparison m = new MapComparison();
                        foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                        {
                            if (LastBiom[site] == null)
                            {
                                LastBiom[site] = new Library.Parameters.Species.AuxParm<int>(PlugIn.modelCore.Species);
                            }

                            comp[site] = Biom[site][spc] - LastBiom[site][spc];

                            LastBiom[site][spc] = Biom[site][spc];
                        }

                        OutputMapSpecies output_map = new OutputMapSpecies(comp, spc, AnnualPsn.MapNameTemplate);

                    }
                }
                else
                {
                    LastBiom = modelCore.Landscape.NewSiteVar<Landis.Library.Parameters.Species.AuxParm<int>>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        LastBiom[site] = new Library.Parameters.Species.AuxParm<int>(PlugIn.modelCore.Species);
                    }
                }

            }

            if (Water != null)
            {
                System.Console.WriteLine("Updating output variable: Water");

                ISiteVar<ushort> Water_site = cohorts.GetIsiteVar(x => x.WaterMax);

                string FileName = FileNames.ReplaceTemplateVars(Water.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar<ushort, ushort>(FileName, Water_site, o => o);

                Water.output_table_ecoregions.WriteUpdate(PlugIn.ModelCore.CurrentTime, Water_site);
            }

            if (SubCanopyPAR != null)
            {
                System.Console.WriteLine("Updating output variable: SubCanopyPAR");

                ISiteVar<float> SubCanopyRadiation = cohorts.GetIsiteVar(x => x.SubCanopyParMAX);

                string FileName = FileNames.ReplaceTemplateVars(SubCanopyPAR.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar<float, float>(FileName, SubCanopyRadiation, o => o);

            }
            if (NonWoodyDebris != null)
            {
                System.Console.WriteLine("Updating output variable: NonWoodyDebris");

                ISiteVar<double> Litter = cohorts.GetIsiteVar(x => x.Litter);

                string FileName = FileNames.ReplaceTemplateVars(NonWoodyDebris.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar<double, double>(FileName, Litter, o => o);

            }

            if (WoodyDebris != null)
            {
                System.Console.WriteLine("Updating output variable: WoodyDebris");

                ISiteVar<double> woody_debris = cohorts.GetIsiteVar(x => x.WoodyDebris);

                string FileName = FileNames.ReplaceTemplateVars(WoodyDebris.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar<double, double>(FileName, woody_debris, o => o);

            }

            if (AgeDistribution != null)
            {
                System.Console.WriteLine("Updating output variable: AgeDistribution");

                ISiteVar<Landis.Library.Parameters.Species.AuxParm<List<ushort>>> values = cohorts.GetIsiteVar(o => o.CohortAges);

                new OutputHistogramCohort<ushort>(AgeDistribution.MapNameTemplate, "NrOfCohortsAtAge", 10).WriteOutputHist(values);

                System.Console.WriteLine("Updating output variable: MaxAges");

                ISiteVar<int> maxage = cohorts.GetIsiteVar(x => x.AgeMax);

                string FileName = FileNames.ReplaceTemplateVars(AgeDistribution.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar<int, int>(FileName, maxage, o => o);

            }
            if (overalloutputs != null)
            {
                System.Console.WriteLine("Updating output variable: overalloutputs");
                OutputAggregatedTable.WriteNrOfCohortsBalance();
            }
        }
 //---------------------------------------------------------------------
 public InputParameters()
 {
     drought_Y = new Landis.Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
     drought_YSE = new Landis.Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
     drought_B = new Landis.Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
     drought_BSE = new Landis.Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
     drought_Sens = new Landis.Library.Parameters.Species.AuxParm<int>(PlugIn.ModelCore.Species);
 }
        public SpeciesPnET()
        {
            #region initialization of private static species variables
            wuecnst = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("WUEcnst"));
            dnsc =  ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("DNSC"));
            cfracbiomass=  ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("CFracBiomass"));
            kwdlit = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("kwdlit"));
            fracbelowg = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("fracbelowg"));
            fracfol = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("fracfol"));
            fractWd = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("fractWd"));
            psnagered = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("psnagered"));
            h2 = ((Landis.Library.Parameters.Species.AuxParm<ushort>)(Parameter<ushort>)PlugIn.GetParameter("h2"));
            h3 = ((Landis.Library.Parameters.Species.AuxParm<ushort>)(Parameter<ushort>)PlugIn.GetParameter("h3"));
            h4 = ((Landis.Library.Parameters.Species.AuxParm<ushort>)(Parameter<ushort>)PlugIn.GetParameter("h4"));
            slwdel = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("slwdel"));
            slwmax = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("slwmax"));
            tofol = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("tofol"));
            halfsat = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("halfsat"));
            toroot = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("toroot"));
            initialnsc = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("initialnsc")); ;
            k = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("k")); ;
            towood = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("towood")); ;
            estrad = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("estrad")); ;
            estmoist = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("estmoist"));
            follignin = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("follignin"));
            preventestablishment = ((Landis.Library.Parameters.Species.AuxParm<bool>)(Parameter<bool>)PlugIn.GetParameter("preventestablishment"));
            psntopt = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("psntopt"));
            q10 = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("q10"));
            psntmin = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("psntmin"));
            dvpd1 = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("dvpd1"));
            dvpd2 = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("dvpd2"));
            foln = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("foln"));
            amaxa = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("amaxa"));
            amaxb = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("amaxb"));
            maintresp = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("maintresp"));
            bfolresp = ((Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("bfolresp"));
            #endregion

            SpeciesCombinations = new List<Tuple<ISpecies, ISpeciesPNET>>();

            foreach (ISpecies spc in PlugIn.ModelCore.Species)
            {
                SpeciesPnET species = new SpeciesPnET(spc);

                SpeciesCombinations.Add(new Tuple<ISpecies, ISpeciesPNET>(spc, species));
            }
        }
        public static void Initialize()
        {
            cFracBiomass = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("CFracBiomass", 0, 1);
            sLWDel = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("SLWDel", 0, float.MaxValue);
            sLWmax = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("SLWmax", 0, float.MaxValue);
            fracFol = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("FracFol", 0, 1);
            dNSC = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("DNSC", 0, 1);
            fracBelowG = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("FracBelowG", 0, 1);
            tOroot = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("TOroot", 0, 1);
            tOwood = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("TOwood", 0, 1);
            tOfol = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("TOfol", 0, 1);
            psnAgeRed = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("PsnAgeRed", 0, float.MaxValue);
            bFolResp = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("BFolResp", 0, float.MaxValue);
            kWdLit = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("KWdLit", 0, 1);
            frActWd = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("FrActWd", 0, float.MaxValue);
            kWdLit = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("KWdLit", 0, 1);
            initialNSC = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("InitialNSC", 0, float.MaxValue);
            preventEstablishment = (Landis.Library.Parameters.Species.AuxParm<bool>)(Parameter<bool>)PlugIn.GetParameter("PreventEstablishment");
            estRad = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("EstRad", 0, float.MaxValue);
            estMoist = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("EstMoist", 0, float.MaxValue);
            psnTMin = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("PsnTMin", -10, 10);
            halfSat = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("HalfSat", 0, float.MaxValue);
            folLignin = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("FolLignin", 0, float.MaxValue);
            k = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("K", 0, float.MaxValue);
            h2 = (Landis.Library.Parameters.Species.AuxParm<ushort>)(Parameter<ushort>)PlugIn.GetParameter("H2", 0, int.MaxValue);
            h3 = (Landis.Library.Parameters.Species.AuxParm<ushort>)(Parameter<ushort>)PlugIn.GetParameter("H3", 0, int.MaxValue);
            h4 = (Landis.Library.Parameters.Species.AuxParm<ushort>)(Parameter<ushort>)PlugIn.GetParameter("H4", 0, int.MaxValue);
            folN = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("FolN", 0, 10);

            maintResp = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("MaintResp", 0, 1);
            psnTOpt = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("PsnTOpt", 0, 30);
            dVPD1 = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("DVPD1", 0, 10);
            dVPD2 = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("DVPD2", 0, 10);
            wUEcnst = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("WUEcnst", 0, 200);
            amaxA = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("AmaxA", -200, 200);
            amaxB = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("AmaxB", 0, float.MaxValue);
            q10 = (Landis.Library.Parameters.Species.AuxParm<float>)(Parameter<float>)PlugIn.GetParameter("Q10", 0, 10);
        }
예제 #16
0
        public override void Run()
        {
            if (LAI != null)
            {
                System.Console.WriteLine("Updating output variable: LAI");
                // Total LAI per site

                ISiteVar <byte> values = cohorts.GetIsiteVar(o => o.CanopyLAImax);

                string FileName = FileNames.ReplaceTemplateVars(LAI.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <byte, byte>(FileName, values, o => o);

                // Values per species each time step
                LAI.output_table_ecoregions.WriteUpdate(PlugIn.ModelCore.CurrentTime, values);
            }
            if (Biomass != null)
            {
                System.Console.WriteLine("Updating output variable: Biomass");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > Biom = cohorts.GetIsiteVar(o => o.BiomassPerSpecies);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar <int> Biom_spc = modelCore.Landscape.NewSiteVar <int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        Biom_spc[site] = Biom[site][spc];
                    }

                    new OutputMapSpecies(Biom_spc, spc, Biomass.MapNameTemplate);
                }

                OutputFilePerTStepPerSpecies.Write <int>(Biomass.MapNameTemplate, Biomass.units, PlugIn.ModelCore.CurrentTime, Biom);

                ISiteVar <float> Biomass_site = cohorts.GetIsiteVar(x => x.BiomassSum);

                Biomass.output_table_ecoregions.WriteUpdate <float>(PlugIn.ModelCore.CurrentTime, Biomass_site);
            }
            if (AbovegroundBiomass != null)
            {
                System.Console.WriteLine("Updating output variable: Aboveground Biomass");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > AGBiom = cohorts.GetIsiteVar(o => o.AbovegroundBiomassPerSpecies);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar <int> AGBiom_spc = modelCore.Landscape.NewSiteVar <int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        AGBiom_spc[site] = AGBiom[site][spc];
                    }

                    new OutputMapSpecies(AGBiom_spc, spc, AbovegroundBiomass.MapNameTemplate);
                }

                OutputFilePerTStepPerSpecies.Write <int>(AbovegroundBiomass.MapNameTemplate, AbovegroundBiomass.units, PlugIn.ModelCore.CurrentTime, AGBiom);

                ISiteVar <float> AGBiomass_site = cohorts.GetIsiteVar(x => x.AbovegroundBiomassSum);

                AbovegroundBiomass.output_table_ecoregions.WriteUpdate <float>(PlugIn.ModelCore.CurrentTime, AGBiomass_site);
            }
            if (WoodySenescence != null)
            {
                System.Console.WriteLine("Updating output variable: Woody Senescence");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > Senes = cohorts.GetIsiteVar(o => o.WoodySenescencePerSpecies);

                /*
                 * foreach (ISpecies spc in PlugIn.SelectedSpecies)
                 * {
                 *  ISiteVar<int> Senes_spc = modelCore.Landscape.NewSiteVar<int>();
                 *
                 *  foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                 *  {
                 *      Senes_spc[site] = Senes[site][spc];
                 *
                 *  }
                 *
                 *  new OutputMapSpecies(Senes_spc, spc, WoodySenescence.MapNameTemplate);
                 * }
                 */
                OutputFilePerTStepPerSpecies.Write <int>(WoodySenescence.MapNameTemplate, WoodySenescence.units, PlugIn.ModelCore.CurrentTime, Senes);

                ISiteVar <float> Senescence_site = cohorts.GetIsiteVar(x => x.WoodySenescenceSum);

                WoodySenescence.output_table_ecoregions.WriteUpdate <float>(PlugIn.ModelCore.CurrentTime, Senescence_site);
            }
            if (FoliageSenescence != null)
            {
                System.Console.WriteLine("Updating output variable: Foliage Senescence");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > Senes = cohorts.GetIsiteVar(o => o.FoliageSenescencePerSpecies);

                /*foreach (ISpecies spc in PlugIn.SelectedSpecies)
                 * {
                 *  ISiteVar<int> Senes_spc = modelCore.Landscape.NewSiteVar<int>();
                 *
                 *  foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                 *  {
                 *      Senes_spc[site] = Senes[site][spc];
                 *  }
                 *
                 *  new OutputMapSpecies(Senes_spc, spc, FoliageSenescence.MapNameTemplate);
                 * }
                 */
                OutputFilePerTStepPerSpecies.Write <int>(FoliageSenescence.MapNameTemplate, FoliageSenescence.units, PlugIn.ModelCore.CurrentTime, Senes);

                ISiteVar <float> Senescence_site = cohorts.GetIsiteVar(x => x.FoliageSenescenceSum);

                FoliageSenescence.output_table_ecoregions.WriteUpdate <float>(PlugIn.ModelCore.CurrentTime, Senescence_site);
            }
            if (AETAvg != null)
            {
                ISiteVar <float> AET_site = cohorts.GetIsiteVar(x => x.AETSum);

                AETAvg.output_table_ecoregions.WriteUpdate <float>(PlugIn.ModelCore.CurrentTime, AET_site);
            }
            if (MonthlyFolResp != null)
            {
                ISiteVar <int[]> monthlyFolResp = cohorts.GetIsiteVar(site => site.FolResp);

                WriteMonthlyOutput(monthlyFolResp, MonthlyFolResp.MapNameTemplate);
            }
            if (MonthlyGrossPsn != null)
            {
                ISiteVar <int[]> monthlyGrossPsn = cohorts.GetIsiteVar(site => site.GrossPsn);

                WriteMonthlyOutput(monthlyGrossPsn, MonthlyGrossPsn.MapNameTemplate);
            }
            if (MonthlyNetPsn != null)
            {
                ISiteVar <int[]> monthlyNetPsn = cohorts.GetIsiteVar(site => site.NetPsn);

                WriteMonthlyOutput(monthlyNetPsn, MonthlyNetPsn.MapNameTemplate);
            }
            if (MonthlyMaintResp != null)
            {
                ISiteVar <int[]> monthlyMaintResp = cohorts.GetIsiteVar(site => site.MaintResp);

                WriteMonthlyOutput(monthlyMaintResp, MonthlyMaintResp.MapNameTemplate);
            }
            if (BelowGround != null)
            {
                System.Console.WriteLine("Updating output variable: BelowGround");

                ISiteVar <uint> values = cohorts.GetIsiteVar(o => o.BelowGroundBiomass);

                string FileName = FileNames.ReplaceTemplateVars(BelowGround.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <uint, uint>(FileName, values, o => o);
            }
            if (CohortsPerSpc != null)
            {
                System.Console.WriteLine("Updating output variable: CohortsPerSpc");
                // Nr of Cohorts per site and per species

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > cps = cohorts.GetIsiteVar(x => x.CohortCountPerSpecies);

                new OutputHistogramCohort <int>(CohortsPerSpc.MapNameTemplate, "CohortsPerSpcPerSite", 10).WriteOutputHist(cps);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    string FileName = FileNames.ReplaceTemplateVars(CohortsPerSpc.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime);

                    new OutputMapSiteVar <Landis.Library.Parameters.Species.AuxParm <int>, int>(FileName, cps, o => o[spc]);
                }

                OutputFilePerTStepPerSpecies.Write <int>(CohortsPerSpc.MapNameTemplate, CohortsPerSpc.units, PlugIn.ModelCore.CurrentTime, cps);
            }
            if (EstablishmentProbability != null)
            {
                System.Console.WriteLine("Updating output variable: EstablishmentProbability");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <byte> > pest = (ISiteVar <Landis.Library.Parameters.Species.AuxParm <byte> >)cohorts.GetIsiteVar(o => o.EstablishmentProbability.Probability);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar <int> _pest = modelCore.Landscape.NewSiteVar <int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        _pest[site] = pest[site][spc];
                    }

                    new OutputMapSpecies(_pest, spc, EstablishmentProbability.MapNameTemplate);
                }
            }
            if (SpeciesEstablishment != null)
            {
                System.Console.WriteLine("Updating output variable: SpeciesEstablishment");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <bool> > SpeciesIsThere = cohorts.GetIsiteVar(o => o.SpeciesPresent);

                if (SpeciesWasThere != null)
                {
                    foreach (ISpecies spc in PlugIn.modelCore.Species)
                    {
                        ISiteVar <int> comp = PlugIn.modelCore.Landscape.NewSiteVar <int>();

                        MapComparison m = new MapComparison();
                        foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                        {
                            if (SpeciesWasThere[site] == null)
                            {
                                SpeciesWasThere[site] = new Library.Parameters.Species.AuxParm <bool>(PlugIn.modelCore.Species);
                            }

                            comp[site] = m[SpeciesWasThere[site][spc], SpeciesIsThere[site][spc]];

                            SpeciesWasThere[site][spc] = SpeciesIsThere[site][spc];
                        }


                        OutputMapSpecies output_map = new OutputMapSpecies(comp, spc, SpeciesEstablishment.MapNameTemplate);

                        // map label text
                        m.PrintLabels(SpeciesEstablishment.MapNameTemplate, spc);
                    }
                }
                else
                {
                    SpeciesWasThere = modelCore.Landscape.NewSiteVar <Landis.Library.Parameters.Species.AuxParm <bool> >();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        SpeciesWasThere[site] = new Library.Parameters.Species.AuxParm <bool>(PlugIn.modelCore.Species);
                    }
                }

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <bool> > Established_spc = cohorts.GetIsiteVar(x => x.SpeciesPresent);

                Landis.Library.Parameters.Species.AuxParm <int> Est_Sum = new Landis.Library.Parameters.Species.AuxParm <int>(PlugIn.modelCore.Species);

                foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
                {
                    foreach (ISpecies spc in PlugIn.modelCore.Species)
                    {
                        if (Established_spc[site][spc] == true)
                        {
                            Est_Sum[spc]++;
                        }
                    }
                }

                OutputFilePerTStepPerSpecies.Write <int>(SpeciesEstablishment.MapNameTemplate, SpeciesEstablishment.units, PlugIn.ModelCore.CurrentTime, Est_Sum);
            }
            if (AnnualPsn != null)
            {
                System.Console.WriteLine("Updating output variable: AnnualPsn");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > Biom = cohorts.GetIsiteVar(o => o.BiomassPerSpecies);

                if (LastBiom != null)
                {
                    foreach (ISpecies spc in PlugIn.modelCore.Species)
                    {
                        ISiteVar <int> comp = PlugIn.modelCore.Landscape.NewSiteVar <int>();

                        MapComparison m = new MapComparison();
                        foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                        {
                            if (LastBiom[site] == null)
                            {
                                LastBiom[site] = new Library.Parameters.Species.AuxParm <int>(PlugIn.modelCore.Species);
                            }

                            comp[site] = Biom[site][spc] - LastBiom[site][spc];

                            LastBiom[site][spc] = Biom[site][spc];
                        }

                        OutputMapSpecies output_map = new OutputMapSpecies(comp, spc, AnnualPsn.MapNameTemplate);
                    }
                }
                else
                {
                    LastBiom = modelCore.Landscape.NewSiteVar <Landis.Library.Parameters.Species.AuxParm <int> >();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        LastBiom[site] = new Library.Parameters.Species.AuxParm <int>(PlugIn.modelCore.Species);
                    }
                }
            }

            if (Water != null)
            {
                System.Console.WriteLine("Updating output variable: Water");

                ISiteVar <ushort> Water_site = cohorts.GetIsiteVar(x => x.WaterMax);

                string FileName = FileNames.ReplaceTemplateVars(Water.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <ushort, ushort>(FileName, Water_site, o => o);

                Water.output_table_ecoregions.WriteUpdate(PlugIn.ModelCore.CurrentTime, Water_site);
            }

            if (SubCanopyPAR != null)
            {
                System.Console.WriteLine("Updating output variable: SubCanopyPAR");

                ISiteVar <float> SubCanopyRadiation = cohorts.GetIsiteVar(x => x.SubCanopyParMAX);

                string FileName = FileNames.ReplaceTemplateVars(SubCanopyPAR.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <float, float>(FileName, SubCanopyRadiation, o => o);
            }
            if (NonWoodyDebris != null)
            {
                System.Console.WriteLine("Updating output variable: NonWoodyDebris");

                ISiteVar <double> Litter = cohorts.GetIsiteVar(x => x.Litter);

                string FileName = FileNames.ReplaceTemplateVars(NonWoodyDebris.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <double, double>(FileName, Litter, o => o);
            }

            if (WoodyDebris != null)
            {
                System.Console.WriteLine("Updating output variable: WoodyDebris");

                ISiteVar <double> woody_debris = cohorts.GetIsiteVar(x => x.WoodyDebris);

                string FileName = FileNames.ReplaceTemplateVars(WoodyDebris.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <double, double>(FileName, woody_debris, o => o);
            }

            if (AgeDistribution != null)
            {
                System.Console.WriteLine("Updating output variable: AgeDistribution");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <List <ushort> > > values = cohorts.GetIsiteVar(o => o.CohortAges);

                new OutputHistogramCohort <ushort>(AgeDistribution.MapNameTemplate, "NrOfCohortsAtAge", 10).WriteOutputHist(values);


                System.Console.WriteLine("Updating output variable: MaxAges");

                ISiteVar <int> maxage = cohorts.GetIsiteVar(x => x.AgeMax);

                string FileName = FileNames.ReplaceTemplateVars(AgeDistribution.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <int, int>(FileName, maxage, o => o);
            }
            if (overalloutputs != null)
            {
                System.Console.WriteLine("Updating output variable: overalloutputs");
                OutputAggregatedTable.WriteNrOfCohortsBalance();
            }
        }
 //---------------------------------------------------------------------
 public static void Initialize(IInputParameters parameters)
 {
     LeafLignin              = parameters.LeafLignin;
     LeafLongevity           = parameters.LeafLongevity;
     MortCurveShapeParm      = parameters.MortCurveShapeParm;
     GrowthCurveShapeParm = parameters.GrowthCurveShapeParm;
     WoodyDebrisDecay = parameters.WoodyDecayRate;
 }
        //---------------------------------------------------------------------
        public Insect(int sppCount)
        {
            
            susceptibility = new Library.Parameters.Species.AuxParm<int>(PlugIn.ModelCore.Species);
            growthreduceslope = new Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
            growthreduceintercept = new Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
            mortalityslope = new Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
            mortalityintercept = new Library.Parameters.Species.AuxParm<double>(PlugIn.ModelCore.Species);
            
            susceptibleTable = new List<ISusceptible>();
            neighbors = new List<RelativeLocation>();

            hostDefoliationByYear = PlugIn.ModelCore.Landscape.NewSiteVar<Dictionary<int, double[]>>();
            disturbed = PlugIn.ModelCore.Landscape.NewSiteVar<bool>();
            lastYearDefoliation = PlugIn.ModelCore.Landscape.NewSiteVar<double>();
            thisYearDefoliation = PlugIn.ModelCore.Landscape.NewSiteVar<double>();
            neighborhoodDefoliation = PlugIn.ModelCore.Landscape.NewSiteVar<double>();
            biomassRemoved = PlugIn.ModelCore.Landscape.NewSiteVar<int>();
            initialOutbreakProb = PlugIn.ModelCore.Landscape.NewSiteVar<double>();

            outbreakStopYear = 0;  //default = beginning of simulation
            outbreakStartYear = 0;  //default = beginning of simulation
            mortalityYear = 0;  //default = beginning of simulation
            activeOutbreak = false;
            initialSites = 0;
            lastStartYear = 0;
            lastStopYear = 0;
            lastBioRemoved = 0;
            annMort = "";
            
            //Initialize outbreaks:
            foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
            {
                hostDefoliationByYear[site] = new Dictionary<int, double[]>();
            }
        }
예제 #19
0
 //---------------------------------------------------------------------
 public static void Initialize(IInputParameters parameters)
 {
     AgeDBH = parameters.AgeDBH;
     MaximumBarkThickness = parameters.MaximumBarkThickness;
 }