library(reshape2)
library(ggplot2)

load("R2_wind.RData")
load("R2_wind_DJF.RData")
load("R2_wind_MAM.RData")
load("R2_wind_JJA.RData")
load("R2_wind_SON.RData")
load("R2_wind.RData")

load("slope_wind_DJF.RData")
load("slope_wind_MAM.RData")
load("slope_wind_JJA.RData")
load("slope_wind_SON.RData")
load("slope_wind.RData")

load("RMSE_wind_DJF.RData")
load("RMSE_wind_MAM.RData")
load("RMSE_wind_JJA.RData")
load("RMSE_wind_SON.RData")
load("RMSE_wind.RData")

head(R2_wind_DJF)
slope <- slope_wind_SON
R2 <- R2_wind_SON
RMSE <- RMSE_wind_SON
dim(R2)
max(R2)
#which(R2 == max(R2), arr.ind = TRUE)

od_steps <- c(0, 1:9 %o% 10^(-(4:0)))
od_steps <- c(od_steps,c(1:9 %o% 10^((1))))
em_steps <- c(0, 1:9 %o% 10^(-(15:0)))
wind_steps <- seq(from = 0, to = 1.5, by = 0.025)


length(wind_steps)
length(od_steps)

rownames(R2) <- as.numeric(wind_steps)
rownames(slope) <- as.numeric(wind_steps)
rownames(RMSE) <- as.numeric(wind_steps)
rownames(R2)
colnames(R2) <- as.numeric(od_steps)
colnames(slope) <- as.numeric(od_steps)
colnames(RMSE) <- as.numeric(od_steps)
colnames(R2)
#----------------------------------------------------
# em_steps2 <- em_steps[1:55]
# for (n in 1:128)
# {
#   em_steps2 <- c(em_steps2,em_steps[1:55])
# }
# length(em_steps2)
# #----------------------------------------------------
# od_steps2 <- vector(length=7095)
# for (n in 1:129)
# {
#   for (s in 1:55)
#   {
#     od_steps2[s+(n-1)*55] <- od_steps[n]
#   }
# }
#----------------------------------------------------
longData<-melt(R2[9:49,24:47])
#longData<-longData[longData$value!=0,]
longData$Var1=as.numeric(longData$Var1)
longData$Var2=as.numeric(longData$Var2)
#head(longData$Var1)
dim(longData)
head(longData)
#longData[,1]
#longData[,2] <- od_steps2
#longData[,2]
# 
# heatplot(R2)

hex <- c("#FF0000", "#FFA500", "#FFFF00", "#008000", "#9999ff", "#000066")
hex <- c("#FF0000", "#FF6600", "#FFFF33", "#00FF00","#00FFFF", "#0000FF", "#9900CC")

#hex <- c("#EF0515","#EE800A","#D8ED0E","#59ED12","#17EC4E","#1BECCA","#1F96EB","#2323EB")
#hex <- c("#A00842", "#AE3055", "#BC5968", "#CA827B", "#D8AA8E", "#E6D3A1", "#F5FCB5")
png("R2_wind_SON.png", width = 400, height = 300)
myplot1 <- ggplot(longData, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,1), name="R²") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green", midpoint = 0.5,
  #   limit = c(0,1), space = "Lab",
  #   breaks=c(0, 0.2, 0.4, 0.6, 0.8, 1),
  #   name="R²")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - SON") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()


longData2<-melt(slope[9:49,24:47])
#longData<-longData[longData$value!=0,]
longData2$Var1=as.numeric(longData2$Var1)
longData2$Var2=as.numeric(longData2$Var2)

png("slope_wind_SON.png", width = 400, height = 300)
myplot1 <- ggplot(longData2, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,400), name="Slope [m²/kg]") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green",  midpoint = 250,
  #   limit = c(0,400),
  #   space = "Lab",
  #   name="Slope [m²/kg]")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - SON") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()


longData2<-melt(RMSE[9:49,24:47])
#longData<-longData[longData$value!=0,]
longData2$Var1=as.numeric(longData2$Var1)
longData2$Var2=as.numeric(longData2$Var2)

png("RMSE_wind_SON.png", width = 400, height = 300)
myplot1 <- ggplot(longData2, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,0.01), name="RMSE") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green",  midpoint = 250,
  #   limit = c(0,400),
  #   space = "Lab",
  #   name="Slope [m²/kg]")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - SON") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()

