Ejemplo n.º 1
0
        /// <summary>
        /// Add the filled NPP grid the memory dataset ready to be written to file
        /// </summary>
        /// <param name="t">The current time step</param>
        public void StoreNPPGrid(uint t, uint stock)
        {
            double[,] NPPout;

            NPPout = new double[_NumLats, _NumLons];
            for (int ii = 0; ii < _NumLats; ii++)
            {
                for (int jj = 0; jj < _NumLons; jj++)
                {
                    NPPout[ii, jj] = NPP[ii, jj, stock];
                }
            }

            DataConverter.Array2DToSDS3D(NPPout, "NPP_" + stock.ToString(), new string[] { "Latitude", "Longitude", "Time step" },
                                         (int)t, 0, NPPOutput);


            for (int ii = 0; ii < _NumLats; ii++)
            {
                for (int jj = 0; jj < _NumLons; jj++)
                {
                    NPP[ii, jj, stock] = -9999.0;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add the mass flows from the current timestep to the dataset
        /// </summary>
        /// <param name="timeStep">the current timestep</param>
        public void AddTimestepFlows(int timeStep)
        {
            // Define the dimensions of the output data
            string[] dimensions = { "Predator mass bin", "Prey mass bin", "Time steps" };

            // Log all values of the mass flow
            for (int i = 0; i < _NumMassBins; i++)
            {
                for (int j = 0; j < _NumMassBins; j++)
                {
                    if (_MassFlows[i, j] > 0)
                    {
                        _MassFlows[i, j] = Math.Log(_MassFlows[i, j]);
                    }
                    else
                    {
                        _MassFlows[i, j] = _MissingValue;
                    }
                }
            }
            // Add the mass flows data to the output file
            DataConverter.Array2DToSDS3D(_MassFlows, "Log mass (g)", dimensions, timeStep, _MissingValue, MassFlowsDataSet);
        }
Ejemplo n.º 3
0
        public void InitialOutputs(ModelGrid ecosystemModelGrid, FunctionalGroupDefinitions cohortFunctionalGroupDefinitions, FunctionalGroupDefinitions
                                   stockFunctionalGroupDefinitions, List <uint[]> cellIndices, MadingleyModelInitialisation initialisation)
        {
            Console.WriteLine("Writing initial grid outputs...");

            // Calculate the output variables
            CalculateOutputs(ecosystemModelGrid, cohortFunctionalGroupDefinitions, stockFunctionalGroupDefinitions, cellIndices, initialisation, 0);

            // Write the total biomass of cohorts to the live display
            if (LiveOutputs)
            {
                DataConverter.Array2DToSDS2D(LogBiomassDensityGridCohorts, "Log(Biomass density, g/km^2)", ecosystemModelGrid.Lats,
                                             ecosystemModelGrid.Lons, ecosystemModelGrid.GlobalMissingValue, DataSetToViewLive);
            }

            // Add the grid of total biomass in cells to the file dataset
            DataConverter.Array2DToSDS3D(LogBiomassDensityGridCohorts, "Biomass density", new string[] { "Latitude", "Longitude", "Time step" }, 0,
                                         ecosystemModelGrid.GlobalMissingValue, GridOutput);

            DataConverter.Array2DToSDS3D(LogAbundanceDensityGridCohorts, "Abundance density", new string[] { "Latitude", "Longitude", "Time step" }, 0,
                                         ecosystemModelGrid.GlobalMissingValue, GridOutput);


            // Temporary outputs to check plant model
            DataConverter.Array2DToSDS3D(Realm, "Realm", new string[] { "Latitude", "Longitude", "Time step" },
                                         0, ecosystemModelGrid.GlobalMissingValue, GridOutput);

            DataConverter.Array2DToSDS3D(HANPP, "HANPP", new string[] { "Latitude", "Longitude", "Time step" },
                                         0, ecosystemModelGrid.GlobalMissingValue, GridOutput);

            DataConverter.Array2DToSDS3D(Temperature, "Temperature", new string[] { "Latitude", "Longitude", "Time step" },
                                         0, ecosystemModelGrid.GlobalMissingValue, GridOutput);

            // File outputs for medium and high detail levels
            if ((ModelOutputDetail == OutputDetailLevel.Medium) || (ModelOutputDetail == OutputDetailLevel.High))
            {
                // Add the biomass grids for individual trait combinations to the file dataset
                foreach (var Key in BiomassDensityGrid.Keys)
                {
                    DataConverter.Array2DToSDS3D(BiomassDensityGrid[Key], Key + "biomass density", new string[]
                                                 { "Latitude", "Longitude", "Time step" }, 0, ecosystemModelGrid.GlobalMissingValue, GridOutput);
                }

                // Add the abundance density grid
                foreach (var Key in AbundanceDensityGrid.Keys)
                {
                    DataConverter.Array2DToSDS3D(AbundanceDensityGrid[Key], Key + "abundance density",
                                                 new string[] { "Latitude", "Longitude", "Time step" },
                                                 0,
                                                 ecosystemModelGrid.GlobalMissingValue,
                                                 GridOutput);
                }

                // Output ecosystem metrics
                if (OutputMetrics)
                {
                    foreach (string Key in MetricsGrid.Keys)
                    {
                        DataConverter.Array2DToSDS3D(MetricsGrid[Key], Key,
                                                     new string[] { "Latitude", "Longitude", "Time step" },
                                                     0,
                                                     ecosystemModelGrid.GlobalMissingValue,
                                                     GridOutput);
                    }
                }
            }
        }