public virtual DataCube <double> GetValues(ITimeSeriesQueryCriteria qc, ITimeSeriesTransform provider) { if (provider != null && qc != null) { return(provider.GetTimeSeries(qc)); } else { return(null); } }
public override DataCube <double> GetValues(ITimeSeriesQueryCriteria qc, ITimeSeriesTransform provider) { if (SitesMeasured.Count > 0) { int count = SitesMeasured.Count; DataCube <double>[] tss = new DataCube <double> [count]; int i = 0; foreach (HydroPoint hp in SitesMeasured) { Variable v = new Variable(this.VariableID); v.SiteID = hp.ID; qc.SiteID = hp.ID; qc.VariableID = this.VariableID; tss[i] = v.GetValues(qc, provider); i++; } int length = tss[0].Size[1]; double[] values = new double[length]; DateTime[] time = new DateTime[length]; Array.Copy(tss[0].DateTimes, time, length); for (int j = 0; j < length; j++) { double sum = 0; for (i = 0; i < tss.Length; i++) { sum += tss[i][0, j, 0]; } values[i] = sum / tss.Length; } DataCube <double> summedts = new DataCube <double>(values, time); return(summedts); } else { TimeSpan span = qc.End - qc.Start; double[] values = new double[span.Days]; DateTime[] time = new DateTime[span.Days]; DataCube <double> summedts = new DataCube <double>(values, time); return(summedts); } }