コード例 #1
0
        public static void WriteMonthlyLogFile(int month)
        {
            double[] ppt = new double[PlugIn.ModelCore.Ecoregions.Count];
            double[] airtemp = new double[PlugIn.ModelCore.Ecoregions.Count];

            double[] avgNPPtc = new double[PlugIn.ModelCore.Ecoregions.Count];
            double[] avgResp = new double[PlugIn.ModelCore.Ecoregions.Count];
            double[] avgNEE = new double[PlugIn.ModelCore.Ecoregions.Count];

            double[] Ndep = new double[PlugIn.ModelCore.Ecoregions.Count];
            double[] StreamN = new double[PlugIn.ModelCore.Ecoregions.Count];
             
            
            foreach (IEcoregion ecoregion in PlugIn.ModelCore.Ecoregions)
            {
                ppt[ecoregion.Index] = 0.0;
                airtemp[ecoregion.Index] = 0.0;
                avgNPPtc[ecoregion.Index] = 0.0;
                avgResp[ecoregion.Index] = 0.0;
                avgNEE[ecoregion.Index] = 0.0;
                Ndep[ecoregion.Index] = 0.0;
                StreamN[ecoregion.Index] = 0.0;
            }

            foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
            {
                IEcoregion ecoregion = PlugIn.ModelCore.Ecoregion[site];

                ppt[ecoregion.Index] = EcoregionData.AnnualWeather[ecoregion].MonthlyPrecip[month];
                airtemp[ecoregion.Index] = EcoregionData.AnnualWeather[ecoregion].MonthlyTemp[month];

                avgNPPtc[ecoregion.Index] += SiteVars.MonthlyAGNPPcarbon[site][month] + SiteVars.MonthlyBGNPPcarbon[site][month];
                avgResp[ecoregion.Index] += SiteVars.MonthlyResp[site][month];
                avgNEE[ecoregion.Index] += SiteVars.MonthlyNEE[site][month];

                SiteVars.AnnualNEE[site] += SiteVars.MonthlyNEE[site][month];

                Ndep[ecoregion.Index] = EcoregionData.MonthlyNDeposition[ecoregion][month];
                StreamN[ecoregion.Index] += SiteVars.MonthlyStreamN[site][month];

            }
            

            foreach (IEcoregion ecoregion in PlugIn.ModelCore.Ecoregions)
            {
                if (EcoregionData.ActiveSiteCount[ecoregion] > 0) 
                {
                    monthlyLog.Clear();
                    MonthlyLog ml = new MonthlyLog();

                    ml.Time = PlugIn.ModelCore.CurrentTime;
                    ml.Month = month + 1;
                    ml.EcoregionName = ecoregion.Name;
                    ml.EcoregionIndex = ecoregion.Index;

                    ml.NumSites = Convert.ToInt32(EcoregionData.ActiveSiteCount[ecoregion]);

                    ml.ppt = EcoregionData.AnnualWeather[ecoregion].MonthlyPrecip[month];
                    ml.airtemp = EcoregionData.AnnualWeather[ecoregion].MonthlyTemp[month];
                    ml.avgNPPtc = (avgNPPtc[ecoregion.Index] / (double)EcoregionData.ActiveSiteCount[ecoregion]);
                    ml.avgResp = (avgResp[ecoregion.Index] / (double)EcoregionData.ActiveSiteCount[ecoregion]);
                    ml.avgNEE = (avgNEE[ecoregion.Index] / (double)EcoregionData.ActiveSiteCount[ecoregion]);
                    ml.Ndep = Ndep[ecoregion.Index];
                    ml.StreamN = (StreamN[ecoregion.Index] / (double)EcoregionData.ActiveSiteCount[ecoregion]);

                    monthlyLog.AddObject(ml);
                    monthlyLog.WriteToFile();
                }
            }

        }
コード例 #2
0
        public static void WriteMonthlyLogFile(int month)
        {
            double[] ppt     = new double[PlugIn.ModelCore.Ecoregions.Count];
            double[] airtemp = new double[PlugIn.ModelCore.Ecoregions.Count];

            double[] avgNPPtc = new double[PlugIn.ModelCore.Ecoregions.Count];
            double[] avgResp  = new double[PlugIn.ModelCore.Ecoregions.Count];
            double[] avgNEE   = new double[PlugIn.ModelCore.Ecoregions.Count];

            double[] Ndep    = new double[PlugIn.ModelCore.Ecoregions.Count];
            double[] StreamN = new double[PlugIn.ModelCore.Ecoregions.Count];


            foreach (IEcoregion ecoregion in PlugIn.ModelCore.Ecoregions)
            {
                ppt[ecoregion.Index]      = 0.0;
                airtemp[ecoregion.Index]  = 0.0;
                avgNPPtc[ecoregion.Index] = 0.0;
                avgResp[ecoregion.Index]  = 0.0;
                avgNEE[ecoregion.Index]   = 0.0;
                Ndep[ecoregion.Index]     = 0.0;
                StreamN[ecoregion.Index]  = 0.0;
            }

            foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
            {
                IEcoregion ecoregion = PlugIn.ModelCore.Ecoregion[site];

                ppt[ecoregion.Index]     = EcoregionData.AnnualWeather[ecoregion].MonthlyPrecip[month];
                airtemp[ecoregion.Index] = EcoregionData.AnnualWeather[ecoregion].MonthlyTemp[month];

                avgNPPtc[ecoregion.Index] += SiteVars.MonthlyAGNPPcarbon[site][month] + SiteVars.MonthlyBGNPPcarbon[site][month];
                avgResp[ecoregion.Index]  += SiteVars.MonthlyResp[site][month];
                avgNEE[ecoregion.Index]   += SiteVars.MonthlyNEE[site][month];

                SiteVars.AnnualNEE[site] += SiteVars.MonthlyNEE[site][month];

                Ndep[ecoregion.Index]     = EcoregionData.MonthlyNDeposition[ecoregion][month];
                StreamN[ecoregion.Index] += SiteVars.MonthlyStreamN[site][month];
            }


            foreach (IEcoregion ecoregion in PlugIn.ModelCore.Ecoregions)
            {
                if (EcoregionData.ActiveSiteCount[ecoregion] > 0)
                {
                    monthlyLog.Clear();
                    MonthlyLog ml = new MonthlyLog();

                    ml.Time           = PlugIn.ModelCore.CurrentTime;
                    ml.Month          = month + 1;
                    ml.EcoregionName  = ecoregion.Name;
                    ml.EcoregionIndex = ecoregion.Index;
                    ml.NumSites       = Convert.ToInt32(EcoregionData.ActiveSiteCount[ecoregion]);
                    ml.ppt            = EcoregionData.AnnualWeather[ecoregion].MonthlyPrecip[month];
                    ml.airtemp        = EcoregionData.AnnualWeather[ecoregion].MonthlyTemp[month];
                    ml.avgNPPtc       = (avgNPPtc[ecoregion.Index] / (double)EcoregionData.ActiveSiteCount[ecoregion]);
                    ml.avgResp        = (avgResp[ecoregion.Index] / (double)EcoregionData.ActiveSiteCount[ecoregion]);
                    ml.avgNEE         = (avgNEE[ecoregion.Index] / (double)EcoregionData.ActiveSiteCount[ecoregion]);
                    ml.Ndep           = Ndep[ecoregion.Index];
                    ml.StreamN        = (StreamN[ecoregion.Index] / (double)EcoregionData.ActiveSiteCount[ecoregion]);

                    monthlyLog.AddObject(ml);
                    monthlyLog.WriteToFile();
                }
            }
        }