Skip to content

Commit

Permalink
fix merge conflict with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoPannetier committed May 30, 2024
2 parents 6701e19 + 7aefe7a commit 17e94e3
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 251 deletions.
18 changes: 0 additions & 18 deletions Cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ pPatch = patch;
envVal = 1.0; // default - no effect of any gradient
envDev = eps = 0.0;
habIxx.push_back(hab);
#if RSDEBUG
//DebugGUI(("Cell::Cell(): this=" + Int2Str((int)this)
// + " x=" + Int2Str(x) + " y=" + Int2Str(y)
// + " habIndex=" + Int2Str(habIndex)
//).c_str());
#endif
visits = 0;
smsData = 0;
}
Expand Down Expand Up @@ -74,12 +68,6 @@ if (smsData != 0) {
}

void Cell::setHabIndex(short hx) {
#if RSDEBUG
//DebugGUI(("Cell::setHabIndex(): this=" + Int2Str((int)this)
// + " x=" + Int2Str(x) + " y=" + Int2Str(y)
// + " habIx=" + Int2Str(habIx)
//).c_str());
#endif
if (hx < 0) habIxx.push_back(0);
else habIxx.push_back(hx);
}
Expand Down Expand Up @@ -118,12 +106,6 @@ pPatch = p;
}
intptr Cell::getPatch(void)
{
#if RSDEBUG
//DebugGUI(("Cell::getPatch(): this=" + Int2Str((int)this)
// + " x=" + Int2Str(x) + " y=" + Int2Str(y)
// + " habIxx[0]=" + Int2Str(habIxx[0]) + " pPatch=" + Int2Str(pPatch)
//).c_str());
#endif
return pPatch;
}

Expand Down
4 changes: 0 additions & 4 deletions Cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ class DistCell{

};

#if RSDEBUG
extern void DebugGUI(string);
#endif

//---------------------------------------------------------------------------

