public MadingleyModelOutput(
            string outputFilesSuffix,
            Madingley.Common.Environment environment,
            Madingley.Common.Configuration configuration,
            MadingleyModelInitialisation outputSettings,
            Madingley.Common.ModelState modelState)
        {
            var modelInitialisation = Converters.ConvertInitialisation(
                outputSettings,
                configuration,
                environment);

            this.ProcessTracker = new Madingley.Common.IProcessTracker[environment.FocusCells.Count()][];
            for (var cellIndex = 0; cellIndex < environment.FocusCells.Count(); cellIndex++)
            {
                var processTracker = new GEMProcessTracker(cellIndex, this);

                this.ProcessTracker[cellIndex] = new Madingley.Common.IProcessTracker[] { processTracker };
            }

            var globalProcessTracker = new GEMGlobalProcessTracker(this);
            this.GlobalProcessTracker = new Madingley.Common.IGlobalProcessTracker[] { globalProcessTracker };

            var crossCellProcessTracker = new GEMCrossCellProcessTracker(this);
            this.CrossCellProcessTracker = new Madingley.Common.ICrossCellProcessTracker[] { crossCellProcessTracker };

            this.model = new MadingleyModel(
                modelInitialisation,
                outputFilesSuffix,
                configuration.Simulation,
                modelState);
        }
예제 #2
0
        public MadingleyModelOutput(
            string outputFilesSuffix,
            Madingley.Common.Environment environment,
            Madingley.Common.Configuration configuration,
            MadingleyModelInitialisation outputSettings,
            Madingley.Common.ModelState modelState)
        {
            var modelInitialisation = Converters.ConvertInitialisation(
                outputSettings,
                configuration,
                environment);

            this.ProcessTracker = new Madingley.Common.IProcessTracker[environment.FocusCells.Count()][];
            for (var cellIndex = 0; cellIndex < environment.FocusCells.Count(); cellIndex++)
            {
                var processTracker = new GEMProcessTracker(cellIndex, this);

                this.ProcessTracker[cellIndex] = new Madingley.Common.IProcessTracker[] { processTracker };
            }

            var globalProcessTracker = new GEMGlobalProcessTracker(this);

            this.GlobalProcessTracker = new Madingley.Common.IGlobalProcessTracker[] { globalProcessTracker };

            var crossCellProcessTracker = new GEMCrossCellProcessTracker(this);

            this.CrossCellProcessTracker = new Madingley.Common.ICrossCellProcessTracker[] { crossCellProcessTracker };

            this.model = new MadingleyModel(
                modelInitialisation,
                outputFilesSuffix,
                configuration.Simulation,
                modelState);
        }
예제 #3
0
        public static MadingleyModelInitialisation ConvertInitialisation(
            MadingleyModelInitialisation outputSettings,
            Madingley.Common.Configuration configuration,
            Madingley.Common.Environment e)
        {
            var i = new MadingleyModelInitialisation();

            i.GlobalModelTimeStepUnit = configuration.GlobalModelTimeStepUnit;
            i.NumTimeSteps            = (uint)configuration.NumTimeSteps;
            i.CellSize                   = (float)e.CellSize;
            i.BottomLatitude             = (float)e.BottomLatitude;
            i.TopLatitude                = (float)e.TopLatitude;
            i.LeftmostLongitude          = (float)e.LeftmostLongitude;
            i.RightmostLongitude         = (float)e.RightmostLongitude;
            i.PlanktonDispersalThreshold = outputSettings.PlanktonDispersalThreshold;
            i.InitialisationFileStrings  = new SortedList <string, string>();
            i.SpecificLocations          = e.SpecificLocations;
            i.InitialisationFileStrings.Add("OutputDetail", outputSettings.InitialisationFileStrings["OutputDetail"]);
            i.CohortFunctionalGroupDefinitions = ConvertFunctionalGroupDefinitions(configuration.CohortFunctionalGroupDefinitions);
            i.StockFunctionalGroupDefinitions  = ConvertFunctionalGroupDefinitions(configuration.StockFunctionalGroupDefinitions);
            i.EnviroStack             = e.CellEnvironment.Select(env => new SortedList <string, double[]>(env)).ToArray();
            i.CellList                = e.FocusCells.Select(a => new UInt32[] { (UInt32)a.Item1, (UInt32)a.Item2 }).ToList();
            i.OutputPath              = outputSettings.OutputPath;
            i.TrackProcesses          = outputSettings.TrackProcesses;
            i.TrackCrossCellProcesses = outputSettings.TrackCrossCellProcesses;
            i.TrackGlobalProcesses    = outputSettings.TrackGlobalProcesses;
            i.ProcessTrackingOutputs  = outputSettings.ProcessTrackingOutputs;
            i.ModelMassBins           = outputSettings.ModelMassBins;
            i.LiveOutputs             = outputSettings.LiveOutputs;
            i.TrackMarineSpecifics    = outputSettings.TrackMarineSpecifics;
            i.OutputMetrics           = outputSettings.OutputMetrics;
            i.OutputStateTimestep     = outputSettings.OutputStateTimestep;

            return(i);
        }
