Skip to content

Commit

Permalink
Updating moisture mode calculation stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
natgeo-wong committed Aug 29, 2024
1 parent 018b4a5 commit 9e8b9ca
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/extract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,10 @@ function extractmoisturemode(
t = collect(t[1:(end-1)] .+ t[2:end]) / 2
t = t / tperday

mse = zeros(64,nt,nmember) * NaN
pre = zeros(64,nt,nmember) * NaN
tbs = zeros(64,nt,nmember) * NaN
qbs = zeros(64,nt,nmember) * NaN

int_mse = zeros(nt,nmember) * NaN
int_tbs = zeros(nt,nmember) * NaN
int_qbs = zeros(nt,nmember) * NaN

Expand All @@ -385,8 +383,7 @@ function extractmoisturemode(
ods = NCDataset(fnc)
try
z[:,ids] .= ods["z"][:]
pre[:,:,ids] .= ods["PRES"][:,:]
mse[:,:,ids] .= ods["MSE"][:,:]
pre[:,:,ids] .= ods["PRES"][:,:] * 100
tbs[:,:,ids] .= ods["TBIAS"][:,:]
qbs[:,:,ids] .= ods["QBIAS"][:,:]
catch
Expand All @@ -399,15 +396,14 @@ function extractmoisturemode(

end

ipp = zeros(66); ipp[1] = 1009.23; iipp = @view ipp[2:(end-1)]
ipp = zeros(66); ipp[1] = 100923; iipp = @view ipp[2:(end-1)]
itmp = zeros(66); iitmp = @view itmp[2:(end-1)]

for ids = 1 : nmember, it = 1 : nt

iipp .= pre[:,it,ids]
iitmp .= mse[:,it,ids]; int_mse[it,ids] = -trapz(ipp,itmp)
iitmp .= tbs[:,it,ids]; int_tbs[it,ids] = -trapz(ipp,itmp)
iitmp .= qbs[:,it,ids]; int_qbs[it,ids] = -trapz(ipp,itmp)
iitmp .= tbs[:,it,ids]; int_tbs[it,ids] = -trapz(ipp,itmp) * 1.0035
iitmp .= qbs[:,it,ids]; int_qbs[it,ids] = -trapz(ipp,itmp) * 2.5009

end

Expand Down Expand Up @@ -455,9 +451,9 @@ function extractmoisturemode(

nctime[:] = t
ncz[:] = dropdims(mean(z,dims=2),dims=2)
ncmse[:,:] = int_mse
nctbs[:,:] = int_tbs
ncqbs[:,:] = int_qbs
ncmse[:,:] = int_tbs .+ int_qbs

close(nds)

Expand Down

0 comments on commit 9e8b9ca

Please sign in to comment.