728x90
이번에는 이전 포스팅과 같은 그림이지만
WRF 결과를 보면 3시간 단위로 2016년 10월 6일 00:00:00 부터 10월 8일 00:00:00까지 총 17개의 파일이 있습니다
아 파일들을 반복문을 이용해서 한 번에 그려지도록 해보겠습니다
begin
DATADir = "/home/lsh/"
FILES = systemfunc("ls -1 /home/lsh/wrfout*") ;ls -1 로 해당 디렉토리 안에 wrfout이 들어간 파일들을 전부 변수로 지정
numFILES = dimsizes(FILES)
print("numFILES =" + numFILES)
print(FILES)
print(" ")
type = "png"
wks = gsn_open_wks(type, "Surface_multi")
res = True
res@MainTitle = "REAL-TIME WRF"
pltres = True
mpres = True
mpres@mpDataBaseVersion = "MediumRes"
mpres@mpDataResolution = "FinestResolution"
mpres@mpDataSetName = "Earth..4"
mpres@mpGridAndLimbOn = True
mpres@mpPerimOn = True
mpres@mpGeophysicalLineColor = "Black"
mpres@mpGridLineColor = "Black"
mpres@mpLimbLineColor = "Black"
mpres@mpNationalLineColor = "Black"
mpres@mpPerimLineColor = "Black"
mpres@mpUSStateLineColor = "Black"
mpres@mpGeophysicalLineThicknessF = 3.0
a = addfiles(FILES + ".nc", "r")
times = wrf_user_getvar(a, "times", -1)
ntimes = dimsizes(times)
;calculate Sea Level Temperature
slp = wrf_user_getvar(a, "slp", -1)
wrf_smooth_2d(slp, 3)
tc = wrf_user_getvar(a, "T2", -1)
tc = tc - 273.15
td = wrf_user_getvar(a, "td2", -1)
u = wrf_user_getvar(a, "U", -1)
v = wrf_user_getvar(a, "V", -1)
u10 = wrf_user_getvar(a, "U10", -1)
v10 = wrf_user_getvar(a, "V10", -1)
u10 = u10 * 1.94836
v10 = v10 * 1.94836
u10@units = "kts"
v10@units = "kts"
do it = 0, ntimes-1, 1 ;앞 포스팅은 마지막이 2였지만 1로 바꿔야함,
;파일 이름들이 들어가있는데 2 간격으로 반복시키면 00,06,12,18 처럼 6시간 단위로 그림
print("Working on time :" + times(it))
res@TimeLabel = times(it)
;Plotting T
opts = res
opts@cnFillOn = True
opts@ContourParameters = (/-10., 40., 5./)
opts@gsnSpreadColorEnd = -3
contour_tc = wrf_contour(a[it], wks, tc(it,:,:), opts) ;시간 부분을 해당 파일의 시간으로 설정
delete(opts)
;Plotting Td
opts = res
opts@cnFillOn = True
opts@cnLinesOn = True
opts@cnLineLabelsOn = True
opts@ContourParameters = (/-10., 30., 5./)
opts@cnLineLabelBackgroundColor = -1
opts@gsnSpreadColorEnd = -3
contour_td = wrf_contour(a[it], wks, td(it,:,:), opts) ; 위와 동일
delete(opts)
;Plotting SLP
opts = res
opts@cnLineColor = "Blue"
opts@cnHighLabelsOn = True
opts@cnLowLabelsOn = True
opts@ContourParameters = (/1000., 1060., 2./)
opts@cnLineLabelBackgroundColor = -1
opts@gsnContourLineThicknessesScale = 2.0
contour_psl = wrf_contour(a[it], wks, slp(it,:,:), opts) ; 위와 동일
delete(opts)
;Plotting Wind Vector
opts = res
opts@FieldTitle = "Wind"
opts@NumVectors = 47
vector = wrf_vector(a[it], wks, u10(it,:,:), v10(it,:,:), opts) ; 위와 동일
delete(opts)
plot = wrf_map_overlays(a[it], wks, (/contour_tc, contour_psl, vector/), pltres, mpres)
plot = wrf_map_overlays(a[it], wks, (/contour_td, vector/), pltres, mpres)
end do
end
전체 코드입니다
위 쪽은 거의 바뀐게 없고 아래쪽에서 반복문을 통해 그림이 그려지도록
dimension을 설정한 부분들은 주석을 달아두겠습니다
그림은 이전 포스팅과 다른건 없습니다
결과는 이렇게 나와야합니다
한 파일 당 기온그림 한 번, 이슬점 온도 그림 한 번
이렇게 교대로 그림을 그리기 때문에 홀수 번째 파일들이 기온그림, 짝수 번째 파일들이 이슬점 온도 그림입니다
728x90
'NCL' 카테고리의 다른 글
NCL로 상층 등고선과 풍향풍속 그려보기 (0) | 2023.07.20 |
---|---|
작업12: NCL로 기상자료 입력하기 (0) | 2023.07.16 |
작업10: WRF 모델 결과 NCL로 시각화하기3 (0) | 2023.06.22 |
작업9: WRF 모델 결과 NCL로 시각화하기2 (0) | 2023.06.21 |
작업8: WRF 모델 결과 NCL로 시각화하기1 (0) | 2023.06.21 |