#------------------------------------------------------------------


R2 <- R2_wind

dim(R2)
max(R2)
#which(R2 == max(R2), arr.ind = TRUE)

length(wind_steps)
length(od_steps)

rownames(R2) <- as.numeric(wind_steps)

rownames(R2)
colnames(R2) <- as.numeric(od_steps)

colnames(R2)
#----------------------------------------------------
# em_steps2 <- em_steps[1:55]
# for (n in 1:128)
# {
#   em_steps2 <- c(em_steps2,em_steps[1:55])
# }
# length(em_steps2)
# #----------------------------------------------------
# od_steps2 <- vector(length=7095)
# for (n in 1:129)
# {
#   for (s in 1:55)
#   {
#     od_steps2[s+(n-1)*55] <- od_steps[n]
#   }
# }
#----------------------------------------------------
longData<-melt(R2[9:49,24:47])
#longData<-longData[longData$value!=0,]
longData$Var1=as.numeric(longData$Var1)
longData$Var2=as.numeric(longData$Var2)
#head(longData$Var1)
dim(longData)
head(longData)
#longData[,1]
#longData[,2] <- od_steps2
#longData[,2]
# 
# heatplot(R2)

hex <- c("#FF0000", "#FFA500", "#FFFF00", "#008000", "#9999ff", "#000066")
hex <- c("#FF0000", "#FF6600", "#FFFF33", "#00FF00","#00FFFF", "#0000FF", "#9900CC")

#hex <- c("#EF0515","#EE800A","#D8ED0E","#59ED12","#17EC4E","#1BECCA","#1F96EB","#2323EB")
#hex <- c("#A00842", "#AE3055", "#BC5968", "#CA827B", "#D8AA8E", "#E6D3A1", "#F5FCB5")
png("R2_wind.png", width = 400, height = 300)
myplot1 <- ggplot(longData, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,1), name="R²") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green", midpoint = 0.5,
  #   limit = c(0,1), space = "Lab",
  #   breaks=c(0, 0.2, 0.4, 0.6, 0.8, 1),
  #   name="R²")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - DJF") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()

#------------------------------------------------------------------

slope <- slope_wind_DJF
R2 <- R2_wind_DJF
RMSE <- RMSE_wind_DJF
dim(R2)
max(R2)
#which(R2 == max(R2), arr.ind = TRUE)

length(wind_steps)
length(od_steps)

rownames(R2) <- as.numeric(wind_steps)
rownames(slope) <- as.numeric(wind_steps)
rownames(RMSE) <- as.numeric(wind_steps)
rownames(R2)
colnames(R2) <- as.numeric(od_steps)
colnames(slope) <- as.numeric(od_steps)
colnames(RMSE) <- as.numeric(od_steps)
colnames(R2)
#----------------------------------------------------
# em_steps2 <- em_steps[1:55]
# for (n in 1:128)
# {
#   em_steps2 <- c(em_steps2,em_steps[1:55])
# }
# length(em_steps2)
# #----------------------------------------------------
# od_steps2 <- vector(length=7095)
# for (n in 1:129)
# {
#   for (s in 1:55)
#   {
#     od_steps2[s+(n-1)*55] <- od_steps[n]
#   }
# }
#----------------------------------------------------
longData<-melt(R2[9:45,24:45])
#longData<-longData[longData$value!=0,]
longData$Var1=as.numeric(longData$Var1)
longData$Var2=as.numeric(longData$Var2)
#head(longData$Var1)
dim(longData)
head(longData)
#longData[,1]
#longData[,2] <- od_steps2
#longData[,2]
# 
# heatplot(R2)

hex <- c("#FF0000", "#FFA500", "#FFFF00", "#008000", "#9999ff", "#000066")
hex <- c("#FF0000", "#FF6600", "#FFFF33", "#00FF00","#00FFFF", "#0000FF", "#9900CC")

#hex <- c("#EF0515","#EE800A","#D8ED0E","#59ED12","#17EC4E","#1BECCA","#1F96EB","#2323EB")
#hex <- c("#A00842", "#AE3055", "#BC5968", "#CA827B", "#D8AA8E", "#E6D3A1", "#F5FCB5")
png("R2_wind_DJF.png", width = 400, height = 300)
myplot1 <- ggplot(longData, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,1), name="R²") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green", midpoint = 0.5,
  #   limit = c(0,1), space = "Lab",
  #   breaks=c(0, 0.2, 0.4, 0.6, 0.8, 1),
  #   name="R²")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - DJF") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()


