Example Script 01
This example was generated 2024-04-05
Example data from Beatenberg is located in subfolder examples/
. WSL is acknowledged for providing the input data (see section Acknowledgments).
To run your own simulations: follow the step-by-step instructions below.
Setup and run simulation
# How to work with a Julia script in a new environment
# create a new folder: "pgm"
# a) start `julia` -> `]` -> activate . -> add LWFBrook90
# b) in VSCode -> click at bottom and select "pgm" as Julia env
# c) run the code
# alternatively right-click on the folder in VSCode
# -> Change to this Directory and Activate this environment
# Load packages:
using LWFBrook90
# `using LWFBrook90` brings the following exported functions into scope:
# - `loadSPAC()` # to define and run a simulation
# - `setup()` # to define and run a simulation
# - `simulate!()` # to define and run a simulation
# - `remakeSPAC()` # to define and run a simulation
# - `SPAC()` # to define and run a simulation
# - `DiscretizedSPAC()` # to define and run a simulation
# - `get_states()` # to postprocess a simulation
# - `get_fluxes()` # to postprocess a simulation
# - `get_forcing()` # to postprocess a simulation
# - `get_soil_()` # to postprocess a simulation
# - `get_water_partitioning()` # to postprocess a simulation
# - `RelativeDaysFloat2DateTime()` # a helper function for time
# - `prepare_for_LWFBrook90R()` # a helper function
Documentation can be accessed by typing: ?loadSPAC
, ?setup
, ?simulate!
, ?plotisotopes
, etc.
Define simulation model by reading in system definition and input data from input files. When printed, the generated SPAC model gives a summary.
# Read in input data
input_path = "../../../examples/DAV2020-full/"; input_prefix = "DAV2020-full"; # make sure to get the path correct relative to `pwd()``
# input_path = "examples/DAV2020-full/"; input_prefix = "DAV2020-full";
# input_path = "examples/isoBEAdense2010-18-reset-FALSE-input/"; input_prefix = "isoBEAdense2010-18-reset-FALSE";
model = loadSPAC(input_path, input_prefix; simulate_isotopes = false);
model = loadSPAC(input_path, input_prefix; simulate_isotopes = true);
model
SPAC model:
===== DATES:===============
===== METEO FORCING:===============
GLOBRAD (MJ/m2/day): avg: 13.90, range: 1.04 to 32.40
PREC (mm/day): avg: 2.61, range: 0.00 to 35.40
TMAX (°C): avg: 9.00, range: -8.90 to 26.60
TMIN (°C): avg: -0.79, range: -18.80 to 12.90
VAPPRES (kPa): avg: 0.64, range: 0.11 to 1.37
WIND (m/s): avg: 2.59, range: 0.70 to 4.90
δ18O (‰): avg: -13.26, range: -22.60 to -6.87
δ2H (‰): avg: -95.98, range:-171.53 to -44.68
===== CANOPY EVOLUTION:===============
model.pars.canopy_evolution was loaded form meteoveg.csv
===== INITIAL CONDITIONS:===============
Soil IC: soil_discretization.csv
Scalar IC: 3×6 DataFrame
Row │ u_GWAT_init_mm u_INTS_init_mm u_INTR_init_mm u_SNOW_init_mm u_CC_in ⋯
│ Float64 Float64 Float64 Float64 Float64 ⋯
─────┼──────────────────────────────────────────────────────────────────────────
1 │ 1.0 0.0 0.0 0.0 ⋯
2 │ -13.0 -13.0 -13.0 -13.0
3 │ -95.0 -95.0 -95.0 -95.0
2 columns omitted
===== MODEL PARAMETRIZATION:===============
VXYLEM_mm => 20.0 | RHOTP => 2.0 | TH => 40.0 |
DISPERSIVITY_mm => 40.0 | NN => 2.5 | MXKPL => 15.6 |
LAT_DEG => 47.0 | FRINTLAI => 0.1 | MXRTLN => 3000.0 |
ESLOPE_DEG => 0.0 | FSINTLAI => 0.0 | INITRLEN => 12.0 |
ASPECT_DEG => 0.0 | FRINTSAI => 0.1 | INITRDEP => 0.2 |
ALB => 0.2 | FSINTSAI => 0.0 | RGRORATE => 0.0 |
ALBSN => 0.5 | CINTRL => 0.1 | RGROPER => 30.0 |
C1 => 0.2 | CINTRS => 0.1 | FXYLEM => 0.5 |
C2 => 0.5 | CINTSL => 0.6 | PSICR => -1.0 |
C3 => 0.2 | CINTSS => 0.6 | RTRAD => 0.3 |
WNDRAT => 0.3 | RSTEMP => -0.5 | NOOUTF => 1.0 |
FETCH => 5000.0 | MELFAC => 1.5 | IDEPTH_m => 0.4 |
Z0W => 0.0 | CCFAC => 0.3 | QDEPTH_m => 0.0 |
ZW => 2.0 | LAIMLT => 0.2 | RSSA => 795.3 |
MAXLAI => 3.0 | SAIMLT => 0.5 | RSSB => 1.0 |
DENSEF_baseline_ => 1.0 | GRDMLT => 0.3 | INFEXP => 0.5 |
SAI_baseline_ => 1.0 | MAXLQF => 0.1 | BYPAR => 0.0 |
AGE_baseline_yrs => 100.0 | KSNVP => 0.3 | QFPAR => 1.0 |
HEIGHT_baseline_m => 25.0 | SNODEN => 0.3 | QFFC => 0.0 |
LWIDTH => 0.1 | GLMAX => 0.0 | IMPERV => 0.0 |
Z0G => 0.0 | GLMIN => 0.0 | DSLOPE => 0.0 |
Z0S => 0.0 | CR => 0.5 | LENGTH_SLOPE => 200.0 |
LPC => 4.0 | RM => 1000.0 | DRAIN => 0.5 |
CZS => 0.1 | R5 => 287.0 | GSC => 0.0 |
CZR => 0.1 | CVPD => 2.0 | GSP => 0.0 |
HS => 1.0 | TL => 0.0 | |
HR => 10.0 | T1 => 10.0 | |
ZMINH => 2.0 | T2 => 30.0 |
===== SOIL DOMAIN:===============
Root distribution: soil_discretization.csv
Soil layer properties: 3×3 DataFrame
Row │ Upper_m Lower_m shp
│ Float64 Float64 MualemVa…
─────┼─────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ 0.0 -0.03 (θ from θr=0.000 to θs=0.379, Ks = 2854.9, STONEF=0.2, l=-3.3, n=1.2, α= 20.4)
2 │ -0.03 -0.4 (θ from θr=0.000 to θs=0.379, Ks = 2854.9, STONEF=0.4, l=-3.3, n=1.2, α= 20.4)
3 │ -0.4 -1.1 (θ from θr=0.000 to θs=0.379, Ks = 2854.9, STONEF=0.8, l=-3.3, n=1.2, α= 20.4)
Soil discretized into N=5 layers, Δz layers: (avg, min, max) = (0.220,0.030,0.400)m.
[-0.03, -0.1, -0.4, -0.8, -1.1]
===== SOLVER OPTIONS:===============
(compute_intermediate_quantities = true, simulate_isotopes = true, DTIMAX = 0.5, DSWMAX = 0.05, DPSIMAX = 0.0005)
If wanted, arguments can be supplied to modify the loaded SPAC (e.g. for parameter estimation), hence requiring less input CSVs. Warnings are output (see below) to signal to the user that existing input CSVs might be ignored.
# Read in providing arguments, requiring less CSVs
model_modified =
loadSPAC(input_path, input_prefix;
simulate_isotopes = true,
Δz_thickness_m = [fill(0.04, 5); # grid spacing (heterogenous), meter (N=21)
fill(0.05, 5); # write Δ in VSCode by typing \Delta and hit shift
fill(0.06, 5);
fill(0.07, 5);
fill(0.10, 1)],
root_distribution = (beta = 0.98, z_rootMax_m=-0.5),
IC_soil = (PSIM_init_kPa = -7.0,
delta18O_init_permil = -9.0,
delta2H_init_permil = -11.0),
canopy_evolution = (DENSEF_rel = 100,
HEIGHT_rel = 100,
SAI_rel = 100,
LAI_rel = (DOY_Bstart = 120,
Bduration = 21,
DOY_Cstart = 270,
Cduration = 60,
LAI_perc_BtoC = 100,
LAI_perc_CtoB = 55)),
storm_durations_h = [5.44, 5.44, 5.44, 5.44, 5.44, 5.44,
5.44, 5.44, 5.44, 5.44, 5.44, 5.44],
IC_scalar = (amount = (u_GWAT_init_mm = 1.,
u_INTS_init_mm = 13.7,
u_INTR_init_mm = 0.,
u_SNOW_init_mm = 22.222,
u_CC_init_MJ_per_m2 = 0.101010,
u_SNOWLQ_init_mm = 0.),
d18O = (u_GWAT_init_permil = -11.111,
u_INTS_init_permil = -12.222,
u_INTR_init_permil = -13.333,
u_SNOW_init_permil = -14.444),
d2H = (u_GWAT_init_permil = -95.111,
u_INTS_init_permil = -95.222,
u_INTR_init_permil = -95.333,
u_SNOW_init_permil = -95.444)));
┌ Warning: Isotopic signature of precipitation is available for the period (2020-12-16T00:00:00 - 2021-11-04T00:00:00), i.e. (days -16.0 - 307.0)
│ Whereas the other meteorologic inputs are available for (2021-01-01T00:00:00 - 2021-12-31T00:00:00), i.e. (days 0.0 - 364.0).
│ Isotopic signatures will be extrapolated with constant values before and after the available period.
└ @ LWFBrook90 ~/work/LWFBrook90.jl/LWFBrook90.jl/src/func_read_inputData.jl:938
┌ Warning: Requested to overwrite storm durations. Values in ../../../examples/DAV2020-full/DAV2020-full_meteo_storm_durations.csv are ignored.
└ @ LWFBrook90 ~/work/LWFBrook90.jl/LWFBrook90.jl/src/func_read_inputData.jl:687
┌ Warning: Received canopy_evolution in loadSPAC(), overwriting values from `meteoveg.csv`.
└ @ LWFBrook90 ~/work/LWFBrook90.jl/LWFBrook90.jl/src/func_read_inputData.jl:142
┌ Warning: Requested to overwrite initial conditions. Values in ../../../examples/DAV2020-full/DAV2020-full_initial_conditions.csv are ignored.
└ @ LWFBrook90 ~/work/LWFBrook90.jl/LWFBrook90.jl/src/func_read_inputData.jl:172
┌ Warning: loadSPAC(...; Δz_thickness_m = ...) provided. Ignoring `soil_discretization.csv`, i.e. also overwriting root distribution and initial conditions.
└ @ LWFBrook90 ~/work/LWFBrook90.jl/LWFBrook90.jl/src/func_read_inputData.jl:202
┌ Warning: Spatial domain soil discretization is larger than the provided soil horizon information. Lowest soil horizon will be extended.
│
│ Lowest soil horizon from -0.4m to -1.1m will be extended down to -1.2000000000000006m.
└ @ LWFBrook90 ~/work/LWFBrook90.jl/LWFBrook90.jl/src/func_discretize_soil_domain.jl:84
Documentation can be accessed by typing: ?loadSPAC
, ?setup
, ?simulate!
, ?plotisotopes
, etc.
The objects model
and model_modified
are instances of a SPAC()
(soil-plant-atmosphere continuum) and contain fully specified simulations. To run them they need to be transformed into a system of ODES (setup()
) and solved (simulate()
):
# Setup and run simulation
simulation = setup(model)
simulation_mod = setup(model_modified)
# Inputs can be checked with:
# `plot_inputs(simulation)`. Note: NOT YET IMPLEMENTED
simulate!(simulation_mod)
simulate!(simulation_mod) # Run it a second time to showcase shorter runtime
# The computed solution is stored within the object.
# When using VSCode a progress bar is shown in the status bar.
┌ Info: Start of simulation at 2024-04-05T13:46:40.622.
└ Saving intermediate results (`saveat=`) between: (0.0, 365.0) days
runtime: 13.541669 seconds (20.97 M allocations: 1.394 GiB, 5.77% gc time, 94.15% compilation time)
[ Info: Time steps for solving: 9088 (9088 accepted out of 9122 total)
[ Info: End of simulation at 2024-04-05T13:46:54.297.
┌ Info: Start of simulation at 2024-04-05T13:46:54.348.
└ Saving intermediate results (`saveat=`) between: (0.0, 365.0) days
runtime: 0.755181 seconds (3.23 M allocations: 263.580 MiB, 9.08% gc time)
[ Info: Time steps for solving: 9088 (9088 accepted out of 9122 total)
[ Info: End of simulation at 2024-04-05T13:46:55.104.
Notice that the very first time a model is simulated, the runtime is longer because it includes compilation. This compilation is not needed for any subsequent run.
Postprocessing results
These simulations can then be post-processed with predefined functions as shown below. Alternatively the following variables contain the simuation results for user-defined post-processing:
simulation_mod.ODESolution;
simulation_mod.ODESolution_datetime;
typeof(simulation_mod.ODESolution);
propertynames(simulation_mod.ODESolution)
# HINT: To get these names, type `simulation_mod.` and wait for the autocomplete!
(:u, :u_analytic, :errors, :t, :k, :prob, :alg, :interp, :dense, :tslocation, :stats, :alg_choice, :retcode)
simulation_mod.ODESolution
is a ODESolution object: documentation how to access under: https://docs.sciml.ai/DiffEqDocs/stable/basics/solution/ and more generally: https://docs.sciml.ai/Overview/stable/ simulationmod.ODESolution.t simulationmod.ODESolution.u simulationmod.ODESolution.retcode simulationmod.ODESolution.destats
Note that it is possible to use R Code from within Julia, e.g ggplot: https://stackoverflow.com/a/70073193/3915004
Postprocessing: Extract values
Below illustrative code how to extract states and fluxes:
# Get simulation output (states, fluxes, forcing) as DataFrames
The three functions: get_states()
, get_fluxes()
, and get_forcing()
return DataFrames
` with daily values of all the state variables, fluxes, and the input forcing.
get_states(simulation_mod)
get_fluxes(simulation_mod)
get_forcing(simulation_mod)
get_states(simulation_mod; days_to_read_out_d = 0:30:360) # specific days relative to simulation.parametrizedSPAC.reference_date can be specified
Row | dates | GWAT_mm | INTS_mm | INTR_mm | SNOW_mm | CC_MJm2 | SNOWLQ_mm | SWAT_mm | GWAT_d18O | INTS_d18O | INTR_d18O | SNOW_d18O | XYLEM_d18O | GWAT_d2H | INTS_d2H | INTR_d2H | SNOW_d2H | XYLEM_d2H | d18O_permil_40mm | d18O_permil_80mm | d18O_permil_120mm | d18O_permil_160mm | d18O_permil_200mm | d18O_permil_250mm | d18O_permil_300mm | d18O_permil_350mm | d18O_permil_400mm | d18O_permil_450mm | d18O_permil_510mm | d18O_permil_570mm | d18O_permil_630mm | d18O_permil_690mm | d18O_permil_750mm | d18O_permil_820mm | d18O_permil_890mm | d18O_permil_960mm | d18O_permil_1030mm | d18O_permil_1100mm | d18O_permil_1200mm | d2H_permil_40mm | d2H_permil_80mm | d2H_permil_120mm | d2H_permil_160mm | d2H_permil_200mm | d2H_permil_250mm | d2H_permil_300mm | d2H_permil_350mm | d2H_permil_400mm | d2H_permil_450mm | d2H_permil_510mm | d2H_permil_570mm | d2H_permil_630mm | d2H_permil_690mm | d2H_permil_750mm | d2H_permil_820mm | d2H_permil_890mm | d2H_permil_960mm | d2H_permil_1030mm | d2H_permil_1100mm | d2H_permil_1200mm | θ_m3m3_40mm | θ_m3m3_80mm | θ_m3m3_120mm | θ_m3m3_160mm | θ_m3m3_200mm | θ_m3m3_250mm | θ_m3m3_300mm | θ_m3m3_350mm | θ_m3m3_400mm | θ_m3m3_450mm | θ_m3m3_510mm | θ_m3m3_570mm | θ_m3m3_630mm | θ_m3m3_690mm | θ_m3m3_750mm | θ_m3m3_820mm | θ_m3m3_890mm | θ_m3m3_960mm | θ_m3m3_1030mm | θ_m3m3_1100mm | θ_m3m3_1200mm | ψ_kPa_40mm | ψ_kPa_80mm | ψ_kPa_120mm | ψ_kPa_160mm | ψ_kPa_200mm | ψ_kPa_250mm | ψ_kPa_300mm | ψ_kPa_350mm | ψ_kPa_400mm | ψ_kPa_450mm | ψ_kPa_510mm | ψ_kPa_570mm | ψ_kPa_630mm | ψ_kPa_690mm | ψ_kPa_750mm | ψ_kPa_820mm | ψ_kPa_890mm | ψ_kPa_960mm | ψ_kPa_1030mm | ψ_kPa_1100mm | ψ_kPa_1200mm |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DateTime | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | |
1 | 2021-01-01T00:00:00 | 1.0 | 13.7 | 0.0 | 22.222 | 0.10101 | 0.0 | 90.2641 | -11.111 | -12.222 | -13.333 | -14.444 | -9.0 | -95.111 | -95.222 | -95.333 | -95.444 | -11.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -9.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | -11.0 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | 0.200587 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 | -7.0 |
2 | 2021-01-31T00:00:00 | 1.0 | 1.09368 | 0.392421 | 158.295 | 0.0 | 7.91476 | 103.182 | -9.00086 | -18.86 | -18.86 | -18.86 | -9.02106 | -11.0329 | -139.79 | -139.79 | -139.79 | -11.3164 | -15.346 | -14.3139 | -13.3697 | -12.601 | -12.0126 | -11.5212 | -11.1661 | -10.8978 | -10.621 | -10.2329 | -9.7563 | -9.40562 | -9.20879 | -9.1058 | -9.05224 | -9.02286 | -9.00926 | -9.00353 | -9.00126 | -9.00042 | -9.0001 | -95.4348 | -82.206 | -69.9365 | -59.798 | -51.9218 | -45.2561 | -40.3967 | -36.7233 | -32.9859 | -27.86 | -21.554 | -16.847 | -14.1243 | -12.6372 | -11.8298 | -11.3705 | -11.1522 | -11.0585 | -11.021 | -11.0071 | -11.0017 | 0.222249 | 0.225594 | 0.228474 | 0.230953 | 0.233097 | 0.235235 | 0.237423 | 0.239735 | 0.242557 | 0.243825 | 0.239224 | 0.233647 | 0.228166 | 0.223399 | 0.21977 | 0.21724 | 0.21614 | 0.216376 | 0.217674 | 0.219877 | 0.223659 | -4.42579 | -4.13508 | -3.90212 | -3.71345 | -3.55852 | -3.41118 | -3.26743 | -3.12278 | -2.95573 | -2.88388 | -3.15416 | -3.51998 | -3.92633 | -4.32324 | -4.65629 | -4.90605 | -5.01934 | -4.99477 | -4.86207 | -4.64607 | -4.30045 |
3 | 2021-03-02T00:00:00 | 1.0 | 0.0 | 0.0 | 104.096 | 0.0 | 5.20478 | 117.624 | -11.891 | -10.11 | -10.11 | -10.11 | -10.1396 | -50.227 | -62.4 | -62.4 | -62.4 | -27.1479 | -12.563 | -13.198 | -13.7049 | -14.087 | -14.3531 | -14.5373 | -14.6138 | -14.6135 | -14.585 | -14.5941 | -14.5639 | -14.4899 | -14.3773 | -14.2266 | -14.0359 | -13.782 | -13.4762 | -13.1326 | -12.7619 | -12.3831 | -11.9707 | -83.8894 | -89.2242 | -93.237 | -95.958 | -97.4743 | -97.9856 | -97.3506 | -95.9984 | -94.5171 | -93.7145 | -92.3726 | -90.4939 | -88.152 | -85.3438 | -82.0442 | -77.8908 | -73.1252 | -67.9673 | -62.5581 | -57.147 | -51.3442 | 0.231595 | 0.234977 | 0.238072 | 0.2411 | 0.244197 | 0.247904 | 0.252516 | 0.257949 | 0.264656 | 0.270333 | 0.270936 | 0.271677 | 0.272474 | 0.273335 | 0.274275 | 0.275417 | 0.276916 | 0.278955 | 0.282146 | 0.287886 | 0.302522 | -3.66629 | -3.42865 | -3.22613 | -3.04071 | -2.86316 | -2.66528 | -2.43937 | -2.19898 | -1.93575 | -1.738 | -1.71819 | -1.69419 | -1.66871 | -1.64163 | -1.61255 | -1.57787 | -1.53346 | -1.47493 | -1.38753 | -1.24216 | -0.929603 |
4 | 2021-04-01T00:00:00 | 1.0 | 0.0 | 0.0 | 71.5081 | 0.0 | 3.5754 | 137.369 | -14.0999 | -14.42 | -14.42 | -14.42 | -10.9482 | -86.7765 | -102.2 | -102.2 | -102.2 | -42.5366 | -14.2381 | -14.1653 | -14.0874 | -14.0093 | -13.9366 | -13.8664 | -13.8163 | -13.7901 | -13.7809 | -13.7745 | -13.7769 | -13.7904 | -13.8146 | -13.8487 | -13.8918 | -13.947 | -14.0069 | -14.0622 | -14.1042 | -14.1238 | -14.1116 | -100.274 | -99.4953 | -98.6503 | -97.7827 | -96.9376 | -96.0624 | -95.3217 | -94.7694 | -94.3629 | -94.0349 | -93.699 | -93.3812 | -93.0839 | -92.7979 | -92.5101 | -92.1685 | -91.7404 | -91.1568 | -90.3303 | -89.2161 | -87.4653 | 0.274451 | 0.27952 | 0.283325 | 0.286516 | 0.289438 | 0.292747 | 0.297087 | 0.303334 | 0.314134 | 0.324941 | 0.324865 | 0.324808 | 0.324747 | 0.324664 | 0.324554 | 0.32437 | 0.323956 | 0.322914 | 0.32024 | 0.31489 | 0.311285 | -1.60714 | -1.45909 | -1.35644 | -1.27553 | -1.20526 | -1.12979 | -1.03696 | -0.91437 | -0.728848 | -0.570732 | -0.571756 | -0.572536 | -0.573362 | -0.574488 | -0.575981 | -0.578492 | -0.584155 | -0.598567 | -0.636531 | -0.716973 | -0.774848 |
5 | 2021-05-01T00:00:00 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 104.664 | -14.1231 | -15.66 | -15.66 | -15.66 | -12.2597 | -99.5033 | -109.29 | -109.29 | -109.29 | -66.366 | -15.0546 | -14.8858 | -14.7794 | -14.7078 | -14.6552 | -14.6082 | -14.5669 | -14.5305 | -14.4958 | -14.4572 | -14.4169 | -14.3835 | -14.3544 | -14.3267 | -14.2994 | -14.2697 | -14.2397 | -14.2104 | -14.1821 | -14.1555 | -14.1289 | -110.949 | -111.052 | -110.756 | -110.227 | -109.579 | -108.799 | -107.997 | -107.261 | -106.645 | -106.219 | -105.712 | -105.165 | -104.598 | -104.012 | -103.408 | -102.736 | -102.055 | -101.395 | -100.767 | -100.19 | -99.6249 | 0.20671 | 0.210187 | 0.213447 | 0.216523 | 0.21946 | 0.222694 | 0.226287 | 0.230061 | 0.234196 | 0.237546 | 0.238186 | 0.238915 | 0.239684 | 0.240596 | 0.241738 | 0.243304 | 0.24552 | 0.248437 | 0.252339 | 0.257716 | 0.267311 | -6.12691 | -5.6882 | -5.30989 | -4.97959 | -4.68608 | -4.38574 | -4.07757 | -3.78011 | -3.48192 | -3.25958 | -3.2189 | -3.17328 | -3.12593 | -3.07074 | -3.00321 | -2.91314 | -2.79076 | -2.63804 | -2.44767 | -2.20878 | -1.84062 |
6 | 2021-05-31T00:00:00 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 97.3131 | -14.7015 | -10.43 | -10.43 | -10.43 | -13.8122 | -107.627 | -72.59 | -72.59 | -72.59 | -93.4353 | -12.7238 | -13.2286 | -13.6589 | -13.9756 | -14.2011 | -14.3769 | -14.4958 | -14.575 | -14.634 | -14.678 | -14.7313 | -14.7862 | -14.8332 | -14.8695 | -14.8921 | -14.9001 | -14.8887 | -14.8602 | -14.8184 | -14.7693 | -14.7136 | -91.4779 | -95.6035 | -99.1178 | -101.699 | -103.534 | -104.969 | -105.949 | -106.615 | -107.118 | -107.494 | -107.951 | -108.422 | -108.828 | -109.144 | -109.344 | -109.418 | -109.323 | -109.073 | -108.7 | -108.252 | -107.739 | 0.18157 | 0.184476 | 0.187625 | 0.190941 | 0.194364 | 0.198306 | 0.202696 | 0.207071 | 0.211394 | 0.215559 | 0.219865 | 0.224411 | 0.228463 | 0.232159 | 0.235619 | 0.23925 | 0.243181 | 0.247404 | 0.252289 | 0.258413 | 0.268751 | -10.8302 | -10.1065 | -9.38671 | -8.69415 | -8.04232 | -7.36227 | -6.68362 | -6.07948 | -5.54454 | -5.0805 | -4.64724 | -4.23533 | -3.90297 | -3.62538 | -3.38547 | -3.15255 | -2.92013 | -2.69109 | -2.44999 | -2.17966 | -1.79099 |
7 | 2021-06-30T00:00:00 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 61.4898 | -14.7897 | -6.87 | -6.87 | -6.87 | -12.2641 | -108.434 | -45.57 | -45.57 | -45.57 | -88.6848 | -7.74638 | -8.40224 | -9.23155 | -10.0457 | -10.7017 | -11.2381 | -11.694 | -12.1313 | -12.8404 | -14.7186 | -14.8055 | -14.8497 | -14.8581 | -14.8738 | -14.8807 | -14.8819 | -14.8738 | -14.8585 | -14.8378 | -14.8155 | -14.796 | -52.8693 | -58.2593 | -64.9581 | -71.4085 | -76.5421 | -80.7354 | -84.3033 | -87.6938 | -93.1703 | -107.917 | -108.601 | -108.965 | -109.049 | -109.184 | -109.246 | -109.256 | -109.187 | -109.052 | -108.867 | -108.667 | -108.492 | 0.146774 | 0.137673 | 0.128518 | 0.121235 | 0.116556 | 0.113916 | 0.113295 | 0.113871 | 0.11491 | 0.116253 | 0.123063 | 0.132545 | 0.140696 | 0.147593 | 0.153448 | 0.158914 | 0.163828 | 0.167966 | 0.171417 | 0.174222 | 0.176869 | -27.1228 | -35.6846 | -47.9007 | -61.4614 | -72.7118 | -80.1822 | -82.0757 | -80.3156 | -77.2622 | -73.523 | -57.6558 | -41.9785 | -32.5148 | -26.4833 | -22.4085 | -19.2763 | -16.9055 | -15.1797 | -13.9019 | -12.9583 | -12.138 |
8 | 2021-07-30T00:00:00 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 118.668 | -12.3845 | -8.63 | -8.63 | -8.63 | -10.146 | -88.9076 | -63.31 | -63.31 | -63.31 | -71.6336 | -8.81982 | -8.89355 | -8.97042 | -9.04911 | -9.12927 | -9.21952 | -9.31228 | -9.40315 | -9.48959 | -9.55796 | -9.65268 | -9.77242 | -9.91288 | -10.0756 | -10.2636 | -10.5015 | -10.7829 | -11.1033 | -11.4594 | -11.8331 | -12.2689 | -64.0676 | -64.365 | -64.6797 | -65.0087 | -65.3538 | -65.7574 | -66.1971 | -66.6551 | -67.1139 | -67.4959 | -68.0424 | -68.7655 | -69.659 | -70.7512 | -72.0806 | -73.8414 | -76.0079 | -78.5424 | -81.4026 | -84.4283 | -87.967 | 0.222437 | 0.227582 | 0.232625 | 0.237582 | 0.242508 | 0.248152 | 0.254705 | 0.261938 | 0.270389 | 0.277803 | 0.280071 | 0.282313 | 0.284106 | 0.285447 | 0.286323 | 0.286756 | 0.286604 | 0.286066 | 0.285845 | 0.287645 | 0.297088 | -4.4088 | -3.97267 | -3.59202 | -3.25725 | -2.95854 | -2.65256 | -2.33938 | -2.03829 | -1.73612 | -1.50773 | -1.44379 | -1.38307 | -1.33623 | -1.30214 | -1.28029 | -1.26963 | -1.27337 | -1.28669 | -1.29217 | -1.24796 | -1.03694 |
9 | 2021-08-29T00:00:00 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 98.4307 | -9.31308 | -12.51 | -12.51 | -12.51 | -9.03339 | -63.61 | -88.72 | -88.72 | -88.72 | -59.9056 | -8.88676 | -8.47391 | -8.42277 | -8.46304 | -8.52557 | -8.60183 | -8.67703 | -8.74284 | -8.79344 | -8.76519 | -8.80515 | -8.86354 | -8.921 | -8.9763 | -9.03036 | -9.08786 | -9.14339 | -9.19369 | -9.23758 | -9.2739 | -9.30587 | -56.7457 | -53.2166 | -52.9087 | -53.4156 | -54.1213 | -54.9672 | -55.8064 | -56.5483 | -57.136 | -57.0224 | -57.5179 | -58.1778 | -58.8272 | -59.4599 | -60.087 | -60.7639 | -61.4306 | -62.0494 | -62.6052 | -63.0801 | -63.5113 | 0.203877 | 0.205006 | 0.205948 | 0.206935 | 0.208064 | 0.209549 | 0.211511 | 0.213789 | 0.216382 | 0.218412 | 0.218968 | 0.220066 | 0.221491 | 0.223179 | 0.225095 | 0.227417 | 0.23025 | 0.233514 | 0.237371 | 0.242077 | 0.249431 | -6.51379 | -6.35628 | -6.22819 | -6.09737 | -5.95146 | -5.76588 | -5.53088 | -5.27199 | -4.99413 | -4.78849 | -4.73382 | -4.62807 | -4.49486 | -4.34268 | -4.17701 | -3.98584 | -3.76586 | -3.52922 | -3.2708 | -2.98345 | -2.58809 |
10 | 2021-09-28T00:00:00 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 94.5777 | -9.13005 | -10.6 | -10.6 | -10.6 | -9.73641 | -61.2659 | -75.17 | -75.17 | -75.17 | -65.0038 | -10.4559 | -10.3972 | -10.3275 | -10.2414 | -10.1403 | -10.0152 | -9.88587 | -9.76824 | -9.66069 | -9.5454 | -9.41766 | -9.29745 | -9.19739 | -9.1213 | -9.06996 | -9.03879 | -9.03041 | -9.03978 | -9.06105 | -9.08808 | -9.11942 | -72.1959 | -71.2875 | -70.4499 | -69.5682 | -68.6149 | -67.4885 | -66.3618 | -65.3645 | -64.4582 | -63.4032 | -62.3087 | -61.3517 | -60.595 | -60.059 | -59.7476 | -59.6319 | -59.7241 | -59.9718 | -60.3194 | -60.7049 | -61.1258 | 0.198246 | 0.200926 | 0.203171 | 0.205004 | 0.206482 | 0.207843 | 0.20913 | 0.210443 | 0.212032 | 0.21305 | 0.211863 | 0.21106 | 0.210644 | 0.210686 | 0.211175 | 0.21213 | 0.2136 | 0.215459 | 0.217721 | 0.220469 | 0.224619 | -7.37211 | -6.94788 | -6.61467 | -6.35652 | -6.15706 | -5.97969 | -5.81757 | -5.65733 | -5.47034 | -5.35441 | -5.48992 | -5.58396 | -5.63338 | -5.6283 | -5.57031 | -5.45907 | -5.29285 | -5.09101 | -4.85739 | -4.58994 | -4.21746 |
11 | 2021-10-28T00:00:00 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 81.1802 | -9.09324 | -22.6 | -22.6 | -22.6 | -10.0599 | -60.3635 | -171.53 | -171.53 | -171.53 | -68.3045 | -10.7563 | -10.6274 | -10.5274 | -10.4468 | -10.3701 | -10.2844 | -10.1862 | -10.0916 | -10.0003 | -9.90606 | -9.81138 | -9.70938 | -9.61455 | -9.52221 | -9.43408 | -9.34603 | -9.26688 | -9.20276 | -9.15452 | -9.12158 | -9.09857 | -75.3572 | -74.1068 | -73.0519 | -72.1706 | -71.3514 | -70.4716 | -69.5105 | -68.6126 | -67.7614 | -66.892 | -66.023 | -65.0966 | -64.2519 | -63.4503 | -62.7089 | -61.9946 | -61.3864 | -60.9302 | -60.6262 | -60.4575 | -60.3765 | 0.15945 | 0.160833 | 0.162335 | 0.16393 | 0.165596 | 0.167539 | 0.169749 | 0.171992 | 0.174245 | 0.176777 | 0.180333 | 0.184146 | 0.187678 | 0.190995 | 0.194149 | 0.197446 | 0.200872 | 0.204231 | 0.207571 | 0.210935 | 0.21515 | -18.9991 | -18.3054 | -17.5864 | -16.8604 | -16.1404 | -15.3477 | -14.5025 | -13.7016 | -12.9506 | -12.1654 | -11.1571 | -10.1857 | -9.37518 | -8.68338 | -8.08142 | -7.50456 | -6.95627 | -6.46393 | -6.01471 | -5.59866 | -5.12397 |
12 | 2021-11-27T00:00:00 | 1.0 | 0.0 | 0.0 | 1.2592 | 0.00689034 | 0.0 | 97.8706 | -13.8754 | -22.6 | -22.6 | -22.6 | -11.2929 | -99.7581 | -171.53 | -171.53 | -171.53 | -78.5307 | -21.5881 | -21.3264 | -21.0166 | -20.6839 | -20.3303 | -19.9218 | -19.4915 | -19.0903 | -18.7589 | -18.5361 | -18.2748 | -17.9781 | -17.6549 | -17.3036 | -16.9223 | -16.4744 | -15.9886 | -15.4858 | -14.9772 | -14.4871 | -13.9897 | -163.267 | -161.135 | -158.605 | -155.884 | -152.99 | -149.644 | -146.116 | -142.824 | -140.103 | -138.271 | -136.12 | -133.678 | -131.014 | -128.118 | -124.971 | -121.272 | -117.257 | -113.097 | -108.886 | -104.826 | -100.706 | 0.1961 | 0.198012 | 0.199943 | 0.201936 | 0.204011 | 0.206455 | 0.209311 | 0.212328 | 0.215524 | 0.218284 | 0.219847 | 0.221632 | 0.223491 | 0.225434 | 0.227483 | 0.229864 | 0.232704 | 0.235962 | 0.23984 | 0.244645 | 0.25231 | -7.73392 | -7.41055 | -7.10009 | -6.79558 | -6.49491 | -6.16059 | -5.79515 | -5.43637 | -5.08413 | -4.80111 | -4.64891 | -4.48192 | -4.31517 | -4.14844 | -3.98053 | -3.79503 | -3.58635 | -3.36267 | -3.11639 | -2.83841 | -2.449 |
13 | 2021-12-27T00:00:00 | 1.0 | 0.0 | 0.0 | 24.8801 | 0.0 | 0.211443 | 93.3393 | -15.525 | -22.6 | -22.6 | -22.6 | -11.7107 | -113.42 | -171.53 | -171.53 | -171.53 | -81.9713 | -21.9172 | -21.7058 | -21.4724 | -21.2203 | -20.9503 | -20.6305 | -20.2893 | -19.9612 | -19.6699 | -19.4461 | -19.1888 | -18.9141 | -18.6318 | -18.3387 | -18.0303 | -17.6728 | -17.2839 | -16.8773 | -16.4613 | -16.0573 | -15.6416 | -165.948 | -164.225 | -162.32 | -160.26 | -158.053 | -155.437 | -152.644 | -149.957 | -147.569 | -145.734 | -143.623 | -141.367 | -139.047 | -136.636 | -134.097 | -131.15 | -127.943 | -124.587 | -121.153 | -117.817 | -114.385 | 0.19261 | 0.194247 | 0.195828 | 0.1974 | 0.198987 | 0.200814 | 0.202919 | 0.205129 | 0.207476 | 0.209356 | 0.209935 | 0.210651 | 0.211462 | 0.212385 | 0.213441 | 0.214759 | 0.216446 | 0.21847 | 0.220924 | 0.22393 | 0.228506 | -8.36878 | -8.0636 | -7.78133 | -7.51236 | -7.25189 | -6.96504 | -6.65125 | -6.33935 | -6.02688 | -5.78956 | -5.71877 | -5.63245 | -5.53659 | -5.42985 | -5.31063 | -5.16596 | -4.98755 | -4.78276 | -4.54737 | -4.27683 | -3.89965 |
Below an illustrative code snippet how to export certain depths into a *.csv:
using CSV, DataFrames
# Single soil variables: How to get θ, or ψ, or δ18Os?
get_soil_(:θ, simulation_mod;
depths_to_read_out_mm = nothing, days_to_read_out_d = nothing)
depth_to_read_out_mm = [10, 150, 500, 1000, 1150]
get_soil_(:θ, simulation_mod;
depths_to_read_out_mm = depth_to_read_out_mm, days_to_read_out_d = nothing)
get_soil_(:θ, simulation_mod;
depths_to_read_out_mm = depth_to_read_out_mm)
get_soil_(:ψ, simulation_mod;
depths_to_read_out_mm = depth_to_read_out_mm)
get_soil_(:δ18O, simulation_mod;
depths_to_read_out_mm = depth_to_read_out_mm)
# How to export θ as CSV?
# Only every day, provide days_to_read_out
days_to_read_out = range(simulation_mod.ODESolution.prob.tspan...)
dates_to_read_out = LWFBrook90.RelativeDaysFloat2DateTime.(
days_to_read_out, simulation_mod.parametrizedSPAC.reference_date)
df_out_daily = get_soil_(:θ, simulation_mod;
depths_to_read_out_mm = depth_to_read_out_mm, days_to_read_out_d = days_to_read_out)
insertcols!(df_out_daily, 1, :dates => dates_to_read_out);
show(df_out_daily)
##plot(df_out_daily[:,:dates], Matrix(df_out_daily[:,Not([:dates, :time])]))
##CSV.write(
# joinpath(out_dir, fname * "_θ_depths_daily.csv"),
# df_out_daily)
366×7 DataFrame
Row │ dates time θ_m3m3_10mm θ_m3m3_150mm θ_m3m3_500mm ⋯
│ DateTime Float64 Float64 Float64 Float64 ⋯
─────┼──────────────────────────────────────────────────────────────────────────
1 │ 2021-01-01T00:00:00 0.0 0.200587 0.200587 0.200587 ⋯
2 │ 2021-01-02T00:00:00 1.0 0.195189 0.199116 0.203679
3 │ 2021-01-03T00:00:00 2.0 0.19362 0.197972 0.205324
4 │ 2021-01-04T00:00:00 3.0 0.192807 0.197298 0.206038
5 │ 2021-01-05T00:00:00 4.0 0.192393 0.19691 0.20635 ⋯
6 │ 2021-01-06T00:00:00 5.0 0.192124 0.196648 0.206501
7 │ 2021-01-07T00:00:00 6.0 0.192024 0.196533 0.206607
8 │ 2021-01-08T00:00:00 7.0 0.191919 0.196427 0.206691
⋮ │ ⋮ ⋮ ⋮ ⋮ ⋮ ⋱
360 │ 2021-12-26T00:00:00 359.0 0.192669 0.197482 0.210105 ⋯
361 │ 2021-12-27T00:00:00 360.0 0.19261 0.1974 0.209935
362 │ 2021-12-28T00:00:00 361.0 0.192623 0.197387 0.209798
363 │ 2021-12-29T00:00:00 362.0 0.192725 0.19746 0.209726
364 │ 2021-12-30T00:00:00 363.0 0.280244 0.284455 0.244632 ⋯
365 │ 2021-12-31T00:00:00 364.0 0.25555 0.267545 0.302739
366 │ 2022-01-01T00:00:00 365.0 0.245386 0.257208 0.295146
2 columns and 351 rows omitted
Postprocessing: Plotting (using provided functions)
Below an example script using the provided plot recipes that plot a) amounts, b) isotopes, or c) forcing and states as an additional internal check:
using Plots, Measures; gr();
pl1 = plotamounts(simulation_mod, :above_and_belowground, :showRWUcentroid)
pl1
pl2 = plotisotopes(simulation_mod, :d18O, (d18O = :auto, d2H = :auto), :showRWUcentroid)
pl2
pl3 = plotforcingandstates(simulation_mod)
pl3
# Use of additional arguments to `plotisotopes` is illustrated here.
# Note that typing `?plotisotopes` provides the documentation to the function.
# plotisotopes(simulation_mod, :d2H)
# plotisotopes(simulation_mod, :d18O)
# plotisotopes(simulation_mod;
# xlim = (DateTime("2010-01-01"), DateTime("2010-03-31")))
# plotisotopes(simulation_mod, :d2H, (d18O = :auto, d2H = :auto), :showRWUcentroid;
# xlim = (DateTime("2010-01-01"), DateTime("2010-08-30")))
Saving plots can be done with savefig
# using Dates: today;
# out_dir = joinpath("gitignored","out", string(today()))
# mkpath(out_dir)
# fname = input_prefix
# savefig(pl1, joinpath(out_dir, fname*"_plotRecipe_AMT.png"))
# savefig(pl2, joinpath(out_dir, fname*"_plotRecipe_ISO.png"))
# savefig(pl3, joinpath(out_dir, fname*"_plotRecipe_CHECK.png"))
Postprocessing: Plotting (using your own functions)
Below an example script using the manually written code to plot the simulation_mod.#
simstates = getstates(simulation) # this gives an error since it has not been simulated!
sim_states = get_states(simulation_mod)
sim_fluxes = get_fluxes(simulation_mod)
names(sim_states) # show column names
names(sim_fluxes) # show column names
53-element Vector{String}:
"dates"
"cum_d_prec"
"cum_d_sfal"
"cum_d_sthr"
"cum_d_sint"
"cum_d_rfal"
"cum_d_rint"
"cum_d_rthr"
"cum_d_rsno"
"cum_d_rnet"
⋮
"TRANI_mmday_630mm"
"TRANI_mmday_690mm"
"TRANI_mmday_750mm"
"TRANI_mmday_820mm"
"TRANI_mmday_890mm"
"TRANI_mmday_960mm"
"TRANI_mmday_1030mm"
"TRANI_mmday_1100mm"
"TRANI_mmday_1200mm"
plot some of the scalar states
states_to_plot = ["INTS_mm", "INTR_mm", "SNOW_mm", "GWAT_mm", "SWAT_mm"]
sim_states_to_plot = sim_states[:, states_to_plot]
plot(sim_states[:,"dates"], Matrix(sim_states_to_plot),
labels=permutedims(names(sim_states_to_plot)), legend=:topleft, ylabel = "-")
plot the fates of water partitioning
fluxes_to_plot = ["flow", "seep", "evap"]
sim_fluxes_to_plot = sim_fluxes[:, fluxes_to_plot]
plot(sim_fluxes[:,"dates"], Matrix(sim_fluxes_to_plot),
labels=permutedims(names(sim_fluxes_to_plot)), legend=:topleft, ylabel = "mm/day")
plot internal fluxes
fluxes_to_plot = [
"cum_d_prec", "cum_d_rnet", "cum_d_smlt",
"cum_d_tran",
"srfl", "slfl", "byfl", "dsfl", "gwfl", "vrfln"]
sim_fluxes_to_plot = sim_fluxes[:, fluxes_to_plot]
plot(sim_fluxes[:,"dates"], Matrix(sim_fluxes_to_plot),
labels=permutedims(names(sim_fluxes_to_plot)), legend=:topleft, ylabel = "mm/day")
plot isotope signatures of fluxes
fluxes_to_plot = ["RWU_d18O", "RWU_d2H", "PREC_d18O", "PREC_d2H"]
sim_fluxes_to_plot = sim_fluxes[:, fluxes_to_plot]
plot(sim_fluxes[:,"dates"], Matrix(sim_fluxes_to_plot),
labels=permutedims(names(sim_fluxes_to_plot)), legend=:topleft, ylabel = "mm/day")
Belowground quantities (θ,ψ,δ of soil water)
if you want some specific depths: use getsoil(): e.g depthtoreadoutmm = [150, 500, 800, 1500] dfδsoil = getsoil([:δ18O, :δ2H], simulationmod; depthstoreadoutmm = depthtoreadoutmm) dfθψ = getsoil([:θ, :ψ], simulationmod, depthstoreadoutmm = depthtoreadoutmm)
if we use depths that are already contained in sim_states we can use those:
@show propertynames(sim_states[:,r"(d18O)|(d2H)"]);
df_δsoil = sim_states[:, ["d18O_permil_160mm", "d18O_permil_510mm",
"d18O_permil_820mm", "d18O_permil_1200mm",
"d2H_permil_160mm", "d2H_permil_510mm",
"d2H_permil_820mm", "d2H_permil_1200mm"]]
df_θψ = sim_states[:, ["θ_m3m3_160mm", "θ_m3m3_510mm",
"θ_m3m3_820mm", "θ_m3m3_1200mm",
"ψ_kPa_160mm", "ψ_kPa_510mm",
"ψ_kPa_820mm", "ψ_kPa_1200mm"]]
pl_θ = plot(sim_states.dates,
Matrix(select(df_θψ, r"θ_")),
labels = permutedims(names(select(df_θψ, r"θ_"))),
xlabel = "Date",
ylabel = "θ\n[-]",
legend = :outerright)
pl_ψ = plot(sim_states.dates,
# Matrix(select(df_θψ, r"ψ_")),
log10.(-Matrix(select(df_θψ, r"ψ_"))), yflip = true,
labels = permutedims(names(select(df_θψ, r"ψ_"))),
xlabel = "Date",
ylabel = "log10(ψ\n[kPa])",
legend = :outerright);
pl_δ18O = plot(sim_states.dates,
Matrix(select(df_δsoil, r"d18O_")),
labels = permutedims(names(select(df_δsoil, r"d18O_"))),
xlabel = "Date",
ylabel = "δ¹⁸O soil\n[‰]",
legend = :outerright);
pl_δ2H = plot(sim_states.dates,
Matrix(select(df_δsoil, r"d2H_")),
labels = permutedims(names(select(df_δsoil, r"d2H_"))),
xlabel = "Date",
ylabel = "δ²H soil\n[‰]",
legend = :outerright);
# add precipitation to soil δ
PREC_color = :black
plot!(pl_δ18O, sim_fluxes.dates, sim_fluxes.PREC_d18O,
labels = "PREC", color = PREC_color, linestyle = :dot);
plot!(pl_δ2H, sim_fluxes.dates, sim_fluxes.PREC_d2H,
labels = "PREC", color = PREC_color, linestyle = :dot);
pl_PREC = plot(
sim_fluxes.dates,
sim_fluxes.cum_d_prec,
t = :bar, color=PREC_color,
legend = :outerright, labels = "PREC ", # whitespace for hardcoded alignment of legend
ylabel = "PREC\n[mm]");
plot(plot(pl_PREC, xlab = "", xticks = :none, topmargin = 5mm, bottommargin = 0mm),
plot(pl_θ; xlab = "", xticks = :none, topmargin = 0mm, bottommargin = 0mm),
plot(pl_ψ; xlab = "", xticks = :none, topmargin = 0mm, bottommargin = 0mm),
plot(pl_δ18O; xlab = "", xticks = :none, topmargin = 0mm, bottommargin = 0mm),
plot(pl_δ2H; xtick_direction=:out , topmargin = 0mm, bottommargin = 5mm),
link = :x,
layout = grid(5, 1, heights=[0.1, 0.25 ,0.25, 0.2, 0.2]),
size=(600,500), dpi = 300, margin = 5mm)
####################
This page was generated using Literate.jl.