Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
GR_jll = "d2c73de3-f751-5644-a686-071e5b155ba9"
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Expand All @@ -29,19 +26,29 @@ ModelParameters = "4744a3fa-6c31-4707-899e-a3298e4618ad"
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"

[weakdeps]
GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"

[extensions]
GraphMakieExt = ["Makie", "GraphMakie"]
MakieExt = "Makie"
GraphPlotExt = ["StatsPlots", "GraphPlot"]
PlotsExt = "StatsPlots"

[compat]
BlackBoxOptim = "0.5, 0.6"
Bootstrap = "2"
Expand All @@ -54,9 +61,6 @@ DataFrames = "1.6"
DataStructures = "0.18.10"
Dates = "1.11.0"
Distributions = "0.25.100"
GR = "0.72.9, 0.73"
GR_jll = "0.73"
GraphPlot = "0.5, 0.6"
Graphs = "1.9"
JSON = "0.20.1, 0.21"
LaTeXStrings = "1.3"
Expand All @@ -66,13 +70,13 @@ ModelParameters = "0.4.4"
OnlineStats = "1.6"
OrderedCollections = "1.6"
Parameters = "0.12"
Plots = "1.39"
PrettyTables = "2.3"
Setfield = "1"
Statistics = "1.10, 1.11.1"
StatsBase = "0.34"
StatsFuns = "1.3"
StatsPlots = "0.15"
YAML = "0.4"
ZipFile = "0.10"
julia = "1"
StatsPlots = "0.15"
GraphPlot = "0.6"
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,17 @@ The examples below are run from the [examples](https://github.com/ConnectedSyste
```julia
using Statistics
using CSV, DataFrames, YAML
using Plots
using StatsPlots
using Streamfall

example_data_dir = joinpath(dirname(dirname(pathof(Streamfall))), "test/data")

# Load data file which holds observed streamflow, precipitation and PET data
obs_data = CSV.read("../test/data/cotter/climate/CAMELS-AUS_410730.csv", DataFrame; comment="#")
obs_data = CSV.read(
joinpath(example_data_dir, "cotter/climate/CAMELS-AUS_410730.csv"),
DataFrame;
comment="#"
)
# 18808×8 DataFrame
# Row │ year month day Date 410730_P 410730_PET 410730_max_T 410730_Q
# │ Int64 Int64 Int64 Date Float64 Float64 Float64 Float64
Expand Down Expand Up @@ -213,17 +219,18 @@ model.

```julia
using CSV, DataFrames, YAML
using Plots
using StatsPlots
using Streamfall


# Load a network from a file, providing a name for the network and the file path.
# Creates a graph representation of the stream with associated metadata.
sn = load_network("Example Network", "../test/data/campaspe/campaspe_network.yml")
example_data_dir = joinpath(dirname(dirname(pathof(Streamfall))), "test/data")
sn = load_network("Example Network", joinpath(example_data_dir, "campaspe/campaspe_network.yml"))

# Load climate data, in this case from a CSV file with data for all nodes.
# Indicate which columns are precipitation and evaporation data based on partial identifiers
climate = Climate("../test/data/campaspe/climate/climate.csv", "_rain", "_evap")
climate = Climate(joinpath(example_data_dir, "campaspe/climate/climate.csv"), "_rain", "_evap")

# This runs an entire stream network
@info "Running an example stream..."
Expand Down
3 changes: 2 additions & 1 deletion docs/src/examples/calibration.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ using Statistics
using CSV, DataFrames, YAML
using Streamfall

using Plots
# Import visualization packages to compile extensions
using Plots, GraphPlot


sn = load_network("Example Network", "../test/data/campaspe/campaspe_network.yml")
Expand Down
1 change: 1 addition & 0 deletions docs/src/examples/network_loading.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Loading a pre-defined network from a YAML file.

```julia
using YAML
using Plots, GraphPlot
using Streamfall


Expand Down
1 change: 1 addition & 0 deletions examples/run_nodes.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using GLMakie, GraphMakie
using YAML, DataFrames, CSV, Plots
using Statistics
using Streamfall
Expand Down
40 changes: 40 additions & 0 deletions ext/GraphMakieExt/GraphMakieExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module GraphMakieExt

using Streamfall
import Streamfall: StreamfallNetwork

using Makie

using Graphs
using GraphMakie


"""
plot_network(sn::StreamfallNetwork)

Simple plot of stream network.
"""
function Streamfall.NetworkViz.plot_network(sn::StreamfallNetwork)
node_labels = ["$(sn[i].name)\n"*string(nameof(typeof(sn[i]))) for i in vertices(sn.mg)]
f, ax, sp = graphplot(
sn.mg;
nlabels=node_labels,
nlabels_align=(:center, :bottom),
node_size=16,
node_color=:blue
)
# f.scene.padding = (50, 50, 50, 50) # (left, right, bottom, top)

# Turn off grid lines
ax.xgridvisible = false
ax.ygridvisible = false

# Hide ticks and labels
hidedecorations!(ax)

reset_limits!(ax)

return f
end

end
34 changes: 34 additions & 0 deletions ext/GraphPlotExt/GraphPlotExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module GraphPlotExt

using StatsPlots, GraphPlot
using Streamfall
import Streamfall: vertices
import Streamfall: StreamfallNetwork

"""
plot_network(sn::StreamfallNetwork)

Simple plot of stream network.
"""
function Streamfall.NetworkViz.plot_network(sn::StreamfallNetwork; as_html::Bool=false)
node_labels = ["$(sn[i].name)\n" * string(nameof(typeof(sn[i]))) for i in vertices(sn.mg)]

if as_html
plot_func = gplothtml
else
plot_func = gplot
end

plot_func(sn.mg, nodelabel=node_labels)
end

"""
save_figure(sn::StreamfallNetwork, fn::String)

Save a figure of the network in SVG format.
"""
function Streamfall.NetworkViz.save_figure(sn::StreamfallNetwork, fn::String)
draw(SVG(fn, 16cm, 16cm), plot_network(sn))
end

end
Loading
Loading