Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/catchstatistics.cc
[mareframe] / trunk / gadget / catchstatistics.cc Repository:
ViewVC logotype

Annotation of /trunk/gadget/catchstatistics.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #include "catchstatistics.h"
2 :     #include "readfunc.h"
3 :     #include "readword.h"
4 :     #include "errorhandler.h"
5 :     #include "areatime.h"
6 :     #include "fleet.h"
7 :     #include "stock.h"
8 :     #include "stockprey.h"
9 :     #include "mathfunc.h"
10 :     #include "readaggregation.h"
11 :     #include "gadget.h"
12 :     #include "global.h"
13 :    
14 :     CatchStatistics::CatchStatistics(CommentStream& infile, const AreaClass* const Area,
15 :     const TimeClass* const TimeInfo, double weight, const char* name)
16 :     : Likelihood(CATCHSTATISTICSLIKELIHOOD, weight, name), alptr(0) {
17 :    
18 :     char text[MaxStrLength];
19 :     strncpy(text, "", MaxStrLength);
20 :     int i, j;
21 :     int numarea = 0, numage = 0;
22 :    
23 :     char datafilename[MaxStrLength];
24 :     char aggfilename[MaxStrLength];
25 :     strncpy(datafilename, "", MaxStrLength);
26 :     strncpy(aggfilename, "", MaxStrLength);
27 :     ifstream datafile;
28 :     CommentStream subdata(datafile);
29 :    
30 :     timeindex = 0;
31 :     functionname = new char[MaxStrLength];
32 :     strncpy(functionname, "", MaxStrLength);
33 :     readWordAndValue(infile, "datafile", datafilename);
34 :     readWordAndValue(infile, "function", functionname);
35 :     //JMB - changed to make the reading of overconsumption optional
36 :     infile >> ws;
37 :     char c = infile.peek();
38 :     if ((c == 'o') || (c == 'O'))
39 :     readWordAndVariable(infile, "overconsumption", overconsumption);
40 :     else
41 :     overconsumption = 0;
42 :    
43 :     if (overconsumption != 0 && overconsumption != 1)
44 :     handle.logFileMessage(LOGFAIL, "\nError in catchstatistics - overconsumption must be 0 or 1");
45 :    
46 :     if ((strcasecmp(functionname, "lengthcalcvar") == 0) || (strcasecmp(functionname, "lengthcalcstddev") == 0))
47 :     functionnumber = 1;
48 :     else if ((strcasecmp(functionname, "lengthgivenvar") == 0) || (strcasecmp(functionname, "lengthgivenstddev") == 0))
49 :     functionnumber = 2;
50 :     else if ((strcasecmp(functionname, "weightgivenvar") == 0) || (strcasecmp(functionname, "weightgivenstddev") == 0))
51 :     functionnumber = 3;
52 :     else if ((strcasecmp(functionname, "weightnovar") == 0) || (strcasecmp(functionname, "weightnostddev") == 0))
53 :     functionnumber = 4;
54 :     else if ((strcasecmp(functionname, "lengthnovar") == 0) || (strcasecmp(functionname, "lengthnostddev") == 0))
55 :     functionnumber = 5;
56 :     else
57 :     handle.logFileMessage(LOGFAIL, "\nError in catchstatistics - unrecognised function", functionname);
58 :    
59 :     //read in area aggregation from file
60 :     readWordAndValue(infile, "areaaggfile", aggfilename);
61 :     datafile.open(aggfilename, ios::in);
62 :     handle.checkIfFailure(datafile, aggfilename);
63 :     handle.Open(aggfilename);
64 :     numarea = readAggregation(subdata, areas, areaindex);
65 :     handle.Close();
66 :     datafile.close();
67 :     datafile.clear();
68 :    
69 :     //read in age aggregation from file
70 :     readWordAndValue(infile, "ageaggfile", aggfilename);
71 :     datafile.open(aggfilename, ios::in);
72 :     handle.checkIfFailure(datafile, aggfilename);
73 :     handle.Open(aggfilename);
74 :     numage = readAggregation(subdata, ages, ageindex);
75 :     handle.Close();
76 :     datafile.close();
77 :     datafile.clear();
78 :    
79 :     //Must change from outer areas to inner areas.
80 :     for (i = 0; i < areas.Nrow(); i++)
81 :     for (j = 0; j < areas.Ncol(i); j++)
82 :     areas[i][j] = Area->getInnerArea(areas[i][j]);
83 :    
84 :     //read in the fleetnames
85 :     i = 0;
86 :     infile >> text >> ws;
87 :     if (strcasecmp(text, "fleetnames") != 0)
88 :     handle.logFileUnexpected(LOGFAIL, "fleetnames", text);
89 :     infile >> text >> ws;
90 :     while (!infile.eof() && (strcasecmp(text, "stocknames") != 0)) {
91 :     fleetnames.resize(new char[strlen(text) + 1]);
92 :     strcpy(fleetnames[i++], text);
93 :     infile >> text >> ws;
94 :     }
95 :     if (fleetnames.Size() == 0)
96 :     handle.logFileMessage(LOGFAIL, "\nError in catchstatistics - failed to read fleets");
97 :     handle.logMessage(LOGMESSAGE, "Read fleet data - number of fleets", fleetnames.Size());
98 :    
99 :     //read in the stocknames
100 :     i = 0;
101 :     if (strcasecmp(text, "stocknames") != 0)
102 :     handle.logFileUnexpected(LOGFAIL, "stocknames", text);
103 :     infile >> text;
104 :     while (!infile.eof() && (strcasecmp(text, "[component]") != 0)) {
105 :     infile >> ws;
106 :     stocknames.resize(new char[strlen(text) + 1]);
107 :     strcpy(stocknames[i++], text);
108 :     infile >> text;
109 :     }
110 :     if (stocknames.Size() == 0)
111 :     handle.logFileMessage(LOGFAIL, "\nError in catchstatistics - failed to read stocks");
112 :     handle.logMessage(LOGMESSAGE, "Read stock data - number of stocks", stocknames.Size());
113 :    
114 :     //We have now read in all the data from the main likelihood file
115 :     //But we have to read in the statistics data from datafilename
116 :     datafile.open(datafilename, ios::in);
117 :     handle.checkIfFailure(datafile, datafilename);
118 :     handle.Open(datafilename);
119 :     readStatisticsData(subdata, TimeInfo, numarea, numage);
120 :     handle.Close();
121 :     datafile.close();
122 :     datafile.clear();
123 :     }
124 :    
125 :     void CatchStatistics::readStatisticsData(CommentStream& infile,
126 :     const TimeClass* TimeInfo, int numarea, int numage) {
127 :    
128 :     int i, year, step;
129 :     double tmpnumber, tmpmean, tmpstddev;
130 :     char tmparea[MaxStrLength], tmpage[MaxStrLength];
131 :     strncpy(tmparea, "", MaxStrLength);
132 :     strncpy(tmpage, "", MaxStrLength);
133 :     int keepdata, needvar, readvar;
134 :     int timeid, ageid, areaid, count, reject;
135 :    
136 :     readvar = 0;
137 :     needvar = 0;
138 :     switch (functionnumber) {
139 :     case 1:
140 :     readvar = 0;
141 :     needvar = 1;
142 :     break;
143 :     case 2:
144 :     case 3:
145 :     readvar = 1;
146 :     needvar = 1;
147 :     break;
148 :     case 4:
149 :     case 5:
150 :     break;
151 :     default:
152 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - unrecognised function", functionname);
153 :     break;
154 :     }
155 :    
156 :     //Check the number of columns in the inputfile
157 :     infile >> ws;
158 :     if ((readvar) && (countColumns(infile) != 7))
159 :     handle.logFileMessage(LOGFAIL, "wrong number of columns in inputfile - should be 7");
160 :     else if ((!readvar) && (countColumns(infile) != 6))
161 :     handle.logFileMessage(LOGFAIL, "wrong number of columns in inputfile - should be 6");
162 :    
163 :     year = step = count = reject = 0;
164 :     while (!infile.eof()) {
165 :     keepdata = 1;
166 :     if (readvar)
167 :     infile >> year >> step >> tmparea >> tmpage >> tmpnumber >> tmpmean >> tmpstddev >> ws;
168 :     else
169 :     infile >> year >> step >> tmparea >> tmpage >> tmpnumber >> tmpmean >> ws;
170 :    
171 :     //crude check to see if something has gone wrong and avoid infinite loops
172 :     if (strlen(tmparea) == 0)
173 :     handle.logFileMessage(LOGFAIL, "failed to read data from file");
174 :    
175 :     //if tmparea is in areaindex find areaid, else dont keep the data
176 :     areaid = -1;
177 :     for (i = 0; i < areaindex.Size(); i++)
178 :     if (strcasecmp(areaindex[i], tmparea) == 0)
179 :     areaid = i;
180 :    
181 :     if (areaid == -1)
182 :     keepdata = 0;
183 :    
184 :     //if tmpage is in ageindex find ageid, else dont keep the data
185 :     ageid = -1;
186 :     for (i = 0; i < ageindex.Size(); i++)
187 :     if (strcasecmp(ageindex[i], tmpage) == 0)
188 :     ageid = i;
189 :    
190 :     if (ageid == -1)
191 :     keepdata = 0;
192 :    
193 :     //check if the year and step are in the simulation
194 :     timeid = -1;
195 :     if ((TimeInfo->isWithinPeriod(year, step)) && (keepdata == 1)) {
196 :     //if this is a new timestep, resize to store the data
197 :     for (i = 0; i < Years.Size(); i++)
198 :     if ((Years[i] == year) && (Steps[i] == step))
199 :     timeid = i;
200 :    
201 :     if (timeid == -1) {
202 :     Years.resize(1, year);
203 :     Steps.resize(1, step);
204 :     likelihoodValues.AddRows(1, numarea, 0.0);
205 :     numbers.resize(new DoubleMatrix(numarea, numage, 0.0));
206 :     obsMean.resize(new DoubleMatrix(numarea, numage, 0.0));
207 :     modelMean.resize(new DoubleMatrix(numarea, numage, 0.0));
208 :     if (readvar)
209 :     obsStdDev.resize(new DoubleMatrix(numarea, numage, 0.0));
210 :     if (needvar)
211 :     modelStdDev.resize(new DoubleMatrix(numarea, numage, 0.0));
212 :     timeid = (Years.Size() - 1);
213 :     }
214 :    
215 :     } else
216 :     keepdata = 0;
217 :    
218 :     if (keepdata == 1) {
219 :     //statistics data is required, so store it
220 :     count++;
221 :     (*numbers[timeid])[areaid][ageid] = tmpnumber;
222 :     (*obsMean[timeid])[areaid][ageid] = tmpmean;
223 :     if (readvar)
224 :     (*obsStdDev[timeid])[areaid][ageid] = tmpstddev;
225 :     } else
226 :     reject++; //count number of rejected data points read from file
227 :     }
228 :    
229 :     AAT.addActions(Years, Steps, TimeInfo);
230 :     if (count == 0)
231 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - found no data in the data file for", this->getName());
232 :     if (reject != 0)
233 :     handle.logMessage(LOGMESSAGE, "Discarded invalid catchstatistics data - number of invalid entries", reject);
234 :     handle.logMessage(LOGMESSAGE, "Read catchstatistics data file - number of entries", count);
235 :     }
236 :    
237 :     CatchStatistics::~CatchStatistics() {
238 :     int i;
239 :     for (i = 0; i < stocknames.Size(); i++)
240 :     delete[] stocknames[i];
241 :     for (i = 0; i < fleetnames.Size(); i++)
242 :     delete[] fleetnames[i];
243 :     for (i = 0; i < areaindex.Size(); i++)
244 :     delete[] areaindex[i];
245 :     for (i = 0; i < ageindex.Size(); i++)
246 :     delete[] ageindex[i];
247 :     delete aggregator;
248 :     for (i = 0; i < numbers.Size(); i++) {
249 :     delete numbers[i];
250 :     delete obsMean[i];
251 :     delete modelMean[i];
252 :     }
253 :     for (i = 0; i < obsStdDev.Size(); i++)
254 :     delete obsStdDev[i];
255 :     for (i = 0; i < modelStdDev.Size(); i++)
256 :     delete modelStdDev[i];
257 :     delete[] functionname;
258 :     delete LgrpDiv;
259 :     }
260 :    
261 :     void CatchStatistics::Reset(const Keeper* const keeper) {
262 :     Likelihood::Reset(keeper);
263 :     if (isZero(weight))
264 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - zero weight for", this->getName());
265 :     int i;
266 :     for (i = 0; i < modelMean.Size(); i++)
267 :     (*modelMean[i]).setToZero();
268 :     if (handle.getLogLevel() >= LOGMESSAGE)
269 :     handle.logMessage(LOGMESSAGE, "Reset catchstatistics component", this->getName());
270 :     }
271 :    
272 :     void CatchStatistics::Print(ofstream& outfile) const {
273 :     int i;
274 :    
275 :     outfile << "\nCatch Statistics " << this->getName() << " - likelihood value " << likelihood
276 :     << "\n\tFunction " << functionname << "\n\tStock names:";
277 :     for (i = 0; i < stocknames.Size(); i++)
278 :     outfile << sep << stocknames[i];
279 :     outfile << "\n\tFleet names:";
280 :     for (i = 0; i < fleetnames.Size(); i++)
281 :     outfile << sep << fleetnames[i];
282 :     outfile << endl;
283 :     aggregator->Print(outfile);
284 :     outfile.flush();
285 :     }
286 :    
287 :     void CatchStatistics::setFleetsAndStocks(FleetPtrVector& Fleets, StockPtrVector& Stocks) {
288 :     int i, j, k, found, minage, maxage;
289 :     FleetPtrVector fleets;
290 :     StockPtrVector stocks;
291 :    
292 :     for (i = 0; i < fleetnames.Size(); i++) {
293 :     found = 0;
294 :     for (j = 0; j < Fleets.Size(); j++) {
295 :     if (strcasecmp(fleetnames[i], Fleets[j]->getName()) == 0) {
296 :     found++;
297 :     fleets.resize(Fleets[j]);
298 :     }
299 :     }
300 :     if (found == 0)
301 :     handle.logMessage(LOGFAIL, "Error in catchstatistics - unrecognised fleet", fleetnames[i]);
302 :     }
303 :    
304 :     for (i = 0; i < fleets.Size(); i++)
305 :     for (j = 0; j < fleets.Size(); j++)
306 :     if ((strcasecmp(fleets[i]->getName(), fleets[j]->getName()) == 0) && (i != j))
307 :     handle.logMessage(LOGFAIL, "Error in catchstatistics - repeated fleet", fleets[i]->getName());
308 :    
309 :     for (i = 0; i < stocknames.Size(); i++) {
310 :     found = 0;
311 :     for (j = 0; j < Stocks.Size(); j++) {
312 :     if (Stocks[j]->isEaten()) {
313 :     if (strcasecmp(stocknames[i], Stocks[j]->getName()) == 0) {
314 :     found++;
315 :     stocks.resize(Stocks[j]);
316 :     }
317 :     }
318 :     }
319 :     if (found == 0)
320 :     handle.logMessage(LOGFAIL, "Error in catchstatistics - unrecognised stock", stocknames[i]);
321 :     }
322 :    
323 :     for (i = 0; i < stocks.Size(); i++)
324 :     for (j = 0; j < stocks.Size(); j++)
325 :     if ((strcasecmp(stocks[i]->getName(), stocks[j]->getName()) == 0) && (i != j))
326 :     handle.logMessage(LOGFAIL, "Error in catchstatistics - repeated stock", stocks[i]->getName());
327 :    
328 :     LgrpDiv = new LengthGroupDivision(*(stocks[0]->getPrey()->getLengthGroupDiv()));
329 :     for (i = 1; i < stocks.Size(); i++)
330 :     if (!LgrpDiv->Combine(stocks[i]->getPrey()->getLengthGroupDiv()))
331 :     handle.logMessage(LOGFAIL, "Error in catchstatistics - length groups for preys not compatible");
332 :    
333 :     if (LgrpDiv->Error())
334 :     handle.logMessage(LOGFAIL, "Error in catchstatistics - failed to create length group");
335 :    
336 :     //check fleet areas and stock areas, ages and lengths
337 :     if (handle.getLogLevel() >= LOGWARN) {
338 :     for (j = 0; j < areas.Nrow(); j++) {
339 :     found = 0;
340 :     for (i = 0; i < fleets.Size(); i++)
341 :     for (k = 0; k < areas.Ncol(j); k++)
342 :     if (fleets[i]->isInArea(areas[j][k]))
343 :     found++;
344 :     if (found == 0)
345 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - fleet not defined on all areas");
346 :     }
347 :    
348 :     for (j = 0; j < areas.Nrow(); j++) {
349 :     found = 0;
350 :     for (i = 0; i < stocks.Size(); i++)
351 :     for (k = 0; k < areas.Ncol(j); k++)
352 :     if (stocks[i]->isInArea(areas[j][k]))
353 :     found++;
354 :     if (found == 0)
355 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - stock not defined on all areas");
356 :     }
357 :    
358 :     minage = 9999;
359 :     maxage = 0;
360 :     for (i = 0; i < ages.Nrow(); i++) {
361 :     for (j = 0; j < ages.Ncol(i); j++) {
362 :     minage = min(ages[i][j], minage);
363 :     maxage = max(ages[i][j], maxage);
364 :     }
365 :     }
366 :    
367 :     found = 0;
368 :     for (i = 0; i < stocks.Size(); i++)
369 :     if (minage >= stocks[i]->minAge())
370 :     found++;
371 :     if (found == 0)
372 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - minimum age less than stock age");
373 :    
374 :     found = 0;
375 :     for (i = 0; i < stocks.Size(); i++)
376 :     if (maxage <= stocks[i]->maxAge())
377 :     found++;
378 :     if (found == 0)
379 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - maximum age greater than stock age");
380 :    
381 :     found = 0;
382 :     for (i = 0; i < stocks.Size(); i++)
383 :     if (LgrpDiv->maxLength(0) > stocks[i]->getLengthGroupDiv()->minLength())
384 :     found++;
385 :     if (found == 0)
386 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - minimum length group less than stock length");
387 :    
388 :     found = 0;
389 :     for (i = 0; i < stocks.Size(); i++)
390 :     if (LgrpDiv->minLength(LgrpDiv->numLengthGroups()) < stocks[i]->getLengthGroupDiv()->maxLength())
391 :     found++;
392 :     if (found == 0)
393 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - maximum length group greater than stock length");
394 :     }
395 :    
396 :     aggregator = new FleetPreyAggregator(fleets, stocks, LgrpDiv, areas, ages, overconsumption);
397 :     }
398 :    
399 :     void CatchStatistics::addLikelihood(const TimeClass* const TimeInfo) {
400 :    
401 :     if ((!(AAT.atCurrentTime(TimeInfo))) || (isZero(weight)))
402 :     return;
403 :    
404 :     int i;
405 :     timeindex = -1;
406 :     for (i = 0; i < Years.Size(); i++)
407 :     if ((Years[i] == TimeInfo->getYear()) && (Steps[i] == TimeInfo->getStep()))
408 :     timeindex = i;
409 :     if (timeindex == -1)
410 :     handle.logMessage(LOGFAIL, "Error in catchstatistics - invalid timestep");
411 :    
412 :     double l = 0.0;
413 :     if (handle.getLogLevel() >= LOGMESSAGE)
414 :     handle.logMessage(LOGMESSAGE, "Calculating likelihood score for catchstatistics component", this->getName());
415 :     aggregator->Sum();
416 :     if ((handle.getLogLevel() >= LOGWARN) && (aggregator->checkCatchData()))
417 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - zero catch found");
418 :    
419 :     l = calcLikSumSquares();
420 :     likelihood += l;
421 :     if (handle.getLogLevel() >= LOGMESSAGE)
422 :     handle.logMessage(LOGMESSAGE, "The likelihood score for this component on this timestep is", l);
423 :     }
424 :    
425 :     double CatchStatistics::calcLikSumSquares() {
426 :    
427 :     int area, age;
428 :     double lik, total, simvar, simdiff;
429 :    
430 :     lik = total = simvar = simdiff = 0.0;
431 :     alptr = &aggregator->getSum();
432 :     for (area = 0; area < areas.Nrow(); area++) {
433 :     likelihoodValues[timeindex][area] = 0.0;
434 :     for (age = (*alptr)[area].minAge(); age <= (*alptr)[area].maxAge(); age++) {
435 :    
436 :     switch (functionnumber) {
437 :     case 1:
438 :     ps.calcStatistics((*alptr)[area][age], LgrpDiv, 0);
439 :     (*modelMean[timeindex])[area][age] = ps.meanLength();
440 :     simvar = ps.sdevLength() * ps.sdevLength();
441 :     (*modelStdDev[timeindex])[area][age] = ps.sdevLength();
442 :     break;
443 :     case 2:
444 :     ps.calcStatistics((*alptr)[area][age], LgrpDiv, 0);
445 :     (*modelMean[timeindex])[area][age] = ps.meanLength();
446 :     simvar = (*obsStdDev[timeindex])[area][age] * (*obsStdDev[timeindex])[area][age];
447 :     break;
448 :     case 3:
449 :     ps.calcStatistics((*alptr)[area][age], LgrpDiv);
450 :     (*modelMean[timeindex])[area][age] = ps.meanWeight();
451 :     simvar = (*obsStdDev[timeindex])[area][age] * (*obsStdDev[timeindex])[area][age];
452 :     break;
453 :     case 4:
454 :     ps.calcStatistics((*alptr)[area][age], LgrpDiv);
455 :     (*modelMean[timeindex])[area][age] = ps.meanWeight();
456 :     simvar = 1.0;
457 :     break;
458 :     case 5:
459 :     ps.calcStatistics((*alptr)[area][age], LgrpDiv, 0);
460 :     (*modelMean[timeindex])[area][age] = ps.meanLength();
461 :     simvar = 1.0;
462 :     break;
463 :     default:
464 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - unrecognised function", functionname);
465 :     break;
466 :     }
467 :    
468 :     if (!(isZero(simvar))) {
469 :     simdiff = (*modelMean[timeindex])[area][age] - (*obsMean[timeindex])[area][age];
470 :     lik = simdiff * simdiff * (*numbers[timeindex])[area][age] / simvar;
471 :     likelihoodValues[timeindex][area] += lik;
472 :     }
473 :     }
474 :     total += likelihoodValues[timeindex][area];
475 :     }
476 :     return total;
477 :     }
478 :    
479 :     void CatchStatistics::printLikelihood(ofstream& outfile, const TimeClass* const TimeInfo) {
480 :    
481 :     if (!AAT.atCurrentTime(TimeInfo))
482 :     return;
483 :    
484 :     int i, area, age;
485 :     timeindex = -1;
486 :     for (i = 0; i < Years.Size(); i++)
487 :     if ((Years[i] == TimeInfo->getYear()) && (Steps[i] == TimeInfo->getStep()))
488 :     timeindex = i;
489 :     if (timeindex == -1)
490 :     handle.logMessage(LOGFAIL, "Error in catchstatistics - invalid timestep");
491 :    
492 :     for (area = 0; area < (*modelMean[timeindex]).Nrow(); area++) {
493 :     for (age = 0; age < (*modelMean[timeindex]).Ncol(area); age++) {
494 :     outfile << setw(lowwidth) << Years[timeindex] << sep << setw(lowwidth)
495 :     << Steps[timeindex] << sep << setw(printwidth) << areaindex[area] << sep
496 :     << setw(printwidth) << ageindex[age] << sep << setprecision(printprecision)
497 :     << setw(printwidth) << (*numbers[timeindex])[area][age]
498 :     << sep << setprecision(largeprecision) << setw(largewidth);
499 :    
500 :     //JMB crude filter to remove the 'silly' values from the output
501 :     if ((*modelMean[timeindex])[area][age] < rathersmall)
502 :     outfile << 0;
503 :     else
504 :     outfile << (*modelMean[timeindex])[area][age];
505 :    
506 :     switch (functionnumber) {
507 :     case 1:
508 :     outfile << sep << setprecision(printprecision) << setw(printwidth)
509 :     << (*modelStdDev[timeindex])[area][age] << endl;
510 :     break;
511 :     case 2:
512 :     case 3:
513 :     outfile << sep << setprecision(printprecision) << setw(printwidth)
514 :     << (*obsStdDev[timeindex])[area][age] << endl;
515 :     break;
516 :     case 4:
517 :     case 5:
518 :     outfile << endl;
519 :     break;
520 :     default:
521 :     handle.logMessage(LOGWARN, "Warning in catchstatistics - unrecognised function", functionname);
522 :     break;
523 :     }
524 :     }
525 :     }
526 :     }
527 :    
528 :     void CatchStatistics::printSummary(ofstream& outfile) {
529 :     int year, area;
530 :    
531 :     for (year = 0; year < likelihoodValues.Nrow(); year++)
532 :     for (area = 0; area < likelihoodValues.Ncol(year); area++)
533 :     outfile << setw(lowwidth) << Years[year] << sep << setw(lowwidth)
534 :     << Steps[year] << sep << setw(printwidth) << areaindex[area] << sep
535 :     << setw(largewidth) << this->getName() << sep << setprecision(smallprecision)
536 :     << setw(smallwidth) << weight << sep << setprecision(largeprecision)
537 :     << setw(largewidth) << likelihoodValues[year][area] << endl;
538 :    
539 :     outfile.flush();
540 :     }

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge