-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_rain_accum.pro
113 lines (91 loc) · 4.43 KB
/
get_rain_accum.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
pro get_rain_accum,pixsum,don,nlonsFull,SrfRain_FULL,raintypeFULL,$
grid_storm_FULL,lonsFull_sub,latsFull_sub,$
RTo_stra,RTo_conv,RTo_othe,RTo_noRa,$
ctaStra,ctaConv,ctaOthe,ctaNoRa,$
freqArray,rainArray,nRaiArray
;; TO DO
;; Check why nlatsFull is not required for calculating 'col' and 'row'
;; Rename 'pila' to something more logical
;; INPUTS: pixsum,don,nlonsFull,SrfRain_FULL,lonsFull_sub,latsFull_sub,
;; freqArray,grid_storm_FULL,raintypeFULL
;; OUTPUTS: RTo_stra,RTo_conv,RTo_othe,RTo_noRa,ctaStra,ctaConv,ctaOthe,ctaNoRa
;; INTERNAL: col,row,nearSrfR_Org,t_col,ctaC,t_row,ctaR,colRT,
COMMON topoBlock,topo_lat,topo_lon,DEM
COMMON coarseBlock,lonsC,latsC,nlonsC,nlatsC,freq_Full,freq_Core
COMMON fineBlock,lonsF,latsF,nlonsF,nlatsF,rain_NSRFull,nRai_NSRFull,rain_NSRCore,nRai_NSRCore
COMMON ncInfoBlock,nlons,nlats,nalts,ntimes,lats,lons,hgts,raintype,raintype_fillValue, $
raintype_noRainValue,SrfRain,SrfRain_fillValue,refl_3D,refl_3D_fillValue, $
cta_strt,cta_conv,cta_ShIs,rain_type3D,hgts_3D
;; include constants
@constants.pro
;; Initialize rain rates and counts and temp arrays
RTo_conv=0. & ctaConv=0l
RTo_stra=0. & ctaStra=0l
RTo_othe=0. & ctaOthe=0l
RTo_noRa=0. & ctaNoRa=0l
;; go through each ??? pixel in storm
for i=0l,pixsum-1l do begin
;; identify col and row ids of pixel
col=don[i] mod nlonsFull
row=long(fix(don[i]/float(nlonsFull)))
nearSrfR_Org=SrfRain_FULL[col,row]
;; count the ??? pixels
t_col=where(lonsC le lonsFull_sub[col],ctaC)
t_row=where(latsC le latsFull_sub[row],ctaR)
;; if pixel located within boundaries
if ctaC ne 0 and ctaR ne 0 then begin
;; ???
colRT=(reverse(t_col))[0]
rowRT=(reverse(t_row))[0]
freqArray[colRT,rowRT]=freqArray[colRT,rowRT]+1l
;; locate indices (x,y,z location of individual pixels within the FULL storm)
pila=reform(grid_storm_FULL[col,row,*])
w_CV=where(pila ne 0,ctaHgt)
if ctaHgt ge 1 then begin
;; distance between lowest pixel and ground
id_top1=(where(topo_lon ge lonsFull_sub[col]))[0]
id_top2=(where(topo_lat ge latsFull_sub[row]))[0]
;; locate the pixel in the nearest fine grid cell
tmp_col=(where(float(lonsF) eq lonsFull_sub[col],ctaC))[0]
tmp_row=(where(float(latsF) eq latsFull_sub[row],ctaR))[0]
;; if pixel located within boundaries
if ctaC ne 0 and ctaR ne 0 then begin
;; if there is rain at pixel
if nearSrfR_Org ne SrfRain_fillValue then begin
rainArray[tmp_col,tmp_row]=rainArray[tmp_col,tmp_row]+nearSrfR_Org
nRaiArray[tmp_col,tmp_row]=nRaiArray[tmp_col,tmp_row]+1l
;; create accumulated rain rate vectors
if raintypeFULL[col,row] eq CONV then begin
RTo_conv=RTo_conv+nearSrfR_Org
ctaConv=ctaConv+1l
endif else begin
if raintypeFULL[col,row] eq STRA then begin
RTo_stra=RTo_stra+nearSrfR_Org
ctaStra=ctaStra+1l
endif else begin
if raintypeFULL[col,row] ge OTHER then begin
RTo_othe=RTo_othe+nearSrfR_Org
ctaOthe=ctaOthe+1l
endif else begin
;;if raintypeFULL[col,row] eq raintype_noRainValue then begin
if raintype[col,row] eq raintype_noRainValue then begin
RTo_noRa=RTo_noRa+0.
ctaNoRa=ctaNoRa+1l
endif
endelse
endelse
endelse
endif ;; if nearSrfR_Org ne SrfRain_fillValue (rain)
endif ;; if ctaC ne 0 and ctaR ne 0 (in boundaries)
endif ;; if ctaHgt ge 1
endif ;; if ctaC ne 0 and ctaR ne 0 (in boundaries)
endfor ;; for i=0l,pixsum-1l
;; clean up
;;undefine,pila
;;undefine,colRT
;;undefine,rowRT
;;undefine,tmp_col
;;undefine,tmp_row
;;undefine,t_col
;;undefine,t_row
end