Skip to content

Commit

Permalink
Merge pull request #7 from fabern/reduce-imports
Browse files Browse the repository at this point in the history
Reduce imports of packages
  • Loading branch information
fabern authored Mar 5, 2021
2 parents 2d04744 + 4094847 commit a7eb41a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LWFBrook90"
uuid = "100deb6c-4418-4b77-ad5c-a1fadb580743"
authors = ["Fabian Bernhard"]
version = "0.1.1"
version = "0.1.2"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand Down
4 changes: 2 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using LWFBrook90
using Documenter
using Documenter: makedocs, deploydocs, HTML

makedocs(;
modules=[LWFBrook90],
authors="Fabian Bernhard",
repo="https://github.com/fabern/LWFBrook90.jl/blob/{commit}{path}#L{line}",
sitename="LWFBrook90.jl",
format=Documenter.HTML(;
format=HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://fabern.github.io/LWFBrook90.jl",
assets=String[],
Expand Down
1 change: 0 additions & 1 deletion src/LWFBrook90.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module LWFBrook90

using OrdinaryDiffEq # instead of loading the full DifferentialEquations
using DiffEqCallbacks # instead of loading the full DifferentialEquations
using Dates

export read_LWFBrook90R_inputData, derive_params_from_inputData
export define_LWFB90_p, define_LWFB90_u0, define_LWFB90_ODE
Expand Down
24 changes: 12 additions & 12 deletions src/func_input_definition.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# [email protected], 2021-02-02

using CSV#: read, File
using DataFrames#: rename, select
using DataFramesMeta
using CSV: read, File
using DataFrames: DataFrame, rename# ,select
using DataFramesMeta#: @linq, transform, DataFramesMeta
using Dates: DateTime, Millisecond, Second, Day, month, value, dayofyear

"""
Expand Down Expand Up @@ -33,7 +33,7 @@ function read_LWFBrook90R_inputData(folder::String, prefix::String)

## B) Load input data (time- and/or space-varying parameters)
# Load meteo
input_meteo = @linq CSV.read(path_meteo, DataFrame;
input_meteo = @linq read(path_meteo, DataFrame;
datarow=2, delim=',', ignorerepeated=true,
header=["dates", #"YY","MM","DD",
"GLOBRAD","TMAX","TMIN","VAPPRES","WIND",
Expand All @@ -54,17 +54,17 @@ function read_LWFBrook90R_inputData(folder::String, prefix::String)

input_meteo = @linq input_meteo |>
transform(dates = DateTime2RelativeDaysFloat.(:dates, reference_date)) |>
DataFrames.rename(Dict(:dates => :days))
rename(Dict(:dates => :days))

## C) Load other parameters
# Load model input parameters
#' @param param A numeric vector of model input parameters. Order (derived from param_to_rlwfbrook90()):
input_param = DataFrame(CSV.File(path_param; types=[Float64, String], strict=true))
input_param = DataFrame(File(path_param; types=[Float64, String], strict=true))

# Load site parameters
#' @param siteparam A [1,6] matrix with site level information:
#' start year, start doy, latitude, initial condition snow, initial condition groundwater, precipitation interval.
input_siteparam = DataFrame(CSV.File(path_siteparam;
input_siteparam = DataFrame(File(path_siteparam;
types=[Int64, Int64, Float64, Float64, Float64, Int64], strict=true,
datarow=2, header=["start_year","start_doy","lat","SNOW_init","GWAT_init","precip_interval"],
delim=',')) # ignorerepeated=true
Expand All @@ -75,13 +75,13 @@ function read_LWFBrook90R_inputData(folder::String, prefix::String)
# TODO(bernhard): currently not implemented.
# Only using PRECIN (resolution daily).
# PRECDAT would allow to have smaller resolution (would require changes).
# unused: input_precdat = CSV.read(path_precdat, DataFrame;
# unused: input_precdat = read(path_precdat, DataFrame;
# unused: missingstring = "-999",
# unused: datarow=2, header=["year","month","day","interval_number","prec","mesflp"], delim=',',
# unused: ignorerepeated=true)

#' @param pdur a [1,12]-matrix of precipitation durations (hours) for each month.
input_pdur = DataFrame(CSV.File(path_pdur;
input_pdur = DataFrame(File(path_pdur;
types=[Int64], strict=true,
datarow=2, header=["pdur_h"], delim=',')) # ignorerepeated=true

Expand All @@ -92,14 +92,14 @@ function read_LWFBrook90R_inputData(folder::String, prefix::String)
#' mat, ths, thr, alpha (m-1), npar, ksat (mm d-1), tort (-), stonef (-).
#' When imodel = 2 (Clapp-Hornberger):
#' mat, thsat, thetaf, psif (kPa), bexp, kf (mm d-1), wetinf (-), stonef (-).
input_soil_materials = DataFrame(CSV.File(path_soil_materials;
input_soil_materials = DataFrame(File(path_soil_materials;
types=[Int64, Float64, Float64, Float64, Float64, Float64, Float64, Float64],
datarow=2, header=["mat","ths","thr","alpha","npar","ksat","tort","gravel"],
delim=','))# ignorerepeated=true

#' @param soil_nodes A matrix of the soil model layers with columns
#' nl (layer number), layer midpoint (m), thickness (mm), mat, psiini (kPa), rootden (-).
input_soil_nodes = DataFrame(CSV.File(path_soil_nodes;
input_soil_nodes = DataFrame(File(path_soil_nodes;
types=[Int64,Float64, Float64, Int64, Float64, Float64],
datarow=2, header=["layer","midpoint","thick","mat","psiini","rootden"],
delim=','))# ignorerepeated=true
Expand Down Expand Up @@ -149,5 +149,5 @@ end
# # Compute time relative to reference date
# transform(dates = DateTime2RelativeDaysFloat.(:dates, reference)) |>
# # Rename colum
# DataFrames.rename(Dict(:dates => :days))
# rename(Dict(:dates => :days))
# end
2 changes: 1 addition & 1 deletion src/module_GLBLDECL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module GLBLDECL

using DataFrames
using Interpolations: interpolate, BSpline, Constant, scale, extrapolate
using DataFrames: DataFrame
using DataFramesMeta
using Dates: DateTime

Expand Down
2 changes: 1 addition & 1 deletion src/module_KPT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module KPT # SOIL WATER PROPERTIES

export SOILPAR, derive_auxiliary_SOILVAR

using Roots # to find wetness for a given hydraulic conductivity
using Roots: find_zero, Bisection # to find wetness for a given hydraulic conductivity


### ### Parameters
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# [email protected], 2021-02-01

using LWFBrook90
using Test
using Test: @test, @testset

# @testset "Module WAT" begin
@testset "KKMEAN" begin
Expand Down

0 comments on commit a7eb41a

Please sign in to comment.