Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR for checking conflicts merging spatial_demography into transloc_new_genetics_spatial_demog_merge #80

Open
wants to merge 39 commits into
base: transloc_new_genetics_spatial_demog_merge
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
45a9cce
all maps (habitat, patch, SMS costs, species dist) are given as numer…
Oct 18, 2021
88e52f6
Merge branch 'master' into thread_safe
Oct 18, 2021
4aba706
fix some small errors
Oct 18, 2021
0c54d45
get dynamic landscapes as raster matrices from R
Oct 19, 2021
77d2c4b
give initial inds list as data.frame from R
Oct 19, 2021
aaef916
create switch 'CreatePopFile' to suppress population file output
Nov 1, 2021
5489385
set varying initial conditions for each replicate, given as list of d…
Nov 1, 2021
f74357d
Added new macro for spatial varying demographic rates SPATIALDEMOG
JetteReeg Nov 23, 2021
c70bf87
tested things in landscape.cpp but disregarded them again
JetteReeg Nov 23, 2021
1951ccc
Added a global parameter NLAYERS for the number of allowed layers in …
JetteReeg Dec 15, 2021
b86ea7b
Implemented new reproduction and survival (in survival0) for spatiall…
JetteReeg Dec 16, 2021
eb1fc07
Merge remote-tracking branch 'origin/thread_safe' into spatial_varian…
Jan 6, 2022
2815916
add R-level parameters for Fec,Dev,Surv-Layer
Jan 7, 2022
bdcaf05
fix bug by checking for initialisation type before loading dataframe …
Jan 7, 2022
77c4a66
Merge remote-tracking branch 'origin/thread_safe' into spatial_varian…
Jan 7, 2022
e817f62
in Patch.cpp:
JetteReeg Jan 10, 2022
3da1dcd
Added creating ODD protocol and parameter table functionality
JetteReeg Jan 25, 2022
de2e5c7
added example for filenames
JetteReeg Jan 25, 2022
c8b9ce3
match name of ODD template directory; add example names to roxygen
Jan 28, 2022
d8743d3
changed figure type for flowchart to pdf (word output is not able to …
JetteReeg Jan 31, 2022
ab2e34b
fixed merge problems
JetteReeg Jan 31, 2022
75331a9
class_DemogParams.R: Allow for -9 values in Fec/Surv/DevLayer matrice…
JetteReeg Feb 4, 2022
3f59798
finish R side of spatial demography: objects for FecLayer, DevLayer a…
Feb 14, 2022
0d32a17
demographic scaling layers as array; implementation for dynamic lands…
Feb 19, 2022
61f513e
function to update patch's demographic scaling values; plus some bug …
Feb 20, 2022
5c612a9
fix error re dimensions of demog layers array
Feb 20, 2022
5375d4f
Minor bug-fixes for windows compiling
JetteReeg Feb 23, 2022
3f246d3
Switched back to c11
JetteReeg Feb 23, 2022
0125b51
deleted function in cell.cpp, which was not used
JetteReeg Feb 24, 2022
5ccae96
fix warnings introduced with R4.2.0; in parameter validation change i…
May 11, 2022
4bcb50d
fix 2 C++ warnings
May 11, 2022
4f5619c
moved source files to base and delete folder
JetteReeg Jun 24, 2022
1ba71ab
deleted source files
JetteReeg Jun 24, 2022
6a54e03
adaptions for compiling
JetteReeg Jun 24, 2022
05c0f7b
Update Parameters.h
JetteReeg Sep 28, 2023
4771e48
updating paths for Version.h file
JetteReeg Sep 28, 2023
3c04ec4
remove Version.cpp and Version.h as files moved one level higher
JetteReeg Sep 29, 2023
33e498b
potential bugfix: MinSteps and MaxSteps now stage and sex dependent
JetteReeg Feb 16, 2024
183920a
added missing semicolon
JetteReeg Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 37 additions & 14 deletions RangeShiftR/src/Cell.cpp → Cell.cpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
/*----------------------------------------------------------------------------
*
* Copyright (C) 2020 Greta Bocedi, Stephen C.F. Palmer, Justin M.J. Travis, Anne-Kathleen Malchow, Damaris Zurell
*
*
* Copyright (C) 2020 Greta Bocedi, Stephen C.F. Palmer, Justin M.J. Travis, Anne-Kathleen Malchow, Damaris Zurell
*
* This file is part of RangeShifter.
*
*
* RangeShifter is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* RangeShifter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with RangeShifter. If not, see <https://www.gnu.org/licenses/>.
*
*
--------------------------------------------------------------------------*/


//---------------------------------------------------------------------------
#if RS_EMBARCADERO
#pragma hdrstop
#endif

#include "Cell.h"
#include "algorithm"

//---------------------------------------------------------------------------
#if RS_EMBARCADERO
#if RS_EMBARCADERO
#pragma package(smart_init)
#endif

Expand Down Expand Up @@ -78,8 +79,11 @@ habIxx.clear();
habitats.clear();
if (smsData != 0) {
if (smsData->effcosts != 0) delete smsData->effcosts;
delete smsData;
delete smsData;
}
#if SPATIALDEMOG
demoScalings.clear();
#endif
#if RSDEBUG
//DEBUGLOG << "Cell::~Cell(): deleted" << endl;
#endif
Expand Down Expand Up @@ -171,7 +175,7 @@ if (period == 0 || period == 1) m = mort[period];
return m;
}

