PlotMap_Fn: Plots surfaces after parameter estimation

Usage Arguments Examples

Usage

1
PlotMap_Fn(MappingDetails, Report, MapSizeRatio, Xlim, Ylim, FileName, Year_Set)

Arguments

MappingDetails
Report
MapSizeRatio
Xlim
Ylim
FileName
Year_Set

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (MappingDetails, Report, MapSizeRatio, Xlim, Ylim, FileName, 
    Year_Set) 
{
    D_it = Report$D_xt[NN_Extrap$nn.idx, ]
    R1_it = Report$R1_xt[NN_Extrap$nn.idx, ]
    R2_it = Report$R2_xt[NN_Extrap$nn.idx, ]
    f = function(Num) ((Num) - min((Num), na.rm = TRUE))/diff(range((Num), 
        na.rm = TRUE))
    Col = colorRampPalette(colors = c("darkblue", "blue", "lightblue", 
        "lightgreen", "yellow", "orange", "red"))
    for (RespI in 1:5) {
        if (RespI == 1) 
            Mat = R1_it
        if (RespI == 2) {
            Mat = log(R2_it + quantile(R2_it, 0.01))
            Mat = ifelse(Mat < (-5), -5, Mat)
        }
        if (RespI == 3) {
            Mat = log(D_it + quantile(D_it, 0.01))
            Mat = ifelse(Mat < (-5), -5, Mat)
        }
        if (RespI == 4) 
            Mat = log(R2_it + quantile(R2_it, 0.25))
        if (RespI == 5) 
            Mat = log(D_it + quantile(D_it, 0.25))
        png(file = paste0(FileName, switch(RespI, "Pres", "Pos", 
            "Dens", "Pos_Rescaled", "Dens_Rescaled"), ".png"), 
            width = 5 * MapSizeRatio["Width(in)"], height = 2 * 
                MapSizeRatio["Height(in)"], res = 400, units = "in")
        par(mfrow = c(2, 6), oma = c(2, 2, 0, 0))
        for (t in 1:length(Year_Set)) {
            Which = which(Data_Extrap[, "Include"] == TRUE)
            map(MappingDetails[[1]], MappingDetails[[2]], ylim = Ylim, 
                xlim = Xlim, col = "grey90", fill = TRUE, main = "", 
                mar = c(0, 0, 2, 0), interior = TRUE)
            points(x = Data_Extrap[Which, "Lon"], y = Data_Extrap[Which, 
                "Lat"], col = Col(n = 50)[ceiling(f(Mat[Which, 
                ])[, t] * 49) + 1], cex = 0.01)
            title(Year_Set[t], line = 0.1, cex.main = 1.5)
            box()
        }
        mtext(side = 1, outer = TRUE, "Longitude", cex = 1.75)
        mtext(side = 2, outer = TRUE, "Latitude", cex = 1.75)
        dev.off()
        png(file = paste0(FileName, switch(RespI, "Pres", "Pos", 
            "Dens", "Pos_Rescaled", "Dens_Rescaled"), "_Legend.png", 
            sep = ""), width = 1, height = 2 * MapSizeRatio["Height(in)"], 
            res = 200, units = "in")
        Heatmap_Legend(colvec = Col(n = 50), heatrange = range(Mat), 
            margintext = switch(RespI, "Encounter probability", 
                "log(Positive catch rate)", expression(paste("log Density, log(kg. / ", 
                  km^2, ")", sep = "")), NULL, NULL))
        dev.off()
    }
  }

aaronmberger/Geo_dGLMM_habitat documentation built on May 10, 2019, 3:20 a.m.