Skip to content

Commit

Permalink
Merge pull request #4 from jagoosw/1.1.0
Browse files Browse the repository at this point in the history
Changed parameter organisation
  • Loading branch information
jagoosw committed Jul 6, 2022
2 parents 7f16404 + e91cd03 commit d55ece8
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 154 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SugarKelp"
uuid = "7cd05660-c499-409f-9aa8-d8700f4bb051"
authors = ["Jago <jagoosw@protonmail.com>"]
version = "1.0.0"
version = "1.1.0"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand All @@ -23,4 +23,4 @@ DiffEqCallbacks = "2.17.0"
Interpolations = "0.13.4"
OrdinaryDiffEq = "5.63.5"
RecursiveArrayTools = "2.17.2"
Roots = "1.3.3"
Roots = "1.3.3"
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ irr_itp=Interpolations.LinearInterpolation(time,irr)
u_itp=Interpolations.LinearInterpolation(time,u);
```

Now the model can be run, the parameter file must be passed and in this run the respiration model proposed in Broch, 2013 is being used

Now the model can be run, the parameter must be passed as a NamedTuple and in this run the respiration model proposed in Broch, 2013 is being used

```julia
solution, results = SugarKelp.solve(t_i, nd, u_itp, temp_itp, irr_itp, no3_itp, lat, a_0, n_0, c_0, "src/parameters/2013.jl",2);
solution, results = SugarKelp.solve(t_i, nd, u_itp, temp_itp, irr_itp, no3_itp, lat, a_0, n_0, c_0, SugarKelp.broch2013params, 2);
```

Solutions contains the raw output of the ODE solver while results is refactored into a dataframe (this can optionally be turned off for an array to be returned)
Expand All @@ -99,9 +98,8 @@ It is useful to convert the results into total carbon and nitrogen masses (rathe


```julia
include("src/parameters/2013.jl")
total_carbon = results.area .* K_A .* (results.carbon .+ C_struct)
total_nitrogen = results.area .* K_A .* (results.nitrogen .+ N_struct);
total_carbon = results.area .* SugarKelp.broch2013params.K_A .* (results.carbon .+ SugarKelp.broch2013params.C_struct)
total_nitrogen = results.area .* SugarKelp.broch2013params.K_A .* (results.nitrogen .+ SugarKelp.broch2013params.N_struct);
```


Expand Down Expand Up @@ -153,7 +151,7 @@ This function automatically parallelised to however many threads you start Julia


```julia
@time results = SugarKelp.solvegrid(t_i, nd, a_0, n_0, c_0, arr_lon, arr_lat, arr_dep, arr_t, arr_no3, arr_temp, arr_u, (arr_irr, arr_t, NaN), (nothing, nothing, nothing), arr_beta, "src/parameters/2013.jl", 2);
@time results = SugarKelp.solvegrid(t_i, nd, a_0, n_0, c_0, arr_lon, arr_lat, arr_dep, arr_t, arr_no3, arr_temp, arr_u, (arr_irr, arr_t, NaN), (nothing, nothing, nothing), arr_beta, SugarKelp.broch2013params, 2);
```
...

Expand Down
8 changes: 4 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ irr_itp=Interpolations.LinearInterpolation(time,irr)
u_itp=Interpolations.LinearInterpolation(time,u);
```

Now the model can be run, the parameter file must be passed and in this run the resparation model proposed in Broch, 2013 is being used
Now the model can be run, the parameter must be passed as a NamedTuple and in this run the respiration model proposed in Broch, 2013 is being used


```julia
solution, results = SugarKelp.solve(t_i, nd, u_itp, temp_itp, irr_itp, no3_itp, lat, a_0, n_0, c_0, "../src/parameters/2013.jl",2);
solution, results = SugarKelp.solve(t_i, nd, u_itp, temp_itp, irr_itp, no3_itp, lat, a_0, n_0, c_0, SugarKelp.broch2013params,2);
```

Solutions contains the raw output of the ODE solver while results is refactored into a dataframe (this can optionally be turned off for an array to be returned)
Expand Down Expand Up @@ -147,11 +147,11 @@ This function automatically paralalises to however many threads you start julia


```julia
@time results = SugarKelp.solvegrid(t_i, nd, a_0, n_0, c_0, arr_lon, arr_lat, arr_dep, arr_t, arr_no3, arr_temp, arr_u, (arr_irr, arr_t, NaN), (nothing, nothing, nothing), arr_beta, "../src/parameters/2013.jl", 2);
@time results = SugarKelp.solvegrid(t_i, nd, a_0, n_0, c_0, arr_lon, arr_lat, arr_dep, arr_t, arr_no3, arr_temp, arr_u, (arr_irr, arr_t, NaN), (nothing, nothing, nothing), arr_beta, SugarKelp.broch2013params, 2);
```
...

