Exemplo n.º 1
0
        protected virtual void setCols()
        {
            try
            {//figure out config dates and get comp columns
                HeightConfigCollection configcollection = new HeightConfigCollection(_collection);
                List <IConfig>         configs          = configcollection.GetConfigs();

                Console.WriteLine(" doing " + _summarytype);

                if (configs.Count > 1)
                {
                    Console.WriteLine("configs found " + configs.Count);
                    foreach (IConfig c in configs)
                    {
                        Console.WriteLine("start date " + c.StartDate);
                    }
                    throw new ApplicationException("Can not process grid. System not yet set up to handle multpile configurations");
                }
                _configstart = configs[0].StartDate;
                Console.WriteLine("start date in summary grid " + _configstart);
                //wscomps
                //SortedDictionary<double, ISessionColumn> wscomps
                //    = _collection.GetColumnsByType(SessionColumnType.WSAvg, _configstart, true);

                _lowerwscompcol = _collection[_collection.LowerWSComp(_configstart)];
                _upperwscompcol = _collection[_collection.UpperWSComp(_configstart)];
                _lowerwsht      = _lowerwscompcol.getConfigAtDate(_configstart).Height;
                _upperwsht      = _upperwscompcol.getConfigAtDate(_configstart).Height;

                //Console.WriteLine("Summary grid found " + wscomps.Values.Count + " ws comps");
                //wdcomp
                List <ISessionColumn> wdcomp =
                    _collection.GetColumnsByType(SessionColumnType.WDAvg);
                var compcol = from c in wdcomp.AsEnumerable()
                              where c.IsComposite
                              select c;

                _wdcompcol = compcol.ToList()[0];

                Console.WriteLine("Summary grid found " + compcol.ToList().Count + " wd comps");

                //shear

                _shearwscol = _collection.GetColumnsByType(_sheartype)[0];
                _shearht    = _shearwscol.getConfigAtDate(_configstart).Height;
                Console.WriteLine("Summary grid found " + _collection.GetColumnsByType(_sheartype).Count + " shear");
            }
            catch
            {
                throw;
            }
        }
        public bool CalculateComposites()
        {
            try
            {
                //**** get list
                List <ISessionColumn> initialColList = _columns.GetColumnsByType(SessionColumnType.WDAvg);
                if (initialColList.Count == 0)
                {
                    Console.WriteLine("no cols found");
                    return(false);
                }
                //add the columns to the datatable to be populated. pass the list of existing wd cols because
                //if one wd has more child columns than the other they all must be created for the code to
                //execue without error

                new WindDirectionCompColumns(_columns, _data).Add(initialColList);
                if (NewCompositeColumnAdded != null)
                {
                    NewCompositeColumnAdded("Wind Direction Composite Column Added");
                }

                string CompColName = Settings.Default.CompColName;
                double missingVal  = Settings.Default.MissingValue;

                string compColPrefix  = string.Empty;
                string ChildColPrefix = string.Empty;
                SortedDictionary <double, ISessionColumn> LocalWdCols;
                double   outPutCatch;
                double   childOutputVal;
                DataView view = _data.AsDataView();
                view.Sort = _columns[_columns.DateIndex].ColName + " asc";

                // Console.WriteLine(_columns[_columns.DateIndex].ColName + " asc");
                if (DeterminingWindDirectionCompositeValues != null)
                {
                    DeterminingWindDirectionCompositeValues("Assigning Wind Direction Composite Values");
                }
                foreach (DataRowView row in view)
                {
                    //Console.WriteLine("date " + DateTime.FromOADate (double.Parse(row[_columns.DateIndex].ToString())));

                    //get list of columns sorted desc by height at this date
                    LocalWdCols = _columns.GetColumnsByType(SessionColumnType.WDAvg, (DateTime)row[_columns.DateIndex]);

                    //set the wd comp column to the first valid value from heighest ht to lowest
                    //Console.WriteLine("WD Columns found " + LocalWdCols.Count);
                    row.BeginEdit();
                    foreach (KeyValuePair <double, ISessionColumn> kv in LocalWdCols.Reverse())
                    {
                        compColPrefix = Enum.GetName(typeof(SessionColumnType), kv.Value.ColumnType);

                        //evaluate parent column
                        //if it is not missing and evaluates to a double use the value
                        if (double.TryParse(row[kv.Value.ColIndex].ToString(), out outPutCatch))
                        {
                            if (outPutCatch >= 0)
                            {
                                //set parent comp
                                StringBuilder s = new StringBuilder();
                                s.Append(compColPrefix);
                                s.Append(CompColName);
                                row[s.ToString()] = outPutCatch;

                                //assign child column values  of the selected parent column to the comp child column
                                foreach (ISessionColumn child in kv.Value.ChildColumns)
                                {
                                    ChildColPrefix = Enum.GetName(typeof(SessionColumnType), child.ColumnType);
                                    StringBuilder sb = new StringBuilder();
                                    sb.Append(ChildColPrefix);
                                    sb.Append(CompColName);

                                    if (double.TryParse(row[child.ColIndex].ToString(), out childOutputVal))
                                    {
                                        row[sb.ToString()] = childOutputVal;
                                    }
                                    else
                                    {
                                        row[sb.ToString()] = missingVal;
                                    }
                                }
                                break;
                            }
                        }


                        //nothing valid found set parent and child comp column values  to missing
                        row[compColPrefix + CompColName] = missingVal;
                        //System.Windows.Forms.MessageBox.Show(row[0].ToString() + " " + row[LocalWdCols.First ().Value .ColIndex].ToString() + row[LocalWdCols.Last().Value.ColIndex].ToString());
                        foreach (ISessionColumn child in kv.Value.ChildColumns)
                        {
                            //Console.WriteLine("System setting wd comp to missing; thinks lower wd val is " + outPutCatch);
                            string        prefix = Enum.GetName(typeof(SessionColumnType), child.ColumnType);
                            StringBuilder sb     = new StringBuilder();
                            sb.Append(prefix);
                            sb.Append(CompColName);
                            row[sb.ToString()] = missingVal;
                        }
                    }
                    row.EndEdit();
                }
                _data.AcceptChanges();
                if (CompletedWindDirectionCompositeValues != null)
                {
                    CompletedWindDirectionCompositeValues("Completed Generating Wind Direction Composites");
                }
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(" Error while processing WD Comps: " + e.Message);
                return(false);
            }
            finally
            {
            }
        }
