当前位置: 首页>>代码示例>>C#>>正文


C# FunctionalGroupDefinitions.GetUniqueTraitValues方法代码示例

本文整理汇总了C#中Madingley.FunctionalGroupDefinitions.GetUniqueTraitValues方法的典型用法代码示例。如果您正苦于以下问题:C# FunctionalGroupDefinitions.GetUniqueTraitValues方法的具体用法?C# FunctionalGroupDefinitions.GetUniqueTraitValues怎么用?C# FunctionalGroupDefinitions.GetUniqueTraitValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Madingley.FunctionalGroupDefinitions的用法示例。


在下文中一共展示了FunctionalGroupDefinitions.GetUniqueTraitValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitialiseTraitBasedOutputs

        /// <summary>
        /// Set up the necessary architecture for generating outputs arranged by trait value
        /// </summary>
        /// <param name="cohortFunctionalGroupDefinitions">Functional group definitions for cohorts in the model</param>
        /// <param name="stockFunctionalGroupDefinitions">Functional group definitions for stocks in the model</param>
        /// <param name="marineCell">Whether the current cell is a marine cell</param>
        private void InitialiseTraitBasedOutputs(FunctionalGroupDefinitions cohortFunctionalGroupDefinitions, FunctionalGroupDefinitions 
            stockFunctionalGroupDefinitions, Boolean marineCell)
        {
            // Define the cohort traits that will be used to separate outputs
            CohortTraits = new string[2] { "Nutrition source", "Endo/Ectotherm"};

            // Declare a sorted dictionary to hold all unique trait values
            CohortTraitValues = new SortedDictionary<string, string[]>();

            // Declare a sorted dictionary to hold all unique trait values for marine systems
            CohortTraitValuesMarine = new SortedDictionary<string, string[]>();

            // Get the list of functional group indices corresponding to each unique trait value
            if (marineCell)
            {
                // Add all unique trait values to the sorted dictionary
                foreach (string Trait in CohortTraits)
                {
                    CohortTraitValuesMarine.Add(Trait, cohortFunctionalGroupDefinitions.GetUniqueTraitValues(Trait));
                }

                foreach (string Trait in CohortTraits)
                {
                    foreach (string TraitValue in CohortTraitValuesMarine[Trait])
                    {
                        // Only add indices of marine functional groups
                        int[] TempIndices = cohortFunctionalGroupDefinitions.GetFunctionalGroupIndex(Trait, TraitValue, false);
                        Boolean[] TempIndices2 = new Boolean[TempIndices.GetLength(0)];
                        for (int ii = 0; ii < TempIndices.GetLength(0); ii++)
                        {
                            if (cohortFunctionalGroupDefinitions.GetTraitNames("Realm", TempIndices[ii]).Equals("Marine", StringComparison.OrdinalIgnoreCase))
                            {
                                TempIndices2[ii] = true;
                            }
                        }

                        // Extract only the indices which are marine
                        int[] TempIndices3 = Enumerable.Range(0, TempIndices2.Length).Where(i => TempIndices2[i]).ToArray();

                        if (TempIndices3.Length > 0)
                        {
                            // Extract the values at these indices
                            for (int ii = 0; ii < TempIndices3.Length; ii++)
                            {
                                TempIndices3[ii] = TempIndices[TempIndices3[ii]];
                            }

                            // Add in the indices for this functional group and this realm
                            CohortTraitIndicesMarine.Add(TraitValue, TempIndices3);
                        }
                    }
                }

                if (TrackMarineSpecifics)
                {
                    // Add in the specific classes of zooplankton and baleen whales

                    // There are functional groups representing obligate zooplankton
                    string[] TempString = new string[1] { "Obligate zooplankton" };
                    CohortTraitValuesMarine.Add("Obligate zooplankton", TempString);
                    CohortTraitIndicesMarine.Add("Obligate zooplankton", cohortFunctionalGroupDefinitions.GetFunctionalGroupIndex("Mobility", "planktonic", false));

                    // Whales have a special dietary index
                    TempString = new string[1] { "Baleen whales" };
                    CohortTraitValuesMarine.Add("Baleen whales", TempString);
                    CohortTraitIndicesMarine.Add("Baleen whales", cohortFunctionalGroupDefinitions.GetFunctionalGroupIndex("Diet", "allspecial", false));

                    // But we also want all zooplankton, including larval/juvenile stages of other cohorts
                    int[] ZooplanktonIndices1 = cohortFunctionalGroupDefinitions.GetFunctionalGroupIndex("Mobility", "planktonic", false);

                    // Then there are all of the other groups which may have planktonic juveniles. In the ModelGrid.cs class, these cohorts are checked to see
                    // if they have a weight of less than the planktonic dispersal threshold.
                    TempString = new string[3] { "Realm", "Endo/Ectotherm", "Mobility" };
                    string[] TempString2 = new string[3] { "marine", "ectotherm", "mobile" };
                    int[] ZooplanktonIndices2 = cohortFunctionalGroupDefinitions.GetFunctionalGroupIndex(TempString, TempString2, true);
                    CohortTraitIndicesMarine.Add("Zooplankton (all)", ZooplanktonIndices2.Concat(ZooplanktonIndices1).ToArray());
                }

                // Add unique trait values to each of the lists that will contain output data arranged by trait value
                foreach (string TraitValue in CohortTraitIndicesMarine.Keys)
                {
                    TotalBiomassDensitiesMarineOut.Add(TraitValue, 0.0);
                    TotalDensitiesMarineOut.Add(TraitValue, 0.0);
                }
            }
            else
            {
                // Add all unique trait values to the sorted dictionary
                foreach (string Trait in CohortTraits)
                {
                    CohortTraitValues.Add(Trait, cohortFunctionalGroupDefinitions.GetUniqueTraitValues(Trait));
                }

                foreach (string Trait in CohortTraits)
//.........这里部分代码省略.........
开发者ID:pierovisconti,项目名称:C-sharp-version-of-Madingley-Development,代码行数:101,代码来源:OutputCell.cs

示例2: InitialiseTraitBasedOutputs

        /// <summary>
        /// Set up the necessary architecture for generating outputs arranged by trait value
        /// </summary>
        /// <param name="cohortFunctionalGroupDefinitions">Functional group definitions for cohorts in the model</param>
        /// <param name="stockFunctionalGroupDefinitions">Functional group definitions for stocks in the model</param>
        private void InitialiseTraitBasedOutputs(FunctionalGroupDefinitions cohortFunctionalGroupDefinitions, FunctionalGroupDefinitions
            stockFunctionalGroupDefinitions)
        {
            // Define the cohort traits that will be used to separate outputs
            CohortTraits = new string[3] { "Nutrition source", "Endo/Ectotherm", "Reproductive strategy" };

            // Declare a sorted dictionary to hold all unique trait values
            CohortTraitValues = new SortedDictionary<string, string[]>();

            // Add all unique trait values to the sorted dictionary
            foreach (string Trait in CohortTraits)
            {
                CohortTraitValues.Add(Trait, cohortFunctionalGroupDefinitions.GetUniqueTraitValues(Trait));
            }

            // Get the list of functional group indices corresponding to each unique trait value
            foreach (string Trait in CohortTraits)
            {
                foreach (string TraitValue in CohortTraitValues[Trait])
                {
                    CohortTraitIndices.Add(TraitValue, cohortFunctionalGroupDefinitions.GetFunctionalGroupIndex(Trait, TraitValue, false));
                }
            }

            // Define the stock traits that will be used to separate outputs
            StockTraits = new string[2] { "Heterotroph/Autotroph" ,"Leaf strategy"};

            // Re-initialise the sorted dictionary to hold all unique trait values
            StockTraitValues = new SortedDictionary<string, string[]>();

            // Add all unique stock trait values to the sorted dictionary
            foreach (string Trait in StockTraits)
            {
                StockTraitValues.Add(Trait, stockFunctionalGroupDefinitions.GetUniqueTraitValues(Trait));
            }

            // Get the list of functional group indices corresponding to each unique trait value
            foreach (string Trait in StockTraits)
            {
                foreach (string TraitValue in StockTraitValues[Trait])
                {
                    StockTraitIndices.Add(TraitValue, stockFunctionalGroupDefinitions.GetFunctionalGroupIndex(Trait, TraitValue, false));
                }
            }
        }
开发者ID:pierovisconti,项目名称:C-sharp-version-of-Madingley-Development,代码行数:50,代码来源:OutputGrid.cs


注:本文中的Madingley.FunctionalGroupDefinitions.GetUniqueTraitValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。