pacotes <- c("dplyr", "magrittr", "RNetCDF", "raster", "ggplot2",
"plotly")
sapply(pacotes,require,character.only = TRUE)
dplyr magrittr RNetCDF raster ggplot2 plotly
TRUE TRUE TRUE TRUE TRUE TRUE
options(max.print = 100)
setwd("/home/wrf/TOPICOS_II/Analises")
source("./R/aux.funs.R")
wrf.list.files <-
list.files(path = "~/Build_WRF/WRFV3/topicosII/",pattern = "wrfout", full.names = TRUE)
basename(wrf.list.files)
[1] "wrfout_d01_2016-04-29_00:00:00" "wrfout_d01_2016-04-29_03:00:00" "wrfout_d01_2016-04-29_06:00:00"
[4] "wrfout_d01_2016-04-29_09:00:00" "wrfout_d01_2016-04-29_12:00:00" "wrfout_d01_2016-04-29_15:00:00"
[7] "wrfout_d01_2016-04-29_18:00:00" "wrfout_d01_2016-04-29_21:00:00" "wrfout_d01_2016-04-30_00:00:00"
[10] "wrfout_d01_2016-04-30_03:00:00" "wrfout_d01_2016-04-30_06:00:00" "wrfout_d01_2016-04-30_09:00:00"
[13] "wrfout_d01_2016-04-30_12:00:00" "wrfout_d01_2016-04-30_15:00:00" "wrfout_d01_2016-04-30_18:00:00"
[16] "wrfout_d01_2016-04-30_21:00:00" "wrfout_d01_2016-05-01_00:00:00"
Segundo a lista de variavéis e atributos no mesmo arquivo NetCDF.
# Reading first file
run.nc <-
open.nc(wrf.list.files[1],write = TRUE)
file.info <- file.inq.nc(run.nc)
vars.info <-
sapply(1:(file.info$nvars-1), function(i){
var <-
var.inq.nc(ncfile = run.nc,variable = i)
var$longname <-
att.get.nc(ncfile = run.nc,variable = i,attribute = 2 )
var$units <-
att.get.nc(ncfile = run.nc,variable = i,attribute = 3 )
c(var$id, var$name ,var$ndims, toupper(var$longname), var$units) %>% t
}) %>% t %>% as.data.frame() %>%
setNames(c("ID","NAME","DIMS","LONGNAME","UNITS")) %>%
mutate(DIMS = as.integer(DIMS))
vars.info
NA
vars.info %>%
filter(DIMS > 1) %>%
arrange(DIMS) %>%
dplyr::select(ID,NAME,LONGNAME,UNITS)
NA
D2ou3 <- ifelse(vars.info$DIMS > 1,TRUE,FALSE)
run.000 <- read.nc(ncfile = run.nc)
run.000 <- run.000[D2ou3]
wrf.vars <- run.000 %>% names
Na configuração atual WRF utiliza a classificação do USGS, com 24 tipos de cobertura do solo. No arquivo LANDUSE.TBL se definem as classificações e diferencia entre INVERNO e VERÃO. No caso não teve diferença.
veg_class_verao <-
read.csv("~/Build_WRF/WRFV3/topicosII/LANDUSE.TBL",
header = FALSE,sep = ",",
skip = 33,nrows = 33) %>%
select(V1,V9) %>%
setNames(c("ID","VERAO"))
veg_class_inverno <-
read.csv("~/Build_WRF/WRFV3/topicosII/LANDUSE.TBL",
header = FALSE,sep = ",",
skip = 67,nrows = 33) %>%
select(V1,V9) %>%
setNames(c("ID","INVERNO"))
veg_class <- left_join(veg_class_verao,veg_class_inverno,by = "ID")
veg_class %<>%
mutate(CHANGE = ifelse(VERAO == INVERNO, "-","X"))
veg_type <-
wrf2raster(file = wrf.list.files[6], ## Função criada para ler o arquivo
vars = "IVGTYP",
level = 1)
wrfout_d01_2016-04-29_15:00:00
wrf2raster(file = wrf.list.files[19],
vars = "LU_INDEX",
level = 3)
NA
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 1, 21 (min, max)
wrf2raster(file = wrf.list.files[9],
vars = "LAI",
level = 1)
wrfout_d01_2016-04-30_00:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0, 5.756851 (min, max)
freq(veg_type) %>%
as.data.frame() %>%
arrange(desc(count)) %>%
setNames(c("ID","NCELL")) %>%
left_join(veg_class, by = "ID")
soil_type <-
wrf2raster(file = wrf.list.files[6],
vars = "ISLTYP",
level = 1)
wrfout_d01_2016-04-29_15:00:00
freq(soil_type) %>%
as.data.frame() %>%
arrange(desc(count)) %>%
setNames(c("ID","NCELL"))
# Eliminando áreas de ocêano
soil_type[soil_type == 14] <- NA
veg_type[veg_type == 16] <- NA
#
# spplot(soil_type)
# spplot(veg_type)
wrf2raster(file = wrf.list.files[7],
vars = "SLWDN",
level = 3)
wrfout_d01_2016-04-29_18:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0, 0 (min, max)
wrf2raster(file = wrf.list.files[7],
vars = "EMISS",
level = 3)
wrfout_d01_2016-04-29_18:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0.88, 0.95 (min, max)
wrf2raster(file = wrf.list.files[19],
vars = "ALBEDO",
level = 3)
NA
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0.12, 0.6 (min, max)
wrf2raster(file = wrf.list.files[19],
vars = "HFX",
level = 1)
NA
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0, 0 (min, max)
wrf2raster(file = wrf.list.files[9],
vars = "GRDFLX",
level = 3)
wrfout_d01_2016-04-30_00:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0, 0 (min, max)
wrf2raster(file = wrf.list.files[9],
vars = "GLW",
level = 1)
wrfout_d01_2016-04-30_00:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0, 0 (min, max)
wrf2raster(file = wrf.list.files[5],
vars = "LH",
level = 1)
wrfout_d01_2016-04-29_12:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0, 0 (min, max)
wrf2raster(file = wrf.list.files[5],
vars = "PBLH",
level = 1)
wrfout_d01_2016-04-29_12:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0, 0 (min, max)
wrf2raster(file = wrf.list.files[5],
vars = "UST",
level = 1)
wrfout_d01_2016-04-29_12:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 1e-04, 1e-04 (min, max)
wrf2raster(file = wrf.list.files[5],
vars = "ACHFX",
level = 1)
wrfout_d01_2016-04-29_12:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0, 0 (min, max)
wrf2raster(file = wrf.list.files[9],
vars = "RAINNC",
level = 1)
wrfout_d01_2016-04-30_00:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0, 0 (min, max)
wrf2raster(file = wrf.list.files[9],
vars = "TSK",
level = 1)
wrfout_d01_2016-04-30_00:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 260.2537, 297.0699 (min, max)
wrf2raster(file = wrf.list.files[9],
vars = "U10",
level = 1)
wrfout_d01_2016-04-30_00:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : -9.413965, 9.036017 (min, max)
wrf2raster(file = wrf.list.files[9],
vars = "V10",
level = 1)
wrfout_d01_2016-04-30_00:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : -6.914836, 10.54784 (min, max)
wrf2raster(file = wrf.list.files[9],
vars = "T2",
level = 1)
wrfout_d01_2016-04-30_00:00:00
class : RasterLayer
dimensions : 205, 333, 68265 (nrow, ncol, ncell)
resolution : 0.1388586, 0.1137923 (x, y)
extent : -76.61996, -30.38004, -41.44027, -18.11285 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 263.1057, 297.6781 (min, max)