Commit e315d4b8 authored by Wesseling, Jan's avatar Wesseling, Jan
Browse files

Read evapotranspiration

parent 5728befd
......@@ -13,4 +13,10 @@ module Types
outflowTo2 :: Int64
percentage2 :: Float64
end
mutable struct Evapotranspiration
year :: Int64
evapotranspiration :: Float64
end
end
......@@ -5,11 +5,11 @@ using DataFrames
include("Types.jl")
catchment = Nothing
ETp = Nothing
P = Nothing
evap = Nothing
precip = Nothing
function createCatchment(aData :: DataFrame)
catchment = Array{Types.CatchmentData}(undef,1)
global catchment = Array{Types.CatchmentData}(undef,1)
try
try
resize!(catchment, size(aData,1)-1)
......@@ -150,11 +150,50 @@ function createCatchment(aData :: DataFrame)
catchment[i-1] = Types.CatchmentData(id,area,cultivated,storage,maxHeight,runoffCoefficient,
global catchment[i-1] = Types.CatchmentData(id,area,cultivated,storage,maxHeight,runoffCoefficient,
infiltrationRate,infiltrationPercentage,outflowsTo1,
percentage1,outflowsTo2,percentage2)
# println(catchment[i-1])
end
catch e
println("???Error in createCatchment: ",e)
end
finally
end
end
function createETp(aData :: DataFrame)
global evap = Array{Types.Evapotranspiration}(undef,1)
try
try
resize!(evap, size(aData,1)-1)
# println(size(catchment,1))
for i in 2:size(aData,1)
year = -1
if !ismissing(aData[i,1])
if typeof(aData[i,1]) == String
if strip(aData[i,1]) != ""
year = tryparse(Int64, aData[i,1])
end
else
year = aData[i,1]
end
end
etp = -1.0
if !ismissing(aData[i,2])
if typeof(aData[i,2]) == String
if strip(aData[i,2]) != ""
etp = tryparse(Float64, aData[i,2])
end
else
etp = aData[i,2]
end
end
global evap[i-1] = Types.Evapotranspiration(year, etp)
# println(evap[i-1])
end
catch e
......@@ -172,11 +211,12 @@ function readData()
xf = XLSX.readxlsx(fileName)
println("After readxlsx")
sheet = xf["Catchment"]
matrix = dropmissing!(DataFrame(sheet[:]))
createCatchment(matrix)
exit(0)
data = dropmissing!(DataFrame(sheet[:]))
createCatchment(data)
sheet = xf["ETp"]
global ETp = dropmissing!(DataFrame(sheet[:]))
data = dropmissing!(DataFrame(sheet[:]))
createETp(data)
exit(0)
sheet = xf["Rainfall"]
global P = dropmissing!(DataFrame(sheet[:]))
println("OK")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment