정보
-
업무명 : WRF 모델자료 푼 후 TXT또는 CSV 로 떨어뜨리기
-
작성자 : 박진만
-
작성일 : 2021-01-27
-
설 명 :
-
수정이력 :
내용
[개요]
-
WRF 모델의 결과 파일인 NC 형태의 파일은 일반적으로 포트란 또는 ncl 로 처리 하는 것이 일반적이나, R을 이용해서도 처리가 가능하다.
-
본 글에서는 R을 통해 WRF 모델 자료를 후처리 하고 TXT 형태로 직접 떨어뜨리는 방법을 소개 하고자 한다.
[특징]
-
WRF 모델 자료 후처리
[기능]
-
데이터형 소개
[활용 자료]
-
없음
[자료 처리 방안 및 활용 분석 기법]
-
없음
[사용법]
-
소스 코드 예시 참조
[사용 OS]
-
Linux (CentOS7.0)
[사용 언어]
-
R v3.6.3
소스 코드
[서브 함수 로드]
-
WRF 의 기상 요소는 결과 파일에 모두 담겨 있는 것이 아닌 섭동 등을 고려하여 최종적으로 계산 하여야 하는 부분이 있다.
-
따라서 이를 고려하여 계산해주는 서브 함수를 별도로 생성 하여 로드하고 있다.
wrf_tk <- function(P = P, PB = PB, T = T) {
# calculate absolute temperature (K)
# Rd / CP = 0.28571 (dimensionless)
# Pair = P + PB
# theta = Tk * (100000./Pair)^(Rd/Cp)
# --> Tk = theta * (Pair / 100000.)^(R\/Cp)
#------------------------------------
Rd = 287.0
Cp = 7.0*Rd / 2.0
Rd_Cp = Rd / Cp
Pair = P + PB
theta = T + 300.0
tk = theta * (( Pair/100000. )**(Rd_Cp))
return(tk)
}
wrf_rh <- function(QVAPOR = QVAPOR, P = P, PB = PB, TK = TK, flag = flag){
# calculate Relative humidity (%) with respect to liquid water
# this function use "Tetens formula"
#------------------------------------
# input variables
# - T: perturbationj potential temperature (theta-t0)";
# - QVAPOR: Water vapor mixing ratio (kg kg-1)
# - P: perturbation pressure
# - PB: base state pressure
# # es is calculated with respect to : flag=1 water, flag=-1 ice, flag=0 mix
#------------------------------------
# epsi = 0.622
# Rd / CP = 0.28571 (dimensionless)
# Pair = P + PB # (Pa)
# theta = T + 300 # (K)
# Tair = theta * ( Pair /100000.)**(Rd/Cp) # (K)
# e_sat = 0.01 * 6.1078 * 10^( a * Tdeg / (b + Tdeg) ) # Teten's formula
# q = QVAPOR # (kg kg-1), water vapor mixing ratio
# e = q * Pair / (q + epsi)
#------------------------------------
# rh = e / e_sat * 100.
#------------------------------------
EP_3 = 0.622
QV = QVAPOR
Pair = P + PB
Tair = TK
#-- calc es -----------------------------
a_liq = 7.5
b_liq = 237.3
a_ice = 9.5
b_ice = 265.3
rTliq = 273.15 # 0 deg.C
rTice = 250.15 # -23 deg.C
# liq / ice / mix judge #
Tdeg = Tair - 273.16
Tdegliq = 0.0
Tdegice = -23.0
# liq / ice / mix judge #
es = 100. * 6.1078 * 10.0**(a_liq * Tdeg/ (b_liq + Tdeg))
es_liq = 100. * 6.1078 * 10.0**(a_liq * Tdeg/ (b_liq + Tdeg))
es_ice = 100. * 6.1078 * 10.0**(a_liq * Tdeg/ (b_liq + Tdeg))
#print(dim(Tdeg))
if (flag == 1) {
es = 100. * 6.1078 * 10.0**(a_liq * Tdeg/ (b_liq + Tdeg))
} else if (flag == -1) {
es = 100. * 6.1078 * 10.0**(a_ice * Tdeg/ (b_ice + Tdeg))
} else if (flag == 0) {
for (i in 1:dim(Tdeg)[1]) {
for (j in 1:dim(Tdeg)[2]) {
if (Tdeg[i,j] >= Tdegliq) {
es[i,j] = 100. * 6.1078 * 10.0**(a_liq * Tdeg[i,j]/ (b_liq + Tdeg[i,j]))
} else if (Tdeg[i,j] < Tdegice) {
es[i,j] = 100. * 6.1078 * 10.0**(a_ice * Tdeg[i,j]/ (b_ice + Tdeg[i,j]))
} else {
es_liq[i,j] = 100.* 6.1078 * 10.0**(a_liq * Tdeg[i,j]/ (b_liq + Tdeg[i,j]))
es_ice[i,j] = 100.* 6.1078 * 10.0**(a_ice * Tdeg[i,j]/ (b_ice + Tdeg[i,j]))
es[i,j] = ((Tdeg[i,j] - Tdegice)*es_liq[i,j] + (Tdegliq - Tdeg[i,j])*es_ice[i,j])/(Tdegliq - Tdegice)
}
}
}
}
#----------------------------------------
QVS = EP_3 * es / (Pair - es) # [kg kg-1]
rh = QV/QVS
rh = ifelse(rh > 1.0, 1.0, rh)
rh = ifelse(rh < 0.0, 0.0, rh)
return(rh)
}
[입력 파라미터 지정 및 라이브러리 로드]
-
본 스크립트는 리눅스에서 실행되고 있다.
-
따라서 이러한 파일은 일반적으로 명령줄 형태로 실행되기 때문에, 이를 리눅스에서 파라미터 형태로 받아 원하는 파일을 실행할 수 있도록 하였다.
#!/usr/bin/Rscript
args = commandArgs(TRUE)
if (! is.na(args[1])) {
today = args[1]
} else {
today <- "2020010100_2020010500"
}
library(ggplot2)
library(dplyr)
library(RNetCDF)
library(data.table)
library(stringr)
source("./sub_pro.R")
[파일 로드 및 nc 파일의 모든 요소 추출 및 계산]
-
지정된 경로로부터 nc 파일을 읽어준 후 모든 요소를 txt로 추출하여 떨어뜨린다. (본문에서는 csv 파일)
-
따라서 이를 일괄적으로 처리하는 스크립트이다.
fn <- Sys.glob(paste0("./WRF_FILE/",today,"/wrfout_d04*"))
OUT_CSV_PATH <- paste0("./WRF_TO_ASCII_FILE/",today,"/")
name = "WRF"
count <- 0
for (i in fn) {
count <- count + 1
# if(count == 10) {
# next
# }
print(i)
print("OPEN")
# open #
ncFile <- tryCatch(ncFile <- open.nc(i,write = TRUE),
error = function(e) return("error"),
warning = function(w) return("warning"),
finally = NULL)
if(ncFile[1] == "error") {
write.table(paste0("nc open error",i),row.names = F, sep = ",", append = TRUE, col.names = F)
next
}
# read #
ncdata <- tryCatch(ncdata <- read.nc(ncFile),
error = function(e) return("error"),
warning = function(w) return("warning"),
finally = NULL)
#print(ncdata)
#ncFile <- open.nc(i)
if(ncdata[1] == "error") {
write.table(paste0("nc read error",i),row.names = F, sep = ",", append = TRUE, col.names = F)
next
}
print("READ")
Times <- ncdata[["Times"]]
#ymdhm#
yy <- substr(Times,1,4)
mm <- substr(Times,6,7)
dd <- substr(Times,9,10)
hh <- substr(Times,12,13)
mn <- substr(Times,15,16)
#ymdhm#
print(c(yy,mm,dd,hh,mn))
# XLAT
XLAT <- ncdata[["XLAT"]]
# XLONG
XLONG <- ncdata[["XLONG"]]
# XLAT_U
XLAT_U <- ncdata[["XLAT_U"]]
# XLONG_U
XLONG_U <- ncdata[["XLONG_U"]]
# XLAT_V
XLAT_V <- ncdata[["XLAT_V"]]
# XLONG_V
XLONG_V <- ncdata[["XLONG_V"]]
## LOCATE ##
## ALTITUDE ##
# ZNU
ZNU <- ncdata[["ZNU"]]
# ZNW
ZNW <- ncdata[["ZNW"]]
## ALTITUDE ##
## VALUE ##
# CLDFRA (ALL layer)
for (kk in seq(1,39,1)) {
CLDFRA_PART <- ncdata[["CLDFRA"]][,,kk]
if(kk == 1) {
xt <- dim(CLDFRA_PART)[1]
yt <- dim(CLDFRA_PART)[2]
CLDFRA <- CLDFRA_PART
}
for (ii in 1:xt) {
for (jj in 1:yt) {
CLDFRA[ii,jj] <- ifelse(CLDFRA_PART[ii,jj] >= CLDFRA[ii,jj],CLDFRA_PART[ii,jj],CLDFRA[ii,jj])
}
}
}
# U (land layer)
U <- ncdata[["U"]][,,1]
# V (land layer)
V <- ncdata[["V"]][,,1]
# W (land layer)
W <- ncdata[["W"]][,,1]
# U10 (10m)
U10 <- ncdata[["U10"]]
# V10 (10m)
V10 <- ncdata[["V10"]]
# PB
PB <- ncdata[["PB"]][,,1]
# P (pressure)
P <- ncdata[["P"]][,,1]
# LAND AIR PRESSURE
PRE <- P + PB
# PSFC (mean sea level pressure)
PSFC <- ncdata[["PSFC"]]
#PSFC <- ncdata[["MSLP"]]
# T2 (2m Tempature)
T2 <- ncdata[["T2"]]
# T
T <- ncdata[["T"]][,,1]
# TK
TK <- wrf_tk(P = P,PB = PB,T = T)
# 비습 (2m)
Q2 <- ncdata[["Q2"]]
# 비습 (layer)
QVAPOR <- ncdata[["QVAPOR"]][,,1]
# HGT
HGT <- ncdata[["HGT"]]
# RAINC
RAINC <- ncdata[["RAINC"]]
# RAINNC
RAINNC <- ncdata[["RAINNC"]]
# PRINC
PRINC <- RAINC + RAINNC
# RH
RH <- wrf_rh(QVAPOR = QVAPOR,P = P,PB = PB,TK = TK, flag = 0)
### OUT ###
# CLDFRA #
CLDFRATABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), CLDFRA = c(CLDFRA))
write.csv(CLDFRATABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_CLDFRA.csv"),row.names = F)
# U #
UTABLE <- data.frame(LAT = c(XLAT_U), LONG = c(XLONG_U), U = c(U))
write.csv(UTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_U.csv"),row.names = F)
# V #
VTABLE <- data.frame(LAT = c(XLAT_V), LONG = c(XLONG_V), V = c(V))
write.csv(VTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_V.csv"),row.names = F)
# W #
WTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), W = c(W))
write.csv(WTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_W.csv"),row.names = F)
# U10 #
U10TABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), U10 = c(U10))
write.csv(U10TABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_U10.csv"),row.names = F)
# V10 #
V10TABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), V10 = c(V10))
write.csv(V10TABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_V10.csv"),row.names = F)
# PB #
PBTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), PB = c(PB))
write.csv(PBTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_PB.csv"),row.names = F)
# P #
PTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), P = c(P))
write.csv(PTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_P.csv"),row.names = F)
# PRE #
PRETABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), PRE = c(PRE))
write.csv(PRETABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_PRE.csv"),row.names = F)
# PSFC #
PSFCTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), PSFC = c(PSFC))
write.csv(PSFCTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_PSFC.csv"),row.names = F)
# T2 #
T2TABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), T2 = c(T2))
write.csv(T2TABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_T2.csv"),row.names = F)
# T #
TTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), T = c(T))
write.csv(TTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_T.csv"),row.names = F)
# TK #
TKTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), TK = c(TK))
write.csv(TKTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_TK.csv"),row.names = F)
# Q2 #
Q2TABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), Q2 = c(Q2))
write.csv(Q2TABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_Q2.csv"),row.names = F)
# QVAPOR #
QVAPORTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), QVAPOR = c(QVAPOR))
write.csv(QVAPORTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_QVAPOR.csv"),row.names = F)
# HGT #
HGTTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), HGT = c(HGT))
write.csv(HGTTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_HGT.csv"),row.names = F)
# RAINC #
RAINCTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), RAINC = c(RAINC))
write.csv(RAINCTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_RAINC.csv"),row.names = F)
# RAINNC #
RAINNCTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), RAINNC = c(RAINNC))
write.csv(RAINNCTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_RAINNC.csv"),row.names = F)
# PRINC #
PRINCTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), PRINC = c(PRINC))
write.csv(PRINCTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_PRINC.csv"),row.names = F)
# RH #
RHTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), RH = c(RH))
write.csv(RHTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_RH.csv"),row.names = F)
### OUT ###
## mean ##
meanCLDFRA <- mean(CLDFRA)
meanU <- mean(U)
meanV <- mean(V)
meanW <- mean(W)
meanU10 <- mean(U10)
meanV10 <- mean(V10)
meanPB <- mean(PB)
meanP <- mean(P)
meanPRE <- mean(PRE)
meanPSFC <- mean(PSFC)
meanT2 <- mean(T2)
meanT <- mean(T)
meanTK <- mean(TK)
meanQ2 <- mean(Q2)
meanQVAPOR <- mean(QVAPOR)
meanHGT <- mean(HGT)
meanRAINC <- mean(RAINC)
meanRAINNC <- mean(RAINNC)
meanPRINC <- mean(PRINC)
meanRH <- mean(RH)
## mean ##
# TT
stime <- paste0(yy,mm,dd,hh,mn)
# mean CLDFRA #
resultCLDFRA <- data.table(stime = stime, meanU = meanCLDFRA)
# mean U #
resultU <- data.table(stime = stime, meanU = meanU)
# mean V #
resultV <- data.table(stime = stime, meanV = meanV)
# mean W #
resultW <- data.table(stime = stime, meanW = meanW)
# mean U10 #
resultU10 <- data.table(stime = stime, meanU10 = meanU10)
# mean V10 #
resultV10 <- data.table(stime = stime, meanV10 = meanV10)
# mean PB #
resultPB <- data.table(stime = stime, meanPB = meanPB)
# mean P #
resultP <- data.table(stime = stime, meanP = meanP)
# mean PRE #
resultPRE <- data.table(stime = stime, meanPRE = meanPRE)
# mean PSFC #
resultPSFC <- data.table(stime = stime, meanPSFC = meanPSFC)
# mean T2 #
resultT2 <- data.table(stime = stime, meanT2 = meanT2)
# mean T #
resultT <- data.table(stime = stime, meanT = meanT)
# mean TK #
resultTK <- data.table(stime = stime, meanTK = meanTK)
# mean Q2 #
resultQ2 <- data.table(stime = stime, meanQ2 = meanQ2)
# mean QVAPOR #
resultQVAPOR <- data.table(stime = stime, meanQVAPOR = meanQVAPOR)
# mean HGT #
resultHGT <- data.table(stime = stime, meanHGT = meanHGT)
# mean RAINC #
resultRAINC <- data.table(stime = stime, meanRAINC = meanRAINC)
# mean RAINNC #
resultRAINNC <- data.table(stime = stime, meanRAINNC = meanRAINNC)
# mean PRINC #
resultPRINC <- data.table(stime = stime, meanPRINC = meanPRINC)
# mean RH #
resultRH <- data.table(stime = stime, meanRH = meanRH)
if(count == 1){
write.table(resultCLDFRA,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_CLDFRA.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultU,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_U.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultV,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_V.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultW,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_W.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultU10,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_U10.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultV10,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_V10.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultPB,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_PB.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultP,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_P.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultPRE,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_PRE.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultPSFC,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_PSFC.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultT2,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_T2.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultT,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_T.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultTK,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_TK.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultQ2,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_Q2.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultQVAPOR,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_QVAPOR.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultHGT,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_HGT.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultRAINC,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_RAINC.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultRAINNC,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_RAINNC.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultPRINC,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_PRINC.csv"),row.names = F, sep = ",", append = FALSE)
write.table(resultRH,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_RH.csv"),row.names = F, sep = ",", append = FALSE)
} else {
write.table(resultCLDFRA,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_CLDFRA.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultU,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_U.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultV,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_V.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultW,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_W.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultU10,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_U10.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultV10,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_V10.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultPB,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_PB.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultP,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_P.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultPRE,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_PRE.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultPSFC,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_PSFC.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultT2,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_T2.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultT,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_T.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultTK,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_TK.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultQ2,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_Q2.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultQVAPOR,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_QVAPOR.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultHGT,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_HGT.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultRAINC,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_RAINC.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultRAINNC,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_RAINNC.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultPRINC,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_PRINC.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
write.table(resultRH,paste0(OUT_CSV_PATH,"MEAN_OUT_",name,"_RH.csv"),row.names = F, sep = ",", append = TRUE, col.names = F)
}
wind_abs = sqrt(U10^2 + V10^2)
wind_dir_trig_to = atan2(U10/wind_abs, V10/wind_abs)
wind_dir_trig_to_degrees = wind_dir_trig_to * 180/pi ## -111.6 degrees
wind_dir_trig_to_degrees = ifelse(wind_dir_trig_to_degrees < 0, wind_dir_trig_to_degrees + 360, wind_dir_trig_to_degrees)
# WDIR #
WDIRTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), WDIR = c(wind_dir_trig_to_degrees))
write.csv(WDIRTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_WDIR.csv"), row.names = F)
# WS #
WSTABLE <- data.frame(LAT = c(XLAT), LONG = c(XLONG), WS = c(wind_abs))
write.csv(WSTABLE,paste0(OUT_CSV_PATH,"OUT_",name,"_",yy,mm,dd,hh,mn,"_WS.csv"),row.names = F)
}
[결과]
-
등 다수의 파일들
참고 문헌
[논문]
- 없음
[보고서]
- 없음
[URL]
- 없음
문의사항
[기상학/프로그래밍 언어]
- sangho.lee.1990@gmail.com
[해양학/천문학/빅데이터]
- saimang0804@gmail.com
'프로그래밍 언어 > R' 카테고리의 다른 글
[R] R 및 flourish studio 를 이용하여 국가별 탄소 배출량 레이싱 차트 만들기 (0) | 2021.02.01 |
---|---|
[R] 격자정보 및 U,V,풍속 정보를 이용하여 동아시아 지도에 매핑하기 (0) | 2021.01.30 |
[R] 온라인 리눅스 (Linux) 환경에서 R 및 R Studio 설치/업데이트 (0) | 2021.01.27 |
[R] 끄투 자동 게임 수행 프로그램 (test) (11) | 2021.01.22 |
[R] WRF 모델 자료로부터 기상 변수 추출 및 단열선도 시각화 그리고 RadioSonde 패키지 내 단열선도 X축 커스터마이징 (켈빈 to 섭씨) (0) | 2021.01.18 |
최근댓글