Skip to content

Commit

Permalink
Merge pull request #1 from JetteReeg/Initialize-Model
Browse files Browse the repository at this point in the history
first running version of BiTZ
  • Loading branch information
JetteReeg authored Jan 27, 2020
2 parents 147998d + 0c19b63 commit c7b4b4e
Show file tree
Hide file tree
Showing 73 changed files with 800,096 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------

*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash

# qtcreator generated files
*.pro.user*

# xemacs temporary files
*.flc

# Vim temporary files
.*.swp

# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*

# MinGW generated files
*.Debug
*.Release

# Python byte code
*.pyc

# Binaries
# --------
*.dll
*.exe

32 changes: 32 additions & 0 deletions Analyse.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require(ggplot2)
require(ggthemes)
require(data.table)
data<-fread("GridOut_1.txt", header=T)
data<-data[FT_ID!=0,]
setkey(data, Year, FT_ID, LU_ID)
data[LU_ID==0,LU:="bare"]
data[LU_ID==1,LU:="arable"]
data[LU_ID==2,LU:="forest"]
data[LU_ID==3,LU:="grassland"]
data[LU_ID==4,LU:="urban"]
data[LU_ID==5,LU:="water"]
data1<-data[,.(mean=mean(Popsize), sd=sd(Popsize)),by=.(Year, FT_ID, LU_ID, LU)]
g1<-ggplot(data=data1, aes(y=mean, x=Year)) +
geom_line(aes( color=factor(FT_ID))) +
facet_wrap(~LU, scales="free")

data<-fread("GridOut.txt", header=T)
data<-data[FT_ID!=0,]
data<-data[FT_ID!=107998672,]
data<-data[FT_ID!=1225530629,]
setkey(data, Year, FT_ID, LU_ID)
data[LU_ID==0,LU:="bare"]
data[LU_ID==1,LU:="arable"]
data[LU_ID==2,LU:="forest"]
data[LU_ID==3,LU:="grassland"]
data[LU_ID==4,LU:="urban"]
data[LU_ID==5,LU:="water"]
data1<-data[,.(mean=mean(Popsize), sd=sd(Popsize)),by=.(Year, FT_ID, LU_ID, LU)]
g2<-ggplot(data=data1, aes(y=mean, x=Year)) +
geom_line(aes( color=factor(FT_ID))) +
facet_wrap(~LU)
Binary file added BiTZ-ODD.docx
Binary file not shown.
39 changes: 39 additions & 0 deletions BiTZ.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
QT -= gui

CONFIG += c++11 console
CONFIG -= app_bundle

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
cell.cpp \
ft_pop.cpp \
ft_traits.cpp \
gridenvironment.cpp \
lcg.cpp \
main.cpp \
runparameter.cpp \
runtimeenvironment.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

HEADERS += \
cell.h \
ft_pop.h \
ft_traits.h \
gridenvironment.h \
lcg.h \
runparameter.h \
runtimeenvironment.h
598 changes: 598 additions & 0 deletions BiTZ.pro.user

Large diffs are not rendered by default.

Empty file added Build.txt
Empty file.
Binary file added Dispersal_direction.bmp
Binary file not shown.
Binary file added Dispersal_distance.bmp
Binary file not shown.
Binary file added Dispersal_distance_1.bmp
Binary file not shown.
Binary file added Dispersal_distance_2.bmp
Binary file not shown.
Binary file added FT_classification.xlsx
Binary file not shown.
112 changes: 112 additions & 0 deletions First_Sim/Analyse.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# required packages
require(ggplot2)
require(ggthemes)
require(data.table)

# read in simulation file
scenarios<-fread("Simulations.txt", header=T)
data_container<-data.table()

# read in data
for (z in min(scenarios$SimNb):max(scenarios$SimNb)){
data<-fread(paste("GridOut_", z, ".txt", sep=""), header=T)
data[,TZ_width:=scenarios[SimNb==z,TZ_width]]
data[,disturbances:=scenarios[SimNb==z,disturbances]]
repetitions <- c()
for (i in 1:scenarios[SimNb==z,Nrep]){
repetitions = c(repetitions, rep(i,nrow(data)/scenarios[SimNb==z,Nrep]))
}
data[,repetition:=repetitions]
l<-list(data_container,data)
data_container=rbindlist(l)
}

setkey(data_container, Year, FT_ID, LU_ID, repetition)
data_container[LU_ID==0,LU:="bare"]
data_container[LU_ID==1,LU:="arable"]
data_container[LU_ID==2,LU:="forest"]
data_container[LU_ID==3,LU:="grassland"]
data_container[LU_ID==4,LU:="urban"]
data_container[LU_ID==5,LU:="water"]
data<-data_container[,.(mean=mean(Popsize), sd=sd(Popsize)),by=.(Year, FT_ID, LU_ID, LU, TZ_width, disturbances)]
data2<-data_container[,.(mean=mean(Popsize), sd=sd(Popsize)),by=.(Year, LU_ID, LU, TZ_width, disturbances)]

