本文整理汇总了C#中Landis.SpatialModeling.Site类的典型用法代码示例。如果您正苦于以下问题:C# Site类的具体用法?C# Site怎么用?C# Site使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Site类属于Landis.SpatialModeling命名空间,在下文中一共展示了Site类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateDomAgeAgeOnly
//---------------------------------------------------------------------
public static int CalculateDomAgeAgeOnly(Site site)
{
Dictionary<int, int> ageDictionary = new Dictionary<int, int>();
foreach (ISpeciesCohorts sppCohorts in SiteVars.AgeCohorts[site])
{
foreach (ICohort cohort in sppCohorts)
{
int age = cohort.Age;
if (ageDictionary.ContainsKey(age))
{
ageDictionary[age] = ageDictionary[age] + 1;
}
else
{
ageDictionary[age] = 1;
}
}
}
int domAge = 0;
int maxValue = 0;
foreach (var i in ageDictionary)
{
if (i.Value > maxValue)
{
domAge = i.Key;
maxValue = i.Value;
}
}
return domAge;
}
示例2: ReduceLayers
//---------------------------------------------------------------------
/// <summary>
/// Computes fire effects on litter, coarse woody debris, mineral soil, and charcoal.
/// No effects on soil organic matter (negligible according to Johnson et al. 2001).
/// </summary>
public static void ReduceLayers(byte severity, Site site)
{
//PlugIn.ModelCore.UI.WriteLine(" Calculating fire induced layer reductions...");
double litterLossMultiplier = ReductionsTable[severity].LitterReduction;
// Structural litter first
double carbonLoss = SiteVars.SurfaceStructural[site].Carbon * litterLossMultiplier;
double nitrogenLoss = SiteVars.SurfaceStructural[site].Nitrogen * litterLossMultiplier;
double summaryNLoss = nitrogenLoss;
SiteVars.SurfaceStructural[site].Carbon -= carbonLoss;
SiteVars.SourceSink[site].Carbon += carbonLoss;
SiteVars.FireCEfflux[site] += carbonLoss;
SiteVars.SurfaceStructural[site].Nitrogen -= nitrogenLoss;
SiteVars.SourceSink[site].Nitrogen += nitrogenLoss;
SiteVars.FireNEfflux[site] += nitrogenLoss;
// Metabolic litter
carbonLoss = SiteVars.SurfaceMetabolic[site].Carbon * litterLossMultiplier;
nitrogenLoss = SiteVars.SurfaceMetabolic[site].Nitrogen * litterLossMultiplier;
summaryNLoss += nitrogenLoss;
SiteVars.SurfaceMetabolic[site].Carbon -= carbonLoss;
SiteVars.SourceSink[site].Carbon += carbonLoss;
SiteVars.FireCEfflux[site] += carbonLoss;
SiteVars.SurfaceMetabolic[site].Nitrogen -= nitrogenLoss;
SiteVars.SourceSink[site].Nitrogen += nitrogenLoss;
SiteVars.FireNEfflux[site] += nitrogenLoss;
// Surface dead wood
double woodLossMultiplier = ReductionsTable[severity].WoodReduction;
carbonLoss = SiteVars.SurfaceDeadWood[site].Carbon * woodLossMultiplier;
nitrogenLoss = SiteVars.SurfaceDeadWood[site].Nitrogen * woodLossMultiplier;
summaryNLoss += nitrogenLoss;
SiteVars.SurfaceDeadWood[site].Carbon -= carbonLoss;
SiteVars.SourceSink[site].Carbon += carbonLoss;
SiteVars.FireCEfflux[site] += carbonLoss;
SiteVars.SurfaceDeadWood[site].Nitrogen -= nitrogenLoss;
SiteVars.SourceSink[site].Nitrogen += nitrogenLoss;
SiteVars.FireNEfflux[site] += nitrogenLoss;
//SiteVars.MineralN[site] += summaryNLoss * 0.01; Need to substract N loss from Mineral N pool. -ML
SiteVars.MineralN[site] -= summaryNLoss * 0.01;
}
示例3: CalculateNLimits
//New method for calculating N limits, called from Century.cs Run method before calling Grow
//Iterates through cohorts, assigning each a N gathering efficiency based on fine root biomass
//and N tolerance.
public static void CalculateNLimits(Site site)
{
// Iterate through the first time, assigning each cohort un un-normalized N multiplier
double NMultTotal=0.0;
foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
foreach (ICohort cohort in speciesCohorts)
{
int Ntolerance = SpeciesData.NTolerance[cohort.Species];
//NMultiplier is a measure of how much N a cohort can gather relative to other cohorts
double NMultiplier = CalculateNMultiplier(cohort.Biomass, Ntolerance);
NMultTotal += NMultiplier;
Dictionary<int,double> newEntry = new Dictionary<int,double>();
newEntry.Add(cohort.Age,NMultiplier);
if (CohortNlimits.ContainsKey(cohort.Species.Index))
{
CohortNlimits[cohort.Species.Index].Add(cohort.Age,NMultiplier);
}
else
{
CohortNlimits.Add(cohort.Species.Index,newEntry);
}
}
double availableN = SiteVars.MineralN[site]; // g/m2
//Iterate through a second time now that we have total N multiplier
//Divide through by total and multiply by total available N so each cohort has a max N value
//and the sum of cohort max N values is the site available N
double totalNUptake = 0.0;
foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
{
foreach (ICohort cohort in speciesCohorts)
{
double NMultiplier = CohortNlimits[cohort.Species.Index][cohort.Age];
double Nfrac = NMultiplier / NMultTotal;
CohortNlimits[cohort.Species.Index][cohort.Age] = Nfrac * availableN;
totalNUptake += Nfrac * availableN;
}
}
if (totalNUptake > availableN)
{
totalNUptake = availableN;
//PlugIn.ModelCore.Log.WriteLine(" ERROR: Total max N uptake = {0:0.000}, availableN = {1:0.000}.", totalNUptake, availableN);
//throw new ApplicationException("Error: Max N uptake > availableN. See AvailableN.cs");
}
return;
}
示例4: Leach
//--------------------------------------------------------------------------
public static void Leach(Site site, double baseFlow, double stormFlow)
{
// double minlch, double frlech[3], double stream[8], double basef, double stormf)
//Originally from leach.f of CENTURY model
//...This routine computes the leaching of inorganic nitrogen (potential for use with phosphorus, and sulfur)
//...Written 2/92 -rm. Revised on 12/11 by ML
// ML left out leaching intensity factor. Cap on MAX leaching (MINLECH/OMLECH3) is poorly defined in CENTURY manual. Added a NO3frac factor to account
//for the fact that only NO3 (not NH4) is leached from soils.
//...Called From: SIMSOM
//...amtlea: amount leached
//...linten: leaching intensity
//...strm: storm flow
//...base: base flow
//Outputs:
//minerl and stream are recomputed
IEcoregion ecoregion = PlugIn.ModelCore.Ecoregion[site];
double waterMove = SiteVars.WaterMovement[site];
double amtNLeached = 0.0;
//PlugIn.ModelCore.UI.WriteLine("WaterMove={0:0}, ", waterMove);
//...waterMove > 0. indicates a saturated water flow out of layer lyr
if (waterMove > 0.0 && SiteVars.MineralN[site] > 0.0)
{
double textureEffect = OtherData.MineralLeachIntercept + OtherData.MineralLeachSlope * EcoregionData.PercentSand[ecoregion];
//double leachIntensity = (1.0 - (OtherData.OMLeachWater - waterMove) / OtherData.OMLeachWater);
//amtNLeached = textureEffect * SiteVars.MineralN[site] * OtherData.NfracLeachWater * OtherData.NO3frac;
amtNLeached = textureEffect * SiteVars.MineralN[site] * OtherData.NO3frac;
//PlugIn.ModelCore.UI.WriteLine("amtNLeach={0:0.0}, textureEffect={1:0.0}, waterMove={2:0.0}, MineralN={3:0.00}", amtNLeached, textureEffect, waterMove, SiteVars.MineralN[site]);
}
double totalNleached = (baseFlow * amtNLeached) + (stormFlow * amtNLeached);
SiteVars.MineralN[site] -= totalNleached;
//PlugIn.ModelCore.UI.WriteLine("AfterSoilWaterLeaching. totalNLeach={0:0.0}, MineralN={1:0.00}", totalNleached, SiteVars.MineralN[site]);
SiteVars.Stream[site].Nitrogen += totalNleached;
SiteVars.MonthlyStreamN[site][Century.Month] += totalNleached;
//PlugIn.ModelCore.UI.WriteLine("AfterSoilWaterLeaching. totalNLeach={0:0.0}, MineralN={1:0.00}", totalNleached, SiteVars.MineralN[site]);
return;
}
示例5: GetOrganicCarbon
//---------------------------------------------------------------------
public static double GetOrganicCarbon(Site site)
{
double totalC =
SiteVars.SurfaceStructural[site].Carbon
+ SiteVars.SoilStructural[site].Carbon
+ SiteVars.SurfaceMetabolic[site].Carbon
+ SiteVars.SoilMetabolic[site].Carbon
+ SiteVars.SOM1surface[site].Carbon
+ SiteVars.SOM1soil[site].Carbon
+ SiteVars.SOM2[site].Carbon
+ SiteVars.SOM3[site].Carbon
;
return totalC;
}
示例6: GetAgeRichness
//---------------------------------------------------------------------
// Number of age classes, an indicator of structural complexity.
public static int GetAgeRichness(Site site)
{
int age_richness = 0;
List<int> ages = new List<int>();
if (SiteVars.Cohorts[site] == null)
return 0;
foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
{
foreach (ICohort cohort in speciesCohorts)
{
if (!ages.Contains(cohort.Age))
{
ages.Add(cohort.Age);
age_richness++;
}
}
}
return age_richness;
}
示例7: GetAgeEvenness
//---------------------------------------------------------------------
//Use E = Hprime / ln S where S apparently is # species)
//where Hprime = -sum (pI * ln(pI)) where pI is proportion of individuals found in Ith species
//from Magurran, A. 1988. Ecological diversity and its measurements. Princeton, NJ: Princeton University Press. Pp 35-37)
//Return E * 100 to fit within uint range
public static int GetAgeEvenness(Site site)
{
double E = 0;
double Hprime = 0;
double proportion=0;
int evenness = 0;
int total_count = 0;
Dictionary<int, int> cohort_counts = new Dictionary<int, int>();
if (SiteVars.Cohorts[site] == null)
return 0;
foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
{
foreach (ICohort cohort in speciesCohorts)
{
total_count++;
if (!cohort_counts.ContainsKey((int) cohort.Age))
{
cohort_counts.Add((int) cohort.Age, 1);
}
else
{
cohort_counts[(int) cohort.Age]++;
}
}
}
foreach (KeyValuePair<int,int> cohortIter in cohort_counts)
{
proportion = (double)cohortIter.Value / (double)total_count;
Hprime += proportion * System.Math.Log(proportion);
}
Hprime = - Hprime;
E = Hprime / System.Math.Log(cohort_counts.Count);
evenness = (int)(E * 100.0);
return evenness;
}
示例8: GetSppMaxAge
//---------------------------------------------------------------------
public static ushort GetSppMaxAge(Site site, ISpecies spp)
{
if (!site.IsActive)
return 0;
if (SiteVars.Cohorts[site] == null)
{
PlugIn.ModelCore.UI.WriteLine("Cohort are null.");
return 0;
}
ushort max = 0;
foreach (ISpeciesCohorts sppCohorts in SiteVars.Cohorts[site])
{
if (sppCohorts.Species == spp)
{
//ModelCore.UI.WriteLine("cohort spp = {0}, compare species = {1}.", sppCohorts.Species.Name, spp.Name);
foreach (ICohort cohort in sppCohorts)
if (cohort.Age > max)
max = cohort.Age;
}
}
return max;
}
示例9: GetSppRichness
//---------------------------------------------------------------------
public static int GetSppRichness(Site site)
{
//return total count of species
int count = 0;
if (SiteVars.Cohorts[site] == null)
return 0;
foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
{
count++;
}
return count;
}
示例10: CalcFuelType
//---------------------------------------------------------------------
private int CalcFuelType(Site site,
IEnumerable<IFuelType> FuelTypes,
IEnumerable<IDisturbanceType> DisturbanceTypes)
{
double[] forTypValue = new double[100]; //Maximum of 100 fuel types
double sumConifer = 0.0;
double sumDecid = 0.0;
IEcoregion ecoregion = modelCore.Ecoregion[(ActiveSite) site];
foreach(ISpecies species in modelCore.Species)
{
ISpeciesCohorts speciesCohorts = (Landis.Library.BiomassCohorts.ISpeciesCohorts) SiteVars.Cohorts[site][species];
if(speciesCohorts == null)
continue;
foreach(IFuelType ftype in FuelTypes)
{
if(ftype.Ecoregions[ecoregion.Index])
{
if(ftype[species.Index] != 0)
{
int sppValue = 0;
foreach(ICohort cohort in speciesCohorts)
if(cohort.Age >= ftype.MinAge && cohort.Age <= ftype.MaxAge)
sppValue += cohort.Biomass;
//modelCore.UI.WriteLine("sppVaue={0}, spp={1}, cohortB={2}.", sppValue, cohort.Species.Name, cohort.Biomass);
if(ftype[species.Index] == -1)
forTypValue[ftype.Index] -= sppValue;
if(ftype[species.Index] == 1)
forTypValue[ftype.Index] += sppValue;
}
}
}
}
int finalFuelType = 0;
int decidFuelType = 0;
int coniferFuelType = 0;
int openFuelType = 0;
int slashFuelType = 0;
double maxValue = 0.0;
double maxDecidValue = 0.0;
double maxConiferValue = 0.0;
double maxConPlantValue = 0.0;
double maxOpenValue = 0.0;
double maxSlashValue = 0.0;
//Set the PERCENT CONIFER DOMINANCE:
int coniferDominance = 0;
int hardwoodDominance = 0;
//First accumulate data for the various Base Fuel Types:
foreach(IFuelType ftype in FuelTypes)
{
if(ftype != null)
{
// Sum for the Conifer and Deciduous dominance
if ((ftype.BaseFuel == BaseFuelType.Conifer || ftype.BaseFuel == BaseFuelType.ConiferPlantation)
&& forTypValue[ftype.Index] > 0)
{
sumConifer += forTypValue[ftype.Index];
}
//This is calculated for the mixed types:
if ((ftype.BaseFuel == BaseFuelType.Deciduous)
&& forTypValue[ftype.Index] > 0)
{
sumDecid += forTypValue[ftype.Index];
}
// CONIFER
if(forTypValue[ftype.Index] > maxConiferValue && ftype.BaseFuel == BaseFuelType.Conifer)
{
maxConiferValue = forTypValue[ftype.Index];
if(maxConiferValue > maxConPlantValue)
coniferFuelType = ftype.Index;
}
// CONIFER PLANTATION
if (forTypValue[ftype.Index] > maxConPlantValue && ftype.BaseFuel == BaseFuelType.ConiferPlantation)
{
maxConPlantValue = forTypValue[ftype.Index];
if(maxConPlantValue > maxConiferValue)
coniferFuelType = ftype.Index;
//.........这里部分代码省略.........
示例11: GetTotalSoilNitrogen
private static double GetTotalSoilNitrogen(Site site)
{
double totalsoilN =
+SiteVars.MineralN[site]
//+ SiteVars.SurfaceDeadWood[site].Nitrogen
//+ SiteVars.SoilDeadWood[site].Nitrogen
+ SiteVars.SurfaceStructural[site].Nitrogen
+ SiteVars.SoilStructural[site].Nitrogen
+ SiteVars.SurfaceMetabolic[site].Nitrogen
+SiteVars.SoilMetabolic[site].Nitrogen
+ SiteVars.SOM1surface[site].Nitrogen
+ SiteVars.SOM1soil[site].Nitrogen
+ SiteVars.SOM2[site].Nitrogen
+ SiteVars.SOM3[site].Nitrogen;
;
return totalsoilN;
}
示例12: GetCohortCount
//---------------------------------------------------------------------
public static int GetCohortCount(Site site)
{
//return total count of cohorts
int count = 0;
if (SiteVars.Cohorts[site] == null)
return 0;
foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
{
foreach (ICohort cohort in speciesCohorts)
{
count++;
}
}
return count;
}
示例13: GetAvgAge
//---------------------------------------------------------------------
public static int GetAvgAge(Site site)
{
if (SiteVars.Cohorts[site] == null)
return 0;
int avg = 0;
int sum = 0;
int count = 0;
foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
{
foreach (ICohort cohort in speciesCohorts)
{
sum += cohort.Age;
count++;
}
}
if (count == 0)
{
return 0;
}
avg = (int)(sum / count);
return avg;
}
示例14: ResetAnnualValues
//---------------------------------------------------------------------
public static void ResetAnnualValues(Site site)
{
// Reset these accumulators to zero:
SiteVars.CohortLeafN[site] = 0.0;
SiteVars.CohortLeafC[site] = 0.0;
SiteVars.CohortWoodN[site] = 0.0;
SiteVars.CohortWoodC[site] = 0.0;
SiteVars.GrossMineralization[site] = 0.0;
SiteVars.AGNPPcarbon[site] = 0.0;
SiteVars.BGNPPcarbon[site] = 0.0;
SiteVars.LitterfallC[site] = 0.0;
SiteVars.Stream[site] = new Layer(LayerName.Other, LayerType.Other);
SiteVars.SourceSink[site] = new Layer(LayerName.Other, LayerType.Other);
SiteVars.SurfaceDeadWood[site].NetMineralization = 0.0;
SiteVars.SurfaceStructural[site].NetMineralization = 0.0;
SiteVars.SurfaceMetabolic[site].NetMineralization = 0.0;
SiteVars.SoilDeadWood[site].NetMineralization = 0.0;
SiteVars.SoilStructural[site].NetMineralization = 0.0;
SiteVars.SoilMetabolic[site].NetMineralization = 0.0;
SiteVars.SOM1surface[site].NetMineralization = 0.0;
SiteVars.SOM1soil[site].NetMineralization = 0.0;
SiteVars.SOM2[site].NetMineralization = 0.0;
SiteVars.SOM3[site].NetMineralization = 0.0;
SiteVars.AnnualNEE[site] = 0.0;
SiteVars.Nvol[site] = 0.0;
SiteVars.AnnualNEE[site] = 0.0;
SiteVars.TotalNuptake[site] = 0.0;
SiteVars.ResorbedN[site] = 0.0;
SiteVars.FrassC[site] = 0.0;
SiteVars.LAI[site] = 0.0;
SiteVars.AgeMortality[site] = 0.0;
//SiteVars.FireEfflux[site] = 0.0;
}
示例15: SetMineralNallocation
// Calculates how much N a cohort gets, based on the amount of N available.
public static void SetMineralNallocation(Site site)
{
AvailableN.CohortMineralNallocation = new Dictionary<int, Dictionary<int, double>>();
double availableN = SiteVars.MineralN[site]; // g/m2
Math.Max(availableN, 0.01);
foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
{
foreach (ICohort cohort in speciesCohorts)
{
int cohortAddYear = GetAddYear(cohort);
if (Century.MonthCnt == 11)
cohortAddYear--;
//PlugIn.ModelCore.UI.WriteLine("SETMineralNallocation: year={0}, mo={1}, species={2}, cohortAge={3}, cohortAddYear={4}.", PlugIn.ModelCore.CurrentTime, Century.Month, cohort.Species.Name, cohort.Age, cohortAddYear);
double Nfraction = 0.05; //even a new cohort gets a little love
Dictionary<int, double> cohortDict = new Dictionary<int,double>();
if (AvailableN.CohortMineralNfraction.TryGetValue(cohort.Species.Index, out cohortDict))
cohortDict.TryGetValue(cohortAddYear, out Nfraction);
double Nallocation = Nfraction * availableN;
//PlugIn.ModelCore.UI.WriteLine(" NallocationlimitedbymineralN={0:0.00}, Nfraction={1:0.00}, availableN={2:0.00}.", Nallocation, Nfraction, availableN);
if (Double.IsNaN(Nallocation) || Double.IsNaN(Nfraction) || Double.IsNaN(availableN))
{
PlugIn.ModelCore.UI.WriteLine(" LIMIT N CALCULATION = NaN! ");
PlugIn.ModelCore.UI.WriteLine(" Nallocation={0:0.00}, Nfraction={1:0.00}, availableN={2:0.00}.", Nallocation, Nfraction, availableN);
}
Dictionary<int, double> newEntry = new Dictionary<int, double>();
newEntry.Add(cohortAddYear, Nallocation);
if (CohortMineralNallocation.ContainsKey(cohort.Species.Index))
{
CohortMineralNallocation[cohort.Species.Index].Add(cohortAddYear, Nallocation);
}
else
{
CohortMineralNallocation.Add(cohort.Species.Index, newEntry);
}
}
}
/*if (totalNUptake > availableN)
{
totalNUptake = availableN;
//PlugIn.ModelCore.UI.WriteLine(" ERROR: Total max N uptake = {0:0.000}, availableN = {1:0.000}.", totalNUptake, availableN);
//throw new ApplicationException("Error: Max N uptake > availableN. See AvailableN.cs");
}
SiteVars.TotalNuptake[site] = totalNUptake;*/
}