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  printMaps();
442  printForestData(false);
443  printProductData(false);
446  if(!earlyPrint) printDebugPixelValues();
448 }
449 
450 void
452  if(oLevel<OUTVL_MAPS) return;
453  int cYear = MTHREAD->SCD->getYear();
454  if ( find(mapsOYears.begin(), mapsOYears.end(), cYear) != mapsOYears.end() ){
455  MTHREAD->GIS->printLayers();
456  if(oLevel<OUTVL_BINMAPS) return;
458  }
459 }
460 
461 void
463  // we do this only if we choosed the outputHumanReadable settings, as we flush the data all in ones at the end.
464  // oterwise we flush data every year
465  if(oHRedeable){
467  printForestData(true);
468  printProductData(true);
470  }
471 }
472 
473 void
474 Output::printForestData(bool finalFlush){
475 
476  if(!oForData) return;
477  if(oHRedeable && !finalFlush) return;
478 
479  msgOut(MSG_INFO, "Printing forest data..");
480  int currentYear = MTHREAD->SCD->getYear();
481  if(oSingleFile){
482  outFileName = baseDir+oDir+"results/forestData"+oFileExt;
483  } else {
484  outFileName = baseDir+oDir+"results/forestData_"+scenarioName+oFileExt;
485  }
486  ofstream out (outFileName.c_str(), ios::app);
487  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for writing.");}
488  double outvalue;
489  for(uint v=0;v<outForVariables.size();v++){
490  vector<string>fTypes_temp = fTypes;
491  if( outForVariables[v]=="expReturns" || outForVariables[v]=="sumExpReturns" || outForVariables[v]=="totalShareInvadedArea") {
492  fTypes_temp.push_back(""); // adding an empty forest type to report for variables that doesn't have a forestType dimension
493  vector<string> ftParents = MTHREAD->MD->getForTypeParents();
494  fTypes_temp.insert(fTypes_temp.end(),ftParents.begin(),ftParents.end()); // also inserting forest type "parents" for expected returns
495  }
496  for (uint r1=0;r1<l2r.size();r1++){
497  for (uint r2=0;r2<l2r[r1].size();r2++){
498  for(uint ft=0;ft<fTypes_temp.size();ft++){
500  for(uint dc=0;dc<dClasses.size();dc++){ // an empty "" dc has been already added to the vector
501  out << scenarioName << d;
502  out << outForVariables[v] << d;
503  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
504  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
505  out << fTypes_temp[ft] << d;
506  out << dClasses[dc] << d;
507  if (oHRedeable){
508  for(int y=0;y<nYears;y++){
509  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],dClasses[dc],y+inYear);
510  out << outvalue << d;
511  }
512  out << "\n";
513  } else {
514  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],dClasses[dc]);
515  out << currentYear << d;
516  out << outvalue << d;
517  out << "\n";
518  }
519  }
520  } else {
521  out << scenarioName << d;
522  out << outForVariables[v] << d;
523  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
524  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
525  out << fTypes_temp[ft] << d;
526  out << d;
527  if (oHRedeable){
528  for(int y=0;y<nYears;y++){
529  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],DIAM_ALL,y+inYear);
530  out << outvalue << d;
531  }
532  out << "\n";
533  } else {
534  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],DIAM_ALL);
535  out << currentYear << d;
536  out << outvalue << d;
537  out << "\n";
538  }
539  }
540  }
541  }
542  }
543  }
544  /*
545  DataMap::const_iterator i;
546  string key;
547  vector <double> values;
548  string parName;
549  int regId;
550  string forType;
551  string diamClass;
552  for(i=MTHREAD->MD->forDataMap.begin();i!=MTHREAD->MD->forDataMap.end();i++){
553  key = i->first;
554  values = i->second;
555  MTHREAD->MD->unpackKeyForData(key, parName, regId, forType, diamClass);
556  ModelRegion* REG = MTHREAD->MD->getRegion(regId);
557  // we don't want to output data from residual region unless it's the world region we are speaking of
558  if(REG->getIsResidual() && !(regId==wRegId_l1 || regId==wRegId_l2)) continue;
559  out << scenarioName << d;
560  out << parName << d;
561  if (REG->getRegLevel()==2){
562  ModelRegion* pREG = MTHREAD->MD->getRegion(REG->getParRegId());
563  out << pREG->getRegSName() << d;
564  out << REG->getRegSName() << d;
565  } else if (REG->getRegLevel()==1){
566  out << REG->getRegSName() << d;
567  out << d;
568  } else {
569  out << d << d;
570  }
571  out << forType << d;
572  out << diamClass << d;
573  if (oHRedeable){
574  for(int y=0;y<nYears;y++){
575  out << MTHREAD->MD->getTimedData(values,y+inYear) << d;
576  }
577  out << "\n";
578  } else {
579  out << currentYear << d;
580  out << MTHREAD->MD->getTimedData(values,currentYear) << d;
581  out << "\n";
582  }
583  }
584  */
585  out.close();
586 }
587 
588 void
589 Output::printProductData(bool finalFlush){
590 
591  if(!oProdData) return;
592  if(oHRedeable && !finalFlush) return;
593 
594  msgOut(MSG_INFO, "Printing market data..");
595  int currentYear = MTHREAD->SCD->getYear();
596 
597  if(oSingleFile){
598  outFileName = baseDir+oDir+"results/productData"+oFileExt;
599  } else {
600  outFileName = baseDir+oDir+"results/productData_"+scenarioName+oFileExt;
601  }
602  ofstream out (outFileName.c_str(), ios::app);
603  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for writing.");}
604 
605 
606  //11042 hardWSawnW 11083 0.00230651
607  //11042 hardWSawnW 11082 0.0390874
608 
609  //if(MTHREAD->SCD->getYear() == 2007){
610 // double test = MTHREAD->MD->getProdData("rt",11042,"hardWSawnW",DATA_NOW);
611 // double test2 = MTHREAD->MD->getProdData("rt",11042,"hardWSawnW",DATA_NOW,"11083");
612 // double test3 = MTHREAD->MD->getProdData("rt",11042,"hardWSawnW",DATA_NOW,"11082");
613 // cout << test << '\t' << test2 << '\t' << test3 << endl;
614 // exit(0);
615 // }
616 
617  double outvalue;
618  for(uint v=0;v<outProdVariables.size();v++){
619  for (uint r1=0;r1<l2r.size();r1++){
620  for (uint r2=0;r2<l2r[r1].size();r2++){
621  for(uint p=0;p<allPr.size();p++){
622 
623  if(outProdVariables[v]=="rt"){
624  for(uint r2b=0;r2b<l2r[r1].size();r2b++){
625  out << scenarioName << d;
626  out << outProdVariables[v] << d;
627  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
628  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
629  out << allPr[p] << d;
630  out << l2r[r1][r2b] << d;
631  if (oHRedeable){
632  for(int y=0;y<nYears;y++){
633  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],y+inYear,i2s(l2r[r1][r2b]));
634  out << outvalue << d;
635  }
636  out << "\n";
637  } else {
638 // if(MTHREAD->SCD->getYear() == 2007 && l2r[r1][r2] == 11042 && allPr[p] == "hardWSawnW" && (l2r[r1][r2b]== 11083 || l2r[r1][r2b]== 11082 )){
639 // outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],currentYear,i2s(l2r[r1][r2b]));
640 // cout << outvalue << endl;
641 // }
642  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],currentYear,i2s(l2r[r1][r2b]));
643  out << currentYear << d;
644  out << outvalue << d;
645  out << "\n";
646  }
647  }
648  } else {
649  out << scenarioName << d;
650  out << outProdVariables[v] << d;
651  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
652  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
653  out << allPr[p] << d;
654  out << d;
655  if (oHRedeable){
656  for(int y=0;y<nYears;y++){
657  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],y+inYear);
658  out << outvalue << d;
659  }
660  out << "\n";
661  } else {
662  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p]);
663  out << currentYear << d;
664  out << outvalue << d;
665  out << "\n";
666  }
667 
668  }
669  }
670  }
671  }
672  }
673 
674 
675 
676 
677 /*
678  DataMap::const_iterator i;
679  string key;
680  vector <double> values;
681  string parName;
682  int regId;
683  string prod;
684  string freeDim;
685  for(i=MTHREAD->MD->prodDataMap.begin();i!=MTHREAD->MD->prodDataMap.end();i++){
686  key = i->first;
687  values = i->second;
688  MTHREAD->MD->unpackKeyProdData(key, parName, regId, prod, freeDim);
689  ModelRegion* REG = MTHREAD->MD->getRegion(regId);
690  // we don't want to output data from residual region unless it's the world region we are speaking of
691  if(REG->getIsResidual() && !(regId==wRegId_l1 || regId==wRegId_l2)) continue;
692  out << scenarioName << d;
693  out << parName << d;
694  if (REG->getRegLevel()==2){
695  ModelRegion* pREG = MTHREAD->MD->getRegion(REG->getParRegId());
696  out << pREG->getRegSName() << d;
697  out << REG->getRegSName() << d;
698  } else if (REG->getRegLevel()==1){
699  out << REG->getRegSName() << d;
700  out << d;
701  } else {
702  out << d << d;
703  }
704  out << prod << d;
705  out << freeDim << d;
706  if (oHRedeable){
707  for(int y=0;y<nYears;y++){
708  out << MTHREAD->MD->getTimedData(values,y+inYear) << d;
709  }
710  out << "\n";
711  } else {
712  out << currentYear << d;
713  out << MTHREAD->MD->getTimedData(values,currentYear) << d;
714  out << "\n";
715  }
716  }
717 
718 */
719  out.close();
720 }
721 
722 
723 
724 
725 
726 void
728 
729  if(!oCarbonData) return;
730  int currentYear = MTHREAD->SCD->getYear();
731  if (currentYear == inYear) {return;} // don't print carbon balance on first year, carbon balance containers has not yet been initialised
732 
733  msgOut(MSG_INFO, "Printing forest data..");
734 
735  if(oSingleFile){
736  outFileName = baseDir+oDir+"results/carbonBalance"+oFileExt;
737  } else {
738  outFileName = baseDir+oDir+"results/carbonBalance_"+scenarioName+oFileExt;
739  }
740  ofstream out (outFileName.c_str(), ios::app);
741  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for writing.");}
742  double outvalue=0;
743 
745 
746  for (uint r1=0;r1<l2r.size();r1++){
747  for (uint r2=0;r2<l2r[r1].size();r2++){
748  int regId = l2r[r1][r2];
749  for (uint b=0;b<balItems.size();b++){
750  out << scenarioName << d;
751  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
752  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
753  string balItemString;
754  switch(balItems[b]){
755  case STOCK_INV: {
756  balItemString = "STOCK_INV";
757  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
758  break;
759  }
760  case STOCK_EXTRA: {
761  balItemString = "STOCK_EXTRA";
762  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
763  break;
764  }
765  case STOCK_PRODUCTS: {
766  balItemString = "STOCK_PRODUCTS";
767  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
768  break;
769  }
770  case EM_ENSUB: {
771  balItemString = "EM_ENSUB";
772  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
773  break;
774  }
775  case EM_MATSUB: {
776  balItemString = "EM_MATSUB";
777  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
778  break;
779  }
780  case EM_FOROP: {
781  balItemString = "EM_FOROP";
782  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
783  break;
784  }
785  default:
786  msgOut(MSG_CRITICAL_ERROR,"Unexpected balance item type in function printCarbonBalance");
787  }
788  out << balItemString << d;
789  out << currentYear << d;
790  out << outvalue << d;
791  out << "\n";
792 
793 
794  } // end bal items
795  } // end r2
796  } // end r1
797  out.close();
798 }
799 
800 
801 char
803  int delimiterID = MTHREAD->MD->getIntSetting("outputFieldDelimiter");
804  switch (delimiterID) {
805  case 1:
806  return ',';
807  break;
808  case 2:
809  return ';';
810  break;
811  case 3:
812  return ':';
813  break;
814  case 4:
815  return '\t';
816  break;
817  case 5:
818  return ' ';
819  break;
820  default:
821  msgOut(MSG_ERROR, "You have specified an unknow output file field delimiter. Using \";\".");
822  return ',';
823  }
824 }
825 
826 void
827 Output::printOptLog(bool optimal, int &nIterations, double &obj){
828  if(oLevel<OUTVL_AGGREGATED) return;
829 
830  ofstream out(logFilename.c_str(), ios::app);
831  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+logFilename+" for writing.");}
832  time_t now;
833  time(&now);
834  struct tm *current = localtime(&now);
835  string timemessage = i2s(current->tm_hour)+":"+i2s(current->tm_min)+":"+ i2s(current->tm_sec);
836  out << scenarioName << d << MTHREAD->SCD->getYear() << d << timemessage << d << optimal;
837  out << d << nIterations << d << obj << "\n";
838  out.close();
839 
840 }
841 
842 void
844  if(oLevel<OUTVL_ALL) return;
845 
846  // print debugging the expected returns...
847 
848  if (!spMode && !expReturnsDebug.empty()){
849  ofstream out (debugFilename.c_str(), ios::app);
850  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugFilename+" for writing.");}
851  int currentYear = MTHREAD->SCD->getYear();
852  vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
853 
854  for (uint r2=0;r2<regIds2.size();r2++){
855  for(uint ft=0;ft<fTypes.size();ft++){
856  for(uint dc=0;dc<(dClasses.size()-1);dc++){
857  for(uint pp=0;pp<priPr.size();pp++){
858  for(uint dv=0;dv<expReturnsDebugVariables.size();dv++){
859  // vector <vector < vector <vector <vector <double> > > > > expReturnsDebug;
860  double outputValue = expReturnsDebug.at(r2).at(ft).at(dc).at(pp).at(dv);
861  out << scenarioName << d;
862  out << currentYear << d;
863  out << MTHREAD->MD->regId2RegSName(regIds2[r2]) << d;
864  out << fTypes[ft] << d;
865  out << dClasses[dc] << d;
866  out << priPr[pp] << d;
867  out << expReturnsDebugVariables[dv] << d;
868  out << outputValue << d;
869  out << "\n";
870  }
871  }
872  }
873  }
874  }
875 
876  } // end initial condition checks
877 }
878 
879 void
881 
882  if(oLevel<OUTVL_ALL) return;
883 
884  bool filter;
885  filter = true; //use this to filter output
886  if(filter && spMode){
887  ofstream out (debugPxValuesFilename.c_str(), ios::app);
888  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugPxValuesFilename+" for writing.");}
889  int currentYear = MTHREAD->SCD->getYear();
890  vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
891  for (uint r=0;r<regIds2.size();r++){
892  int rId = regIds2[r];
893  //if(rId != 11002) continue;
894  ModelRegion* REG = MTHREAD->MD->getRegion(rId);
895  vector<Pixel*> regPx = REG->getMyPixels();
896  for (uint p=0;p<regPx.size();p++){
897  Pixel* px = regPx[p];
898  int pxID = px->getID();
899  int pxX = px->getX();
900  int pxY = px->getY();
901  string common = scenarioName + d + i2s(currentYear) + d + i2s(rId) + d+ i2s(pxID) +d +i2s(pxX)+d+i2s(pxY)+d;
902 
903 
904 // for(uint f=0;f<fTypes.size();f++){
905 // double tp_m = px->getMultiplier("tp_multiplier",fTypes[f]);
906 // common += d2s(tp_m)+d;
907 // }
908 // for(uint f=0;f<fTypes.size();f++){
909 // double m_m = px->getMultiplier("mortCoef_multiplier",fTypes[f]);
910 // common += d2s(m_m)+d;
911 // }
912 
913 
914 // // First vars by only ft...
915 // // expectedReturns
916 // out << common << "expectedReturns" << d;
917 // for(uint f=0;f<fTypes.size();f++){
918 // for(uint u=0;u<dClasses.size()-1;u++){
919 // out << d;
920 // }
921 // out << px->expectedReturns[f] << d;
922 // //out << 0.0 << d;
923 // }
924 // out << "\n";
925 
926  //----
927 
928  vector <string> outVars = MTHREAD->MD->getStringVectorSetting("debugVariablesToPrint");
929 
930  if (std::find(outVars.begin(), outVars.end(), "vol") != outVars.end()){
931  out << common <<"vol" << d;
932  for(uint f=0;f<fTypes.size();f++){
933  for(uint u=0;u<dClasses.size()-1;u++){
934  out << px->vol[f][u]<< d;
935  }
936  out << vSum(px->vol[f]) << d;
937  }
938  out << "\n";
939  }
940 
941  if (std::find(outVars.begin(), outVars.end(), "area") != outVars.end()){
942  out << common <<"area" << d;
943  for(uint f=0;f<fTypes.size();f++){
944  for(uint u=0;u<dClasses.size()-1;u++){
945  out << px->area[f][u]<< d;
946  }
947  out << vSum(px->area[f]) << d;
948  }
949  out << "\n";
950  }
951 
952  if (std::find(outVars.begin(), outVars.end(), "hArea") != outVars.end()){
953  out << common <<"hArea" << d;
954  for(uint f=0;f<fTypes.size();f++){
955  for(uint u=0;u<dClasses.size()-1;u++){
956  out << px->hArea[f][u]<< d;
957  }
958  out << vSum(px->hArea[f]) << d;
959  }
960  out << "\n";
961  }
962 
963  if (std::find(outVars.begin(), outVars.end(), "hVol") != outVars.end()){
964  out << common <<"hVol" << d;
965  for(uint f=0;f<fTypes.size();f++){
966  for(uint u=0;u<dClasses.size()-1;u++){
967  out << px->hVol[f][u]<< d;
968  }
969  out << vSum(px->hVol[f]) << d;
970  }
971  out << "\n";
972  }
973 
974  if (std::find(outVars.begin(), outVars.end(), "tp") != outVars.end()){
975  out << common <<"tp" << d;
976  for(uint f=0;f<fTypes.size();f++){
977  for(uint u=0;u<dClasses.size()-1;u++){
978  out << px->tp[f][u]<< d;
979  }
980  out << 0 << d;
981  }
982  out << "\n";
983  }
984 
985  if (std::find(outVars.begin(), outVars.end(), "mort") != outVars.end()){
986  out << common <<"mort" << d;
987  for(uint f=0;f<fTypes.size();f++){
988  for(uint u=0;u<dClasses.size()-1;u++){
989  out << px->mort[f][u]<< d;
990  }
991  out << 0 << d;
992  }
993  out << "\n";
994  }
995 
996  if (std::find(outVars.begin(), outVars.end(), "tp_multiplier") != outVars.end()){
997  out << common <<"tp_multiplier" << d;
998  for(uint f=0;f<fTypes.size();f++){
999  for(uint u=0;u<dClasses.size()-1;u++){
1000  out << d;
1001  }
1002  out << px->getMultiplier("tp_multiplier",fTypes[f]) << d;
1003  }
1004  out << "\n";
1005  }
1006 
1007  if (std::find(outVars.begin(), outVars.end(), "mortCoef_multiplier") != outVars.end()){
1008  out << common <<"mortCoef_multiplier" << d;
1009  for(uint f=0;f<fTypes.size();f++){
1010  for(uint u=0;u<dClasses.size()-1;u++){
1011  out << d;
1012  }
1013  out << px->getMultiplier("mortCoef_multiplier",fTypes[f]) << d;
1014  }
1015  out << "\n";
1016  }
1017 
1018  if (std::find(outVars.begin(), outVars.end(), "vMort") != outVars.end()){
1019  out << common <<"vMort" << d;
1020  for(uint f=0;f<fTypes.size();f++){
1021  for(uint u=0;u<dClasses.size()-1;u++){
1022  out << px->vMort[f][u]<< d;
1023  }
1024  out << vSum(px->vMort[f]) << d;
1025  }
1026  out << "\n";
1027  }
1028 
1029  if (std::find(outVars.begin(), outVars.end(), "vMortAdd") != outVars.end()){
1030  out << common <<"vMortAdd" << d;
1031  for(uint f=0;f<fTypes.size();f++){
1032  for(uint u=0;u<dClasses.size()-1;u++){
1033  out << px->vMortAdd[f][u]<< d;
1034  }
1035  out << vSum(px->vMortAdd[f]) << d;
1036  }
1037  out << "\n";
1038  }
1039 
1040  if (std::find(outVars.begin(), outVars.end(), "optDc") != outVars.end()){
1041  out << common <<"optDc" << d;
1042  for(uint f=0;f<fTypes.size();f++){
1043  for(uint u=0;u<dClasses.size()-1;u++){
1044  out << d;
1045  }
1046  out << px->optDc[f] << d;
1047  }
1048  out << "\n";
1049  }
1050 
1051  if (std::find(outVars.begin(), outVars.end(), "expectedAnnualIncome_timber") != outVars.end()){
1052  out << common <<"expectedAnnualIncome_timber" << d;
1053  for(uint f=0;f<fTypes.size();f++){
1054  for(uint u=0;u<dClasses.size()-1;u++){
1055  out << d;
1056  }
1057  out << px->expectedAnnualIncome_timber[f] << d;
1058  }
1059  out << "\n";
1060  }
1061 
1062  if (std::find(outVars.begin(), outVars.end(), "expectedAnnualIncome_carbon") != outVars.end()){
1063  out << common <<"expectedAnnualIncome_carbon" << 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->expectedAnnualIncome_carbon[f] << d;
1069  }
1070  out << "\n";
1071  }
1072 
1073  if (std::find(outVars.begin(), outVars.end(), "expectedReturnsNotCorrByRa") != outVars.end()){
1074  out << common <<"expectedReturnsNotCorrByRa" << d;
1075  for(uint f=0;f<fTypes.size();f++){
1076  for(uint u=0;u<dClasses.size()-1;u++){
1077  out << d;
1078  }
1079  out << px->expectedReturnsNotCorrByRa[f] << d;
1080  }
1081  out << "\n";
1082  }
1083 
1084  if (std::find(outVars.begin(), outVars.end(), "expectedReturns") != outVars.end()){
1085  out << common <<"expectedReturns" << d;
1086  for(uint f=0;f<fTypes.size();f++){
1087  for(uint u=0;u<dClasses.size()-1;u++){
1088  out << d;
1089  }
1090  out << px->expectedReturns[f] << d;
1091  }
1092  out << "\n";
1093  }
1094 
1095  if (std::find(outVars.begin(), outVars.end(), "optFtChosen") != outVars.end()){
1096  out << common <<"optFtChosen" << d;
1097  for(uint f=0;f<fTypes.size();f++){
1098  for(uint u=0;u<dClasses.size()-1;u++){
1099  out << d;
1100  }
1101  out << px->optFtChosen[f] << d;
1102  }
1103  out << "\n";
1104  }
1105 
1106  if (std::find(outVars.begin(), outVars.end(), "optDcChosen") != outVars.end()){
1107  out << common <<"optDcChosen" << d;
1108  for(uint f=0;f<fTypes.size();f++){
1109  for(uint u=0;u<dClasses.size()-1;u++){
1110  out << d;
1111  }
1112  out << px->optDcChosen[f] << d;
1113  }
1114  out << "\n";
1115  }
1116 
1117  if (std::find(outVars.begin(), outVars.end(), "deltaAreas") != outVars.end()){
1118  out << common <<"deltaAreas" << d;
1119  for(uint f=0;f<fTypes.size();f++){
1120  for(uint u=0;u<dClasses.size()-1;u++){
1121  out << d;
1122  }
1123  out << d;
1124  }
1125  for(uint f=0;f<fTypes.size()+1;f++){
1126  for(uint f2=0;f2<fTypes.size()+1;f2++){ // +1 because there is also noforest
1127  out << px->deltaArea[f][f2]<<d;
1128  }
1129  }
1130  out << "\n";
1131  }
1132 
1133 
1134 
1135  } // end for each pixel
1136  } // end for each region
1137  } // end filter
1138 } // end function printDebugPixelValues
1139 
1140 
1141 /**
1142 This routine clean the output scenario from previous outputs of the defined scenario.
1143 Other scenarios are untouched. The scenarioName must be in the first row.
1144 @param filename Filename of the output file to clean
1145 @param scenarioName Name of the scenario we are replacing
1146 @param d Field delimiter. It must not be changed in the meantime (between the various scenarios)
1147 */
1148 void
1149 Output::cleanScenario(string fileName, string scenarioName, char d){
1150  string dStr(&d,1);
1151  vector <string> rows;
1152  string tempRow;
1153  ifstream inFile (fileName.c_str(), ios::in);
1154  if (!inFile){
1155  msgOut(MSG_ERROR,"Error in opening the file "+fileName+" for reading.");
1156  return;
1157  }
1158  while( getline (inFile,tempRow) ){
1159  vector<string> tokens;
1160  tokenize(tempRow,tokens,dStr);
1161  if(tokens[0] != scenarioName)
1162  rows.push_back( tempRow );
1163  }
1164  inFile.close();
1165  ofstream out(fileName.c_str(), ios::out);
1166  for(uint i=0;i<rows.size();i++){
1167  out << rows[i];
1168  out << "\n";
1169  }
1170 }
1171 
1172  void
1173  Output::printDetailedHV(map<tr1::array<string, 4>,double> hVol_byPrd){
1174  if(!MTHREAD->MD->getBoolSetting("outDetailedHv",DATA_NOW)) return;
1175  outFileName = baseDir+oDir+"results/detailedHV_"+scenarioName+oFileExt;
1176  int currentYear = MTHREAD->SCD->getYear();
1177  ofstream outHV(outFileName.c_str(), ios::app);
1178  if (!outHV){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
1179  //outHV << "scen" << d << "parName" << d << "country" << d << "region" << d << "forType" << d << "freeDim" << d << "prod" << d << "year" << d << "value" << d;
1180  for (uint r1=0;r1<l2r.size();r1++){
1181  string reg1Id = i2s(l1regIds.at(r1));
1182  string reg1Name = MTHREAD->MD->regId2RegSName(l1regIds.at(r1));
1183  for (uint r2=0;r2<l2r[r1].size();r2++){
1184  string reg2Id = i2s(l2r[r1][r2]);
1185  string reg2Name = MTHREAD->MD->regId2RegSName(l2r[r1][r2]);
1186  for(uint j=0;j<fTypes.size();j++){
1187  string ft = fTypes[j];
1188  for(uint u=0;u<dClasses.size();u++){
1189  string dc = dClasses[u];
1190  if(dc == "") continue;
1191  for(uint p=0;p<priPr.size();p++){
1192  string prd = priPr[p];
1193  tr1::array<string, 4> hVKey = {reg2Id, ft, dc, prd};
1194  double value = findMap(hVol_byPrd,hVKey);
1195  outHV << scenarioName << d;
1196  outHV << "hVbyPrd" << d;
1197  outHV << reg1Name << d;
1198  outHV << reg2Name << d;
1199  outHV << ft << d;
1200  outHV << dc << d;
1201  outHV << prd << d;
1202  outHV << currentYear << d;
1203  outHV << value << d;
1204  outHV << "\n";
1205  }
1206  } //end dc
1207  } //end ft
1208  } // end r2
1209  } // end r1
1210 
1211 
1212  outHV.close();
1213 
1214  }
1215 
vector< vector< double > > deltaArea
Definition: Pixel.h:108
void initOutput()
Definition: Output.cpp:48
void printDebugOutput()
Definition: Output.cpp:843
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:727
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:451
void printDebugPixelValues()
Definition: Output.cpp:880
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:133
void printOptLog(bool optimal, int &nIterations, double &obj)
Definition: Output.cpp:827
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< double > expectedAnnualIncome_carbon
Definition: Pixel.h:124
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 initOptimisationLog()
Definition: Output.cpp:131
int oLevel
Definition: Output.h:79
Material substitution.
Definition: BaseClass.h:111
string oFileExt
Definition: Output.h:86
void printProductData(bool finalFlush)
Definition: Output.cpp:589
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< vector< double > > vMortAdd
Definition: Pixel.h:119
vector< int > optDcChosen
Definition: Pixel.h:123
Flow from forest operations.
Definition: BaseClass.h:112
void printBinMaps(string layerName_h="")
Save an image in standard png format.
Definition: Gis.cpp:963
vector< double > expectedAnnualIncome_timber
Definition: Pixel.h:125
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:1149
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:802
Carbon * CBAL
Module for the Carbon Balance.
Definition: ThreadManager.h:79
void initCarbonBalance()
Definition: Output.cpp:370
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:122
string getScenarioName()
vector< int > optDc
Definition: Pixel.h:121
vector< double > expectedReturns
Definition: Pixel.h:120
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:135
void printFinalOutput()
Definition: Output.cpp:462
void commonInit()
Definition: Output.cpp:61
void printDetailedHV(map< tr1::array< string, 4 >, double > hVol_byPrd)
Definition: Output.cpp:1173
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:127
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
void printForestData(bool finalFlush)
Definition: Output.cpp:474
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