Ejemplo n.º 1
0
 private Condtions GetConditions()
 {
     Condtions conditions = new Condtions();
     conditions.OutputFolder = this.s_outputPath;
     conditions.MDBPath = this.s_databasePath;
     conditions.TimescaleRange = this.dt_timeScale;
     conditions.TimelagRange = this.dt_timeLag;
     conditions.Type = this.Type;
     conditions.Lambda = (double)this.nudLambda.Value;
     return conditions;
 }
Ejemplo n.º 2
0
        private void Caculate(Condtions condtions)
        {
            this.bw.ReportProgress(0, string.Format("正在准备数据..."));

            DataTable dtTimeLagRange = condtions.TimelagRange;
            DataTable dtTimeScaleRange = condtions.TimescaleRange;
            List<int> listTimeLag = GetRangeList(dtTimeLagRange);
            List<int> listTimeScale = GetRangeList(dtTimeScaleRange);
            string sConStr = string.Format(this.sConnectionString, condtions.MDBPath);
            OleDbDataAdapter dbAdapter1 = new OleDbDataAdapter(this.sSQLGetZD, sConStr);
            DataTable dtSiteLocation = new DataTable();
            dbAdapter1.Fill(dtSiteLocation);
            OleDbDataAdapter dbAdapter2 = new OleDbDataAdapter(this.sSQLGetZDValue, sConStr);
            DataTable dtSiteSeries = new DataTable();
            dbAdapter2.Fill(dtSiteSeries);

            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];
            Cells cells = sheet.Cells;

            this.bw.ReportProgress(0, string.Format("正在计算..."));
            double[,] SpatialWeightMatrix = DTSTI.GetSpatialWeightMatrix(dtSiteLocation, condtions.Type, condtions.Lambda);
            double[] OriginalSpatioTemporalSeries = DTSTI.GetOriginalSpatioTemporalSeries(dtSiteSeries);
            double[] IntegratedOriginalSpatioTemporalSeries = DTSTI.GetIntegratedSeries(OriginalSpatioTemporalSeries);

            int iRow = 1;
            for (int i = 0; i < listTimeScale.Count; i++)
            {
                int iTimeScale = listTimeScale[i];

                cells[iRow, 0].PutValue(iTimeScale);
                int iColumn = 1;

                for (int j = 0; j < listTimeLag.Count; j++)
                {
                    int iTimeLag = listTimeLag[j];
                    cells[0, iColumn].PutValue(iTimeLag);

                    double[,] TemporalWeightMatrix = DTSTI.GetTemporalWeightMatrix(dtSiteSeries.Rows.Count / dtSiteLocation.Rows.Count, iTimeLag);
                    double[] LaggedSpatioTemporalSeries = DTSTI.GetLaggedSpatioTemporalSeries(OriginalSpatioTemporalSeries, SpatialWeightMatrix, TemporalWeightMatrix);
                    double[] IntegratedLaggedSpatioTemporalSeries = DTSTI.GetIntegratedSeries(LaggedSpatioTemporalSeries);
                    double DTSTIValue = DTSTI.GetDetrend(IntegratedOriginalSpatioTemporalSeries, IntegratedLaggedSpatioTemporalSeries, iTimeScale);
                    this.bw.ReportProgress(0, string.Format("TimeScale:{1},TimeLag:{0},DTSTI:{2}", iTimeLag, iTimeScale, DTSTIValue));
                    cells[iRow, iColumn].PutValue(DTSTIValue);
                    iColumn++;
                }
                iRow++;
            }
            System.IO.MemoryStream ms = workbook.SaveToStream();
            byte[] bt = ms.ToArray();
            string sOutPath = Path.Combine(condtions.OutputFolder, string.Format("{0}(Lambda={1}).xls", (condtions.Type == SpatialMatrixType.Complete ? "Complete" : "Mixtrue"), condtions.Lambda));
            workbook.Save(sOutPath);
        }