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/sibyacousticonstep.cc
[mareframe] / trunk / gadget / sibyacousticonstep.cc Repository:
ViewVC logotype

Annotation of /trunk/gadget/sibyacousticonstep.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #include "sibyacousticonstep.h"
2 :     #include "stock.h"
3 :     #include "areatime.h"
4 :     #include "mathfunc.h"
5 :     #include "errorhandler.h"
6 :     #include "gadget.h"
7 :     #include "global.h"
8 :    
9 :     SIByAcousticOnStep::SIByAcousticOnStep(CommentStream& infile, const IntMatrix& areas,
10 :     const CharPtrVector& areaindex, const CharPtrVector& fleetindex,
11 :     const TimeClass* const TimeInfo, const char* datafilename, const char* givenname, int bio)
12 :     : SIOnStep(infile, datafilename, areaindex, TimeInfo, areas, fleetindex, givenname, bio, SIACOUSTIC) {
13 :     }
14 :    
15 :     SIByAcousticOnStep::~SIByAcousticOnStep() {
16 :     if (aggregator != 0)
17 :     delete aggregator;
18 :     }
19 :    
20 :     void SIByAcousticOnStep::setFleetsAndStocks(FleetPtrVector& Fleets, StockPtrVector& Stocks) {
21 :     int i, minage, maxage;
22 :     double minlength, maxlength;
23 :    
24 :     if (Stocks.Size() == 0)
25 :     handle.logMessage(LOGFAIL, "Error in surveyindex - failed to initialise stock data");
26 :    
27 :     minage = Stocks[0]->minAge();
28 :     maxage = Stocks[0]->maxAge();
29 :     minlength = Stocks[0]->getLengthGroupDiv()->minLength();
30 :     maxlength = Stocks[0]->getLengthGroupDiv()->maxLength();
31 :    
32 :     if (Stocks.Size() > 1) {
33 :     for (i = 1; i < Stocks.Size(); i++) {
34 :     minlength = min(Stocks[i]->getLengthGroupDiv()->minLength(), minlength);
35 :     maxlength = max(Stocks[i]->getLengthGroupDiv()->maxLength(), maxlength);
36 :     minage = min(Stocks[i]->minAge(), minage);
37 :     maxage = max(Stocks[i]->maxAge(), maxage);
38 :     }
39 :     }
40 :    
41 :     LgrpDiv = new LengthGroupDivision(minlength, maxlength, maxlength - minlength);
42 :     if (LgrpDiv->Error())
43 :     handle.logMessage(LOGFAIL, "Error in surveyindex - failed to create length group");
44 :    
45 :     Ages.AddRows(1, maxage - minage + 1, 0);
46 :     for (i = 0; i < Ages.Ncol(); i++)
47 :     Ages[0][i] = i + minage;
48 :    
49 :     aggregator = new StockAggregator(Stocks, LgrpDiv, Areas, Ages);
50 :     }
51 :    
52 :     void SIByAcousticOnStep::Sum(const TimeClass* const TimeInfo) {
53 :     if (!AAT.atCurrentTime(TimeInfo))
54 :     return;
55 :    
56 :     int a;
57 :     timeindex = -1;
58 :     for (a = 0; a < Years.Size(); a++)
59 :     if ((Years[a] == TimeInfo->getYear()) && (Steps[a] == TimeInfo->getStep()))
60 :     timeindex = a;
61 :     if (timeindex == -1)
62 :     handle.logMessage(LOGFAIL, "Error in surveyindex - invalid timestep");
63 :    
64 :     if (handle.getLogLevel() >= LOGMESSAGE)
65 :     handle.logMessage(LOGMESSAGE, "Calculating index for surveyindex component", this->getName());
66 :    
67 :     aggregator->Sum();
68 :     alptr = &aggregator->getSum();
69 :     //alptr will only have one length group and one age group
70 :     for (a = 0; a < Areas.Nrow(); a++)
71 :     (*modelIndex[timeindex])[a][0] = (*alptr)[a][0][0].N;
72 :    
73 :     if (biomass)
74 :     for (a = 0; a < Areas.Nrow(); a++)
75 :     (*modelIndex[timeindex])[a][0] *= (*alptr)[a][0][0].W;
76 :     }

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

Powered By FusionForge