public XbyYShearStationSummary(
            ISessionColumnCollection collection,
            DataView data,
            double wdbin,
            double wdrosebin,
            double wsbin,
            AbstractAlpha gridcollection
            )
        {
            _collection      = collection;
            _data            = data;
            _wdbin           = wdbin;
            _wdrosebin       = wdrosebin;
            _wsbin           = wsbin;
            _alphacollection = gridcollection;

            _ef            = new ExcelFile();
            _ef.LimitNear += new LimitEventHandler(_ef_LimitNear);

            //original data
            _shearWksht        = new MonthbyHourShearWorkSheet(_alphacollection, _ef);
            _monthHourWorksht  = new WindSpeedFrequencyMonthHourWorkSheet(collection, data.Table, _ef, SessionColumnType.WSAvgShear);
            _wSWDworkSht       = new WindSpeedFrequencyWDWSWorkSheet(collection, data, wdbin, wsbin, _ef, SessionColumnType.WSAvgShear);
            _wroseWksht        = new WindRoseWorkSheet(collection, data, wdrosebin, _ef, SessionColumnType.WSAvgShear);
            _dataRecoveryWksht = new DataRecoveryWorksheet(_ef, collection, data.Table);

            //built in order they will appear in work book
            _shearWksht.BuildWorkSheet();
            _monthHourWorksht.BuildWorkSheet();
            _wSWDworkSht.BuildWorkSheet();
            _wroseWksht.BuildWorkSheet();
            _dataRecoveryWksht.BuildWorkSheet();
        }
 public MonthbyHourShearWorkSheet(AbstractAlpha gridcollection, ExcelFile ef, IAxis x, IAxis y)
 {
     //prepare the grids
     _ef             = ef;
     _upperCountGrid = new Grid(new CreateXbyYGrid(x, y, gridcollection.UpperAvgCount));
     _upperAvgGrid   = new Grid(new CreateXbyYGrid(x, y, gridcollection.UpperAvg));
     _lowerCountGrid = new Grid(new CreateXbyYGrid(x, y, gridcollection.LowerAvgCount));
     _lowerAvgGrid   = new Grid(new CreateXbyYGrid(x, y, gridcollection.LowerAvg));
     _alphaGrid      = new Grid(new CreateXbyYGrid(x, y, gridcollection.Alpha));
     GridCollection  = gridcollection;
 }
        public XbyYShearStationSummary(
            ISessionColumnCollection collection,
            DataView data,
            double wdbin,
            double wdrosebin,
            double wsbin,

            AbstractAlpha gridcollection,
            List <StationSummarySheetType> whatToRun
            )
        {
            _collection     = collection;
            _data           = data;
            _wdbin          = wdbin;
            _wdrosebin      = wdrosebin;
            _wsbin          = wsbin;
            _gridcollection = new ShearCalculationGridCollection();
            _gridcollection.UpperAvgCount = gridcollection.UpperAvgCount;
            _gridcollection.LowerAvgCount = gridcollection.LowerAvgCount;
            _gridcollection.Alpha         = gridcollection.Alpha;
            _gridcollection.LowerAvg      = gridcollection.LowerAvg;
            _gridcollection.UpperAvg      = gridcollection.UpperAvg;

            _ef            = new ExcelFile();
            _ef.LimitNear += new LimitEventHandler(_ef_LimitNear);
            foreach (StationSummarySheetType s in whatToRun)
            {
                try
                {
                    RunReports[s].Invoke();
                }
                catch
                {
                }
            }
        }
