本文整理汇总了C#中ICohort类的典型用法代码示例。如果您正苦于以下问题:C# ICohort类的具体用法?C# ICohort怎么用?C# ICohort使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICohort类属于命名空间,在下文中一共展示了ICohort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetResorbedNallocation
//---------------------------------------------------------------------
// Method for setting the available resorbed N for each cohort.
// Amount of resorbed N must be in units of g N m-2.
public static void SetResorbedNallocation(ICohort cohort, double resorbedNallocation, ActiveSite site)
{
int cohortAddYear = GetAddYear(cohort);
//PlugIn.ModelCore.UI.WriteLine("SETResorbedNallocation: year={0}, mo={1}, species={2}, cohortAge={3}, cohortAddYear={4}.", PlugIn.ModelCore.CurrentTime, Century.Month, cohort.Species.Name, cohort.Age, cohortAddYear);
Dictionary<int, double> cohortDict;
double oldResorbedNallocation;
// If the dictionary entry exists for the cohort, overwrite it:
if (SiteVars.CohortResorbedNallocation[site].TryGetValue(cohort.Species.Index, out cohortDict))
if (cohortDict.TryGetValue(cohortAddYear, out oldResorbedNallocation))
{
SiteVars.CohortResorbedNallocation[site][cohort.Species.Index][cohortAddYear] = resorbedNallocation;
return;
}
// If the dictionary does not exist for the cohort, create it:
Dictionary<int, double> newEntry = new Dictionary<int, double>();
newEntry.Add(cohortAddYear, resorbedNallocation);
if (SiteVars.CohortResorbedNallocation[site].ContainsKey(cohort.Species.Index))
{
SiteVars.CohortResorbedNallocation[site][cohort.Species.Index].Add(cohortAddYear, resorbedNallocation);
}
else
{
SiteVars.CohortResorbedNallocation[site].Add(cohort.Species.Index, newEntry);
}
//PlugIn.ModelCore.UI.WriteLine("SET ResorbedNallocation: ResorbedNallocation={0:0.00000}.", resorbedNallocation);
return;
}
示例2:
//---------------------------------------------------------------------
float[] IDisturbance.ReduceOrKillMarkedCohort(ICohort cohort)
{
float reduction;
float[] leafWoodReduction = new float[2]{0F, 0F};
if (reductions[cohort.Species.Index].TryGetValue(cohort.Age, out reduction)) {
leafWoodReduction[0] = cohort.WoodBiomass / (cohort.LeafBiomass + cohort.WoodBiomass) * (float) reduction;
leafWoodReduction[1] = cohort.LeafBiomass / (cohort.LeafBiomass + cohort.WoodBiomass) * (float) reduction;
SiteVars.BiomassRemoved[currentSite] += (int) reduction;
SiteVars.CohortsPartiallyDamaged[currentSite]++;
if (originalStand.LastPrescription.PreventEstablishment)
{
numberCohortsReduced++;
capacityReduction += (double)reduction / (double)cohort.Biomass;
}
// Record any cohort touched, not just killed:
BaseHarvest.SiteVars.Stand[currentSite].UpdateDamageTable(cohort.Species.Name);
return leafWoodReduction;
}
else
return leafWoodReduction;
}
示例3:
//---------------------------------------------------------------------
int IDisturbance.ReduceOrKillMarkedCohort(ICohort cohort)
{
int reduction;
if (reductions[cohort.Species.Index].TryGetValue(cohort.Age, out reduction))
{
int litter = cohort.ComputeNonWoodyBiomass(currentSite);
int woody = reduction - litter;
SiteVars.BiomassRemoved[currentSite] += reduction;
SiteVars.WoodyDebris[currentSite].Mass += woody;
SiteVars.Litter[currentSite].Mass += litter;
SiteVars.CohortsPartiallyDamaged[currentSite]++;
if (originalStand.LastPrescription.PreventEstablishment)
{
numberCohortsReduced++;
capacityReduction += (double) reduction / (double) cohort.Biomass;
}
// Record any cohort touched, not just killed:
BaseHarvest.SiteVars.Stand[currentSite].UpdateDamageTable(cohort.Species.Name);
BaseHarvest.SiteVars.Stand[currentSite].RecordBiomassRemoved(cohort.Species, reduction);
return reduction;
}
else
return 0;
}
示例4: Damage
//---------------------------------------------------------------------
public ushort Damage(ICohort cohort)
{
if (ageCohortDisturbance.Damage(cohort))
return cohort.Biomass;
else
return 0;
}
示例5:
//---------------------------------------------------------------------
int IDisturbance.Damage(ICohort cohort)
{
int reduction;
if (reductions[cohort.Species.Index].TryGetValue(cohort.Age, out reduction))
{
//UI.WriteLine("Removing: {0:0.0}/{1:0.0}.", reduction, cohort.Biomass);
SiteVars.BiomassRemoved[currentSite] += reduction;
SiteVars.CohortsPartiallyDamaged[currentSite]++;
if (originalStand.LastPrescription.PreventEstablishment)
{
numberCohortsReduced++;
capacityReduction += (double) reduction / (double) cohort.Biomass;
}
// Record any cohort touched, not just killed:
BaseHarvest.SiteVars.Stand[currentSite].UpdateDamageTable(cohort.Species.Name);
return reduction;
}
else
return 0;
}
示例6: CohortBiomass
public CohortBiomass(ActiveSite Site, ICohort Cohort, int Index)
{
this.cohort = Cohort;
fRad = 0;
site = Site;
spc = Cohort.Species;
}
示例7:
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ushort IDisturbance.Damage(ICohort cohort)
{
if (5 <= cohort.Age && cohort.Age <= 30)
return cohort.Biomass;
else
return 0;
}
示例8: ReduceCohortGrowth
//---------------------------------------------------------------------
// This method replaces the delegate method. It is called every year when
// ACT_ANPP is calculated, for each cohort. Therefore, this method is operating at
// an ANNUAL time step and separate from the normal extension time step.
public static double ReduceCohortGrowth(ICohort cohort, ActiveSite site)//, int siteBiomass)
{
// PlugIn.ModelCore.UI.WriteLine(" Calculating cohort growth reduction due to insect defoliation...");
double summaryGrowthReduction = 0.0;
int sppIndex = cohort.Species.Index;
foreach(IInsect insect in PlugIn.ManyInsect)
{
if(!insect.ActiveOutbreak)
continue;
int suscIndex = insect.SppTable[sppIndex].Susceptibility - 1;
//if (suscIndex < 0) suscIndex = 0;
int yearBack = 0;
double annualDefoliation = 0.0;
if(insect.HostDefoliationByYear[site].ContainsKey(PlugIn.ModelCore.CurrentTime - yearBack))
{
// PlugIn.ModelCore.UI.WriteLine("Host Defoliation By Year: Time={0}, suscIndex={1}, spp={2}.", (PlugIn.ModelCore.CurrentTime - yearBack), suscIndex+1, cohort.Species.Name);
annualDefoliation += insect.HostDefoliationByYear[site][PlugIn.ModelCore.CurrentTime - yearBack][suscIndex];
}
double cumulativeDefoliation = annualDefoliation;
while(annualDefoliation > 0)
{
yearBack++;
annualDefoliation = 0.0;
if(insect.HostDefoliationByYear[site].ContainsKey(PlugIn.ModelCore.CurrentTime - yearBack))
{
// PlugIn.ModelCore.UI.WriteLine("Host Defoliation By Year: Time={0}, suscIndex={1}, spp={2}.", (PlugIn.ModelCore.CurrentTime - yearBack), suscIndex+1, cohort.Species.Name);
annualDefoliation = insect.HostDefoliationByYear[site][PlugIn.ModelCore.CurrentTime - yearBack][suscIndex];
cumulativeDefoliation += annualDefoliation;
}
}
double slope = insect.SppTable[sppIndex].GrowthReduceSlope;
double intercept = insect.SppTable[sppIndex].GrowthReduceIntercept;
double growthReduction = 1.0 - (cumulativeDefoliation * slope + intercept);
summaryGrowthReduction += growthReduction;
// PlugIn.ModelCore.UI.WriteLine("Time={0}, Spp={1}, SummaryGrowthReduction={2:0.00}.", PlugIn.ModelCore.CurrentTime,cohort.Species.Name, summaryGrowthReduction);
}
if (summaryGrowthReduction > 1.0) // Cannot exceed 100%
summaryGrowthReduction = 1.0;
if(summaryGrowthReduction > 1.0 || summaryGrowthReduction < 0)
{
PlugIn.ModelCore.UI.WriteLine("Cohort Total Growth Reduction = {0:0.00}. Site R/C={1}/{2}.", summaryGrowthReduction, site.Location.Row, site.Location.Column);
throw new ApplicationException("Error: Total Growth Reduction is not between 1.0 and 0.0");
}
return summaryGrowthReduction;
}
示例9: ComputeChange
//---------------------------------------------------------------------
public int ComputeChange(ICohort cohort,
ActiveSite site,
int siteBiomass,
int prevYearSiteMortality)
{
CountCalled++;
return Change;
}
示例10: DeathEventArgs
//---------------------------------------------------------------------
/// <summary>
/// Initializes a new instance.
/// </summary>
public DeathEventArgs(ICohort cohort,
ActiveSite site,
ExtensionType disturbanceType)
{
this.cohort = cohort;
this.site = site;
this.disturbanceType = disturbanceType;
}
示例11: Died
//---------------------------------------------------------------------
/// <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));
}
示例12: DefoliateCohort
//---------------------------------------------------------------------
// This method replaces the delegate method. It is called every year when
// ACT_ANPP is calculated, for each cohort. Therefore, this method is operating at
// an ANNUAL time step and separate from the normal extension time step.
public static double DefoliateCohort(ICohort cohort, ActiveSite site, int siteBiomass)
{
// This maintains backwards compatibility with succession versions that don't use Biomass Library
// but the functions must be sure to provide siteBiomass not cohortBiomass
double defoliation = Landis.Extension.Insects.Defoliate.DefoliateCohort(site, cohort.Species, cohort.Biomass, siteBiomass);
return defoliation;
}
示例13: MyCompute
//---------------------------------------------------------------------
public double MyCompute(ICohort cohort,
ActiveSite site,
int siteBiomass)
{
Assert.AreEqual(myCohort, cohort);
Assert.AreEqual(myActiveSite, site);
Assert.AreEqual(mySiteBiomass, siteBiomass);
myComputeCalled = true;
return myComputeResult;
}
示例14: ReduceOrKillMarkedCohort
public int ReduceOrKillMarkedCohort(ICohort cohort)
{
if (ageCohortDisturbance.MarkCohortForDeath(cohort)) {
Cohort.KilledByAgeOnlyDisturbance(this, cohort,
ageCohortDisturbance.CurrentSite,
ageCohortDisturbance.Type);
return (int)cohort.Wood;
}
else
return 0;
}
示例15: AddResorbedN
//, int month)
//---------------------------------------------------------------------
public static void AddResorbedN(ICohort cohort, double leafBiomass, ActiveSite site)
{
// Resorbed N: We are assuming that any leaves dropped as a function of normal
// growth and maintenance (e.g., fall senescence) will involve resorption of leaf N.
double resorbedN = AvailableN.CalculateResorbedN(site, cohort.Species, leafBiomass); //, month);
double previouslyResorbedN = GetResorbedNallocation(cohort);
AvailableN.SetResorbedNallocation(cohort, resorbedN + previouslyResorbedN);
return;
}