Skip to content

Commit

Permalink
DDAI-7: Add script to produce total column water
Browse files Browse the repository at this point in the history
  • Loading branch information
mpartio committed Nov 19, 2024
1 parent 51aaa3d commit 3ff30ff
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions himan-scripts/tcw.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Produce total column water for MEPS / MNWC
-- "This parameter is the sum of water vapour, liquid water, cloud ice,
-- rain and snow in a column extending from the surface of the Earth to
-- the top of the atmosphere."
-- Source: https://codes.ecmwf.int/grib/param-db/136

local tcwv = luatool:Fetch(current_time, level(HPLevelType.kEntireAtmosphere, 0), param("TOTCWV-KGM2"), current_forecast_type)
local cldice = hitool:VerticalSum(param("CLDICE-KGKG"),8,15000)
local cldwtr = hitool:VerticalSum(param("CLDWAT-KGKG"),8,15000)
local snowmr = hitool:VerticalSum(param("SNOWMR-KGKG"),8,15000)
local rainmr = hitool:VerticalSum(param("RAINMR-KGKG"),8,15000)
local graupmr = hitool:VerticalSum(param("GRAUPMR-KGKG"),8,15000)

if not tcwv or not cldice or not cldwtr or not snowmr or not rainmr or not graupmr then
logger:Error("Data not found")
return
end

local tcw = {}
for i=1, #tcwv do
tcw[i] = tcwv[i] + cldice[i] + cldwtr[i] + snowmr[i] + rainmr[i] + graupmr[i]
end

result:SetParam(param("TCW-KGM2"))
result:SetValues(tcw)
luatool:WriteToFile(result)

0 comments on commit 3ff30ff

Please sign in to comment.