private void cmbObsVars_SelectedIndexChanged(object sender, EventArgs e) { if (ODM != null) { var pck = Package as IDataPackage; var site = cmbObsSite.SelectedItem as Site; var varb = cmbObsVars.SelectedItem as Variable; var ts = ODM.GetTimeSeries(new QueryCriteria() { Start = pck.StartOfLoading, End = pck.EndOfLoading, SiteID = site.ID, VariableID = varb.ID, VariableName = varb.Name }); if (ts != null) { var derieved_ts = TimeSeriesAnalyzer.Derieve(ts, pck.NumericalDataType, pck.TimeUnits); string sereis = string.Format("{1} at {0}", site.Name, varb.Name); if (btnCompareMode.Checked) { var sim_site = cmbSimSite.SelectedItem as Site; if (sim_site != null && sim_site.TimeSeries != null) { TimeSeriesAnalyzer.Compensate(derieved_ts, sim_site.TimeSeries); winChart_timeseries.Plot <double>(derieved_ts.DateTimes, derieved_ts[0, ":", "0"], sereis); } } else { winChart_timeseries.Plot <double>(derieved_ts.DateTimes, derieved_ts[0, ":", "0"], sereis); } } } }
private void cmbSimVars_SelectedIndexChanged(object sender, EventArgs e) { if (cmbSimSite.SelectedItem != null && cmbSimVars.SelectedItem != null) { var sim_site = cmbSimSite.SelectedItem as Site; var pck = Package as IDataPackage; var ts = pck.DataCube.GetDoubleSeriesBetween(SelectedVariableIndex, cmbSimSite.SelectedIndex, pck.StartOfLoading, pck.EndOfLoading); var series_anme = sim_site.Name; if (ts != null) { if (btnCompareMode.Checked) { winChart_timeseries.Clear(); } var derieved_ts = TimeSeriesAnalyzer.Derieve(ts, pck.NumericalDataType, pck.TimeUnits); string sereis = string.Format("{1} at {0}", sim_site.Name, cmbSimSite.SelectedItem.ToString()); sim_site.TimeSeries = derieved_ts; winChart_timeseries.Plot <double>(derieved_ts.DateTimes, derieved_ts[0, ":", "0"], sereis); var sites = cmbObsSite.DataSource as Site[]; if (sites != null) { var selected_site = from ss in sites where ss.ID == sim_site.ID select ss; if (selected_site.Count() > 0) { cmbObsSite.SelectedItem = selected_site.First(); } } } } }
private void cmbObsVars_SelectedIndexChanged(object sender, EventArgs e) { if (ODM != null) { var site = cmbSite.SelectedItem as Site; var varb = cmbObsVars.SelectedItem as Variable; var ts = ODM.GetTimeSeries(new QueryCriteria() { Start = _SFROutputPackage.StartOfLoading, End = _SFROutputPackage.EndOfLoading, SiteID = site.ID, VariableID = varb.ID, VariableName = varb.Name }); if (ts != null) { var derieved_ts = TimeSeriesAnalyzer.Derieve(ts, _SFROutputPackage.NumericalDataType, _SFROutputPackage.TimeUnits); string sereis = string.Format("{1} at {0}", site.Name, varb.Name); winChart_timeseries.Plot <double>(derieved_ts.DateTimes, derieved_ts[0, ":", "0"], sereis); } } }
public DataCube <float> GetTimeSeries(int segIndex, int varid) { DataCube <float> ts = null; if (DataCube != null) { var scaleFactor = ScaleFactor; var vector = DataCube.GetVector(varid, ":", segIndex.ToString()); DateTime[] dates = new DateTime[DataCube.Size[1]]; for (int t = 0; t < DataCube.Size[1]; t++) { dates[t] = DataCube.DateTimes[t]; } MatrixOperation.Mulitple(vector, (float)scaleFactor); ts = new DataCube <float>(vector, dates); if (TimeUnits != Core.TimeUnits.Day) { ts = TimeSeriesAnalyzer.Derieve(ts, NumericalDataType, TimeUnits); } } else if (DataCube != null) { var scaleFactor = ScaleFactor; var vector = DataCube.GetVector(varid, ":", segIndex.ToString()); DateTime[] dates = new DateTime[DataCube.Size[1]]; for (int t = 0; t < DataCube.Size[1]; t++) { dates[t] = DataCube.DateTimes[t]; } MatrixOperation.Mulitple(vector, (float)scaleFactor); ts = new DataCube <float>(vector, dates); if (TimeUnits != Core.TimeUnits.Day) { ts = TimeSeriesAnalyzer.Derieve(ts, NumericalDataType, TimeUnits); } } return(ts); }
public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler) { var var_index = 0; var mat = Get3DMat(Source, ref var_index); double prg = 0; int count = 1; if (mat != null) { int nstep = mat.Size[1]; int ncell = mat.Size[2]; var vec = mat[var_index, ":", "0"]; var dou_vec = MatrixOperation.ToDouble(vec); var date_source = new DateTime[nstep]; if (mat.DateTimes != null && mat.DateTimes.Length >= nstep) { for (int i = 0; i < nstep; i++) { date_source[i] = mat.DateTimes[i]; } } else { for (int i = 0; i < nstep; i++) { date_source[i] = ModelService.Start.AddDays(i); } } var ts = new DataCube <float>(vec, date_source); var derieved_ts = TimeSeriesAnalyzer.Derieve(ts, NumericalDataType, TimeUnits); var derieved_steps = derieved_ts.DateTimes.Length; var mat_out = new DataCube <float>(1, derieved_steps, ncell); mat_out.Name = Derived; mat_out.Variables = new string[] { "Derived" }; mat_out.DateTimes = derieved_ts.DateTimes.ToArray(); mat_out.TimeBrowsable = true; for (int c = 0; c < ncell; c++) { vec = mat[var_index, ":", c.ToString()]; ts = new DataCube <float>(vec, date_source); derieved_ts = TimeSeriesAnalyzer.Derieve(ts, NumericalDataType, TimeUnits); for (int t = 0; t < derieved_steps; t++) { mat_out[0, t, c] = derieved_ts[0, t, 0]; } prg = (c + 1) * 100.0 / ncell; if (prg > count) { cancelProgressHandler.Progress("Package_Tool", (int)prg, "Caculating Cell: " + (c + 1)); count++; } } Workspace.Add(mat_out); return(true); } else { return(false); } }