NicheMapR Model Tutorial (initial setup) The NicheMapR package includes a microclimate model and an ectotherm model, which are Fortran programs originally developed by Porter and colleagues (Beckman et al. 1973, Porter et al. 1973). The microclimate model incorporates a sophisticated model of solar radiation (McCullough and Porter 1971) and over the past few years has been substantially developed and tested (Kearney et al. 2014). The ectotherm model uses output from the microclimate model to work out heat and water budgets of organisms, and also includes the standard Dynamic Energy Budget model which can be optionally used to do the mass budget of food uptake and use. These Fortran programs can now be called from the R environment. In this tutorial you will install R, RStudio and the required packages on your computer. You will then download the microclimate and ectotherm models from an online repository, go through the basic input and output of the models, and run them from a global climate database. Installing R and RStudio R is a powerful environment for data manipulation, analysis and visualization. It is open source and comprises a growing library of ‘packages’ developed by the R community including sophisticated GIS tools. R can be run in a number of ways, from a terminal in the simplest case where you simply type in commands at a console, to a simple Graphical User Interface (GUI), to menu-driven interfaces. In this tutorial we will work with the RStudio interface, which provides a very nice way to arrange your work. You can download R for your system here: http://cran.r-project.org/ and RStudio from here: http://www.rstudio.com/ Installing the required R packages Once you have installed R and RStudio, load RStudio, you need to install the packages that are needed to do the exercises in this tutorial (using the command ‘install.packages’). They are: raster, sp, ncdf, XML, dismo, chron, rgdal, zoo Installing Git and GitHub As it develops, the NicheMapR system is being placed at an online software ‘repository’ called GitHub. GitHub is based on the ‘Git’ system, ‘version control’ program that allows software developers to keep track of how they have changed their code through time and to revert back to old versions if necessary. Git works with the user’s computer only, i.e. there is no online aspect to it. GitHub, in contrast, is a cloud-based version of Git, whereby the repository is stored online. This potentially allows public access to the code and also provides a way for software developers to collaborate easily on code development. It will be easiest for you to work with the NicheMapR models if you install Git and GitHub. Git integrates beautifully with RStudio and you will be able to install the programs and keep up to date with changes this way. An excellent overview of how to do this is provided here – follow the instructions carefully: http://www.molecularecologist.com/2013/11/using-github-with-r-and-rstudio/ Getting the models from GitHub In RStudio, go to File/New Project and you should see a window like this: If you have correctly installed Git and GitHub, then if you choose ‘Version Control’, you should see the option to clone a project from a Git repository: Choose this option and paste the following address into the URL box: https://github.com/mrke/microclimate.git : Note also that in the example above the project is going into a directory called ‘microclimate’ off a subdirectory called “c:/git” – it is best if you create a folder (outside of RStudio, in case user permissions are need) called “git” off your root directory and install into it similarly to the example above. That way, there should be fewer issues about getting file paths right when running the model (getting the file paths right is one of the main stumbling blocks in getting all of this to work!). When you click on ‘Create Project’, the core microclimate model will download to your computer and you will find that in the “Files” tab on the bottom right you can see the following: Now repeat the procedure to obtain two other repositories, one for the global climate implementation of the microclimate model and one for the ectotherm model: https://github.com/mrke/micro_global.git https://github.com/mrke/ectotherm.git Downloading the global climate data I have put together a global database of monthly climate, based on the dataset generated by New et al. (2002). There is also a soil moisture dataset from NOAA CPC Soil Moisture http://140.172.38.100/psd/thredds/catalog/Datasets/cpcsoil/catalog.html. Finally, there is global Digital Elevation Model (DEM) from the Worldclim dataset. All these files are in the following dropbox location for you to download (you need to decompress them to a folder on your system somewhere – they take up approximately 900 megabytes): https://www.dropbox.com/s/9eg1aaooid4lbqv/global%20climate.zip?dl=0 References Beckman WA, Mitchell JW, Porter WP. 1973. Thermal Model for Prediction of a Desert Iguana's Daily and Seasonal Behavior. Journal of Heat Transfer 95:257-262. Kearney MR, Shamakhy A, Tingley R, Karoly DJ, Hoffmann AA, Briggs PR, Porter WP. 2014. Microclimate modelling at macro scales: a test of a general microclimate model integrated with gridded continental-scale soil and weather data. Methods in Ecology and Evolution 5:273-286. McCullough EC, Porter WP. 1971. Computing clear day solar radiation spectra for the terrestrial ecological environment. Ecology 52:1008-1015. New M, Lister D, Hulme M, Makin I. 2002. A high-resolution data set of surface climate over global land areas. Climate Research 21:1-25. Porter WP, Mitchell JW, Beckman WA, DeWitt CB. 1973. Behavioral implications of mechanistic ecology - Thermal and behavioral modeling of desert ectotherms and their microenvironment. Oecologia 13:1-54.