public void Init()//bool fromRegression { if (ModelYear != null) { ExcludeBlanks(); } // set model data string yrcol = EnPIResources.yearColName; string fltr = yrcol + "='" + ModelYear + "'"; ModelData = SourceData.Copy(); if (ModelYear != null) //replace all data with just the data for the model year { ModelData.Clear(); foreach (DataRow dr in SourceData.Select(fltr)) { ModelData.ImportRow(dr); } if (ModelData.Rows.Count < Utilities.Constants.MODEL_MIN_DATAPOINTS) { DataRow vr = VariableWarnings.NewRow(); vr[2] = "Selected model year contains less than " + Utilities.Constants.MODEL_MIN_DATAPOINTS.ToString() + " data points"; VariableWarnings.Rows.Add(vr); } } // set knownXs and knownYs knownXs = ModelData.Copy(); knownYs = ModelData.Copy(); foreach (DataColumn dc in ModelData.Columns) { if (!EnergySourceVariables.Contains(dc.ColumnName)) { knownYs.Columns.Remove(dc.ColumnName); } if (!IndependentVariables.Contains(dc.ColumnName)) { knownXs.Columns.Remove(dc.ColumnName); } } if (EnergySourceVariables.Contains(EnPIResources.unadjustedTotalColName)) { knownYs = DataHelper.AddSumColumn(knownYs); } if (EnergySourceVariables != null) { // this will create the collection of energy sources and the list of IVs foreach (string col in EnergySourceVariables) { EnergySource aSource = new EnergySource(col); aSource.knownXs = knownXs; try { double dcol = Convert.ToDouble(col); string col1 = dcol.ToString("#,###0"); aSource.Ys = Ys(col1); } catch { aSource.Ys = Ys(col); } aSource.Combinations = AllCombinations(); aSource.AddModels(); EnergySources.Add(aSource); } } WriteVariableWarnings(); }