Exemplo n.º 3
0
        public bool CalculateWindSpeed(double shearht, out ShearCalculationGridCollection gridcollection)
        {
            try
            {
                //make sure there are axis vals set
                if (_xaxis == null || _yaxis == null)
                {
                    Console.WriteLine(" shear not calculated because no axes were provided");
                    gridcollection = null;
                    return(false);
                }

                //Console.WriteLine(" x axis " + _xaxis.AxisValues.Length + " y axis " + _yaxis.AxisValues.Length);

                HourAxis          hourAxis  = null;
                MonthAxis         monthAxis = null;
                WindDirectionAxis wdAxis    = null;

                //add axes to a list for easier parsing
                List <IAxis> AssignedAxis = new List <IAxis>();
                AssignedAxis.Add(_xaxis);
                AssignedAxis.Add(_yaxis);
                bool useWD = false;

                foreach (IAxis a in AssignedAxis)
                {
                    switch (a.AxisType)
                    {
                    case AxisType.Hour:
                        hourAxis = (HourAxis)a;
                        break;

                    case AxisType.Month:
                        monthAxis = (MonthAxis)a;
                        break;

                    case AxisType.WD:
                        wdAxis = (WindDirectionAxis)a;
                        useWD  = true;

                        throw new NotImplementedException("shear by WD not yet developed");

                    default:
                        break;
                    }
                }

                // Console.WriteLine("assigned axis types");

                _data.Sort = Settings.Default.TimeStampName;
                DateTime t       = DateTime.Now;
                double   missing = Settings.Default.MissingValue;

                //get a date at the beginning of the dataset provided
                DateTime start = DateTime.Parse(_data[2][_collection.DateIndex].ToString());

                //get a list of the columns for this config sorted ascending by height
                SortedDictionary <double, ISessionColumn> orderedWsCols
                    = _collection.GetColumnsByType(SessionColumnType.WSAvg, start, true);

                if (orderedWsCols.Count == 0)
                {
                    throw new ApplicationException("No WS Composite columns were found in MonthHourShear class. Config boundary dates may have been passed incorrectly");
                }

                //sort columns descending by height
                orderedWsCols.Reverse();

                //put the column indexes into a list for coincident values constructor
                SortedDictionary <double, int> TopCols = new SortedDictionary <double, int>();

                foreach (KeyValuePair <double, ISessionColumn> kv in orderedWsCols)
                {
                    //Console.WriteLine("passed to getrows as ws idx:" + kv.Value.ColName);
                    TopCols.Add(kv.Key, _collection[kv.Value.ColName].ColIndex);
                }
                List <double> SensorHts = TopCols.Keys.ToList();
                SensorHts.Sort();
                //Console.WriteLine("first row after sort " + _data[1][0] + " " + _[SensorHts [1]] + " " + _data[1][SensorHts[0]]);

                //pass the column list and the dataview to get only  coincident rows for the columns passed
                XbyYShearCoincidentRowCollection coincident
                    = new XbyYShearCoincidentRowCollection(_collection.DateIndex, TopCols, _data);

                int wdColIndex = 0;
                List <XbyYCoincidentRow> coincidentValues = new List <XbyYCoincidentRow>();
                if (_collection["WDAvgComposite"] != null)
                {
                    wdColIndex = _collection["WDAvgComposite"].ColIndex;

                    //Console.WriteLine("Shear.CalculateWS:wd comp index=" + wdColIndex );

                    coincidentValues = coincident.GetRows(wdColIndex);


                    //Console.WriteLine("coincident rows count " + coincidentValues.Count);
                }
                else
                {
                    coincidentValues = coincident.GetRows(1);
                }

                //collection to hold averages at each x y point
                gridcollection = new ShearCalculationGridCollection();

                //get number of elements in each axis
                int hour  = 0;
                int month = 0;
                int x     = _xaxis.AxisValues.Length;
                int y     = _yaxis.AxisValues.Length;
                // Console.WriteLine("assigned axis lengths " + x + ", " + y);
                if (AxisLengthsDetermined != null)
                {
                    AxisLengthsDetermined("Assigned Alpha Grid Axis lengths " + x + " by " + y);
                }
                //arrays to hold upper and lower avgs at each x,y point
                double[,] UpperAvgGrid = new double[x, y];
                double[,] LowerAvgGrid = new double[x, y];

                //list to hold avg values for each sensor grid at each x and y bin
                List <double> upperWsVals = new List <double>();
                List <double> lowerWSVals = new List <double>();

                for (int a = 0; a < x; a++)
                {
                    for (int j = 0; j < y; j++)
                    {
                        int TestCount = 0;
                        if (useWD)
                        {
                        }
                        else
                        {
                            if (_xaxis.AxisType == AxisType.Hour)
                            {
                                hour = a;  month = j;
                            }
                            else
                            {
                                hour = j;  month = a;
                            }
                            hour  = (int)hourAxis.AxisValues[hour];
                            month = (int)monthAxis.AxisValues[month];
                            //Console.WriteLine("hour " + hour + ", Month " + month);
                            //find the row collection for this x,y point
                            var r = from s in coincidentValues.AsEnumerable()
                                    where s.Date.Month == month && s.Date.Hour == hour &&
                                    s.WD >= 0
                                    select s;

                            //Console.WriteLine(month + " " + hour + " value: " + r.Count());

                            double useUpperWSVal;
                            double useLowerWSVal;

                            foreach (var row in r)
                            {
                                //if (month == 11)
                                //{
                                //    Console.WriteLine("date " + row.Date + " upper ws " + (double)row.UpperWS);
                                //}
                                if (Double.TryParse(row.UpperWS.ToString(), out useUpperWSVal) &&
                                    Double.TryParse(row.LowerWS.ToString(), out useLowerWSVal))
                                {
                                    upperWsVals.Add(useUpperWSVal);
                                    lowerWSVals.Add(useLowerWSVal);
                                }
                                TestCount++;
                            }
                        }
                        //Console.WriteLine("upper count at " + month + ", " + hour + ": " + TestCount);
                        //add each collection  avg to the avg grids

                        //Console.WriteLine("lower average at " + month + ", " + hour + ": " + lowerWSVals.Average() + "/n");
                        if (upperWsVals.Count > 0 && lowerWSVals.Count > 0)
                        {
                            UpperAvgGrid[a, j] = upperWsVals.Average();
                            // Console.WriteLine( a + " by " + j + "           " + upperWsVals.Count);

                            LowerAvgGrid[a, j] = lowerWSVals.Average();
                        }
                        else
                        {
                            UpperAvgGrid[a, j] = 0;
                            LowerAvgGrid[a, j] = 0;
                        }

                        upperWsVals.Clear();
                        lowerWSVals.Clear();

                        //Console.WriteLine("Upper average at " + a + ", " + hour + " "+ UpperAvgGrid[a, j]);
                        //Console.WriteLine("Lower average at " + month + ", " + hour + " " + LowerAvgGrid[a, j]);
                    }
                }
                gridcollection.LowerAvg = LowerAvgGrid;
                gridcollection.UpperAvg = UpperAvgGrid;


                //calculate each alpha value and assign to  a single grid
                double[,] alphaGrid = new double[x, y];

                //fill alpha table

                for (int a = 0; a < x; a++)
                {
                    for (int j = 0; j < y; j++)
                    {
                        //Console.WriteLine(" x=" + a.ToString() + " y=" + j.ToString());
                        alphaGrid[a, j] = Math.Log(gridcollection.UpperAvg [a, j] / gridcollection.LowerAvg [a, j])
                                          / Math.Log(SensorHts[1] / SensorHts[0]);
                        //Console.WriteLine("Alpha in grid=" + alphaGrid[a, j].ToString() +
                        //    " upper ws =" + gridcollection.UpperAvg[a, j].ToString() +
                        //    " Lower ws =" + gridcollection.LowerAvg[a, j].ToString() +
                        //    " upper ht " + SensorHts[1] + " lower ht " + SensorHts[0] +
                        //    " month=" + monthAxis.AxisValues[a] + " hour=" + hourAxis.AxisValues[j]);
                        if (Double.IsNaN(alphaGrid[a, j]))
                        {
                            alphaGrid[a, j] = 0;
                        }
                    }
                }

                gridcollection.Alpha = alphaGrid;

                //create a single multi-d array from the original dictionary of values
                //values must stay in order
                List <int> CombineCols = TopCols.Values.ToList();

                //height and value of the valid ws comp at each row ordered by datetime
                double[,] result = CombineSensorVals(CombineCols);

                //Console.WriteLine("Rows in full data " + _data.Count + " rows in combined dataset " + result.GetLength (1));
                //array to store sheared ws
                List <double> ShearResult = new List <double>(result.GetLength(1));

                //add colummn to dataset and capture colindex
                string localcolname = shearht.ToString();
                localcolname += Enum.GetName(typeof(SessionColumnType), SessionColumnType.WSAvgShear);
                localcolname += x + "by" + y;
                //Console.WriteLine("X by Y shear column  will be named " + localcolname);

                int shearIndex = AddShearColumnToTable(localcolname, shearht);
                int alphaIndex = AddAlphaColumn("Alpha");

                double   thisAlpha;
                int      xVal;
                int      yVal;
                DateTime thisDate;
                double   thisWD;
                if (AddingShearValues != null)
                {
                    AddingShearValues("Calculating " + shearht + "m Sheared Windspeed");
                }
                //loop combined values
                for (int i = 0; i < result.GetLength(1); i++)
                {
                    thisDate = (DateTime)_data[i][_collection.DateIndex];

                    if (useWD)
                    {
                        thisWD = (double)_data[i][wdColIndex];
                    }
                    else
                    {
                        xVal                 = monthAxis.ReturnAxisValue(thisDate);
                        yVal                 = hourAxis.ReturnAxisValue(thisDate);
                        thisAlpha            = gridcollection.Alpha [xVal, yVal];
                        _data[i][alphaIndex] = thisAlpha;
                        if (result[1, i] >= 0)
                        {
                            _data[i][shearIndex] = (result[1, i] * Math.Pow((shearht / result[0, i]), thisAlpha));
                        }
                        else
                        {
                            _data[i][shearIndex] = missing;
                        }
                    }
                }
                _data.Table.AcceptChanges();

                DateTime t_end = DateTime.Now;
                TimeSpan dur   = t_end - t;
                //Console.WriteLine("Calculating and adding " + x + " by " + y + " shear ws takes  " + dur);
                if (AddedShearValues != null)
                {
                    AddedShearValues("Shear Calculation Complete");
                }

                return(true);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 4
0
        public bool CalculateWindSpeed(double shearht, out ShearCalculationGridCollection grid)
        {
            //there is nothing here that guarantees that the view does not span multple configs
            //but assumes that it does not
            try
            {
                _data.Sort = Settings.Default.TimeStampName;
                DateTime t       = DateTime.Now;
                double   missing = Settings.Default.MissingValue;

                //get a date at the beginning of the dataset provided
                DateTime start = DateTime.Parse(_data[0][_collection.DateIndex].ToString());

                //get a list of the columns for this config sorted ascending by height
                SortedDictionary <double, ISessionColumn> orderedWsCols
                    = _collection.GetColumnsByType(SessionColumnType.WSAvg, start, true);


                //sort columns descending by height
                orderedWsCols.Reverse();
                List <ISessionColumn> workCols = orderedWsCols.Values.ToList();

                //put the column indexes into a list for coincident values constructor
                List <int> TopCols = new List <int>();
                foreach (KeyValuePair <double, ISessionColumn> kv in orderedWsCols)
                {
                    Console.WriteLine("col name " + kv.Value.ColName);
                    TopCols.Add(kv.Value.ColIndex);
                }
                Console.WriteLine("first row after sort " + _data[0][0] + " " + _data[0][TopCols[0]] + " " + _data[0][TopCols[1]]);

                //pass the column list and the dataview to get the coincident values of the columns
                ICoincidentValues coincident = new CoincidentValues(TopCols, _data);

                //take the average of the each of the lists of values
                //add the average to a dictionary indexed by the column index
                Dictionary <int, List <double> > coincidentValues = coincident.GetValues();

                Dictionary <int, double> avgvals = new Dictionary <int, double>();

                foreach (KeyValuePair <int, List <double> > kv in coincidentValues)
                {
                    avgvals.Add(kv.Key, kv.Value.Average());

                    Console.WriteLine(_collection[kv.Key].ColName + " " + kv.Value.Count);

                    double ht = _collection[kv.Key].getConfigAtDate(start).Height;
                }

                Console.WriteLine("upper avg " + avgvals[TopCols[1]] + " lower avg " + avgvals[TopCols[0]]);
                Console.WriteLine("upper ht " + orderedWsCols.Keys.ToList()[1] + " lower ht " + orderedWsCols.Keys.ToList()[0]);
                //calculate alpha
                Console.WriteLine(" num " + Math.Log(avgvals[TopCols[1]] / avgvals[TopCols[0]]));
                Console.WriteLine(" den " + Math.Log(orderedWsCols.Keys.ToList()[1] / orderedWsCols.Keys.ToList()[0]));

                double alpha = Math.Log(avgvals[TopCols[1]] / avgvals[TopCols[0]])
                               / Math.Log(orderedWsCols.Keys.ToList()[1] / orderedWsCols.Keys.ToList()[0]);

                Console.WriteLine("alpha=" + alpha.ToString());

                //create a single multi-d array from the original dictionary of values
                //values must stay in order
                double[,] result = CombineSensorVals(TopCols);

                List <double> ShearResult = new List <double>(result.GetLength(1));

                //add colummn to dataset
                string localcolname = shearht.ToString();
                localcolname += Enum.GetName(typeof(SessionColumnType), SessionColumnType.WSAvgBulkShear);
                Console.WriteLine("composite col will be named " + localcolname);

                int shearIndex = AddBulkShearToTable(localcolname, shearht);

                //apply bulk shear alpha to create sheared array values
                for (int i = 0; i < result.GetLength(1); i++)
                {
                    if (result[1, i] >= 0)
                    {
                        _data[i][shearIndex] = (result[1, i] * Math.Pow((shearht / result[0, i]), alpha));
                    }
                    else
                    {
                        _data[i][shearIndex] = missing;
                    }
                }
                _data.Table.AcceptChanges();

                DateTime t_end = DateTime.Now;
                TimeSpan dur   = t_end - t;
                Console.WriteLine("Calculating and adding bulk shear ws takes  " + dur);
                grid = null;
                return(true);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 5
0
        public bool CalculateWindSpeed(double shearht, out ShearCalculationGridCollection gridcollection)
        {
            //make sure there are axis vals set
            if (_xaxis == null)
            {
                Console.WriteLine(" shear not calculated because no axis was provided");
                gridcollection = null;
                return(false);
            }
            Console.WriteLine(" x axis " + _xaxis.AxisValues.Length);
            HourAxis hourAxis = (HourAxis)_xaxis;

            _data.Sort = Settings.Default.TimeStampName;
            DateTime t       = DateTime.Now;
            double   missing = Settings.Default.MissingValue;

            //get a date at the beginning of the dataset provided
            DateTime start = DateTime.Parse(_data[2][_collection.DateIndex].ToString());

            //get a list of the columns for this config sorted ascending by height
            SortedDictionary <double, ISessionColumn> orderedWsCols
                = _collection.GetColumnsByType(SessionColumnType.WSAvg, start, true);

            //sort columns descending by height
            orderedWsCols.Reverse();

            //put the column indexes into a list for coincident values constructor
            SortedDictionary <double, int> TopCols = new SortedDictionary <double, int>();

            foreach (KeyValuePair <double, ISessionColumn> kv in orderedWsCols)
            {
                TopCols.Add(kv.Key, kv.Value.ColIndex);
            }
            List <double> SensorHts = TopCols.Keys.ToList();

            SensorHts.Sort();

            //pass the column list and the dataview to get only  coincident rows for the columns passed
            XbyYShearCoincidentRowCollection coincident
                = new XbyYShearCoincidentRowCollection(_collection.DateIndex, TopCols, _data);

            int wdColIndex = _collection["WDAvgComposite"].ColIndex;

            Console.WriteLine("wd comp index=" + wdColIndex);

            List <XbyYCoincidentRow> coincidentValues = coincident.GetRows(wdColIndex);

            Console.WriteLine("coincident rows count " + coincidentValues.Count);

            //collection to hold averages at each x y point
            gridcollection = new ShearCalculationGridCollection();

            //get number of elements in each axis
            int hour = 0;

            int x = _xaxis.AxisValues.Length;

            Console.WriteLine("assigned axis length  1 by " + x);
            //arrays to hold upper and lower avgs at each x,y point
            double[,] UpperAvgGrid = new double[1, x];
            double[,] LowerAvgGrid = new double[1, x];

            //list to hold avg values for each sensor grid at each x and y bin
            List <double> upperWsVals = new List <double>();
            List <double> lowerWSVals = new List <double>();

            //only 1 element because this is a 1 by x shear
            for (int a = 0; a < 1; a++)
            {
                for (int j = 0; j < x; j++)
                {
                    int TestCount = 0;
                    //Console.WriteLine(" a " + a + " j " + j);
                    hour = (int)hourAxis.AxisValues[j];

                    //find the row collection for this x,y point
                    var r = from s in coincidentValues.AsEnumerable()
                            where s.Date.Hour == hour &&
                            s.WD >= 0
                            select s;

                    //Console.WriteLine(month + " " + hour + " value: " + r.Count());

                    double useUpperWSVal;
                    double useLowerWSVal;
                    foreach (var row in r)
                    {
                        if (Double.TryParse(row.UpperWS.ToString(), out useUpperWSVal) &&
                            Double.TryParse(row.LowerWS.ToString(), out useLowerWSVal))
                        {
                            upperWsVals.Add(useUpperWSVal);
                            lowerWSVals.Add(useLowerWSVal);
                        }
                        TestCount++;
                    }
                    if (upperWsVals.Count > 0 && lowerWSVals.Count > 0)
                    {
                        UpperAvgGrid[a, j] = upperWsVals.Average();
                        LowerAvgGrid[a, j] = lowerWSVals.Average();
                    }
                    else
                    {
                        UpperAvgGrid[a, j] = 0;
                        LowerAvgGrid[a, j] = 0;
                    }
                    upperWsVals.Clear();
                    lowerWSVals.Clear();
                }
            }
            gridcollection.LowerAvg = LowerAvgGrid;
            gridcollection.UpperAvg = UpperAvgGrid;


            //calculate each alpha value and assign to  a single grid
            double[,] alphaGrid = new double[1, x];

            //fill alpha table

            for (int a = 0; a < 1; a++)
            {
                for (int j = 0; j < x; j++)
                {
                    //Console.WriteLine(" x=" + a.ToString() + " y=" + j.ToString());
                    alphaGrid[a, j] = Math.Log(gridcollection.UpperAvg[a, j] / gridcollection.LowerAvg[a, j])
                                      / Math.Log(SensorHts[1] / SensorHts[0]);
                    //Console.WriteLine("Alpha in grid=" + alphaGrid[a, j].ToString() +
                    //    " upper ws =" + gridcollection.UpperAvg[a, j].ToString() +
                    //    " Lower ws =" + gridcollection.LowerAvg[a, j].ToString() +
                    //    " upper ht " + SensorHts[1] + " lower ht " + SensorHts[0] +
                    //    " month=" + monthAxis.AxisValues[a] + " hour=" + hourAxis.AxisValues[j]);
                }
            }

            gridcollection.Alpha = alphaGrid;

            //create a single multi-d array from the original dictionary of values
            //values must stay in order
            List <int> CombineCols = TopCols.Values.ToList();

            //height and value of the valid ws comp at each row ordered by datetime
            double[,] result = CombineSensorVals(CombineCols);

            Console.WriteLine("Rows in full data " + _data.Count + " rows in combined dataset " + result.GetLength(1));
            //array to store sheared ws
            List <double> ShearResult = new List <double>(result.GetLength(1));

            //add colummn to dataset and capture colindex
            string localcolname = shearht.ToString();

            localcolname += Enum.GetName(typeof(SessionColumnType), SessionColumnType.WSAvgSingleAxisShear);
            localcolname += "1" + "by" + x;
            Console.WriteLine("X by Y shear column will be named " + localcolname);

            int shearIndex = AddShearColumnToTable(localcolname, shearht);

            double   thisAlpha;
            int      yVal;
            DateTime thisDate;

            //loop combined values
            for (int i = 0; i < result.GetLength(1); i++)
            {
                thisDate = (DateTime)_data[i][_collection.DateIndex];

                yVal      = hourAxis.ReturnAxisValue(thisDate);
                thisAlpha = gridcollection.Alpha[0, yVal];

                if (result[0, i] > 0)
                {
                    _data[i][shearIndex] = (result[1, i] * Math.Pow((shearht / result[0, i]), thisAlpha));
                    //Console.WriteLine(_data[i][shearIndex]);
                }
                else
                {
                    _data[i][shearIndex] = missing;
                }
            }
            _data.Table.AcceptChanges();

            DateTime t_end = DateTime.Now;
            TimeSpan dur   = t_end - t;

            Console.WriteLine("Calculating and adding 1 by " + x + " shear ws takes  " + dur);

            return(true);
        }