//--------------------------------------------------------------------- /// <summary> /// Creates a new instance. /// </summary> public PartialCohortCutter(Landis.Library.SiteHarvest.ICohortSelector cohortSelector, PartialCohortSelectors partialCohortSelectors, ExtensionType extensionType) : base(cohortSelector, extensionType) { this.partialCohortSelectors = new PartialCohortSelectors(partialCohortSelectors); }
public static void Allocate(object sitecohorts, Cohort cohort, ExtensionType disturbanceType) { if (sitecohorts == null) return;// Deaths in spinup are not added yet float pwoodlost = 0; float prootlost = 0; float pfollost = 0; Parameter<string> p; if (disturbanceType != null && PlugIn.TryGetParameter(disturbanceType.Name, out p)) { if (p.ContainsKey(Reductions.WoodReduction)) { pwoodlost = float.Parse(p[Reductions.WoodReduction]); } if (p.ContainsKey(Reductions.RootReduction)) { prootlost = float.Parse(p[Reductions.RootReduction]); } if (p.ContainsKey(Reductions.FolReduction)) { pfollost = float.Parse(p[Reductions.FolReduction]); } } ((SiteCohorts)sitecohorts).AddWoodyDebris((float)((1 - pwoodlost) * cohort.Wood), cohort.species.KWdLit()); ((SiteCohorts)sitecohorts).AddWoodyDebris((float)((1 - prootlost) * cohort.Root), cohort.species.KWdLit()); ((SiteCohorts)sitecohorts).AddLitter((float)((1 - pfollost) * cohort.Fol), cohort.species); }
//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance. /// </summary> public DeathEventArgs(ICohort cohort, ActiveSite site, ExtensionType disturbanceType) { this.cohort = cohort; this.site = site; this.disturbanceType = disturbanceType; }
//--------------------------------------------------------------------- /// <summary> /// Raises a Cohort.DeathEvent. /// </summary> public static void Died(object sender, ICohort cohort, ActiveSite site, ExtensionType disturbanceType) { if (DeathEvent != null) DeathEvent(sender, new DeathEventArgs(cohort, site, disturbanceType)); }
//--------------------------------------------------------------------- public override bool Equals(object obj) { if (object.ReferenceEquals(obj, null) || GetType() != obj.GetType()) { return(false); } ExtensionType type = (ExtensionType)obj; return(name == type.name); }
/// <summary> /// Creates a cohort cutter instance. /// </summary> /// <returns> /// An instance of WholeCohortCutter if no species is partially thinned /// by the cohort selector. If the selector has a percentage for at /// least one species, then an instance of PartialCohortCutter is /// returned. /// </returns> public static ICohortCutter CreateCutter(ICohortSelector cohortSelector, ExtensionType extensionType) { ICohortCutter cohortCutter; if (PartialThinning.CohortSelectors.Count == 0) cohortCutter = new WholeCohortCutter(cohortSelector, extensionType); else cohortCutter = new PartialCohortCutter(cohortSelector, PartialThinning.CohortSelectors, extensionType); return cohortCutter; }
//--------------------------------------------------------------------- /// <summary> /// Gets the pair of percentages for a particular disturbance type. /// </summary> public PoolPercentages this[ExtensionType disturbanceType] { get { PoolPercentages poolPercentages; //PlugIn.ModelCore.Log.WriteLine(" Trying to acquire pool percentages for {0}.", disturbanceType); if (percentages.TryGetValue(disturbanceType, out poolPercentages)) return poolPercentages; return defaultPercentages; } set { //PoolPercentages poolPercentages; percentages[disturbanceType] = value; } }
public static void Allocate(object sitecohorts, Cohort cohort, ExtensionType disturbanceType) { if (sitecohorts == null) { throw new System.Exception("sitecohorts should not be null"); } // By default, all material is allocated to the woody debris or the litter pool float pwoodlost = 0; float prootlost = 0; float pfollost = 0; Parameter<string> parameter; if (disturbanceType != null && PlugIn.TryGetParameter(disturbanceType.Name, out parameter)) { // If parameters are available, then set the loss fractions here. if (parameter.ContainsKey("WoodReduction")) { pwoodlost = float.Parse(parameter["WoodReduction"]); } if (parameter.ContainsKey("RootReduction")) { prootlost = float.Parse(parameter["RootReduction"]); } if (parameter.ContainsKey("FolReduction")) { pfollost = float.Parse(parameter["FolReduction"]); } } float woodLost = (float)((1 - pwoodlost) * cohort.Wood); float rootLost = (float)((1 - prootlost) * cohort.Root); float folLost = (float)((1 - pfollost) * cohort.Fol); ((SiteCohorts)sitecohorts).AddWoodyDebris(woodLost, cohort.SpeciesPNET.KWdLit); ((SiteCohorts)sitecohorts).AddWoodyDebris(rootLost, cohort.SpeciesPNET.KWdLit); ((SiteCohorts)sitecohorts).AddLitter(folLost, cohort.SpeciesPNET); cohort.AccumulateWoodySenescence((int)(woodLost + rootLost)); cohort.AccumulateFoliageSenescence((int)(folLost)); }
//--------------------------------------------------------------------- /// <summary> /// Raises a Cohort.AgeOnlyDeathEvent. /// </summary> public static void KilledByAgeOnlyDisturbance(object sender, ICohort cohort, ActiveSite site, ExtensionType disturbanceType) { if (AgeOnlyDeathEvent != null) AgeOnlyDeathEvent(sender, new DeathEventArgs(cohort, site, disturbanceType)); }
//--------------------------------------------------------------------- /// <summary> /// Raises a Cohort.AgeOnlyDeathEvent. /// </summary> public static void RaiseDeathEvent(object sender, Cohort cohort, ActiveSite site, ExtensionType disturbanceType) { //if (AgeOnlyDeathEvent != null) //{ // AgeOnlyDeathEvent(sender, new Landis.Library.BiomassCohorts.DeathEventArgs(cohort, site, disturbanceType)); //} if (DeathEvent != null) { DeathEvent(sender, new Landis.Library.BiomassCohorts.DeathEventArgs(cohort, site, disturbanceType)); } }
//--------------------------------------------------------------------- /// <summary> /// Gets the pair of percentages for a particular disturbance type. /// </summary> public PoolPercentages this[ExtensionType disturbanceType] { get { PoolPercentages poolPercentages; if (percentages.TryGetValue(disturbanceType, out poolPercentages)) return poolPercentages; return defaultPercentages; } }
//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance. /// </summary> protected ExtensionMain(string name, ExtensionType type) { this.name = name; this.type = type; }
//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance. /// </summary> protected ExtensionMain(string name, ExtensionType type) { this.name = name; this.type = type; }
/// <summary> /// Raises a Cohort.DeathEvent. /// </summary> public static void Died(object sender, Landis.Library.BiomassCohortsPnET.Cohort cohort, ActiveSite site, ExtensionType disturbanceType) { if (cohort.cohortoutput != null) { cohort.cohortoutput.Write(); } if (DeathEvent != null) { DeathEvent(sender, new Landis.Library.AgeOnlyCohorts.DeathEventArgs(cohort, site, disturbanceType)); } if (allocatelitters != null) { allocatelitters(cohort, site, disturbanceType); } }
//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance. /// </summary> public DisturbanceEventArgs(ActiveSite site, ExtensionType disturbanceType) { this.site = site; this.disturbanceType = disturbanceType; }
//--------------------------------------------------------------------- /// <summary> /// Raises a Cohort.AgeOnlyDeathEvent. /// </summary> public static void Died(object sender, Cohort cohort, ActiveSite site, ExtensionType disturbanceType) { if (AgeOnlyDeathEvent != null) { AgeOnlyDeathEvent(sender, new Landis.Library.BiomassCohorts.DeathEventArgs(cohort, site, disturbanceType)); } if (DeathEvent != null) { DeathEvent(sender, new Landis.Library.BiomassCohorts.DeathEventArgs(cohort, site, disturbanceType)); } Allocation.Allocate(sender, cohort, disturbanceType); }
//--------------------------------------------------------------------- /// <summary> /// Create a new instance. /// </summary> public WholeCohortCutter(ICohortSelector cohortSelector, ExtensionType extensionType) { Type = extensionType; CohortSelector = cohortSelector; }