#endif
11 changes: 3 additions & 8 deletions Community.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,11 +860,8 @@ void Community::outRange(Species* pSpecies, int rep, int yr, int gen)
if (emig.indVar || trfr.indVar || sett.indVar) { // output trait means
traitsums ts;
traitsums scts; // sub-community traits
traitCanvas tcanv;
int ngenes, popsize;

tcanv.pcanvas[0] = NULL;

for (int i = 0; i < NSEXES; i++) {
ts.ninds[i] = 0;
ts.sumD0[i] = ts.ssqD0[i] = 0.0;
Expand All @@ -882,7 +879,7 @@ void Community::outRange(Species* pSpecies, int rep, int yr, int gen)

int nsubcomms = (int)subComms.size();
for (int i = 0; i < nsubcomms; i++) { // all sub-communities (incl. matrix)
scts = subComms[i]->outTraits(tcanv, pLandscape, rep, yr, gen, true);
scts = subComms[i]->outTraits(pLandscape, rep, yr, gen, true);
for (int j = 0; j < NSEXES; j++) {
ts.ninds[j] += scts.ninds[j];
ts.sumD0[j] += scts.sumD0[j]; ts.ssqD0[j] += scts.ssqD0[j];
Expand Down Expand Up @@ -1196,7 +1193,6 @@ void Community::outOccSuit(bool view) {
else sd = 0.0;
se = sd / sqrt((double)(sim.reps));
outsuit << i * sim.outIntOcc << "\t" << mean << "\t" << se << endl;
if (view) viewOccSuit(i * sim.outIntOcc, mean, se);
}

}
Expand All @@ -1212,8 +1208,7 @@ only, this function relies on the fact that subcommunities are created in the sa
sequence as patches, which is in asecending order of x nested within descending
order of y
*/
void Community::outTraits(traitCanvas tcanv, Species* pSpecies,
int rep, int yr, int gen)
void Community::outTraits(Species* pSpecies, int rep, int yr, int gen)
{
simParams sim = paramsSim->getSim();
simView v = paramsSim->getViews();
Expand Down Expand Up @@ -1247,7 +1242,7 @@ void Community::outTraits(traitCanvas tcanv, Species* pSpecies,
// generate output for each sub-community (patch) in the community
int nsubcomms = (int)subComms.size();
for (int i = 1; i < nsubcomms; i++) { // // all except matrix sub-community
sctraits = subComms[i]->outTraits(tcanv, pLandscape, rep, yr, gen, false);
sctraits = subComms[i]->outTraits(pLandscape, rep, yr, gen, false);
locn loc = subComms[i]->getLocn();
int y = loc.y;
if (sim.outTraitsRows && yr >= sim.outStartTraitRow && yr % sim.outIntTraitRow == 0)
Expand Down
16 changes: 0 additions & 16 deletions Community.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,6 @@ class Community {
void outOccSuit(
bool // TRUE if occupancy graph is to be viewed on screen
);
void viewOccSuit( // Update the occupancy graph on the screen
// NULL for the batch version
int, // year
double, // mean occupancy
double // standard error of occupancy
);
bool outTraitsHeaders( // Open traits file and write header record
Species*, // pointer to Species
int // Landscape number (-999 to close the file)
Expand All @@ -180,9 +174,6 @@ class Community {
int // Landscape number (-999 to close the file)
);
void outTraits( // Write records to traits file
traitCanvas,// pointers to canvases for drawing variable traits
// see SubCommunity.h
// in the batch version, these are replaced by integers set to zero
Species*, // pointer to Species
int, // replicate
int, // year
Expand All @@ -196,13 +187,6 @@ class Community {
int, // row number (Y cell co-ordinate)
traitsums // structure holding sums of trait genes for dispersal (see Population.h)
);
void draw( // Draw the Community on the landscape map and optionally save the map
// NULL for the batch version
int, // replicate
int, // year
int, // generation
int // Landscape number
);
#if RS_RCPP && !R_CMD
Rcpp::IntegerMatrix addYearToPopList(int,int);
#endif
Expand Down
11 changes: 1 addition & 10 deletions FractalGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,8 @@ while (iter != patches.end())
}

if (arena != NULL) {
#if RSDEBUG
//DebugGUI(("fractal_landscape(): arena=" + Int2Str((int)arena)
// + " X=" + Int2Str(X) + " Y=" + Int2Str(Y)
// ).c_str());
#endif
for(ii = 0; ii < X; ii++) {
#if RSDEBUG
//DebugGUI(("fractal_landscape(): ii=" + Int2Str(ii)
// + " arena[ii]=" + Int2Str((int)arena[ii])
// ).c_str());
#endif

delete[] arena[ii];
}
delete[] arena;
Expand Down
1 change: 0 additions & 1 deletion FractalGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ bool compare(const land&, const land&);

extern RSrandom *pRandom;
#if RSDEBUG
extern void DebugGUI(string);
#endif

//---------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion Genome.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ extern RSrandom* pRandom;
#if RSDEBUG
extern ofstream DEBUGLOG;
extern ofstream MUTNLOG;
extern void DebugGUI(string);
#endif

//---------------------------------------------------------------------------
Expand Down
73 changes: 32 additions & 41 deletions Landscape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,9 @@ int Landscape::readLandChange(int filenum, bool costs)
}
if (costs) {
if (c < 1) { // invalid cost
#if RS_RCPP
Rcpp::Rcout << "Found invalid cost value of " << c << " in cell x " << x << " and y " << y << std::endl;
#endif
hfile.close(); hfile.clear();
if (pfile.is_open()) {
pfile.close(); pfile.clear();
Expand All @@ -1304,8 +1307,8 @@ int Landscape::readLandChange(int filenum, bool costs)
}
}
}
}
}
} // for x
} // for y
#if RS_RCPP
hfile >> hfloat;
if (!hfile.eof()) EOFerrorR("habitatchgfile");
Expand Down Expand Up @@ -1431,6 +1434,9 @@ int Landscape::readLandChange(int filenum, bool costs)
}
if (costs) {
if (c < 1) { // invalid cost
#if RS_RCPP
Rcpp::Rcout << "Found invalid cost value of " << c << "in cell x " << x << " and y " << y << std::endl;
#endif
hfile.close(); hfile.clear();
if (pfile.is_open()) {
pfile.close(); pfile.clear();
Expand All @@ -1442,8 +1448,8 @@ int Landscape::readLandChange(int filenum, bool costs)
}
}
}
}
}
} // end x
} // end y
#if RS_RCPP
hfile >> hfloat;
if (!hfile.eof()) EOFerrorR("habitatchgfile");
Expand Down Expand Up @@ -1668,7 +1674,7 @@ bool Landscape::inInitialDist(Species* pSpecies, locn loc) {
void Landscape::deleteDistribution(Species* pSpecies) {
// WILL NEED TO SELECT DISTRIBUTION FOR CORRECT SPECIES ...
// ... CURRENTLY IT IS THE ONLY ONE ...
// ... FOR MULTIPLE SPECIES IT MAY BE BETTER TO USE A DYNAMIC ARRAY FOR
// ... FOR MULTIPLE SPECIES IT MAY BE BETTER TO USE A DYNAMIC ARRAY FOR
// SPECIES DISTRIBUTIONS INDEXED BY SPECIES NUMBER, RATHER THAN A VECTOR
if (distns[0] != 0) delete distns[0]; distns.clear();
}
Expand Down Expand Up @@ -1948,7 +1954,7 @@ int Landscape::readLandscape(int fileNum, string habfile, string pchfile, string
if (existsPatch(p)) {
pPatch = findPatch(p);
addNewCellToPatch(pPatch, x, y, h);
// addNewCellToPatch(findPatch(p),x,y,h);
// addNewCellToPatch(findPatch(p),x,y,h);
}
else {
pPatch = newPatch(seq++, p);
Expand Down Expand Up @@ -2294,15 +2300,11 @@ int Landscape::readCosts(string fname)
costs.close(); costs.clear();
return -1;
}
double tmpresolCost;
double tmpresolCost;
costs >> maxXcost >> header >> maxYcost >> header >> minLongCost;
costs >> header >> minLatCost >> header >> tmpresolCost >> header >> NODATACost;
resolCost = (int) tmpresolCost;

#if !RS_RCPP
MemoLine("Loading costs map. Please wait...");
#endif

for (int y = maxYcost - 1; y > -1; y--) {
for (int x = 0; x < maxXcost; x++) {
#if RS_RCPP
Expand All @@ -2326,17 +2328,26 @@ resolCost = (int) tmpresolCost;
#endif
if (hc < 1 && hc != NODATACost) {
#if RS_RCPP && !R_CMD
Rcpp::Rcout << "Cost map my only contain values of 1 or higher, but found " << fcost << "." << endl;
Rcpp::Rcout << "Cost map may only contain values of 1 or higher, but found " << fcost << "." << endl;
#endif
// error - zero / negative cost not allowed
costs.close(); costs.clear();
return -999;
}
pCell = findCell(x, y);
if (pCell != 0) { // not no-data cell
pCell->setCost(hc);
if (hc > maxcost) maxcost = hc;
}
if (hc > 0){ // only if cost value is above 0 in a data cell
pCell->setCost(hc);
if (hc > maxcost) maxcost = hc;
} else { // if cost value is below 0
#if RS_RCPP && !R_CMD
Rcpp::Rcout << "Cost map may only contain values of 1 or higher in habiat cells, but found " << hc << " in cell x: " << x << " y: " << y << "." << endl;
#endif
// costs.close(); costs.clear(); // not sure if it should stop at this point
// return -999;
}

} // end not no data vell
}
}
#if RS_RCPP
Expand All @@ -2347,8 +2358,6 @@ if (costs.eof()) {
#endif
}
else EOFerrorR(fname);
#else
MemoLine("Costs map loaded.");
#endif

costs.close(); costs.clear();
Expand All @@ -2373,40 +2382,22 @@ rasterdata CheckRasterFile(string fname)
infile.open(fname.c_str());
if (infile.is_open()) {
infile >> header >> r.ncols;
#if RSDEBUG
DebugGUI(("CheckRasterFile(): header=" + header + " r.ncols=" + Int2Str(r.ncols)
).c_str());
#endif

if (header != "ncols" && header != "NCOLS") r.errors++;
infile >> header >> r.nrows;
#if RSDEBUG
DebugGUI(("CheckRasterFile(): header=" + header + " r.nrows=" + Int2Str(r.nrows)
).c_str());
#endif

if (header != "nrows" && header != "NROWS") r.errors++;
infile >> header >> r.xllcorner;
#if RSDEBUG
DebugGUI(("CheckRasterFile(): header=" + header + " r.xllcorner=" + Float2Str(r.xllcorner)
).c_str());
#endif

if (header != "xllcorner" && header != "XLLCORNER") r.errors++;
infile >> header >> r.yllcorner;
#if RSDEBUG
DebugGUI(("CheckRasterFile(): header=" + header + " r.yllcorner=" + Float2Str(r.yllcorner)
).c_str());
#endif

if (header != "yllcorner" && header != "YLLCORNER") r.errors++;
infile >> header >> r.cellsize;
#if RSDEBUG
DebugGUI(("CheckRasterFile(): header=" + header + " r.cellsize=" + Int2Str(r.cellsize)
).c_str());
#endif

if (header != "cellsize" && header != "CELLSIZE") r.errors++;
infile >> header >> inint;
#if RSDEBUG
DebugGUI(("CheckRasterFile(): header=" + header + " inint=" + Int2Str(inint)
).c_str());
#endif

if (header != "NODATA_value" && header != "NODATA_VALUE") r.errors++;
infile.close();
infile.clear();
Expand Down
12 changes: 0 additions & 12 deletions Landscape.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,14 +454,6 @@ class Landscape{
int readCosts(
string // costs file name
);
// the following four functions are implemented for the GUI version only
// in the batch version, they are defined, but empty
void setLandMap(void);
void drawLandscape(
int, // replicate no.
int, // landscape index number (always 0 if landscape is not dynamic)
int // landscape no.
);
void resetVisits(void);
void outVisits(int,int); // save SMS path visits map to raster text file

Expand Down Expand Up @@ -545,13 +537,9 @@ extern RSrandom *pRandom;

#if RSDEBUG
extern ofstream DEBUGLOG;
extern void DebugGUI(string);
Landscape createLandscapeFromCells(vector<Cell*> cells, const landParams& lp, Species sp);
void testLandscape();
#endif

extern void MemoLine(string);

#if RS_RCPP
extern rasterdata landraster,patchraster,spdistraster,costsraster;
extern void EOFerrorR(string);
Expand Down
Loading

0 comments on commit 17e94e3

Please sign in to comment.