/// <summary> /// Generalized method to load Stochastic Data Parameters from AGEPRO Input Data files. /// </summary> /// <param name="inp">AGEPRO InputFile StochasticAge Parameters </param> /// <param name="generalOpt">AGEPRO InputFile General Options values</param> public void LoadStochasticAgeInputData(Nmfs.Agepro.CoreLib.AgeproStochasticAgeTable inp, Nmfs.Agepro.CoreLib.AgeproGeneral generalOpt) { this.readInputFileState = true; this.seqYears = Array.ConvertAll(generalOpt.SeqYears(), element => element.ToString()); this.numFleets = generalOpt.numFleets; this.timeVarying = inp.timeVarying; this.stochasticDataFile = inp.dataFile; this.stochasticAgeTable = Util.GetAgeproInputDataTable(this.stochasticAgeTable, inp.byAgeData); this.stochasticCV = Util.GetAgeproInputDataTable(this.stochasticCV, inp.byAgeCV); if (this.stochasticAgeTable == null) { this.enableTimeVaryingCheckBox = false; } else { this.enableTimeVaryingCheckBox = true; } this.readInputFileState = false; }
/// <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; }
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); }