private void WriteStockGroupRasters(int iteration, int timestep) { Debug.Assert(this.m_IsSpatial); foreach (StockGroup g in this.m_StockGroups) { if (!g.OutputFilter.HasFlag(Constants.OutputFilter.Spatial)) { continue; } StochasticTimeRaster rastOutput = this.STSimTransformer.InputRasters.CreateOutputRaster(RasterDataType.DTDouble); foreach (StockTypeLinkage l in g.StockTypeLinkages) { StochasticTimeRaster rastStockType = this.STSimTransformer.InputRasters.CreateOutputRaster(RasterDataType.DTDouble); GetStockValues(l.StockType.Id, rastStockType); rastStockType.ScaleDblCells(l.Value); rastOutput.AddDblCells(rastStockType); } Spatial.WriteRasterData( rastOutput, this.ResultScenario.GetDataSheet(Constants.DATASHEET_OUTPUT_SPATIAL_STOCK_GROUP), iteration, timestep, g.Id, Constants.SPATIAL_MAP_STOCK_GROUP_VARIABLE_PREFIX, Constants.DATASHEET_OUTPUT_SPATIAL_FILENAME_COLUMN); } }
private void WriteLateralFlowRasters(int iteration, int timestep) { Debug.Assert(this.m_IsSpatial); foreach (FlowGroup g in this.m_FlowGroups) { if (!g.OutputFilter.HasFlag(Constants.OutputFilter.Spatial)) { continue; } bool AtLeastOne = false; StochasticTimeRaster rastOutput = this.STSimTransformer.InputRasters.CreateOutputRaster(RasterDataType.DTDouble); foreach (FlowTypeLinkage l in g.FlowTypeLinkages) { if (GetLateralOutputFlowDictionary().ContainsKey(l.FlowType.Id)) { SpatialOutputFlowRecord rec = GetLateralOutputFlowDictionary()[l.FlowType.Id]; if (rec.HasOutputData) { StochasticTimeRaster rastFlowType = this.STSimTransformer.InputRasters.CreateOutputRaster(RasterDataType.DTDouble); double[] arr = rastFlowType.DblCells; foreach (Cell c in this.m_STSimTransformer.Cells) { arr[c.CellId] = rec.Data[c.CollectionIndex]; } rastFlowType.ScaleDblCells(l.Value); rastOutput.AddDblCells(rastFlowType); AtLeastOne = true; } } } if (AtLeastOne) { Spatial.WriteRasterData( rastOutput, this.ResultScenario.GetDataSheet(Constants.DATASHEET_OUTPUT_LATERAL_FLOW_GROUP), iteration, timestep, g.Id, Constants.SPATIAL_MAP_LATERAL_FLOW_GROUP_VARIABLE_PREFIX, Constants.DATASHEET_OUTPUT_SPATIAL_FILENAME_COLUMN); } } }
public void Merge(string inpRasterFileName, int numIterations) { if (m_rasterMerge == null) { this.m_rasterMerge = new StochasticTimeRaster(inpRasterFileName, RasterDataType.DTDouble); m_rasterMerge.ScaleDblCells(numIterations); return; } StochasticTimeRaster rastInput = new StochasticTimeRaster(inpRasterFileName, RasterDataType.DTDouble); if (rastInput.Width != m_rasterMerge.Width || rastInput.Height != m_rasterMerge.Height) { string sMsg = string.Format(CultureInfo.InvariantCulture, "The metadata of the merge raster file '{0}' does not match that used in previous raster files.", inpRasterFileName); throw new ArgumentException(sMsg); } rastInput.ScaleDblCells(numIterations); m_rasterMerge.AddDblCells(rastInput); }