31 vector<double> temp(nft,1);
59 vector <Pixel *> toReturn;
62 int thisX = this->
getX();
63 int thisY = this->
getY();
64 int minX = max(0 , (thisX - distLevel_h)+1);
65 int maxX = min(xNPixels , thisX + distLevel_h);
66 int minY = max(0 , (thisY - distLevel_h)+1);
67 int maxY = min(yNPixels , thisY + distLevel_h);
70 if (thisY-distLevel_h >=0){
71 for(
int i=minX;i<maxX;i++){
76 if (thisX+distLevel_h < xNPixels){
77 for(
int i=minY;i<maxY;i++){
82 if (thisY+distLevel_h < yNPixels){
83 for(
int i=minX;i<maxX;i++){
88 if (thisX-distLevel_h >= 0){
89 for(
int i=minY;i<maxY;i++){
96 if (thisX-distLevel_h >= 0 && thisY-distLevel_h >=0){
100 if (thisX+distLevel_h < xNPixels && thisY-distLevel_h >=0){
104 if (thisX+distLevel_h < xNPixels && thisY+distLevel_h <yNPixels){
108 if (thisX-distLevel_h >= 0 && thisY+distLevel_h <yNPixels){
136 map<string, double>::iterator p;
137 p=
values.find(layerName_h);
139 if(setNoValueForZero && value_h == 0){
145 msgOut(
MSG_ERROR,
"Coud not change pixel value for layer "+layerName_h+
". Layer don't found.");
164 return vIter->second;
168 if(returnZeroForNoValue){
190 double multiplierSpVar = (multiplierName ==
"tp_multiplier")?
getSpModifier(forName):1.0;
194 if(std::find(modifiersFromTable.begin(), modifiersFromTable.end(), multiplierName) != modifiersFromTable.end()) {
198 if (multiplierName ==
"mortCoef_multiplier"){
201 return multiplier*multiplierSpVar;
205 return getSTData(multiplierName, forName, year,
"", 1.0);
246 Pixel::getSTData(
const string& parName,
const string& forName,
int year,
const string& d2,
double naToReturn){
249 if (naToReturn ==
RETNA) naToReturn = defaultNoValue;
258 string search_for = parName+
"#"+forName+
"#"+d2+
"#"+
i2s(year);
259 map <string,double>::const_iterator i =
values.upper_bound(search_for);
260 if(i!=
values.begin()) i--;
261 const string& key = i->first;
262 string search_base = search_for.substr(0,search_for.size()-4);
263 if (key.compare(0, search_base.size(), search_base) == 0){
269 return i->second == defaultNoValue ? naToReturn : i->second;
272 string search_for2 = parName+
"#"+
"#"+d2+
"#"+
i2s(year);
273 map <string,double>::const_iterator i2 =
values.upper_bound(search_for2);
274 if(i2!=
values.begin()) i2--;
275 const string& key2 = i2->first;
276 string search_base2 = search_for2.substr(0,search_for2.size()-4);
277 if (key2.compare(0, search_base2.size(), search_base2) == 0){
283 return i2->second == defaultNoValue ? naToReturn : i2->second;
286 string search_for2 = parName+
"#"+forName+
"#"+
"#"+
i2s(year);
287 map <string,double>::const_iterator i2 =
values.upper_bound(search_for2);
288 if(i2!=
values.begin()) i2--;
289 const string& key2 = i2->first;
290 string search_base2 = search_for2.substr(0,search_for2.size()-4);
291 if (key2.compare(0, search_base2.size(), search_base2) == 0){
297 return i2->second == defaultNoValue ? naToReturn : i2->second;
300 string search_for2 = parName+
"#"+
"#"+
"#"+
i2s(year);
301 map <string,double>::const_iterator i2 =
values.upper_bound(search_for2);
302 if(i2!=
values.begin()) i2--;
303 const string& key2 = i2->first;
304 string search_base2 = search_for2.substr(0,search_for2.size()-4);
305 if (key2.compare(0, search_base2.size(), search_base2) == 0){
311 return i2->second == defaultNoValue ? naToReturn : i2->second;
332 string debug=forType;
336 int maxYear = initialOptYear + simulationYears;
340 double pathMort = 0.0;
343 for(uint r=0;r<pathRules.size();r++){
344 string pathId=pathRules[r]->pathId;
345 double pres_min=pathRules[r]->pres_min;
346 vector<double> mortCoefficients=pathRules[r]->mortCoefficents;
347 double pathMort_thispath = 0.0;
348 for(uint y=year;y>(year-mortCoefficients.size());y--){
355 string layerName=
"pathogen_pp#"+pathId+
"#"+
i2s(y2);
358 pathMort_thispath = mortCoefficients[i];
362 pathMort += pathMort_thispath;
370 string search_for = multiplierName+
"#"+forName+
"#";
371 for (std::map<string,double>::iterator it=
values.lower_bound(search_for); it!=
values.end(); ++it){
372 if (it->first.compare(0, search_for.size(), search_for) == 0){
374 it->second = it->second * coefficient;
380 Pixel::getDoubleValue (
const string& parName,
const string& forName,
const string& dClass,
const int& year,
const bool& returnZeroForNoValue){
391 map <int,vector<double> >::const_iterator i=
regArea.find(year);
393 return i->second.at(ft_idx);
395 msgOut(
MSG_ERROR,
"Asking for a pastRegArea of a not-registered year. I don't have year "+
i2s(year)+
"!");
439 for (
int i=0;i<ftypes.size();i++){
440 if (ftypes[i] == ft){
452 }
else if (rLevel==1) {
455 msgOut(
MSG_ERROR,
"Requested a unknown level region code in getMyRegion().");
string pack(const string &parName, const string &forName, const string &dClass, const int &year) const
Print an ERROR message, but don't stop the model.
The required data is for the current year.
double getSpModifier(const string &ft)
int getIntSetting(const string &name_h, int position=0, int reg=WORLD) const
vector< vector< double > > area
bool getBoolSetting(const string &name_h, int position=0, int reg=WORLD) const
void setPastRegArea(const double &value, const int &ft_idx, const int &year)
string i2s(const int &int_h) const
integer to string conversion
ThreadManager * MTHREAD
Pointer to the Thread manager.
bool layerExist(const string &layerName_h, bool exactMatch=true) const
Return a pointer to a layer given its name.
void changeValue(const string &layerName_h, const double &value_h, const bool &setNoValueForZero=false)
Change the value of an existing layerMTHREAD->GIS->pack(parName, forName, dClass, year)...
ModelData * MD
the model data object
map< string, double >::const_iterator vIter
void correctInputMultiplier(const string &multiplierName, const string &forName, double coefficient=1)
It apply a given coefficient to all the multipliers layers of a given ft.
vector< double > avalCoef
Availability (of wood resources) coefficient. A [0,1] coefficient (new: by forest type) that reduces ...
double getNoValue() const
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
ModelRegion * l2region
Pointer to level 2 region where this pixel is.
vector< vector< double > > vol_l
store the volumes of the previous year
void msgOut(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
Overloaded function to print the output log.
vector< Pixel * > getPixelsAtDistLevel(int distLevel_h) const
Return a vector of pixels at the specified distance (in levels, not in physical units) ...
Gis * GIS
GIS information and methods.
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
vector< string > getStringVectorSetting(const string &name_h, int reg=WORLD) const
ModelRegion * getMyRegion(const int &rLevel=2)
vector< pathRule * > getPathMortalityRule(const string &forType, const string &dC)
Return the pathogen mortality rule(s) associated with a given ft and dc (plural as more than a single...
int getYNPixels() const
Return the number of pixels on X.
Print an error message and stop the model.
vector< double > spMods
The sampled spatial modifiers (by forest type)
double getSTData(const string &parName, const string &forName, int year, const string &d2="", double naToReturn=RETNA)
double getDoubleValue(const string &layerName_h, const bool &returnZeroForNoValue=false) const
Return the value for a specific layer.
const double getForData(const string &type_h, const int ®Id_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW)
Pixel(double ID_h, ThreadManager *MTHREAD_h)
double getPastRegArea(const int &ft_idx, const int &year)
vector< vector< double > > vol
double getMultiplier(const string &multiplierName, const string &forName, int year=DATA_NOW)
Request the (scenario specific) NO VALUE to be returned.
vector< vector< double > > area_l
store the areas of the previous year
vector< string > getForTypeIds(bool all=false)
By default it doesn't return forTypes used only as input.
map< string, double > values
Map of values for each layer.
double getPathMortality(const string &forType, const string &dC, int year=DATA_NOW)
Return the INCREASED mortality due to pathogen presence for a given ft and dc in a certain year (defa...
void swap(const int &swap_what)
Assign to the delayed value the current values, e.g. vol_l = vol.
Pixel * getPixel(int x_h, int y_h)
double getDoubleSetting(const string &name_h, int position=0, int reg=WORLD) const
ModelRegion * getParent()
map< int, vector< double > > regArea