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

Read Precipitation

parent e315d4b8
......@@ -18,5 +18,9 @@ module Types
year :: Int64
evapotranspiration :: Float64
end
mutable struct Precipitation
year :: Int64
event :: Array{Float64}
end
end
......@@ -197,7 +197,58 @@ function createETp(aData :: DataFrame)
catch e
println("???Error in createCatchment: ",e)
println("???Error in createETp: ",e)
end
finally
end
end
function createPrecipitationData(aData :: DataFrame)
global prec = Array{Types.Precipitation}(undef,1)
try
try
resize!(prec, size(aData,1)-1)
# println(size(catchment,1))
for i in 2:size(aData,1)
# println(i)
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
# println(i, " ",year)
leap = isleapyear(Date(year,1,1))
ev = Array{Float64}(undef,1)
p = Types.Precipitation(year, ev)
p.year = year
days = 365
if leap
days = 366
end
resize!(p.event, days)
for j in 2:days+1
event = -1.0
if !ismissing(aData[i,j])
if typeof(aData[i,j]) == String
if strip(aData[i,j]) != ""
event = tryparse(Float64, aData[i,j])
end
else
event = aData[i,j]
end
end
p.event[j-1] = event
end
global prec[i-1] = p
# println(evap[i-1])
end
catch e
println("???Error in createPrecipitationData: ",e)
end
finally
end
......@@ -216,9 +267,10 @@ function readData()
sheet = xf["ETp"]
data = dropmissing!(DataFrame(sheet[:]))
createETp(data)
exit(0)
sheet = xf["Rainfall"]
global P = dropmissing!(DataFrame(sheet[:]))
data = DataFrame(sheet[:])
# println(first(data,10))
createPrecipitationData(data)
println("OK")
catch e
println("???ERROR in readData: ",e)
......
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