# calculate nb_FT/land use type
tmp<-data_container[Popsize!=0,]
tmp <- tmp[,.(nb_FT=length(Popsize), totalN=sum(Popsize)),by=.(Year, LU_ID, LU, TZ_width, disturbances, repetition)]
setkey(data_container, Year, FT_ID, LU_ID, LU, repetition, TZ_width, disturbances)
setkey(tmp, Year, LU_ID, LU, repetition, TZ_width, disturbances)
test<-merge(tmp,data_container)
test<-test[Popsize!=0,]
test[,pi:=Popsize/totalN]
test<-test[,.(div=-sum(pi*log(pi))),by=.(Year, LU_ID, LU, TZ_width, disturbances, repetition, nb_FT, totalN)]
data.com<-test[,.(mean.div=mean(div), sd.div=sd(div), mean.nb_FT=mean(nb_FT), sd.nb_FT=sd(nb_FT), mean.totalN=mean(totalN), sd.totalN=sd(totalN)),by=.(Year, LU_ID, LU, TZ_width, disturbances)]



# read landscape configuration
landscape<-fread("Patch_ID_definitions.txt", header=T)
landscape_proportions<-landscape[,.(cumArea=sum(AREA)), by=.(TYPE)]
totalArea=sum(landscape_proportions[,cumArea])
landscape_proportions[,relativeArea:=cumArea/totalArea]
landscape_proportions[,LU:=TYPE]

# merging
setkey(data, Year, FT_ID, LU_ID, LU, TZ_width, disturbances)
setkey(data.com, Year, LU_ID, LU, TZ_width, disturbances)
setkey(landscape_proportions, TYPE, LU)
data3<-merge(data, landscape_proportions)
data3[,relPop:=mean/cumArea]

data4<-merge(data.com, landscape_proportions)
data4[,relPop:=mean/cumArea]

relPop1<-ggplot(data=data3[LU!="water"&FT_ID<9]) +
theme_few() +
geom_line(aes(x=Year, y=relPop, colour=factor(TZ_width), linetype=factor(disturbances))) +
ylab("nb individuals/ha") +
facet_grid(LU~FT_ID, scales="free")
ggsave("relPop1.png", relPop1)
relPop2<-ggplot(data=data3[LU!="water"&FT_ID>=9]) +
theme_few() +
geom_line(aes(x=Year, y=relPop, colour=factor(TZ_width), linetype=factor(disturbances))) +
ylab("nb individuals/ha") +
facet_grid(LU~FT_ID, scales="free")
ggsave("relPop2.png", relPop2)

div<-ggplot(data=data.com) +
theme_few() +
geom_line(aes(x=Year, y=mean.div, colour=factor(TZ_width), linetype=factor(disturbances))) +
geom_ribbon(aes(x=Year, ymin=mean.div-sd.div, ymax=mean.div+sd.div, group=factor(TZ_width+disturbances)), alpha=0.1) +
ylab("mean diversity") +
facet_wrap(~LU, scales="free")
ggsave("Shannon.png", div)

nb_FT<-ggplot(data=data.com) +
theme_few() +
geom_line(aes(x=Year, y=mean.nb_FT, colour=factor(TZ_width), linetype=factor(disturbances))) +
geom_ribbon(aes(x=Year, ymin=mean.nb_FT-sd.nb_FT, ymax=mean.nb_FT+sd.nb_FT, group=factor(TZ_width+disturbances)), alpha=0.1) +
ylab("mean number of FT") +
facet_wrap(~LU, scales="free")
ggsave("NB_FT.png", nb_FT)

totalN<-ggplot(data=data.com) +
theme_few() +
geom_line(aes(x=Year, y=mean.totalN, colour=factor(TZ_width), linetype=factor(disturbances))) +
geom_ribbon(aes(x=Year, ymin=mean.totalN-sd.totalN, ymax=mean.totalN+sd.totalN, group=factor(TZ_width+disturbances)), alpha=0.1) +
ylab("mean total N") +
facet_wrap(~LU, scales="free")
ggsave("totalN.png", totalN)






g<-ggplot(data=data[LU=="arable",]) +
geom_line(aes(x=Year, y=mean, colour=factor(TZ_width), linetype=factor(disturbances))) +
facet_wrap(~FT_ID, scales="free")

g<-ggplot(data=data[LU=="grassland",]) +
geom_line(aes(x=Year, y=mean, colour=factor(TZ_width), linetype=factor(disturbances))) +
facet_wrap(~FT_ID, scales="free")
Loading

0 comments on commit c7b4b4e

Please sign in to comment.