#endif // SPATIALMORT
#endif // SPATIALMORT

// Functions to handle costs for SMS

Expand Down Expand Up @@ -210,7 +214,7 @@ else
return a;
}

void Cell::setEffCosts(array3x3f a) {
void Cell::setEffCosts(array3x3f a) {
if (smsData->effcosts == 0) smsData->effcosts = new array3x3f;
*smsData->effcosts = a;
}
Expand All @@ -236,7 +240,26 @@ unsigned long int Cell::getVisits(void) { return visits; }
void Cell::setDamage(DamageLocn *pDmg) { pDamage = pDmg; }
DamageLocn* Cell::getDamage(void) { return pDamage; }

#endif // RS_CONTAIN
#endif // RS_CONTAIN

#if SPATIALDEMOG

void Cell::addchgDemoScaling(std::vector<float> ds) {
std::for_each(ds.begin(), ds.end(), [](float& perc){ if(perc < 0.0 || perc > 100.0) perc=100; });
demoScalings.push_back(ds);
return;
}

std::vector<float> Cell::getDemoScaling(short chgyear) {
if (chgyear < 0 || chgyear >= (int)demoScalings.size()) {
std::vector<float> ret(1, -1);
return ret;
}
else return demoScalings[chgyear];
}

#endif // SPATIALDEMOG


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

Expand Down
18 changes: 17 additions & 1 deletion RangeShiftR/src/Cell.h → Cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ Last updated: 14 January 2021 by Steve Palmer
#ifndef CellH
#define CellH

#if SPATIALDEMOG
#include <algorithm>
#endif
#include <vector>

using namespace std;

#include "Parameters.h"
Expand Down Expand Up @@ -137,7 +141,12 @@ class Cell{
// unsigned int getDamage(void);
void setDamage(DamageLocn*);
DamageLocn* getDamage(void);
#endif // RS_CONTAIN
#endif // RS_CONTAIN
#if SPATIALDEMOG
void addchgDemoScaling(std::vector<float>);
void setDemoScaling(std::vector<float>, short);
std::vector<float> getDemoScaling(short);
#endif // SPATIALDEMOG

private:
int x,y; // cell co-ordinates
Expand All @@ -161,6 +170,9 @@ class Cell{
// NB initially, habitat codes are loaded, then converted to index nos.
// once landscape is fully loaded
vector <float> habitats; // habitat proportions (rasterType=1) or quality (rasterType=2)
#if SPATIALDEMOG
std::vector<std::vector<float>> demoScalings; // demographic scaling layers (only if rasterType==2)
#endif
};

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -193,6 +205,10 @@ class DistCell{
extern void DebugGUI(string);
#endif

#if SPATIALDEMOG
extern short nDSlayer;
#endif // SPATIALDEMOG

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

#endif
27 changes: 15 additions & 12 deletions RangeShiftR/src/Community.cpp → Community.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2644,7 +2644,7 @@ return fileOK;
#endif

#if RS_RCPP && !R_CMD
Rcpp::IntegerMatrix Community::addYearToPopList(int rep, int yr) { // TODO: define new simparams to control start and interval of output
Rcpp::IntegerMatrix Community::addYearToPopList(int rep, int yr) { // TODO: define new simparams to control type as well as start and interval of output

landParams ppLand = pLandscape->getLandParams();
Rcpp::IntegerMatrix pop_map_year(ppLand.dimY,ppLand.dimX);
Expand All @@ -2663,19 +2663,22 @@ Rcpp::IntegerMatrix Community::addYearToPopList(int rep, int yr) { // TODO: def
pop_map_year(ppLand.dimY-1-y,x) = NA_INTEGER;
} else {
patch = pCell->getPatch();
if (patch == 0) { // matrix cell
pop_map_year(ppLand.dimY-1-y,x) = 0;
}
else{
if (patch != 0) {
pPatch = (Patch*)patch;
subcomm = pPatch->getSubComm();
if (subcomm == 0) { // check if sub-community exists
if (pPatch->getSeqNum() == 0) { // cell in matrix patch
pop_map_year(ppLand.dimY-1-y,x) = 0;
} else {
pSubComm = (SubCommunity*)subcomm;
pop = pSubComm->getPopStats();
//pop_map_year(ppLand.dimY-1-y,x) = pop.nInds; // use indices like this because matrix gets transposed upon casting it into a raster on R-level
pop_map_year(ppLand.dimY-1-y,x) = pop.nAdults;
}
else{
pPatch = (Patch*)patch;
subcomm = pPatch->getSubComm();
if (subcomm == 0) { // check if sub-community exists
pop_map_year(ppLand.dimY-1-y,x) = 0;
} else {
pSubComm = (SubCommunity*)subcomm;
pop = pSubComm->getPopStats();
pop_map_year(ppLand.dimY-1-y,x) = pop.nInds; // use indices like this because matrix gets transposed upon casting it into a raster on R-level
//pop_map_year(ppLand.dimY-1-y,x) = pop.nAdults;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion RangeShiftR/src/Community.h → Community.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Last updated: 25 June 2021 by Anne-Kathleen Malchow
#include <algorithm>
using namespace std;

#include "Version.h"
#include "../Version.h"
#include "SubCommunity.h"
#include "Landscape.h"
#include "Patch.h"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading