private double GetFlowLateralMultiplier( Cell cell, FlowLateralMultiplierMap map, int flowGroupId, int iteration, int timestep) { Debug.Assert(this.m_IsSpatial); Debug.Assert(this.m_FlowLateralMultipliers.Count > 0); FlowLateralMultiplier m = map.GetFlowLateralMultiplier(flowGroupId, iteration, timestep); if (m == null) { return(1.0); } if (!this.m_FlowLateralMultiplierRasters.ContainsKey(m.FileName)) { return(1.0); } StochasticTimeRaster raster = this.m_FlowLateralMultiplierRasters[m.FileName]; double v = raster.DblCells[cell.CollectionIndex]; if ((v < 0.0) || (MathUtils.CompareDoublesEqual(v, raster.NoDataValue, double.Epsilon))) { return(1.0); } else { return(v); } }
internal void AddFlowLateralMultiplier(FlowLateralMultiplier multiplier) { if (multiplier.FlowMultiplierTypeId != this.m_FlowMultiplierTypeId) { throw new ArgumentException("The flow multiplier type is not correct."); } this.m_FlowLateralMultipliers.Add(multiplier); }
private void FillFlowLateralMultipliers() { Debug.Assert(this.m_IsSpatial); Debug.Assert(this.m_FlowLateralMultipliers.Count == 0); Debug.Assert(this.m_FlowLateralMultiplierRasters.Count == 0); DataSheet ds = this.ResultScenario.GetDataSheet(Constants.DATASHEET_FLOW_LATERAL_MULTIPLIER_NAME); foreach (DataRow dr in ds.GetData().Rows) { int FlowGroupId = Convert.ToInt32(dr[Constants.FLOW_GROUP_ID_COLUMN_NAME], CultureInfo.InvariantCulture); int? FlowMultiplierTypeId = null; int? Iteration = null; int? Timestep = null; string FileName = Convert.ToString(dr[Constants.MULTIPLIER_FILE_COLUMN_NAME], CultureInfo.InvariantCulture); if (dr[Constants.FLOW_MULTIPLIER_TYPE_ID_COLUMN_NAME] != DBNull.Value) { FlowMultiplierTypeId = Convert.ToInt32(dr[Constants.FLOW_MULTIPLIER_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.ITERATION_COLUMN_NAME] != DBNull.Value) { Iteration = Convert.ToInt32(dr[Constants.ITERATION_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TIMESTEP_COLUMN_NAME] != DBNull.Value) { Timestep = Convert.ToInt32(dr[Constants.TIMESTEP_COLUMN_NAME], CultureInfo.InvariantCulture); } FlowLateralMultiplier Multiplier = new FlowLateralMultiplier(FlowGroupId, FlowMultiplierTypeId, Iteration, Timestep, FileName); string FullFilename = Spatial.GetSpatialInputFileName(ds, FileName, false); StochasticTimeRaster MultiplierRaster; try { MultiplierRaster = new StochasticTimeRaster(FullFilename, RasterDataType.DTDouble); } catch (Exception) { string msg = string.Format(CultureInfo.InvariantCulture, Constants.SPATIAL_PROCESS_WARNING, FullFilename); throw new ArgumentException(msg); } this.m_FlowLateralMultipliers.Add(Multiplier); //Only load a single instance of a each unique filename to conserve memory if (!this.m_FlowLateralMultiplierRasters.ContainsKey(FileName)) { this.STSimTransformer.CompressRasterForCellCollection(MultiplierRaster); this.m_FlowLateralMultiplierRasters.Add(FileName, MultiplierRaster); } } }
private void ValidateFlowLateralMultipliers() { Debug.Assert(this.m_IsSpatial); DataSheet ds = this.ResultScenario.GetDataSheet(Constants.DATASHEET_FLOW_LATERAL_MULTIPLIER_NAME); for (int i = this.m_FlowLateralMultipliers.Count - 1; i >= 0; i--) { FlowLateralMultiplier r = this.m_FlowLateralMultipliers[i]; if (!this.m_FlowLateralMultiplierRasters.ContainsKey(r.FileName)) { string msg = string.Format(CultureInfo.InvariantCulture, Constants.SPATIAL_PROCESS_WARNING, r.FileName); RecordStatus(StatusType.Warning, msg); continue; } string cmpMsg = ""; var cmpRes = this.STSimTransformer.InputRasters.CompareMetadata(this.m_FlowLateralMultiplierRasters[r.FileName], ref cmpMsg); string FullFilename = Spatial.GetSpatialInputFileName(ds, r.FileName, false); if (cmpRes == CompareMetadataResult.RowColumnMismatch) { string msg = string.Format(CultureInfo.InvariantCulture, Constants.SPATIAL_METADATA_ROW_COLUMN_MISMATCH, FullFilename); ExceptionUtils.ThrowArgumentException(msg); } else { if (cmpRes == CompareMetadataResult.UnimportantDifferences) { string msg = string.Format(CultureInfo.InvariantCulture, Constants.SPATIAL_METADATA_INFO, FullFilename, cmpMsg); RecordStatus(StatusType.Information, msg); } } } }