FFSM++  1.1.0
French Forest Sector Model ++
Output.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2015 by Laboratoire d'Economie Forestière *
3  * http://ffsm-project.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version, given the compliance with the *
9  * exceptions listed in the file COPYING that is distribued together *
10  * with this file. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 #include <fstream>
23 
24 #include <algorithm>
25 
26 #include "Output.h"
27 #include "ThreadManager.h"
28 #include "Scheduler.h"
29 #include "ModelData.h"
30 #include "Gis.h"
31 #include "Carbon.h"
32 
33 typedef map<string, vector <double> > DataMap;
34 typedef pair<string, vector <double> > DataPair;
35 
36 
38  MTHREAD=MTHREAD_h;
39 }
40 
42 }
43 
44 // ---- functions ... ----------------------
45 
46 
47 void
49  commonInit();
57 }
58 
59 
60 void
62  oLevel = MTHREAD->MD->getIntSetting("outputLevel");
64  inYear = MTHREAD->MD->getIntSetting("initialYear");
65  nYears = MTHREAD->MD->getIntSetting("simulationYears");
68 // bool initSeed = MTHREAD->MD->getBoolSetting("newRandomSeed");
69 // if (initSeed){
70 // uniform_int_distribution<> d(1, 1000000);
71 // int random = d(*MTHREAD->gen);
72 // scenarioName = MTHREAD->getScenarioName()+"_"+i2s(random);
73 // } else {
74 // scenarioName = MTHREAD->getScenarioName();
75 // }
76  if (MTHREAD->MD->getStringSetting("overridenScenarioName") == "none"){
78  } else {
79  scenarioName = MTHREAD->MD->getStringSetting("overridenScenarioName");
80  }
81  oFileExt = MTHREAD->MD->getStringSetting("outputFileExtension");
82  oHRedeable = MTHREAD->MD->getBoolSetting("outputHumanReadable");
83  oSingleFile = MTHREAD->MD->getBoolSetting("outputSingleFile");
84  oYears = MTHREAD->MD->getIntVectorSetting("outYears");
85  mapsOYears = MTHREAD->MD->getIntVectorSetting("mapsOutYears");
86  wRegId_l1 = MTHREAD->MD->getIntSetting("worldCodeLev1");
87  wRegId_l2 = MTHREAD->MD->getIntSetting("worldCodeLev2");
88  outForVariables = MTHREAD->MD->getStringVectorSetting("outForVariables");
89  outProdVariables = MTHREAD->MD->getStringVectorSetting("outProdVariables");
90  dClasses = MTHREAD->MD->getStringVectorSetting("dClasses");
91  pDClasses.insert(pDClasses.end(), dClasses.begin()+1, dClasses.end() ); // production diameter classes
92  dClasses.push_back(""); // needed for reporting of variables without diameter attribute
93  outStepRange = MTHREAD->MD->getIntSetting("outStepRange");
94  forestDiamDetailedOutput = MTHREAD->MD->getBoolSetting("forestDiamDetailedOutput");
96 
97  oForData = (oLevel>=OUTVL_DETAILED && outForVariables.size() > 0)?true:false;
98  oProdData = (oLevel>=OUTVL_DETAILED && outProdVariables.size() > 0)?true:false;
99  oCarbonData = (oLevel>=OUTVL_DETAILED)?true:false;
100 
101  priPr = MTHREAD->MD->getStringVectorSetting("priProducts");
102  secPr = MTHREAD->MD->getStringVectorSetting("secProducts");
103  allPr = priPr;
104  allPr.insert( allPr.end(), secPr.begin(), secPr.end() );
105  nPriPr = priPr.size();
106  nSecPr = secPr.size();
107  nAllPr = allPr.size();
108  l1regIds = MTHREAD->MD->getRegionIds(1, true);
109  nL2r = MTHREAD->MD->getRegionIds(2, true).size();
110  spMode = MTHREAD->MD->getBoolSetting("usePixelData");
111  //if(spMode) {
112  // pxIds = getXyNPixels();
113  //}
114 
115 
116  for(uint i=0;i<l1regIds.size();i++){
117  std::vector<int> l2ChildrenIds;
118  ModelRegion* l1Region = MTHREAD->MD->getRegion(l1regIds[i]);
119  std::vector<ModelRegion*> l2Childrens = l1Region->getChildren(true);
120  for(uint j=0;j<l2Childrens.size();j++){
121  l2ChildrenIds.push_back(l2Childrens[j]->getRegId());
122  }
123  if(l2ChildrenIds.size()){
124  l2r.push_back(l2ChildrenIds);
125  }
126  }
127 
128 }
129 
130 void
132  if(oLevel<OUTVL_AGGREGATED) return;
133 
134  if (oSingleFile){
135  logFilename = baseDir+oDir+"optimisationLogs/optimisationLogs.txt";
136 
137  } else {
138  logFilename = baseDir+oDir+"optimisationLogs/"+scenarioName+".txt";
139  }
140 
141 
142  ifstream in(logFilename.c_str(), ios::in);
143  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
144  in.close();
146  ofstream out(logFilename.c_str(), ios::app);
147  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+logFilename+" for writing.");}
148  time_t now;
149  time(&now);
150  struct tm *current = localtime(&now);
151  string timemessage = i2s(current->tm_hour)+":"+i2s(current->tm_min)+":"+ i2s(current->tm_sec);
152  out << scenarioName << d << "0000" << d << timemessage << d << d << d <<"\n";
153  out.close();
154  return;
155  } else { // file doesn't exist
156  in.close();
157  ofstream out(logFilename.c_str(), ios::out);
158  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+logFilename+" for writing.");}
159  out << "scenario" << d << "year" << d << "time" << d << "opt flag" << d << "iterations" << d <<"\n";
160  time_t now;
161  time(&now);
162  struct tm *current = localtime(&now);
163  string timemessage = i2s(current->tm_hour)+":"+i2s(current->tm_min)+":"+ i2s(current->tm_sec);
164  out << scenarioName << d << "0000" << d << timemessage << d << d << d <<"\n";
165  out.close();
166  }
167 }
168 
169 void
171  if(oLevel<OUTVL_ALL) return;
172 
173  // init debugging the expected returns...
174  if(spMode) return;
175  expReturnsDebugVariables.push_back("hVol_byUPp");
176  expReturnsDebugVariables.push_back("hV_byFT");
177  expReturnsDebugVariables.push_back("finalHarvestFlag");
178  expReturnsDebugVariables.push_back("pondCoeff");
179  expReturnsDebugVariables.push_back("pW");
180  expReturnsDebugVariables.push_back("cumTp");
181  expReturnsDebugVariables.push_back("vHa");
182  expReturnsDebugVariables.push_back("expectedReturns");
183  expReturnsDebugVariables.push_back("weightedAvgCompModeFlag");
184 
185  if (oSingleFile){
186  debugFilename = baseDir+oDir+"debugs/debugOut.csv";
187  } else {
188  debugFilename = baseDir+oDir+"debugs/debugOut_"+scenarioName+".csv";
189  }
190 
191  ifstream in(debugFilename.c_str(), ios::in);
192  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
193  in.close();
195  return;
196  } else { // file doesn't exist
197  in.close();
198  ofstream out(debugFilename.c_str(), ios::out);
199  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugFilename+" for writing.");}
200  out << "scenario" << d << "year" << d << "region or pixel" << d << "forType" << d << "freeDim" << d << "prod" << d << "parName" << d << "value" << d <<"\n";
201  out.close();
202  }
203 }
204 
205 
206 void
208  if(oLevel<OUTVL_ALL) return;
209 
210  // init debugging the expected returns...
211  if(!spMode) return;
212 
213  if (oSingleFile){
214  debugPxValuesFilename = baseDir+oDir+"debugs/debugPxValues.csv";
215  } else {
216  debugPxValuesFilename = baseDir+oDir+"debugs/debugPxValues_"+scenarioName+".csv";
217  }
218 
219  ifstream in(debugPxValuesFilename.c_str(), ios::in);
220  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
221  in.close();
223  return;
224  } else { // file doesn't exist
225  in.close();
226  ofstream out(debugPxValuesFilename.c_str(), ios::out);
227  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugPxValuesFilename+" for writing.");}
228  out << "scenario" << d << "year" << d << "region" << d << "pxId" << d << "pxX" << d << "pxY" << d ;
229  /*for(uint f=0;f<fTypes.size();f++){
230  string ft = fTypes[f];
231  string header = "tp_multiplier_"+ft;
232  out << header <<d;
233  }
234  for(uint f=0;f<fTypes.size();f++){
235  string ft = fTypes[f];
236  string header = "mortCoef_multiplier_"+ft;
237  out << header <<d;
238  }*/
239  out << "var" << d ;
240 
241  for(uint f=0;f<fTypes.size();f++){
242  string ft = fTypes[f];
243  for (uint u=0;u<dClasses.size();u++){
244  string dc=dClasses[u];
245  string header = ft+"_"+dc;
246  out << header <<d;
247  }
248  }
249  for(uint f=0;f<fTypes.size()+1;f++){
250  string ft1 = (f == fTypes.size()) ? "NonFor" : fTypes[f];
251  for(uint f2=0;f2<fTypes.size()+1;f2++){
252  string ft2 = (f2 == fTypes.size()) ? "NonFor" : fTypes[f2];
253  string header = ft1+"_2_"+ft2;
254  out << header <<d;
255  }
256  }
257  out << "\n";
258 
259 
260  out.close();
261  }
262 
263 
264 
265 
266  /*
267  if(oSingleFile){
268  outFileName = baseDir+oDir+"results/forestData"+oFileExt;
269  ifstream in(outFileName.c_str(), ios::in);
270  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
271  in.close();
272  cleanScenario(outFileName, scenarioName, d);
273  return;
274  } else {
275  in.close();
276  }
277  } else {
278  outFileName = baseDir+oDir+"results/forestData_"+scenarioName+oFileExt;
279  }
280 
281  ofstream out(outFileName.c_str(), ios::out);
282  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
283  out << "scen" << d << "parName" << d << "country" << d << "region" << d << "forType" << d << "freeDim" << d;
284  */
285 
286 
287 
288 
289 
290 
291 
292 
293 }
294 
295 void
297  if(!oForData) return;
298 
299  if(oSingleFile){
300  outFileName = baseDir+oDir+"results/forestData"+oFileExt;
301  ifstream in(outFileName.c_str(), ios::in);
302  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
303  in.close();
305  return;
306  } else {
307  in.close();
308  }
309  } else {
310  outFileName = baseDir+oDir+"results/forestData_"+scenarioName+oFileExt;
311  }
312 
313  ofstream out(outFileName.c_str(), ios::out);
314  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
315  out << "scen" << d << "parName" << d << "country" << d << "region" << d << "forType" << d << "freeDim" << d;
316  if(oHRedeable){
317  for(int i=0;i<nYears;i++){
318  out << i+inYear << d;
319  }
320  } else {
321  out << "year" << d << "value" << d;
322  }
323  out << "\n";
324  out.close();
325 
326  // gonna do the same for detailed hV..
327  if(!MTHREAD->MD->getBoolSetting("outDetailedHv",DATA_NOW)) return;
328  outFileName = baseDir+oDir+"results/detailedHV_"+scenarioName+oFileExt;
329  ofstream outHV(outFileName.c_str(), ios::out);
330  if (!outHV){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
331  outHV << "scen" << d << "parName" << d << "country" << d << "region" << d << "forType" << d << "freeDim" << d << "prod" << d << "year" << d << "value" << d;
332  outHV << "\n";
333  outHV.close();
334 
335 }
336 
337 void
339  if(!oProdData) return;
340 
341  if(oSingleFile){
342  outFileName = baseDir+oDir+"results/productData"+oFileExt;
343  ifstream in(outFileName.c_str(), ios::in);
344  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
345  in.close();
347  return;
348  } else {
349  in.close();
350  }
351  } else {
352  outFileName = baseDir+oDir+"results/productData_"+scenarioName+oFileExt;
353  }
354 
355  ofstream out(outFileName.c_str(), ios::out);
356  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
357  out << "scen" << d << "parName" << d << "country" << d << "region" << d << "prod" << d << "freeDim" << d;
358  if(oHRedeable){
359  for(int i=0;i<nYears;i++){
360  out << i+inYear << d;
361  }
362  } else {
363  out << "year" << d << "value" << d;
364  }
365  out << "\n";
366  out.close();
367 }
368 
369 void
371  if(!oCarbonData) return;
372  if(oSingleFile){
373  outFileName = baseDir+oDir+"results/carbonBalance"+oFileExt;
374  ifstream in(outFileName.c_str(), ios::in);
375  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
376  in.close();
378  return;
379  } else {
380  in.close();
381  }
382  } else {
383  outFileName = baseDir+oDir+"results/carbonBalance_"+scenarioName+oFileExt;
384  }
385 
386  ofstream out(outFileName.c_str(), ios::out);
387  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
388  out << "scen" << d << "country" << d << "region" << d << "balItem" << d;
389  //if(oHRedeable){
390  // for(int i=0;i<nYears;i++){
391  // out << i+inYear << d;
392  // }
393  //} else {
394  out << "year" << d << "value" << d;
395  //}
396  out << "\n";
397  out.close();
398 }
399 
400 
401 /**
402 Resetting the list of printed layers and the scenario name..
403 <br>Printing scenario name for post-processing scripts
404 */
405 void
407  if(oLevel<OUTVL_MAPS) return;
408  string mapBaseDirectory = baseDir+oDir+"maps/";
409  string filenameToSaveScenarioName = mapBaseDirectory+"scenarioNames/"+scenarioName;
410  string filenameListIntLayers = mapBaseDirectory+"integerListLayers/"+scenarioName;
411  string filenameListFloatLayers = mapBaseDirectory+"floatListLayers/"+scenarioName;
412 
413  // printing the scenario name in the "scenarioName file"...
414  ofstream outSN(filenameToSaveScenarioName.c_str(), ios::out);
415  if (!outSN){ msgOut(MSG_ERROR,"Error in opening the file "+filenameToSaveScenarioName+".");}
416  outSN << scenarioName << "\n";
417  outSN.close();
418  // cleaning the "integerListLayers" and "floatListLayers" file...
419  ofstream outi(filenameListIntLayers.c_str(), ios::out);
420  outi.close();
421  ofstream outf(filenameListFloatLayers.c_str(), ios::out);
422  outf.close();
423 }
424 
425 void
426 Output::print(bool earlyPrint){
427  int cYear = MTHREAD->SCD->getYear();
428  int initialSimulationYear = MTHREAD->MD->getIntSetting("initialOptYear");
429 
430  if (outStepRange != -1 && (cYear-initialSimulationYear)%outStepRange != 0 && cYear != (initialSimulationYear+nYears)-1 ) {
431  cout << cYear << " not printed" << endl;
432  return;
433  }
434  bool printThisYear = false;
435  for(uint i=0;i<oYears.size();i++){
436  if (outStepRange == -1 && oYears[i] == cYear) printThisYear = true;
437  }
438  if(outStepRange == -1 && !printThisYear) return;
439 
440 
441  cout << "printing " << cYear << endl;
442  printMaps();
444  printForestData(false);
445  printProductData(false);
448  if(!earlyPrint) printDebugPixelValues();
450 }
451 
452 void
454  if(oLevel<OUTVL_MAPS) return;
455  int cYear = MTHREAD->SCD->getYear();
456  if ( find(mapsOYears.begin(), mapsOYears.end(), cYear) != mapsOYears.end() ){
457  MTHREAD->GIS->printLayers();
458  if(oLevel<OUTVL_BINMAPS) return;
460  }
461 }
462 
463 void
465  // we do this only if we choosed the outputHumanReadable settings, as we flush the data all in ones at the end.
466  // oterwise we flush data every year
467  if(oHRedeable){
469  printForestData(true);
470  printProductData(true);
472  }
473 }
474 
475 void
476 Output::printForestData(bool finalFlush){
477 
478  if(!oForData) return;
479  if(oHRedeable && !finalFlush) return;
480 
481  msgOut(MSG_INFO, "Printing forest data..");
482  int currentYear = MTHREAD->SCD->getYear();
483  if(oSingleFile){
484  outFileName = baseDir+oDir+"results/forestData"+oFileExt;
485  } else {
486  outFileName = baseDir+oDir+"results/forestData_"+scenarioName+oFileExt;
487  }
488  ofstream out (outFileName.c_str(), ios::app);
489  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for writing.");}
490  double outvalue;
491  for(uint v=0;v<outForVariables.size();v++){
492  vector<string>fTypes_temp = fTypes;
493  if( outForVariables[v]=="expReturns" || outForVariables[v]=="sumExpReturns" || outForVariables[v]=="totalShareInvadedArea") {
494  fTypes_temp.push_back(""); // adding an empty forest type to report for variables that doesn't have a forestType dimension
495  vector<string> ftParents = MTHREAD->MD->getForTypeParents();
496  fTypes_temp.insert(fTypes_temp.end(),ftParents.begin(),ftParents.end()); // also inserting forest type "parents" for expected returns
497  }
498  for (uint r1=0;r1<l2r.size();r1++){
499  for (uint r2=0;r2<l2r[r1].size();r2++){
500  for(uint ft=0;ft<fTypes_temp.size();ft++){
502  for(uint dc=0;dc<dClasses.size();dc++){ // an empty "" dc has been already added to the vector
503  out << scenarioName << d;
504  out << outForVariables[v] << d;
505  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
506  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
507  out << fTypes_temp[ft] << d;
508  out << dClasses[dc] << d;
509  if (oHRedeable){
510  for(int y=0;y<nYears;y++){
511  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],dClasses[dc],y+inYear);
512  out << outvalue << d;
513  }
514  out << "\n";
515  } else {
516  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],dClasses[dc]);
517  out << currentYear << d;
518  out << outvalue << d;
519  out << "\n";
520  }
521  }
522  } else {
523  out << scenarioName << d;
524  out << outForVariables[v] << d;
525  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
526  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
527  out << fTypes_temp[ft] << d;
528  out << d;
529  if (oHRedeable){
530  for(int y=0;y<nYears;y++){
531  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],DIAM_ALL,y+inYear);
532  out << outvalue << d;
533  }
534  out << "\n";
535  } else {
536  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],DIAM_ALL);
537  out << currentYear << d;
538  out << outvalue << d;
539  out << "\n";
540  }
541  }
542  }
543  }
544  }
545  }
546  /*
547  DataMap::const_iterator i;
548  string key;
549  vector <double> values;
550  string parName;
551  int regId;
552  string forType;
553  string diamClass;
554  for(i=MTHREAD->MD->forDataMap.begin();i!=MTHREAD->MD->forDataMap.end();i++){
555  key = i->first;
556  values = i->second;
557  MTHREAD->MD->unpackKeyForData(key, parName, regId, forType, diamClass);
558  ModelRegion* REG = MTHREAD->MD->getRegion(regId);
559  // we don't want to output data from residual region unless it's the world region we are speaking of
560  if(REG->getIsResidual() && !(regId==wRegId_l1 || regId==wRegId_l2)) continue;
561  out << scenarioName << d;
562  out << parName << d;
563  if (REG->getRegLevel()==2){
564  ModelRegion* pREG = MTHREAD->MD->getRegion(REG->getParRegId());
565  out << pREG->getRegSName() << d;
566  out << REG->getRegSName() << d;
567  } else if (REG->getRegLevel()==1){
568  out << REG->getRegSName() << d;
569  out << d;
570  } else {
571  out << d << d;
572  }
573  out << forType << d;
574  out << diamClass << d;
575  if (oHRedeable){
576  for(int y=0;y<nYears;y++){
577  out << MTHREAD->MD->getTimedData(values,y+inYear) << d;
578  }
579  out << "\n";
580  } else {
581  out << currentYear << d;
582  out << MTHREAD->MD->getTimedData(values,currentYear) << d;
583  out << "\n";
584  }
585  }
586  */
587  out.close();
588 }
589 
590 void
591 Output::printProductData(bool finalFlush){
592 
593  if(!oProdData) return;
594  if(oHRedeable && !finalFlush) return;
595 
596  msgOut(MSG_INFO, "Printing market data..");
597  int currentYear = MTHREAD->SCD->getYear();
598 
599  if(oSingleFile){
600  outFileName = baseDir+oDir+"results/productData"+oFileExt;
601  } else {
602  outFileName = baseDir+oDir+"results/productData_"+scenarioName+oFileExt;
603  }
604  ofstream out (outFileName.c_str(), ios::app);
605  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for writing.");}
606 
607 
608  //11042 hardWSawnW 11083 0.00230651
609  //11042 hardWSawnW 11082 0.0390874
610 
611  //if(MTHREAD->SCD->getYear() == 2007){
612 // double test = MTHREAD->MD->getProdData("rt",11042,"hardWSawnW",DATA_NOW);
613 // double test2 = MTHREAD->MD->getProdData("rt",11042,"hardWSawnW",DATA_NOW,"11083");
614 // double test3 = MTHREAD->MD->getProdData("rt",11042,"hardWSawnW",DATA_NOW,"11082");
615 // cout << test << '\t' << test2 << '\t' << test3 << endl;
616 // exit(0);
617 // }
618 
619  double outvalue;
620  for(uint v=0;v<outProdVariables.size();v++){
621  for (uint r1=0;r1<l2r.size();r1++){
622  for (uint r2=0;r2<l2r[r1].size();r2++){
623  for(uint p=0;p<allPr.size();p++){
624 
625  if(outProdVariables[v]=="rt"){
626  for(uint r2b=0;r2b<l2r[r1].size();r2b++){
627  out << scenarioName << d;
628  out << outProdVariables[v] << d;
629  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
630  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
631  out << allPr[p] << d;
632  out << l2r[r1][r2b] << d;
633  if (oHRedeable){
634  for(int y=0;y<nYears;y++){
635  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],y+inYear,i2s(l2r[r1][r2b]));
636  out << outvalue << d;
637  }
638  out << "\n";
639  } else {
640 // if(MTHREAD->SCD->getYear() == 2007 && l2r[r1][r2] == 11042 && allPr[p] == "hardWSawnW" && (l2r[r1][r2b]== 11083 || l2r[r1][r2b]== 11082 )){
641 // outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],currentYear,i2s(l2r[r1][r2b]));
642 // cout << outvalue << endl;
643 // }
644  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],currentYear,i2s(l2r[r1][r2b]));
645  out << currentYear << d;
646  out << outvalue << d;
647  out << "\n";
648  }
649  }
650  } else {
651  out << scenarioName << d;
652  out << outProdVariables[v] << d;
653  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
654  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
655  out << allPr[p] << d;
656  out << d;
657  if (oHRedeable){
658  for(int y=0;y<nYears;y++){
659  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],y+inYear);
660  out << outvalue << d;
661  }
662  out << "\n";
663  } else {
664  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p]);
665  out << currentYear << d;
666  out << outvalue << d;
667  out << "\n";
668  }
669 
670  }
671  }
672  }
673  }
674  }
675 
676 
677 
678 
679 /*
680  DataMap::const_iterator i;
681  string key;
682  vector <double> values;
683  string parName;
684  int regId;
685  string prod;
686  string freeDim;
687  for(i=MTHREAD->MD->prodDataMap.begin();i!=MTHREAD->MD->prodDataMap.end();i++){
688  key = i->first;
689  values = i->second;
690  MTHREAD->MD->unpackKeyProdData(key, parName, regId, prod, freeDim);
691  ModelRegion* REG = MTHREAD->MD->getRegion(regId);
692  // we don't want to output data from residual region unless it's the world region we are speaking of
693  if(REG->getIsResidual() && !(regId==wRegId_l1 || regId==wRegId_l2)) continue;
694  out << scenarioName << d;
695  out << parName << d;
696  if (REG->getRegLevel()==2){
697  ModelRegion* pREG = MTHREAD->MD->getRegion(REG->getParRegId());
698  out << pREG->getRegSName() << d;
699  out << REG->getRegSName() << d;
700  } else if (REG->getRegLevel()==1){
701  out << REG->getRegSName() << d;
702  out << d;
703  } else {
704  out << d << d;
705  }
706  out << prod << d;
707  out << freeDim << d;
708  if (oHRedeable){
709  for(int y=0;y<nYears;y++){
710  out << MTHREAD->MD->getTimedData(values,y+inYear) << d;
711  }
712  out << "\n";
713  } else {
714  out << currentYear << d;
715  out << MTHREAD->MD->getTimedData(values,currentYear) << d;
716  out << "\n";
717  }
718  }
719 
720 */
721  out.close();
722 }
723 
724 
725 
726 
727 
728 void
730 
731  if(!oCarbonData) return;
732  int currentYear = MTHREAD->SCD->getYear();
733  if (currentYear == inYear) {return;} // don't print carbon balance on first year, carbon balance containers has not yet been initialised
734 
735  msgOut(MSG_INFO, "Printing forest data..");
736 
737  if(oSingleFile){
738  outFileName = baseDir+oDir+"results/carbonBalance"+oFileExt;
739  } else {
740  outFileName = baseDir+oDir+"results/carbonBalance_"+scenarioName+oFileExt;
741  }
742  ofstream out (outFileName.c_str(), ios::app);
743  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for writing.");}
744  double outvalue=0;
745 
747 
748  for (uint r1=0;r1<l2r.size();r1++){
749  for (uint r2=0;r2<l2r[r1].size();r2++){
750  int regId = l2r[r1][r2];
751  for (uint b=0;b<balItems.size();b++){
752  out << scenarioName << d;
753  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
754  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
755  string balItemString;
756  switch(balItems[b]){
757  case STOCK_INV: {
758  balItemString = "STOCK_INV";
759  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
760  break;
761  }
762  case STOCK_EXTRA: {
763  balItemString = "STOCK_EXTRA";
764  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
765  break;
766  }
767  case STOCK_PRODUCTS: {
768  balItemString = "STOCK_PRODUCTS";
769  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
770  break;
771  }
772  case EM_ENSUB: {
773  balItemString = "EM_ENSUB";
774  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
775  break;
776  }
777  case EM_MATSUB: {
778  balItemString = "EM_MATSUB";
779  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
780  break;
781  }
782  case EM_FOROP: {
783  balItemString = "EM_FOROP";
784  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
785  break;
786  }
787  default:
788  msgOut(MSG_CRITICAL_ERROR,"Unexpected balance item type in function printCarbonBalance");
789  }
790  out << balItemString << d;
791  out << currentYear << d;
792  out << outvalue << d;
793  out << "\n";
794 
795 
796  } // end bal items
797  } // end r2
798  } // end r1
799  out.close();
800 }
801 
802 
803 char
805  int delimiterID = MTHREAD->MD->getIntSetting("outputFieldDelimiter");
806  switch (delimiterID) {
807  case 1:
808  return ',';
809  break;
810  case 2:
811  return ';';
812  break;
813  case 3:
814  return ':';
815  break;
816  case 4:
817  return '\t';
818  break;
819  case 5:
820  return ' ';
821  break;
822  default:
823  msgOut(MSG_ERROR, "You have specified an unknow output file field delimiter. Using \";\".");
824  return ',';
825  }
826 }
827 
828 void
829 Output::printOptLog(bool optimal, int &nIterations, double &obj){
830  if(oLevel<OUTVL_AGGREGATED) return;
831 
832  ofstream out(logFilename.c_str(), ios::app);
833  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+logFilename+" for writing.");}
834  time_t now;
835  time(&now);
836  struct tm *current = localtime(&now);
837  string timemessage = i2s(current->tm_hour)+":"+i2s(current->tm_min)+":"+ i2s(current->tm_sec);
838  out << scenarioName << d << MTHREAD->SCD->getYear() << d << timemessage << d << optimal;
839  out << d << nIterations << d << obj << "\n";
840  out.close();
841 
842 }
843 
844 void
846  if(oLevel<OUTVL_ALL) return;
847 
848  // print debugging the expected returns...
849 
850  if (!spMode && !expReturnsDebug.empty()){
851  ofstream out (debugFilename.c_str(), ios::app);
852  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugFilename+" for writing.");}
853  int currentYear = MTHREAD->SCD->getYear();
854  vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
855 
856  for (uint r2=0;r2<regIds2.size();r2++){
857  for(uint ft=0;ft<fTypes.size();ft++){
858  for(uint dc=0;dc<(dClasses.size()-1);dc++){
859  for(uint pp=0;pp<priPr.size();pp++){
860  for(uint dv=0;dv<expReturnsDebugVariables.size();dv++){
861  // vector <vector < vector <vector <vector <double> > > > > expReturnsDebug;
862  double outputValue = expReturnsDebug.at(r2).at(ft).at(dc).at(pp).at(dv);
863  out << scenarioName << d;
864  out << currentYear << d;
865  out << MTHREAD->MD->regId2RegSName(regIds2[r2]) << d;
866  out << fTypes[ft] << d;
867  out << dClasses[dc] << d;
868  out << priPr[pp] << d;
869  out << expReturnsDebugVariables[dv] << d;
870  out << outputValue << d;
871  out << "\n";
872  }
873  }
874  }
875  }
876  }
877 
878  } // end initial condition checks
879 }
880 
881 void
883 
884  if(oLevel<OUTVL_ALL) return;
885 
886  bool filter;
887  filter = true; //use this to filter output
888  if(filter && spMode){
889  ofstream out (debugPxValuesFilename.c_str(), ios::app);
890  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugPxValuesFilename+" for writing.");}
891  int currentYear = MTHREAD->SCD->getYear();
892  vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
893  for (uint r=0;r<regIds2.size();r++){
894  int rId = regIds2[r];
895  //if(rId != 11002) continue;
896  ModelRegion* REG = MTHREAD->MD->getRegion(rId);
897  vector<Pixel*> regPx = REG->getMyPixels();
898  for (uint p=0;p<regPx.size();p++){
899  Pixel* px = regPx[p];
900  int pxID = px->getID();
901  int pxX = px->getX();
902  int pxY = px->getY();
903  string common = scenarioName + d + i2s(currentYear) + d + i2s(rId) + d+ i2s(pxID) +d +i2s(pxX)+d+i2s(pxY)+d;
904 
905 
906 // for(uint f=0;f<fTypes.size();f++){
907 // double tp_m = px->getMultiplier("tp_multiplier",fTypes[f]);
908 // common += d2s(tp_m)+d;
909 // }
910 // for(uint f=0;f<fTypes.size();f++){
911 // double m_m = px->getMultiplier("mortCoef_multiplier",fTypes[f]);
912 // common += d2s(m_m)+d;
913 // }
914 
915 
916 // // First vars by only ft...
917 // // expectedReturns
918 // out << common << "expectedReturns" << d;
919 // for(uint f=0;f<fTypes.size();f++){
920 // for(uint u=0;u<dClasses.size()-1;u++){
921 // out << d;
922 // }
923 // out << px->expectedReturns[f] << d;
924 // //out << 0.0 << d;
925 // }
926 // out << "\n";
927 
928  //----
929  out << common <<"vol" << d;
930  for(uint f=0;f<fTypes.size();f++){
931  for(uint u=0;u<dClasses.size()-1;u++){
932  out << px->vol[f][u]<< d;
933  }
934  out << vSum(px->vol[f]) << d;
935  }
936  out << "\n";
937  //----
938  out << common <<"area" << d;
939  for(uint f=0;f<fTypes.size();f++){
940  for(uint u=0;u<dClasses.size()-1;u++){
941  out << px->area[f][u]<< d;
942  }
943  out << vSum(px->area[f]) << d;
944  }
945  out << "\n";
946  //----
947 // out << common <<"cumTp_exp" << d;
948 // for(uint f=0;f<fTypes.size();f++){
949 // for(uint u=0;u<dClasses.size()-1;u++){
950 // out << px->cumTp_exp[f][u]<< d;
951 // }
952 // out << vSum(px->cumTp_exp[f]) << d;
953 // }
954 // out << "\n";
955 // //----
956 // out << common <<"vHa_exp" << d;
957 // for(uint f=0;f<fTypes.size();f++){
958 // for(uint u=0;u<dClasses.size()-1;u++){
959 // out << px->vHa_exp[f][u]<< d;
960 // }
961 // out << vSum(px->vHa_exp[f]) << d;
962 // }
963 // out << "\n";
964  //----
965  out << common <<"hArea" << d;
966  for(uint f=0;f<fTypes.size();f++){
967  for(uint u=0;u<dClasses.size()-1;u++){
968  out << px->hArea[f][u]<< d;
969  }
970  out << vSum(px->hArea[f]) << d;
971  }
972  out << "\n";
973  out << common <<"hVol" << d;
974  for(uint f=0;f<fTypes.size();f++){
975  for(uint u=0;u<dClasses.size()-1;u++){
976  out << px->hVol[f][u]<< d;
977  }
978  out << vSum(px->hVol[f]) << d;
979  }
980  out << "\n";
981 
982  out << common <<"tp" << d;
983  for(uint f=0;f<fTypes.size();f++){
984  for(uint u=0;u<dClasses.size()-1;u++){
985  out << px->tp[f][u]<< d;
986  }
987  out << 0 << d;
988  }
989  out << "\n";
990  out << common <<"mort" << d;
991  for(uint f=0;f<fTypes.size();f++){
992  for(uint u=0;u<dClasses.size()-1;u++){
993  out << px->mort[f][u]<< d;
994  }
995  out << 0 << d;
996  }
997  out << "\n";
998 
999  out << common <<"tp_multiplier" << d;
1000  for(uint f=0;f<fTypes.size();f++){
1001  for(uint u=0;u<dClasses.size()-1;u++){
1002  out << d;
1003  }
1004  out << px->getMultiplier("tp_multiplier",fTypes[f]) << d;
1005  }
1006  out << "\n";
1007  out << common <<"mortCoef_multiplier" << d;
1008  for(uint f=0;f<fTypes.size();f++){
1009  for(uint u=0;u<dClasses.size()-1;u++){
1010  out << d;
1011  }
1012  out << px->getMultiplier("mortCoef_multiplier",fTypes[f]) << d;
1013  }
1014  out << "\n";
1015 
1016 
1017  out << common <<"vMort" << d;
1018  for(uint f=0;f<fTypes.size();f++){
1019  for(uint u=0;u<dClasses.size()-1;u++){
1020  out << px->vMort[f][u]<< d;
1021  }
1022  out << vSum(px->vMort[f]) << d;
1023  }
1024  out << "\n";
1025 
1026  out << common <<"optDc" << d;
1027  for(uint f=0;f<fTypes.size();f++){
1028  for(uint u=0;u<dClasses.size()-1;u++){
1029  out << d;
1030  }
1031  out << px->optDc[f] << d;
1032  }
1033  out << "\n";
1034 
1035  out << common <<"expectedReturnsNotCorrByRa" << d;
1036  for(uint f=0;f<fTypes.size();f++){
1037  for(uint u=0;u<dClasses.size()-1;u++){
1038  out << d;
1039  }
1040  out << px->expectedReturnsNotCorrByRa[f] << d;
1041  }
1042  out << "\n";
1043 
1044  out << common <<"expectedReturns" << d;
1045  for(uint f=0;f<fTypes.size();f++){
1046  for(uint u=0;u<dClasses.size()-1;u++){
1047  out << d;
1048  }
1049  out << px->expectedReturns[f] << d;
1050  }
1051  out << "\n";
1052 
1053 
1054  out << common <<"optFtChosen" << d;
1055  for(uint f=0;f<fTypes.size();f++){
1056  for(uint u=0;u<dClasses.size()-1;u++){
1057  out << d;
1058  }
1059  out << px->optFtChosen[f] << d;
1060  }
1061  out << "\n";
1062 
1063  out << common <<"optDcChosen" << d;
1064  for(uint f=0;f<fTypes.size();f++){
1065  for(uint u=0;u<dClasses.size()-1;u++){
1066  out << d;
1067  }
1068  out << px->optDcChosen[f] << d;
1069  }
1070  out << "\n";
1071 
1072  //----
1073  out << common <<"deltaAreas" << d;
1074  for(uint f=0;f<fTypes.size();f++){
1075  for(uint u=0;u<dClasses.size()-1;u++){
1076  out << d;
1077  }
1078  out << d;
1079  }
1080  for(uint f=0;f<fTypes.size()+1;f++){
1081  for(uint f2=0;f2<fTypes.size()+1;f2++){ // +1 because there is also noforest
1082  out << px->deltaArea[f][f2]<<d;
1083  }
1084  }
1085  out << "\n";
1086  //----
1087 
1088 
1089 
1090  } // end for each pixel
1091  } // end for each region
1092  } // end filter
1093 } // end function printDebugPixelValues
1094 
1095 
1096 /**
1097 This routine clean the output scenario from previous outputs of the defined scenario.
1098 Other scenarios are untouched. The scenarioName must be in the first row.
1099 @param filename Filename of the output file to clean
1100 @param scenarioName Name of the scenario we are replacing
1101 @param d Field delimiter. It must not be changed in the meantime (between the various scenarios)
1102 */
1103 void
1104 Output::cleanScenario(string fileName, string scenarioName, char d){
1105  string dStr(&d,1);
1106  vector <string> rows;
1107  string tempRow;
1108  ifstream inFile (fileName.c_str(), ios::in);
1109  if (!inFile){
1110  msgOut(MSG_ERROR,"Error in opening the file "+fileName+" for reading.");
1111  return;
1112  }
1113  while( getline (inFile,tempRow) ){
1114  vector<string> tokens;
1115  tokenize(tempRow,tokens,dStr);
1116  if(tokens[0] != scenarioName)
1117  rows.push_back( tempRow );
1118  }
1119  inFile.close();
1120  ofstream out(fileName.c_str(), ios::out);
1121  for(uint i=0;i<rows.size();i++){
1122  out << rows[i];
1123  out << "\n";
1124  }
1125 }
1126 
1127  void
1128  Output::printDetailedHV(map<tr1::array<string, 4>,double> hVol_byPrd){
1129  if(!MTHREAD->MD->getBoolSetting("outDetailedHv",DATA_NOW)) return;
1130  outFileName = baseDir+oDir+"results/detailedHV_"+scenarioName+oFileExt;
1131  int currentYear = MTHREAD->SCD->getYear();
1132  ofstream outHV(outFileName.c_str(), ios::app);
1133  if (!outHV){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
1134  //outHV << "scen" << d << "parName" << d << "country" << d << "region" << d << "forType" << d << "freeDim" << d << "prod" << d << "year" << d << "value" << d;
1135  for (uint r1=0;r1<l2r.size();r1++){
1136  string reg1Id = i2s(l1regIds.at(r1));
1137  string reg1Name = MTHREAD->MD->regId2RegSName(l1regIds.at(r1));
1138  for (uint r2=0;r2<l2r[r1].size();r2++){
1139  string reg2Id = i2s(l2r[r1][r2]);
1140  string reg2Name = MTHREAD->MD->regId2RegSName(l2r[r1][r2]);
1141  for(uint j=0;j<fTypes.size();j++){
1142  string ft = fTypes[j];
1143  for(uint u=0;u<dClasses.size();u++){
1144  string dc = dClasses[u];
1145  if(dc == "") continue;
1146  for(uint p=0;p<priPr.size();p++){
1147  string prd = priPr[p];
1148  tr1::array<string, 4> hVKey = {reg2Id, ft, dc, prd};
1149  double value = findMap(hVol_byPrd,hVKey);
1150  outHV << scenarioName << d;
1151  outHV << "hVbyPrd" << d;
1152  outHV << reg1Name << d;
1153  outHV << reg2Name << d;
1154  outHV << ft << d;
1155  outHV << dc << d;
1156  outHV << prd << d;
1157  outHV << currentYear << d;
1158  outHV << value << d;
1159  outHV << "\n";
1160  }
1161  } //end dc
1162  } //end ft
1163  } // end r2
1164  } // end r1
1165 
1166 
1167  outHV.close();
1168 
1169  }
1170 
vector< vector< double > > deltaArea
Definition: Pixel.h:108
void initOutput()
Definition: Output.cpp:48
void printDebugOutput()
Definition: Output.cpp:845
vector< int > mapsOYears
Definition: Output.h:90
Print an ERROR message, but don&#39;t stop the model.
Definition: BaseClass.h:61
The required data is for the current year.
Definition: BaseClass.h:73
void initOutputProductData()
Definition: Output.cpp:338
int nSecPr
Definition: Output.h:110
int getIntSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1105
vector< vector< double > > area
Definition: Pixel.h:107
string debugFilename
Definition: Output.h:114
void initOutputForestData()
Definition: Output.cpp:296
vector< string > getForTypeParents()
Definition: ModelData.cpp:122
vector< string > dClasses
Definition: Output.h:107
bool getBoolSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1117
Do not actually output any message.
Definition: BaseClass.h:57
int nL2r
Definition: Output.h:112
void printCarbonBalance()
Definition: Output.cpp:729
string i2s(const int &int_h) const
integer to string conversion
Definition: BaseClass.cpp:219
Output(ThreadManager *MTHREAD_h)
Constructor.
Definition: Output.cpp:37
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
void printMaps()
Definition: Output.cpp:453
void printDebugPixelValues()
Definition: Output.cpp:882
ModelData * MD
the model data object
Definition: ThreadManager.h:72
string getBaseDirectory() const
Definition: ModelData.h:118
int getX() const
Definition: Pixel.h:68
void tokenize(const string &str, vector< string > &tokens, const string &delimiter=" ") const
Tokenize a string using a delimiter (default is space)
Definition: BaseClass.cpp:374
string outFileName
Definition: Output.h:93
double getCumSavedEmissions(const int &regId, const int &em_type) const
Returns the current cumulative saved emissions by type [Mt CO2].
Definition: Carbon.cpp:138
Output verbosity level print everything.
Definition: BaseClass.h:89
pair< string, vector< double > > DataPair
Definition: Output.cpp:34
vector< string > expReturnsDebugVariables
Definition: Output.h:76
double getStock(const int &regId, const int &stock_type) const
Returns the current stock of carbon [Mt CO2].
Definition: Carbon.cpp:53
vector< string > pDClasses
includes an empty string for variables without diameter attribute
Definition: Output.h:108
Output verbosity level print (also) the maps in ascii grid format.
Definition: BaseClass.h:87
void initDebugPixelValues()
Definition: Output.cpp:207
int outStepRange
Definition: Output.h:99
string logFilename
Definition: Output.h:113
vector< vector< double > > mort
Definition: Pixel.h:130
void printOptLog(bool optimal, int &nIterations, double &obj)
Definition: Output.cpp:829
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
Definition: ThreadManager.h:75
vector< vector< double > > vMort
Definition: Pixel.h:118
void msgOut(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
Overloaded function to print the output log.
Definition: BaseClass.cpp:50
string debugPxValuesFilename
Definition: Output.h:115
vector< string > secPr
Definition: Output.h:102
Gis * GIS
GIS information and methods.
Definition: ThreadManager.h:73
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
Definition: ThreadManager.h:65
vector< string > getStringVectorSetting(const string &name_h, int reg=WORLD) const
Definition: ModelData.cpp:1129
void printProductData(bool finalFlush=false)
Definition: Output.cpp:591
void initOptimisationLog()
Definition: Output.cpp:131
int oLevel
Definition: Output.h:79
Material substitution.
Definition: BaseClass.h:111
string oFileExt
Definition: Output.h:86
string baseDir
Definition: Output.h:83
vector< int > l1regIds
Definition: Output.h:104
int inYear
Definition: Output.h:81
Output verbosity level print aggregated output (e.g. optimisation log)
Definition: BaseClass.h:85
string getStringSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1113
const double getProdData(const string &type_h, const int &regId_h, const string &prodId_h, const int &year=DATA_NOW, const string &freeDim_h="")
Definition: ModelData.cpp:1216
Output verbosity level print (also) detailed output.
Definition: BaseClass.h:86
bool oHRedeable
Definition: Output.h:87
map< string, vector< double > > DataMap
Definition: Output.cpp:33
Print an error message and stop the model.
Definition: BaseClass.h:62
vector< string > allPr
Definition: Output.h:103
vector< vector< int > > l2r
Definition: Output.h:105
Output verbosity level print (also) binary (png) maps.
Definition: BaseClass.h:88
vector< int > optDcChosen
Definition: Pixel.h:122
Flow from forest operations.
Definition: BaseClass.h:112
void printBinMaps(string layerName_h="")
Save an image in standard png format.
Definition: Gis.cpp:963
int wRegId_l2
Definition: Output.h:92
const double getForData(const string &type_h, const int &regId_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW)
Definition: ModelData.cpp:1281
int vSum(const vector< int > &vector_h) const
Definition: BaseClass.h:276
int getYear()
Definition: Scheduler.h:49
vector< int > oYears
Definition: Output.h:89
void cleanScenario(string fileName, string scenarioName, char d)
Definition: Output.cpp:1104
Pixel-level class.
Definition: Pixel.h:47
Invetoried biomass (live and death tree logs)
Definition: BaseClass.h:104
Extra biomass (soils, branches..)
Definition: BaseClass.h:105
vector< vector< double > > vol
Definition: Pixel.h:90
double getMultiplier(const string &multiplierName, const string &forName, int year=DATA_NOW)
Definition: Pixel.cpp:184
char getOutputFieldDelimiter()
Definition: Output.cpp:804
Carbon * CBAL
Module for the Carbon Balance.
Definition: ThreadManager.h:79
void initCarbonBalance()
Definition: Output.cpp:370
void printForestData(bool finalFlush=false)
Definition: Output.cpp:476
char d
Definition: Output.h:80
vector< string > getForTypeIds(bool all=false)
By default it doesn&#39;t return forTypes used only as input.
Definition: ModelData.cpp:430
void printLayers(string layerName_h="")
Print the specified layer or all layers (if param layerName_h is missing).
Definition: Gis.cpp:940
int nAllPr
Definition: Output.h:111
vector< string > priPr
Definition: Output.h:101
bool oCarbonData
Definition: Output.h:98
vector< int > optFtChosen
Definition: Pixel.h:121
string getScenarioName()
vector< int > optDc
Definition: Pixel.h:120
vector< double > expectedReturns
Definition: Pixel.h:119
vector< string > outProdVariables
Definition: Output.h:95
V findMap(const map< K, V > &mymap, const K &key, const int &error_level=MSG_CRITICAL_ERROR, const V &notFoundValue=numeric_limits< V >::min()) const
Lookup a map for a value. Return the value starting from the key.
Definition: BaseClass.h:286
vector< vector< double > > tp
Definition: Pixel.h:131
void printFinalOutput()
Definition: Output.cpp:464
void commonInit()
Definition: Output.cpp:61
void printDetailedHV(map< tr1::array< string, 4 >, double > hVol_byPrd)
Definition: Output.cpp:1128
bool oForData
Definition: Output.h:96
vector< double > expectedReturnsNotCorrByRa
by ft. Attenction, reported expReturns at "forest" level (compared with those at forest type level) d...
Definition: Pixel.h:124
int nYears
Definition: Output.h:82
vector< vector< double > > hVol
Definition: Pixel.h:111
vector< int > getIntVectorSetting(const string &name_h, int reg=WORLD) const
Definition: ModelData.cpp:1121
void setErrorLevel(int errorLevel_h)
Definition: ModelData.h:143
~Output()
Definition: Output.cpp:41
Energy substitution.
Definition: BaseClass.h:110
vector< int > getRegionIds(int level_h, bool excludeResidual=true)
Definition: ModelData.cpp:366
void print(bool earlyPrint=true)
Print output. If earlyPrinting it doesn&#39;t print some stuff for which we don&#39;t yet have values...
Definition: Output.cpp:426
bool oSingleFile
Definition: Output.h:88
bool forestDiamDetailedOutput
Definition: Output.h:100
vector< vector< double > > hArea
Definition: Pixel.h:110
vector< ModelRegion * > getChildren(bool excludeResidual=true)
Returns a pointer to the parent regions.
Definition: ModelRegion.cpp:55
void initDebugOutput()
Definition: Output.cpp:170
string getOutputDirectory() const
Return a vector of objects that together provide the specified resource in the specified quantity...
Definition: ModelData.h:113
int nPriPr
Definition: Output.h:109
int wRegId_l1
Definition: Output.h:91
vector< vector< vector< vector< vector< double > > > > > expReturnsDebug
l2_region, for type, d.c., pr prod, variable name
Definition: Output.h:75
vector< Pixel * > getMyPixels()
Definition: ModelRegion.h:86
Print an INFO message.
Definition: BaseClass.h:59
ModelRegion * getRegion(int regId_h)
Definition: ModelData.cpp:346
bool oProdData
Definition: Output.h:97
Biomass in forest products (sawns, pannels..)
Definition: BaseClass.h:106
#define DIAM_ALL
All diameter classes.
Definition: BaseClass.h:157
vector< string > fTypes
Definition: Output.h:106
void initOutputMaps()
Definition: Output.cpp:406
int getY() const
Definition: Pixel.h:69
string scenarioName
Definition: Output.h:85
bool spMode
Definition: Output.h:116
double getID() const
Definition: Pixel.h:67
string regId2RegSName(const int &regId_h) const
Definition: ModelData.cpp:408
string oDir
Definition: Output.h:84
vector< string > outForVariables
Definition: Output.h:94