Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
WaterHarvesting
WHCatch
Commits
e315d4b8
Commit
e315d4b8
authored
Apr 05, 2021
by
Wesseling, Jan
Browse files
Read evapotranspiration
parent
5728befd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Types.jl
View file @
e315d4b8
...
...
@@ -13,4 +13,10 @@ module Types
outflowTo2
::
Int64
percentage2
::
Float64
end
mutable struct
Evapotranspiration
year
::
Int64
evapotranspiration
::
Float64
end
end
WHCatch.jl
View file @
e315d4b8
...
...
@@ -5,11 +5,11 @@ using DataFrames
include
(
"Types.jl"
)
catchment
=
Nothing
ET
p
=
Nothing
P
=
Nothing
eva
p
=
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"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment