Ich versuche TRMM 3B42 3-Stunden-Binärdaten für eine bestimmte Zeitspanne von diesem NASA FTP server herunterladen.Kann jemand TRMM 3B42 Zeitreihendaten herunterladen?
Es ist ein ausgezeichneter Code gemacht von Florian Detsch das tägliche Produkt zum Download (hier ist der Link: https://github.com/environmentalinformatics-marburg/Rsenal/blob/master/R/downloadTRMM.R) im GitHub-only Rsenal Paket. Leider funktioniert es nicht für die 3-Stunden-Daten.
änderte ich den Code:
downloadTRMM <- function(begin, end, dsn = ".", format = "%Y-%m-%d.%H") {
## transform 'begin' and 'end' to 'Date' object if necessary
if (!class(begin) == "Date")
begin <- as.Date(begin, format = format)
if (!class(end) == "Date")
end <- as.Date(end, format = format)
## trmm ftp server
ch_url <-"ftp://disc2.nascom.nasa.gov/data/TRMM/Gridded/3B42_V7/"
## loop over daily sequence
ls_fls_out <- lapply(seq(begin, end, 1), function(i) {
# year and julian day (name of the corresponding folder)
tmp_ch_yr <- strftime(i, format = "%Y%m")
#tmp_ch_dy <- strftime(i, format = "%j")
# trmm date format
tmp_dt <- strftime(i+1, format = "%Y%m%d.%H")
# list files available on server
tmp_ch_url <- paste(ch_url, tmp_ch_yr, "", sep = "/")
tmp_ch_fls <- tmp_ch_fls_out <- character(2L)
for (j in 1:2) {
tmp_ch_fls[j] <- paste0("3B42.", tmp_dt, "z.7.precipitation",
ifelse(j == 1, ".bin"))
tmp_ch_fls[j] <- paste(tmp_ch_url, tmp_ch_fls[j], sep = "/")
tmp_ch_fls_out[j] <- paste(dsn, basename(tmp_ch_fls[j]), sep = "/")
download.file(tmp_ch_fls[j], tmp_ch_fls_out[j], mode = "wb")
}
# return data frame with *.bin and *.xml filenames
tmp_id_xml <- grep("xml", tmp_ch_fls_out)
data.frame(bin = tmp_ch_fls_out[-tmp_id_xml],
xml = tmp_ch_fls_out[tmp_id_xml],
stringsAsFactors = FALSE)
})
## join and return names of processed files
ch_fls_out <- do.call("rbind",ls_fls_out)
return(ch_fls_out)
}
getwd()
setwd("C:/Users/joaoreis/Documents/Bases_Geograficas/trmm_3h/")
fls_trmm <- downloadTRMM(begin = "2008-01-01.00", end = "2008-01-05.00")
fls_trmm
Aber ich erhalte den folgenden Fehler:
trying URL ' ftp://disc2.nascom.nasa.gov/data/TRMM/Gridded/3B42_V7//200801//3B42.20080102.00z.7.precipitation.bin ' Error in download.file(tmp_ch_fls[j], tmp_ch_fls_out[j], mode = "wb") : cannot open URL ' ftp://disc2.nascom.nasa.gov/data/TRMM/Gridded/3B42_V7//200801//3B42.20080102.00z.7.precipitation.bin ' In addition: Warning message: In download.file(tmp_ch_fls[j], tmp_ch_fls_out[j], mode = "wb") : InternetOpenUrl failed: '' Called from: download.file(tmp_ch_fls[j], tmp_ch_fls_out[j], mode = "wb")
Wer weiß, wie es zu beheben R verwenden?
Danke!
Es sieht nicht so schwierig aus, den ursprünglichen Code zu ändern, um 3-Stunden-Daten unterzubringen. Was hast du bisher versucht? Welche Fehler haben Sie bekommen? – Tung
@thecatalyst, gibt es einige Unterschiede in der Art, wie die Daten gespeichert werden. Zum Beispiel wird der Dateiname julian day ([daily data] (ftp://disc3.nascom.nasa.gov/data/s4pa/TRMM_L3/TRMM_3B42_daily/2008/001/)) verwendet und der andere verwendet jeweils einen Ordner Monat des Jahres, um die Datendatei zu speichern ([3-Stunden-Daten] (ftp://disc2.nascom.nasa.gov/data/TRMM/Gridded/3B42_V7/)). Ich denke, deshalb funktioniert nicht. Ich versuche zu lösen, aber ich kann noch nicht viel in R machen, ich benutze normalerweise nur das Raster-Paket. –