Skip to content
Snippets Groups Projects
Commit c346859a authored by xo30xoqa's avatar xo30xoqa
Browse files

Updated weather.jl to new weather parameters

Now include cloud cover, humidity, and ETo, dropped vapourpressure
parent a239757c
Branches
Tags
No related merge requests found
...@@ -13,10 +13,12 @@ struct Weather ...@@ -13,10 +13,12 @@ struct Weather
windspeed::Union{Missing,Float64} windspeed::Union{Missing,Float64}
precipitation::Union{Missing,Float64} precipitation::Union{Missing,Float64}
sunshine::Union{Missing,Float64} sunshine::Union{Missing,Float64}
vapourpressure::Union{Missing,Float64} cloudcover::Union{Missing,Float64}
humidity::Union{Missing,Float64}
meantemp::Union{Missing,Float64} meantemp::Union{Missing,Float64}
maxtemp::Union{Missing,Float64} maxtemp::Union{Missing,Float64}
mintemp::Union{Missing,Float64} mintemp::Union{Missing,Float64}
evapotranspiration::Union{Missing,Float64}
end end
""" """
...@@ -31,15 +33,15 @@ mapped to dates. ...@@ -31,15 +33,15 @@ mapped to dates.
function initweather(weatherfile::String, startdate::Date, enddate::Date) function initweather(weatherfile::String, startdate::Date, enddate::Date)
@debug "Initialising weather" @debug "Initialising weather"
data = CSV.File(weatherfile, missingstring="NA", dateformat="yyyymmdd", data = CSV.File(weatherfile, missingstring="NA", dateformat="yyyymmdd",
types=[Date, Float64, Float64, Float64, Float64, types=[Date, Float64, Float64, Float64, Float64, Float64,
Float64, Float64, Float64]) Float64, Float64, Float64])
weather = Dict{Date,Weather}() weather = Dict{Date,Weather}()
for row in data for row in data
if row.date >= startdate && row.date <= enddate if row.date >= startdate && row.date <= enddate
weather[row.date] = Weather(row.mean_windspeed, row.precipitation, weather[row.date] = Weather(row.mean_windspeed, row.precipitation,
row.sunshine_hours, row.mean_vapour_pressure, row.sunshine_hours, row.mean_cloud_cover,
row.mean_temperature, row.max_temperature, row.mean_humidity, row.mean_temperature,
row.min_temperature) row.max_temperature, row.min_temperature)
end end
end end
if length(weather) <= Dates.value(enddate-startdate) if length(weather) <= Dates.value(enddate-startdate)
...@@ -76,12 +78,12 @@ function sunshine(model::SimulationModel) ...@@ -76,12 +78,12 @@ function sunshine(model::SimulationModel)
end end
""" """
vapourpressure(model) humidity(model)
Return today's average vapour pressure in hPa. Return today's average vapour pressure in %.
""" """
function vapourpressure(model::SimulationModel) function humidity(model::SimulationModel)
model.weather[model.date].vapourpressure model.weather[model.date].humidity
end end
""" """
...@@ -110,3 +112,15 @@ Return today's minimum temperature in °C. ...@@ -110,3 +112,15 @@ Return today's minimum temperature in °C.
function mintemp(model::SimulationModel) function mintemp(model::SimulationModel)
model.weather[model.date].mintemp model.weather[model.date].mintemp
end end
"""
evapotranspiration(model)
Return today's potential evapotranspiration (ETo), based on
the
"""
function evapotranspiration(model::SimulationModel)
model.weather[model.date].evapotranspiration
end
#TODO add functions for evapotranspiration
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment