I am trying to estimate the water balance (as printed at the end of the site***.OUT file) using the .SAD files. My codes (using R) are below. As can be noticed, no value matches with the ones reported in the .OUT file, not even the before/after values. What am I doing wrong? (In yellow the ones that are a close match).
sa <- sao[,by=SAID,.(WSA=unique(WSAha))] # Table with the area per subarea
sad[,date := as.IDate(sprintf("%4d-%2d-%2d", Y, M, D))] # .SAD table
# focusing on the water components
w_sa <- unique(sad[,.(SAID, date, Y, M, D, PRCP, ET, Q, QIN, PRK,
DPRK, WYLD, SSF, RSSF, SSFI, QRF, SW, RZSW, GWST)])
# Estimating the total water flows
w_sa[sa, on="SAID", .(PRCP=sum(PRCP*WSA*10), # Precipitation
ET=sum(ET*WSA*10), # Evapotranspiration
Q=sum(Q*WSA*10), # Flow
Q13=sum(Q*WSA*(SAID==13)*10), # Flow from the outflow only
PRK=sum(PRK*WSA*10), # Percolation
QRF=sum(QRF*WSA*10), # Quick return flow
WYLD=sum(WYLD*WSA*10), # Water yield
DPRK=sum(DPRK*WSA*10))] # Deep percolation
# Results:
# PRCP ET Q Q13 PRK QRF WYLD DPRK
# 1: 35377089 18319300 8526136 55004.1 8363367 609.715 8739426 8234800
# Values before and after
w_sa[date %in% range(w_sa$date)][sa, on="SAID"][, by=date,
.(n=.N, SW=sum(SW*WSA*10), RZSW=sum(RZSW*WSA*10), GWST=sum(GWST*WSA*10))]
date n SW RZSW GWST
1: 2002-01-01 28 1135.431 1135.431 28791490
2: 2015-12-31 28 339030.372 339030.372 10757589
# From SITE13.OUT
# TOTAL WATER BALANCE (m3)
#
# PER =-0.740862D+01 DF =-0.653582D+05 BSW = 0.642210D+06
# BGWS= 0.125815D+06 BRSV= 0.000000D+00 BSNO= 0.000000D+00
# BSWL= 0.000000D+00 PCP = 0.353898D+08 WYLD= 0.867023D+07
# DPRK= 0.823769D+07 ET = 0.183257D+08 IRG = 0.000000D+00
# QIN = 0.000000D+00 PSOQ= 0.000000D+00 EVRT= 0.860678D+04
# RSIR= 0.000000E+00 WLIR= 0.000000E+00 IRDL= 0.000000D+00
# FSW = 0.882192D+06 FGWS= 0.427163D+05 FRSV= 0.000000D+00
# FSNO= 0.560344D+05 FSWL= 0.000000D+00