// special add for Array2d<Real> // Array2D needs a special add that cannot be implemented in the macro because // we need to call the function copy(), or otherwise we only get references void Pool::add(const string& name, const Array2D<Real>& value, bool validityCheck) { /* first check if the pool has ever seen this key before, if it has, we can * just add it, if not, we need to run some validation tests */ { MutexLocker lock(mutexArray2DReal); if (validityCheck && !isValid(value)) { throw EssentiaException("Pool::add array contains invalid numbers (NaN or inf)"); } if (_poolArray2DReal.find(name) != _poolArray2DReal.end()) { _poolArray2DReal[name].push_back(value.copy()); return; } } GLOBAL_LOCK validateKey(name); _poolArray2DReal[name].push_back(value.copy()); }
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Creates a raster from raw data //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- void LSDSoilHydroRaster::create(int nrows, int ncols, float xmin, float ymin, float cellsize, float ndv, Array2D<float> data) { NRows = nrows; NCols = ncols; XMinimum = xmin; YMinimum = ymin; DataResolution = cellsize; NoDataValue = ndv; RasterData = data.copy(); if (RasterData.dim1() != NRows) { cout << "LSDSoilHydroRaster dimension of data is not the same as stated in NRows!" << endl; exit(EXIT_FAILURE); } if (RasterData.dim2() != NCols) { cout << "LSDSoilHydroRaster dimension of data is not the same as stated in NCols!" << endl; exit(EXIT_FAILURE); } }