private double GetFlowSpatialMultiplier(
            Cell cell,
            FlowSpatialMultiplierMap map,
            int flowGroupId,
            int iteration,
            int timestep)
        {
            Debug.Assert(this.m_IsSpatial);
            Debug.Assert(this.m_FlowSpatialMultipliers.Count > 0);

            FlowSpatialMultiplier m = map.GetFlowSpatialMultiplier(flowGroupId, iteration, timestep);

            if (m == null)
            {
                return(1.0);
            }

            if (!this.m_FlowSpatialMultiplierRasters.ContainsKey(m.FileName))
            {
                return(1.0);
            }

            StochasticTimeRaster raster = this.m_FlowSpatialMultiplierRasters[m.FileName];
            double v = raster.DblCells[cell.CollectionIndex];

            if (MathUtils.CompareDoublesEqual(v, raster.NoDataValue, double.Epsilon))
            {
                return(1.0);
            }
            else
            {
                return(v);
            }
        }
Ejemplo n.º 2
0
        internal void AddFlowSpatialMultiplier(FlowSpatialMultiplier multiplier)
        {
            if (multiplier.FlowMultiplierTypeId != this.m_FlowMultiplierTypeId)
            {
                throw new ArgumentException("The flow multiplier type is not correct.");
            }

            this.m_FlowSpatialMultipliers.Add(multiplier);
        }
Ejemplo n.º 3
0
        private void FillFlowSpatialMultipliers()
        {
            Debug.Assert(this.m_IsSpatial);
            Debug.Assert(this.m_FlowSpatialMultipliers.Count == 0);
            Debug.Assert(this.m_FlowSpatialMultiplierRasters.Count == 0);
            DataSheet ds = this.ResultScenario.GetDataSheet(Constants.DATASHEET_FLOW_SPATIAL_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);
                }

                FlowSpatialMultiplier Multiplier = new FlowSpatialMultiplier(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_FlowSpatialMultipliers.Add(Multiplier);

                //Only load a single instance of a each unique filename to conserve memory

                if (!this.m_FlowSpatialMultiplierRasters.ContainsKey(FileName))
                {
                    this.STSimTransformer.CompressRasterForCellCollection(MultiplierRaster);
                    this.m_FlowSpatialMultiplierRasters.Add(FileName, MultiplierRaster);
                }
            }
        }
        private void ValidateFlowSpatialMultipliers()
        {
            Debug.Assert(this.m_IsSpatial);
            DataSheet ds = this.ResultScenario.GetDataSheet(Constants.DATASHEET_FLOW_SPATIAL_MULTIPLIER_NAME);

            for (int i = this.m_FlowSpatialMultipliers.Count - 1; i >= 0; i--)
            {
                FlowSpatialMultiplier r = this.m_FlowSpatialMultipliers[i];

                if (!this.m_FlowSpatialMultiplierRasters.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_FlowSpatialMultiplierRasters[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);
                    }
                }
            }
        }