longData2<-melt(slope[9:49,24:47])
#longData<-longData[longData$value!=0,]
longData2$Var1=as.numeric(longData2$Var1)
longData2$Var2=as.numeric(longData2$Var2)

png("slope_wind_DJF.png", width = 400, height = 300)
myplot1 <- ggplot(longData2, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,400), name="Slope [m²/kg]") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green",  midpoint = 250,
  #   limit = c(0,400),
  #   space = "Lab",
  #   name="Slope [m²/kg]")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - DJF") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()

longData2<-melt(RMSE[9:49,24:47])
#longData<-longData[longData$value!=0,]
longData2$Var1=as.numeric(longData2$Var1)
longData2$Var2=as.numeric(longData2$Var2)

png("RMSE_wind_DJF.png", width = 400, height = 300)
myplot1 <- ggplot(longData2, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,0.01), name="RMSE") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green",  midpoint = 250,
  #   limit = c(0,400),
  #   space = "Lab",
  #   name="Slope [m²/kg]")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - DJF") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()




#-----------------------------------------------------------------------------------------
slope <- slope_wind_MAM
R2 <- R2_wind_MAM
dim(R2)
max(R2)
#which(R2 == max(R2), arr.ind = TRUE)




rownames(R2) <- as.numeric(wind_steps)
rownames(slope) <- as.numeric(wind_steps)
rownames(R2)
colnames(R2) <- as.numeric(od_steps)
colnames(slope) <- as.numeric(od_steps)
colnames(R2)
#----------------------------------------------------
# em_steps2 <- em_steps[1:55]
# for (n in 1:128)
# {
#   em_steps2 <- c(em_steps2,em_steps[1:55])
# }
# length(em_steps2)
# #----------------------------------------------------
# od_steps2 <- vector(length=7095)
# for (n in 1:129)
# {
#   for (s in 1:55)
#   {
#     od_steps2[s+(n-1)*55] <- od_steps[n]
#   }
# }
#----------------------------------------------------
longData<-melt(R2[9:49,24:47])
#longData<-longData[longData$value!=0,]
longData$Var1=as.numeric(longData$Var1)
longData$Var2=as.numeric(longData$Var2)
#head(longData$Var1)
dim(longData)
head(longData)
#longData[,1]
#longData[,2] <- od_steps2
#longData[,2]
# 
# heatplot(R2)

hex <- c("#FF0000", "#FFA500", "#FFFF00", "#008000", "#9999ff", "#000066")
hex <- c("#FF0000", "#FF6600", "#FFFF33", "#00FF00","#00FFFF", "#0000FF", "#9900CC")

#hex <- c("#EF0515","#EE800A","#D8ED0E","#59ED12","#17EC4E","#1BECCA","#1F96EB","#2323EB")
#hex <- c("#A00842", "#AE3055", "#BC5968", "#CA827B", "#D8AA8E", "#E6D3A1", "#F5FCB5")
png("R2_wind_MAM.png", width = 400, height = 300)
myplot1 <- ggplot(longData, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,1), name="R²") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green", midpoint = 0.5,
  #   limit = c(0,1), space = "Lab",
  #   breaks=c(0, 0.2, 0.4, 0.6, 0.8, 1),
  #   name="R²")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - MAM") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()


longData2<-melt(slope[9:49,24:47])
#longData<-longData[longData$value!=0,]
longData2$Var1=as.numeric(longData2$Var1)
longData2$Var2=as.numeric(longData2$Var2)

png("slope_wind_MAM.png", width = 400, height = 300)
myplot1 <- ggplot(longData2, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,400), name="Slope [m²/kg]") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green",  midpoint = 250,
  #   limit = c(0,400),
  #   space = "Lab",
  #   name="Slope [m²/kg]")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - MAM") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()


#------------------------------------------------------------------------------

slope <- slope_wind_JJA
R2 <- R2_wind_JJA
dim(R2)
max(R2)
#which(R2 == max(R2), arr.ind = TRUE)