예제 #4
0
        public static Madingley.Common.Environment Load(
            string environmentDataRoot,
            string inputPath)
        {
            var mmi = MadingleyModelInitialisation.Load(simulationInitialisationFile, definitionsFilename, environmentDataRoot, inputPath);

            MadingleyModel.Load(mmi);

            return(mmi.Item1);
        }
예제 #5
0
        /// <summary>
        /// Reads the initalization file to get information for the set of simulations to be run
        /// </summary>
        /// <param name="inputPath">The path to folder which contains the inputs</param>
        public static Madingley.Common.Configuration Load(string inputPath)
        {
            var configuration = MadingleyModelInitialisation.Load(simulationInitialisationFile, definitionsFilename, inputPath);

            var fileName = System.IO.Path.Combine(inputPath, "Initial Model State Setup", scenariosFilename);

            configuration.FileNames.Add(fileName);

            configuration.ScenarioParameters = ScenarioParameterInitialisation.Load(fileName);

            return(configuration);
        }
예제 #6
0
        public static Madingley.Common.IOutput Create(
            Madingley.Common.RunState state,
            Madingley.Common.Configuration configuration,
            Madingley.Common.Environment environment,
            Madingley.Common.ModelState modelState)
        {
            // Specify the working directory
            string OutputDir = "Parameters";
            OutputDir += System.DateTime.Now.Year + "-"
                + System.DateTime.Now.Month + "-"
                + System.DateTime.Now.Day + "_"
                + System.DateTime.Now.Hour + "."
                + System.DateTime.Now.Minute + "."
                + System.DateTime.Now.Second + "/";

            // Create the working directory if this does not already exist
            System.IO.Directory.CreateDirectory(OutputDir);

            foreach (var sourceFileName in configuration.FileNames)
            {
                var fileName = System.IO.Path.GetFileName(sourceFileName);
                var destFileName = System.IO.Path.Combine(OutputDir, fileName);

                System.IO.File.Copy(sourceFileName, destFileName, true);
            }

            foreach (var sourceFileName in environment.FileNames)
            {
                var fileName = System.IO.Path.GetFileName(sourceFileName);
                var destFileName = System.IO.Path.Combine(OutputDir, fileName);

                System.IO.File.Copy(sourceFileName, destFileName, true);
            }

            // Set up the suffix for the output files
            var OutputFilesSuffix = "_";

            // Add the scenario label to the suffix for the output files
            OutputFilesSuffix += configuration.ScenarioParameters[configuration.ScenarioIndex].Label + "_";

            // Add the simulation index number to the suffix
            OutputFilesSuffix += configuration.Simulation.ToString();

            var i = new MadingleyModelInitialisation(simulationInitialisationFile, definitionsFilename, outputsFilename, outputPath, inputPath);
            i.OutputPath = OutputDir;

            var output = new Madingley.Output.MadingleyModelOutput(
                OutputFilesSuffix,
                environment,
                configuration,
                i,
                modelState);

            if (state != null)
            {
                var existing = (Madingley.Output.MadingleyModelOutput)state.Output;
                output.model.Copy(existing.model);
            }

            return output;
        }
예제 #7
0
        public static Madingley.Common.IOutput Create(
            Madingley.Common.RunState state,
            Madingley.Common.Configuration configuration,
            Madingley.Common.Environment environment,
            Madingley.Common.ModelState modelState)
        {
            // Specify the working directory
            string OutputDir = "Parameters";

            OutputDir += System.DateTime.Now.Year + "-"
                         + System.DateTime.Now.Month + "-"
                         + System.DateTime.Now.Day + "_"
                         + System.DateTime.Now.Hour + "."
                         + System.DateTime.Now.Minute + "."
                         + System.DateTime.Now.Second + "/";

            // Create the working directory if this does not already exist
            System.IO.Directory.CreateDirectory(OutputDir);

            foreach (var sourceFileName in configuration.FileNames)
            {
                var fileName     = System.IO.Path.GetFileName(sourceFileName);
                var destFileName = System.IO.Path.Combine(OutputDir, fileName);

                System.IO.File.Copy(sourceFileName, destFileName, true);
            }

            foreach (var sourceFileName in environment.FileNames)
            {
                var fileName     = System.IO.Path.GetFileName(sourceFileName);
                var destFileName = System.IO.Path.Combine(OutputDir, fileName);

                System.IO.File.Copy(sourceFileName, destFileName, true);
            }

            // Set up the suffix for the output files
            var OutputFilesSuffix = "_";

            // Add the scenario label to the suffix for the output files
            OutputFilesSuffix += configuration.ScenarioParameters[configuration.ScenarioIndex].Label + "_";

            // Add the simulation index number to the suffix
            OutputFilesSuffix += configuration.Simulation.ToString();

            var i = new MadingleyModelInitialisation(simulationInitialisationFile, definitionsFilename, outputsFilename, outputPath, inputPath);

            i.OutputPath = OutputDir;

            var output = new Madingley.Output.MadingleyModelOutput(
                OutputFilesSuffix,
                environment,
                configuration,
                i,
                modelState);

            if (state != null)
            {
                var existing = (Madingley.Output.MadingleyModelOutput)state.Output;
                output.model.Copy(existing.model);
            }

            return(output);
        }