The output from this is an array with area/nitrogen reserve/carbon reserve/nitrate uptake in the first dimention, then lon,lat,dep,time in the others. We can extract the total carbon and nitrogen again:
The output from this is an array with area/nitrogen reserve/carbon reserve/nitrate uptake in the first dimension, then lon,lat,dep,time in the others. We can extract the total carbon and nitrogen again:


```julia
Expand Down
13 changes: 6 additions & 7 deletions examples/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"cell_type": "code",
"execution_count": 6,
"source": [
"solution, results = SugarKelp.solve(t_i, nd, u_itp, temp_itp, irr_itp, no3_itp, lat, a_0, n_0, c_0, \"../src/parameters/2013.jl\",2);"
"solution, results = SugarKelp.solve(t_i, nd, u_itp, temp_itp, irr_itp, no3_itp, lat, a_0, n_0, c_0, SugarKelp.broch2013params,2);"
],
"outputs": [],
"metadata": {}
Expand Down Expand Up @@ -234,9 +234,8 @@
"cell_type": "code",
"execution_count": 8,
"source": [
"include(\"../src/parameters/2013.jl\")\n",
"total_carbon = results.area .* K_A .* (results.carbon .+ C_struct)\n",
"total_nitrogen = results.area .* K_A .* (results.nitrogen .+ N_struct);"
"total_carbon = results.area .* SugarKelp.broch2013params.K_A .* (results.carbon .+ SugarKelp.broch2013params.C_struct)\n",
"total_nitrogen = results.area .* SugarKelp.broch2013params.K_A .* (results.nitrogen .+ SugarKelp.broch2013params.N_struct);"
],
"outputs": [],
"metadata": {}
Expand Down Expand Up @@ -324,7 +323,7 @@
"cell_type": "code",
"execution_count": 12,
"source": [
"@time results = SugarKelp.solvegrid(t_i, nd, a_0, n_0, c_0, arr_lon, arr_lat, arr_dep, arr_t, arr_no3, arr_temp, arr_u, (arr_irr, arr_t, NaN), (nothing, nothing, nothing), arr_beta, \"../src/parameters/2013.jl\", 2);"
"@time results = SugarKelp.solvegrid(t_i, nd, a_0, n_0, c_0, arr_lon, arr_lat, arr_dep, arr_t, arr_no3, arr_temp, arr_u, (arr_irr, arr_t, NaN), (nothing, nothing, nothing), arr_beta, SugarKelp.broch2013params, 2);"
],
"outputs": [
{
Expand Down Expand Up @@ -388,8 +387,8 @@
"cell_type": "code",
"execution_count": 13,
"source": [
"total_carbon = results[1,:,:,:,:] .* K_A .* (results[3,:,:,:,:] .+ C_struct)\n",
"total_nitrogen = results[1,:,:,:,:] .* K_A .* (results[2,:,:,:,:] .+ N_struct);"
"total_carbon = results[1,:,:,:,:] .* SugarKelp.broch2013params.K_A .* (results[3,:,:,:,:] .+ SugarKelp.broch2013params.C_struct)\n",
"total_nitrogen = results[1,:,:,:,:] .* SugarKelp.broch2013params.K_A .* (results[2,:,:,:,:] .+ SugarKelp.broch2013params.N_struct);"
],
"outputs": [],
"metadata": {}
Expand Down
2 changes: 1 addition & 1 deletion examples/paper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ irr_arr = Interpolations.LinearInterpolation(irr_t, irr, extrapolation_bc=Flat()

a_0 = 30;n_0 = 0.01;c_0 = 0.6

solution, results = SugarKelp.solve(t_i, nd, u_arr, temp_arr, irr_arr, no3_arr, lat, a_0, n_0, c_0, "../src/parameters/2013.jl", 1)
solution, results = SugarKelp.solve(t_i, nd, u_arr, temp_arr, irr_arr, no3_arr, lat, a_0, n_0, c_0, SugarKelp.broch2013params, 1)

# Horrible plotting and loading/inline horriblness from their paper from here down
pyplot()
Expand Down
Loading

2 comments on commit d55ece8

@jagoosw
Copy link
Owner Author

@jagoosw jagoosw commented on d55ece8 Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/63774

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.0 -m "<description of version>" d55ece871a3c8bc9d452560c3efa8155451a1a33
git push origin v1.1.0

Please sign in to comment.