rownames(R2) <- as.numeric(wind_steps)
rownames(slope) <- as.numeric(wind_steps)
rownames(R2)
colnames(R2) <- as.numeric(od_steps)
colnames(slope) <- as.numeric(od_steps)
colnames(R2)
#----------------------------------------------------
# em_steps2 <- em_steps[1:55]
# for (n in 1:128)
# {
#   em_steps2 <- c(em_steps2,em_steps[1:55])
# }
# length(em_steps2)
# #----------------------------------------------------
# od_steps2 <- vector(length=7095)
# for (n in 1:129)
# {
#   for (s in 1:55)
#   {
#     od_steps2[s+(n-1)*55] <- od_steps[n]
#   }
# }
#----------------------------------------------------
longData<-melt(R2[9:49,24:47])
#longData<-longData[longData$value!=0,]
longData$Var1=as.numeric(longData$Var1)
longData$Var2=as.numeric(longData$Var2)
#head(longData$Var1)
dim(longData)
head(longData)
#longData[,1]
#longData[,2] <- od_steps2
#longData[,2]
# 
# heatplot(R2)

hex <- c("#FF0000", "#FFA500", "#FFFF00", "#008000", "#9999ff", "#000066")
hex <- c("#FF0000", "#FF6600", "#FFFF33", "#00FF00","#00FFFF", "#0000FF", "#9900CC")

#hex <- c("#EF0515","#EE800A","#D8ED0E","#59ED12","#17EC4E","#1BECCA","#1F96EB","#2323EB")
#hex <- c("#A00842", "#AE3055", "#BC5968", "#CA827B", "#D8AA8E", "#E6D3A1", "#F5FCB5")
png("R2_wind_JJA.png", width = 400, height = 300)
myplot1 <- ggplot(longData, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,1), name="R²") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green", midpoint = 0.5,
  #   limit = c(0,1), space = "Lab",
  #   breaks=c(0, 0.2, 0.4, 0.6, 0.8, 1),
  #   name="R²")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - JJA") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()


longData2<-melt(slope[9:49,24:47])
#longData<-longData[longData$value!=0,]
longData2$Var1=as.numeric(longData2$Var1)
longData2$Var2=as.numeric(longData2$Var2)

png("slope_wind_JJA.png", width = 400, height = 300)
myplot1 <- ggplot(longData2, aes(x = as.factor(Var1), y = as.factor(Var2))) +
  geom_raster(aes(fill=value)) + coord_equal(expand = F) +
  scale_fill_gradientn(colours = rev(hex),limit = c(0,400), name="Slope [m²/kg]") +
  # scale_fill_gradient2(
  #   low = "red", mid = "yellow", high = "green",  midpoint = 250,
  #   limit = c(0,400),
  #   space = "Lab",
  #   name="Slope [m²/kg]")  +
  scale_x_discrete(breaks = c("0","0.2","0.4","0.6","0.8","1","1.2","1.4") )+
  scale_y_discrete(breaks = c("1e-04", "0.001","0.01","0.1", "1","10") )+
  labs(y="DOD threshold", x="U* threshold [m/s]", title="North Africa - JJA") +
  #scale_x_discrete(breaks = c("0","1e-14","1e-13","1") ) +
  theme_bw() + theme(axis.text.x=element_text(size=15, angle=90, vjust=0.3),
                     axis.text.y=element_text(size=15),
                     plot.title=element_text(size=17),
                     legend.text = element_text(size=15),
                     axis.title=element_text(size=16),
                     legend.title=element_text(size=16))
print(myplot1)
dev.off()


# length(longData$Var1)
# length(longData$Var2)
# length(longData$value)
# raster <- ggplot(longData, aes(x = as.factor(Var2), y = as.factor(Var1), z=value)) +
#   geom_raster(aes(fill = value), alpha = 1) + coord_equal(expand = F) +
#   scale_fill_gradient(low = "red", high = "green")+
#   #geom_contour(colour = "white", binwidth = 0.2) +
#   scale_x_discrete(breaks = c("0","1e-14","1e-13","1e-12","1e-11","1e-10","1e-9","1e-8","1") )+
#   scale_y_discrete(breaks = c("0","1e-04","0.001","1e-2","1e-1","1e-0") )+
#   labs(fill = "Frequency", title = "Frequency per area", x = 'Longitude', y = 'Latitude')
# raster


warning()