calcul_donnes_Tmp_iir.R 1.35 KiB
setwd("D:/IIR/temperatures/IIR")
require(fastmatch)
camp <- read.table("./data/camp_2017_06_21.txt", sep = "\t", header = TRUE, stringsAsFactor = FALSE)
wd <- "D:/Data/SAFRAN/"
temps <- matrix(numeric(), nrow(camp), 3)
colnames(temps) <- c("TMOY", "TMAX", "TAMP")
auxiJul <- seq(7, 10*12, 12)
auxiJan <- seq(1, 120, 12)
for (i in 1:nrow(camp)) {
  if (grepl("NA", u <- camp$gridcode[i]))
    temps[i,] <- NA
  else {
    temp <- read.table(sprintf("%s%s_month_tmp.txt", wd, u), sep = ";", header = TRUE, colClasses = c("character", "numeric"))
    annee <- as.integer(substr(camp$Date[i], 7, 10))-1
    d1 <- expand.grid(Annee = (annee-9):annee, Mois = sprintf("%02d", 1:12))
    d1 <- do.call(paste0, d1[do.call(order, d1),])
    temp <- temp$Tmp[fmatch(d1, temp$Date)]
    tmean <- sum(temp)/120
    tjul <- sum(temp[auxiJul])/12
    tjan <- sum(temp[auxiJan])/12
    tamp <- tjul - tjan
    temps[i,] <- c(tmean, tjul, tamp)
camp$deltaT <- with(camp, (Altitude-AltitudePla)*0.65/100)
temps <- temps+camp$deltaT
camp <- cbind(camp, temps)
write.table(camp, file = "./data/camp_temp_2017_06_21.txt", sep = "\t", row.names = FALSE, quote = TRUE)
SPt <- SpatialPoints(coords = camp[, c("X", "Y")],
                     proj4string = CRS("+init=epsg:2154"))
FR_ctr_L93 <- rgdal::spTransform(FR_ctr_L2E, )
FR_ctr_W84 <- rgdal::spTransform(FR_ctr_L2E, CRS("+init=epsg:4326"))