/// <summary>
        /// Creates a empty Data Table for the Stochastic Parameter Control based on the user inputs gathered
        /// from the General Options control parameter.
        /// </summary>
        /// <param name="objNT">Object representing the Stochastic Parameter</param>
        /// <param name="genOpt">Paramters from the General Options Control</param>
        /// <param name="fleetDependent">Is this Stochastic Parameter dependent on the
        /// nubmber of fleets? Default is false.</param>
        public void CreateStochasticParameterFallbackDataTable(Nmfs.Agepro.CoreLib.AgeproStochasticAgeTable objNT,
                                                               Nmfs.Agepro.CoreLib.AgeproGeneral genOpt,
                                                               StochasticAgeFleetDependency fleetDependent = StochasticAgeFleetDependency.independent)
        {
            this.numFleets          = Convert.ToInt32(genOpt.numFleets);
            this.seqYears           = Array.ConvertAll(genOpt.SeqYears(), element => element.ToString());
            this.readInputFileState = true;
            //Reset Tables if they were used before
            if (this.stochasticAgeTable != null)
            {
                this.stochasticAgeTable.Reset();
                this.stochasticCV.Reset();
            }

            if (this.timeVarying == true)
            {
                this.stochasticAgeTable = CreateFallbackAgeDataTable(genOpt.NumAges(),
                                                                     genOpt.SeqYears().Count(), this.numFleets);
            }
            else
            {
                if (fleetDependent == StochasticAgeFleetDependency.dependent)
                {
                    this.stochasticAgeTable = CreateFallbackAgeDataTable(genOpt.NumAges(), 1, this.numFleets);
                    this.stochasticCV       = CreateFallbackAgeDataTable(genOpt.NumAges(), 1, this.numFleets);
                }
                else
                {
                    this.stochasticAgeTable = CreateFallbackAgeDataTable(genOpt.NumAges(), 1, 1);
                    this.stochasticCV       = CreateFallbackAgeDataTable(genOpt.NumAges(), 1, 1);
                }
            }

            objNT.byAgeData = this.stochasticAgeTable;
            objNT.byAgeCV   = this.stochasticCV;

            this.readInputFileState = false;
        }
Пример #2
0
        public string ReadRetroAdjustmentFactorsTable(StreamReader sr, AgeproGeneral General)
        {
            string line = sr.ReadLine();

            string[]  rafLine  = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            DataTable rafTable = new DataTable("Retro Adjustment Factors");

            _ = rafTable.Columns.Add(); //set column without name

            //Throw warning/error if 'rafLine' length doesn't match number of Ages
            if (rafLine.Length != General.NumAges())
            {
                throw new InvalidAgeproParameterException("Number of retro adjustment factors does not match number of ages");
            }

            for (int i = 0; i < General.NumAges(); i++)
            {
                _ = rafTable.Rows.Add(rafLine[i]);
            }

            RetroAdjust = rafTable;
            return(line);
        }
        /// <summary>
        /// Reads in the AGERPRO Input file values by line
        /// </summary>
        /// <param name="sr">SreamReader Object</param>
        private void ReadInputFileLineValues(StreamReader sr)
        {
            string line;

            _ = CheckINPVersion(sr);

            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
                //Case ID
                if (line.Equals("[CASEID]"))
                {
                    CaseID = sr.ReadLine();
                }
                //General
                else if (line.Equals("[GENERAL]"))
                {
                    _ = General.ReadGeneralModelParameters(sr);
                }
                else if (line.Equals("[RECRUIT]"))
                {
                    //Read Recruit Data
                    Recruitment.ObservationYears = General.SeqYears();
                    Recruitment.ReadRecruitmentData(sr, General.NumYears(), General.NumRecModels);
                }
                else if (line.Equals("[STOCK_WEIGHT]"))
                {
                    Jan1StockWeight.ReadStochasticAgeData(sr, General.NumYears(), General.NumAges());
                }
                else if (line.Equals("[SSB_WEIGHT]"))
                {
                    SSBWeight.ReadStochasticAgeData(sr, General.NumYears(), General.NumAges());
                }
                else if (line.Equals("[MEAN_WEIGHT]"))
                {
                    MeanWeight.ReadStochasticAgeData(sr, General.NumYears(), General.NumAges());
                }
                else if (line.Equals("[CATCH_WEIGHT]"))
                {
                    CatchWeight.ReadStochasticAgeData(sr, General.NumYears(), General.NumAges(), General.NumFleets);
                }
                else if (line.Equals("[DISC_WEIGHT]"))
                {
                    DiscardWeight.ReadStochasticAgeData(sr, General.NumYears(), General.NumAges(), General.NumFleets);
                }
                else if (line.Equals("[NATMORT]"))
                {
                    NaturalMortality.ReadStochasticAgeData(sr, General.NumYears(), General.NumAges());
                }
                else if (line.Equals("[MATURITY]"))
                {
                    BiologicalMaturity.ReadStochasticAgeData(sr, General.NumYears(), General.NumAges());
                }
                else if (line.Equals("[FISHERY]"))
                {
                    Fishery.ReadStochasticAgeData(sr, General.NumYears(), General.NumAges(), General.NumFleets);
                }
                else if (line.Equals("[DISCARD]"))
                {
                    DiscardFraction.ReadStochasticAgeData(sr, General.NumYears(), General.NumAges(), General.NumFleets);
                }
                else if (line.Equals("[BIOLOGICAL]"))
                {
                    BiologicalTSpawn.ReadBiologicalData(sr, General.SeqYears());
                }
                else if (line.Equals("[BOOTSTRAP]"))
                {
                    Bootstrap.ReadBootstrapData(sr);
                }
                else if (line.Equals("[HARVEST]"))
                {
                    HarvestScenario.ReadHarvestTable(sr, General.NumYears(), General.NumFleets);
                }
                else if (line.Equals("[REBUILD]"))
                {
                    Rebuild.ObsYears = General.SeqYears();
                    Rebuild.ReadCalculationDataLines(sr);
                    HarvestScenario.AnalysisType = HarvestScenarioAnalysis.Rebuilder;
                }
                else if (line.Equals("[REFPOINT]"))
                {
                    Options.EnableRefpoint = true;
                    _ = Refpoint.ReadRefpointLines(sr);
                }
                else if (line.Equals("[BOUNDS]"))
                {
                    Options.EnableBounds = true;
                    _ = Bounds.ReadBounds(sr);
                }
                else if (line.Equals("[RETROADJUST]"))
                {
                    Options.EnableRetroAdjustmentFactors = true;
                    _ = RetroAdjustments.ReadRetroAdjustmentFactorsTable(sr, General);
                }
                else if (line.Equals("[OPTIONS]"))
                {
                    _ = Options.ReadAgeproOptions(sr);
                }
                else if (line.Equals("[SCALE]"))
                {
                    Options.EnableScaleFactors = true;
                    _ = Scale.ReadScaleFactors(sr);
                }
                else if (line.Equals("[PERC]"))
                {
                    Options.EnablePercentileReport = true;
                    ReportPercentile.Percentile    = Convert.ToDouble(sr.ReadLine());
                }
                else if (line.Equals("[PSTAR]"))
                {
                    PStar.ObsYears = General.SeqYears();
                    PStar.ReadCalculationDataLines(sr);
                    HarvestScenario.AnalysisType = HarvestScenarioAnalysis.PStar;
                }
            }
        }