Exemple #4
0
        public override List <double> DeriveNewWS(ISessionColumnCollection collection, AbstractAlpha alpha,
                                                  double[,] sourceWS, DataTable data, double derivedHt)
        {
            SessionColumnCollection colclxn = (SessionColumnCollection)collection;
            int rowcount      = data.Rows.Count;
            int xAxisColIndex = default(int);
            int yAxisColIndex = default(int);

            List <double> newDerivedWS = new List <double>(rowcount);

            //dynamically create list for xAxis source data

            if (alpha.Xaxis != null && alpha.Yaxis == null)
            {
                AssignColIndex(alpha.Xaxis, (SessionColumnCollection)collection);

                Type t = Type.GetType(collection.Columns[alpha.Xaxis.SessionColIndex].ColumnType.ToString());

                MethodInfo mi          = typeof(WindART.Utils).GetMethod("ExtractDataTableColumn", new Type[] { typeof(int), typeof(DataTable) });
                MethodInfo mi1         = mi.MakeGenericMethod(new Type[] { t });
                dynamic    xAxisSource = mi1.Invoke(null, new object[] { alpha.Xaxis.SessionColIndex, data });

                //only 1 axis
                for (int i = 0; i <= rowcount; i++)
                {
                    double thisAlpha = alpha.Alpha[alpha.Xaxis.GetAxisValue(xAxisSource[i]), 0];
                    newDerivedWS[i] = sourceWS[1, i] * Math.Pow((derivedHt / sourceWS[0, i]), thisAlpha);
                }

                return(newDerivedWS);
            }
            if (alpha.Xaxis != null && alpha.Yaxis != null)
            {
                AssignColIndex(alpha.Xaxis, (SessionColumnCollection)collection);
                AssignColIndex(alpha.Yaxis, (SessionColumnCollection)collection);

                MethodInfo miX = typeof(WindART.Utils).GetMethod("ExtractDataTableColumn", new Type[] { typeof(int), typeof(DataTable) });
                //Console.WriteLine(miX.ToString());
                //x
                //Console.WriteLine(" idx passed in...");
                //Console.WriteLine(alpha.Xaxis.SessionColIndex);

                Type tX = Type.GetType(data.Columns[alpha.Xaxis.SessionColIndex].DataType.ToString());
                //Console.WriteLine(tX.ToString ());

                MethodInfo miX1 = miX.MakeGenericMethod(new Type[] { tX });
                //Console.WriteLine("just before invoke..." + miX1.ToString ());
                dynamic xAxisSource = miX1.Invoke(null, new object[] { alpha.Xaxis.SessionColIndex, data });
                //Console.WriteLine(" xsource " + xAxisSource.Count);
                //y
                Type       tY          = Type.GetType(data.Columns[alpha.Yaxis.SessionColIndex].DataType.ToString());
                MethodInfo miY1        = miX.MakeGenericMethod(new Type[] { tY });
                dynamic    yAxisSource = miY1.Invoke(null, new object[] { alpha.Yaxis.SessionColIndex, data });
                //Console.WriteLine(" ysource " + yAxisSource.Count);

                Console.WriteLine(alpha.Alpha.GetUpperBound(0) + "   " + alpha.Alpha.GetUpperBound(1));
                //2 axes
                for (int i = 0; i <= rowcount - 1; i++)
                {
                    //Console.WriteLine(xAxisSource[i]);
                    // Console.WriteLine(" wd " + alpha.Xaxis.GetAxisValue(xAxisSource[i]).ToString());
                    // Console.WriteLine("                      hour " + alpha.Yaxis.GetAxisValue(yAxisSource[i]).ToString());
                    int x; int y;
                    if (alpha.Xaxis.AxisType != AxisType.WS)
                    {
                        x = (int)alpha.Xaxis.GetAxisValue(xAxisSource[i]);
                    }
                    else
                    {
                        x = (int)alpha.Xaxis.GetAxisValue(sourceWS[1, i]);
                    }

                    if (alpha.Yaxis.AxisType != AxisType.WS)
                    {
                        y = (int)alpha.Yaxis.GetAxisValue(yAxisSource[i]);
                    }
                    else
                    {
                        y = (int)alpha.Yaxis.GetAxisValue(sourceWS[1, i]);
                    }

                    if (x < 0 || y < 0)
                    {
                        newDerivedWS.Add(-9999.99);
                    }
                    else
                    {
                        double thisAlpha = default(double);
                        try
                        {
                            thisAlpha = alpha.Alpha[x, y];
                        }
                        catch
                        {
                            //if there is no bin for the ws encountered use a bulk shear
                            thisAlpha = alpha.AllAlphaAvg;
                        }
                        if (sourceWS[1, i] < 0)
                        {
                            newDerivedWS.Add(-9999.99);
                        }
                        else
                        {
                            newDerivedWS.Add(sourceWS[1, i] * Math.Pow((derivedHt / sourceWS[0, i]), thisAlpha));
                        }
                    }
                }

                return(newDerivedWS);
            }

            return(null);
        }
Exemple #5
0
 public override List <double> DeriveNewWS(ISessionColumnCollection collection,
                                           AbstractAlpha alpha, double[,] sourceWS, Dictionary <string, List <double> > axisSourceData, double derivedHt)
 {
     throw new NotImplementedException();
 }
 public abstract List <double> DeriveNewWS(ISessionColumnCollection collection, AbstractAlpha alpha, double[,] sourceWS, Dictionary <string, List <double> > axisSourceData, double derivedHt);
 public abstract List <double> DeriveNewWS(ISessionColumnCollection collection, AbstractAlpha alpha, double[,] sourceWS, DataTable data, double derivedHt);