diff --git a/docs/Project.toml b/docs/Project.toml index 0f95a0e..c8f6ff3 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,6 +1,7 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244" +DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656" OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" PALEOaqchem = "673cec3b-17d1-411f-9fcd-71c01c593120" PALEOboxes = "804b410e-d900-4b2a-9ecd-f5a06d4c1fd4" @@ -13,9 +14,9 @@ Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4" [compat] Documenter = "1" DocumenterCitations = "1" +PALEOaqchem = "0.3.9" PALEOboxes = "0.21.23" PALEOmodel = "0.15.40" -PALEOaqchem = "0.3.9" Revise = "3.1" julia = "1.6" diff --git a/docs/make.jl b/docs/make.jl index f4baf3b..b8f5e9d 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,6 +2,8 @@ using Documenter using DocumenterCitations +using DocumenterInterLinks + import PALEOboxes as PB bib = CitationBibliography( @@ -9,6 +11,17 @@ bib = CitationBibliography( style=:authoryear, ) +links = InterLinks( + "PALEOboxes" => ( + "https://paleotoolkit.github.io/PALEOboxes.jl/stable/", + "https://paleotoolkit.github.io/PALEOboxes.jl/stable/objects.inv", + ), + "PALEOmodel" => ( + "https://paleotoolkit.github.io/PALEOmodel.jl/stable/", + "https://paleotoolkit.github.io/PALEOmodel.jl/stable/objects.inv", + ), +) + # Collate all markdown files and images folders from PALEOexamples/src/ into a tree of pages ENV["PALEO_EXAMPLES"] = normpath(@__DIR__, "../examples") # make ENV["PALEO_EXAMPLES"] available in README.md etc io = IOBuffer() @@ -32,8 +45,11 @@ makedocs(; "ExampleInstallConfig.md", examples_pages, ), - # no Design docs yet + "Design" => [ + "ComponentsWorkflow.md", + ], "HOWTOS" => [ + "HOWTOshowmodelandoutput.md", "HOWTOJuliaUsage.md", "HOWTOadditionalconfig.md", "HOWTOminimalGit.md", @@ -47,7 +63,7 @@ makedocs(; format = Documenter.HTML( prettyurls = get(ENV, "CI", nothing) == "true" ), - plugins = [bib], + plugins = [bib, links], ) @info "Local html documentation is available at $(joinpath(@__DIR__, "build/index.html"))" diff --git a/docs/src/ComponentsWorkflow.md b/docs/src/ComponentsWorkflow.md new file mode 100644 index 0000000..4427444 --- /dev/null +++ b/docs/src/ComponentsWorkflow.md @@ -0,0 +1,3 @@ +# PALEOtoolkit components and workflow + +![image](images/PALEO_components_workflow.svg) diff --git a/docs/src/HOWTOJuliaUsage.md b/docs/src/HOWTOJuliaUsage.md index 50cbfbe..86fe0c2 100644 --- a/docs/src/HOWTOJuliaUsage.md +++ b/docs/src/HOWTOJuliaUsage.md @@ -1,8 +1,7 @@ -# Julia usage +# Julia and VS code usage ## Julia resources -- Julia manual -- Think Julia book (an introduction to programming) +- Julia homepage (see links to `Documentation` and a curated list of tutorials, books, etc under `Learn`) - Julia cheatsheet: - Matlab-Python-Julia cheatsheet: (NB: the first example on Creating Vectors is misleading - use 1d Arrays in Julia!) @@ -18,20 +17,27 @@ VS code has an option to automatically load Revise.jl at startup (enabled by def The Debugger.jl built in to VSCode is an interpreter (Interpreter.jl), and is unusably slow for PALEO. +## Install the VS code yaml extension + +A VS code yaml extension is now available, https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml, +this will flag errors in the PALEO yaml configuration files when opened in the VS code editor. + +NB: The Julia [YAML.jl](https://github.com/JuliaData/YAML.jl) parser allows duplicate keys (later key overwrites earlier) . This is easy to hit when generating model configurations, the VS code yaml linter will catch this and other errors. If all else fails, check the .yaml file using an online validator eg . + ## Julia best practices - Performance tips: - Julia antipatterns: - Batch usage: ## Julia bugs/gotchas -- [YAML.jl](https://github.com/JuliaData/YAML.jl) parser allows duplicate keys (later key overwrites earlier) TODO report. This is easy to hit when generating model configurations. Workaround: check the .yaml file using an online validator eg . - Continuation lines in multi-line formulas can silently fail (this is easy to hit when copying across Fortran code). Workaround - add brackets. - Debug in VSCode is very slow. Use [Infiltrator.jl](https://github.com/JuliaDebug/Infiltrator.jl) instead. - Legends on subplots are merged with some backends eg plotlyjs (). Workaround - use a different backend for multiple-panel plots. - [jldoctest](https://juliadocs.github.io/Documenter.jl/stable/man/doctests/) fails if there is an initial blank line (apparent off-by-one in input and validation output). TODO report. ## Julia performance issues/gotchas -NB: the only place this matters in PALEO is for the model main loop. Everything else is non-performance critical. +NB: the only place this matters in PALEO is for the model main loop. Everything else is non-performance critical. +The `PALEOboxes.TestUtils.bench_model` function provides a convenient way of benchmarking a model and identifying problem Reactions (where all Reactions in the registered PALEO packages should have zero allocations). - It is easy to write code which is 'type unstable', or generates memory allocations, which then gives low performance, see 'Performance tips' above. - Iterating over tuples: really need a `foreach` that is optimised eg , . PALEO provides `PALEOboxes.foreach_longtuple`. - @views for sparse matrices reverts to slow (dense) pathways (, ) (update - much improved in Julia 1.6 according to updates to these posts) diff --git a/docs/src/HOWTOPython.md b/docs/src/HOWTOPython.md index 0f4e727..99b7980 100644 --- a/docs/src/HOWTOPython.md +++ b/docs/src/HOWTOPython.md @@ -1,49 +1,7 @@ # Configuring for Julia - python interoperability -Julia has near-seamless interoperability with Python, provided by the [PyCall.jl](https://github.com/JuliaPy/PyCall.jl) and [Conda.jl](https://github.com/JuliaPy/Conda.jl) packages in the [JuliaPy](https://github.com/JuliaPy) github organisation. +Julia interoperability with Python is provided by the [PythonCall.jl](https://github.com/JuliaPy/PythonCall.jl) package in the [JuliaPy](https://github.com/JuliaPy) github organisation. This is now recommended over the earlier [PyCall.jl](https://github.com/JuliaPy/PyCall.jl) package. -However configuration of Python and Julia inevitably introduces dependencies. There are two overall strategies: -1. allow Julia to install and maintain a private Python installion (the default) -2. configure Julia and Python for a shared Python installation +See for configuration options to either use an existing python +install from Julia, or to let Julia install it's own copy of python. -## 1. Private Python installation for Julia -This is simplest for cases where you just want to use a few python packages from Julia (eg IJulia for Jupyter notebooks). - - julia> ENV["PYTHON"]="" - julia> Pkg.add("PyCall") # will build automatically - -Rebuild PyCall after installation to use private python installation: - - julia> ENV["PYTHON"]="" - julia> Pkg.build("PyCall") # will rebuild to use private Python install, and install Matplotlib next time PyPlot is imported. - -(Re)build Julia packages that depend on python: - - julia> ENV["JUPYTER"]=""; - julia> Pkg.build("IJulia") # force IJulia to use its own Conda-based Jupyter version - - -## 2. Use an external python installation -As of 2021-12-06, the simplest way to do this is to use [miniforge](https://github.com/conda-forge/miniforge) to manage the python installation. - -(Re)build [Conda.jl](https://github.com/JuliaPy/Conda.jl) to use the pre-existing Conda installation: - - julia> ENV["CONDA_JL_HOME"] = "/home/sd336/miniforge3/envs/conda_jl38" # path from unix> conda info --envs - pkg> build Conda - -(Re)build [PyCall.jl](https://github.com/JuliaPy/PyCall.jl) - - julia> ENV["PYTHON"] = "/home/sd336/miniforge3/envs/conda_jl38/bin/python" # may be redundant (picks up location from Conda.jl ?) - pkg> build PyCall - -Restart Julia - - julia> PyCall.libpython # check we have picked up the new libpython etc - "/home/sd336/miniforge3/envs/conda_jl38/lib/libpython3.8.so.1.0" - -(Re)build [IJulia.jl](https://github.com/JuliaLang/IJulia.jl): - - julia> ENV["JUPYTER"] = "/home/sd336/miniforge3/envs/conda_jl38/bin/jupyter" # path from unix> which jupyter - "/home/sd336/miniforge3/envs/conda_jl38/bin/jupyter" - - pkg> build IJulia diff --git a/docs/src/HOWTOshowmodelandoutput.md b/docs/src/HOWTOshowmodelandoutput.md new file mode 100644 index 0000000..16878a9 --- /dev/null +++ b/docs/src/HOWTOshowmodelandoutput.md @@ -0,0 +1,198 @@ + + +# Displaying model configuration and output from the Julia REPL + +The specific examples below were generated after running the [`PALEOcopse`](https://github.com/PALEOtoolkit/PALEOcopse.jl) `COPSE Reloaded` example from the Julia REPL, but apply to any PALEOtoolkit model. + +## Displaying large tables in Julia +Several PALEO commands produce large tables. + +There are several options to display these: +- Julia in VS code provides the `julia> vscodedisplay()` command. As of Jan 2022 this is now usually the best option. +- Use `julia> show(, allcols=true, allrows=true)` to show as text in the REPL. +- Use `julia> CSV.write("some_table.csv", )` to save as a CSV file and open in Excel etc. + +## Find code and documentation + +The documentation for a PALEO reaction can be looked up using the `PALEOboxes.doc_reaction` command: + + julia> PB.doc_reaction("ReactionReservoirScalar") + +NB: the VS Code Documentation browser has similar functionality and is often easier to use. The key difference that it looks at definitions visible in the VS code projects and editor windows, whilst doc_reaction looks at definitions available to code in the current REPL ie provided by modules that are currently loaded in the REPL. + +## Display model configuration + +### Display parameters: + +Examples illustrating the use of [`PALEOboxes.show_parameters`](@extref): + +To show parameters for every Reaction in the model: + + julia> vscodedisplay(PB.show_parameters(model)) # show in VS code table viewer + julia> show(PB.show_parameters(model), allrows=true) # show as text in REPL + julia> import CSV + julia> CSV.write("parameters.csv", PB.show_parameters(model)) # save as CSV for Excel etc + +This illustrates the modularised model structure, with: +- Domains global, atm, land, ocean, oceansurface, oceanfloor, sedcrust containing forcings and biogeochemical Reactions, with Parameters attached to each Reaction. +- Additional Domains fluxAtoLand, fluxLandtoSedCrust, fluxOceanBurial, fluxOceanfloor, fluxRtoOcean, fluxSedCrusttoAOcean containing flux coupler Reactions. + +To show parameters for a single Reaction: + + julia> rct_temp_global = PB.get_reaction(model, "global", "temp_global") + julia> PB.show_parameters(rct_temp_global) # GEOCARB temperature function parameters + +The Julia Type of `rct_temp_global` `PALEOcopse.Global.Temperature.ReactionGlobalTemperatureBerner` usually makes it possible to guess the location `src/global/Temperature.jl` in the source code of the `PALEOcopse` Julia package. + +### Display Variables: + +#### Show Variables in the model: + +Use [`PALEOboxes.show_variables`](@extref) to list all Variables in the model, or Variables for a specific Domain: + + julia> vscodedisplay(PB.show_variables(model)) # VS code only + julia> vscodedisplay(PB.show_variables(model, "land")) # just the "land" Domain + +To list full information for all Variables in the model (including Variable linking and current values): + + julia> vscodedisplay(PB.show_variables(model, modeldata=modeldata, showlinks=true)) + +This illustrates the modularized model structure, with: + +- Domains global, atm, land, ocean, oceansurface, oceanfloor, sedcrust containing Variables linked to Reactions (either property-dependencies or target-contributors pairs). +- Additional Domains fluxAtoLand, fluxLandtoSedCrust, fluxOceanBurial, fluxOceanfloor, fluxRtoOcean, fluxSedCrusttoAOcean containing target-contributor pairs representing inter-module fluxes. + +#### Show linkage for a single Domain or ReactionMethod Variable + +To show linkage of a single Variable in Domain "atm" with name "pO2PAL": + + julia> PB.show_links(model, "atm.pO2PAL") + +To show linkage of a ReactionMethod Variable with localname "pO2PAL", Reaction "ocean_copse" in Domain "ocean": + + julia> PB.show_links(PB.get_reaction_variables(model, "ocean", "ocean_copse", "pO2PAL")) + +## Display model output + +Model output is stored in a [`PALEOmodel.AbstractOutputWriter`](@extref) object, which is +available as `paleorun.output`, ie the `output` field of the default [`PALEOmodel.Run`](@extref) instance created +by the `COPSE_reloaded_reloaded.jl` script. + +The default [`PALEOmodel.OutputWriters.OutputMemory`](@extref) stores model output in memory, by Domain: + + julia> paleorun.output # shows Domains + +To show metadata for all Variables in the output: + + julia> vscodedisplay(PB.show_variables(paleorun.output)) # VS code only + julia> vscodedisplay(PB.show_variables(paleorun.output, "land")) # just the land Domain + +Output from a list of Variables or for each `Domain` can be exported to a Julia [DataFrame](https://dataframes.juliadata.org/stable/): + + julia> # display data for a list of Variables as a Table + julia> vscodedisplay(PB.get_table(paleorun.output, ["atm.tmodel", "atm.pCO2PAL", "fluxOceanBurial.flux_total_P"])) + + julia> # display data for every Variable in the 'atm' Domain as a Table + julia> vscodedisplay(PB.get_table(paleorun.output, "atm")) + + julia> # show a subset of output variables from the 'atm' Domain + julia> PB.get_table(paleorun.output, "atm")[!, [:tmodel, :pCO2atm, :pCO2PAL]] + +Data from each Variable can be accessed as a [`PALEOmodel.FieldArray`](@extref) (a Python-xarray like struct with +named dimensions and coordinates): + + julia> pCO2atm = PALEOmodel.get_array(paleorun.output, "atm.pCO2atm") + julia> pCO2atm.values # raw data Array + julia> pCO2atm.dims[1] # pCO2 is a scalar Variable with one dimension `records` which has a coordinate `tmodel` + julia> pCO2atm.dims[1].coords[1].values # raw values for model time (`tmodel`) + +Raw data arrays can also be accessed as Julia Vectors using `get_data`: + + julia> pCO2atm_raw = PB.get_data(paleorun.output, "atm.pCO2atm") # raw data Array + julia> tmodel_raw = PB.get_data(paleorun.output, "atm.tmodel") # raw data Array + +(here these are the values and coordinate of the `pCO2atm` [`PALEOmodel.FieldArray`](@extref), ie `pCO2atm_raw == pCO2atm.values` and `tmodel_raw == pCO2atm.dims[1].coords[1].values`). + +## Plot model output + +The output can be plotted using the Julia Plots.jl package, see [Plotting output](@extref PALEOmodel). Plot recipes are defined for [`PALEOmodel.FieldArray`](@extref), so output data can be plotted directly using the `plot` command: + + julia> using Plots + + julia> plot(paleorun.output, "atm.pCO2atm") # plot output variable as a single command + julia> plot(title="Oxygen", paleorun.output, ["atm.pO2PAL", "ocean.ANOX"]) # overlay multiple output variables in one plot + + julia> pCO2atm = PALEOmodel.get_array(paleorun.output, "atm.pCO2atm") + julia> plot(pCO2atm) # a PALEOmodel.FieldArray can be plotted + + julia> pCO2atm_raw = PB.get_data(paleorun.output, "atm.pCO2atm") # raw data Array + julia> tmodel_raw = PB.get_data(paleorun.output, "atm.tmodel") # raw data Array + julia> plot!(tmodel_raw, pCO2atm_raw, label="some raw data") # overlay data from standard Julia Vectors + +## Spatial or wavelength-dependent output + +To analyze spatial or eg wavelength-dependent output (eg time series from a 1D column or 3D general circulation model, or quantities that are a function of wavelength or frequency), `PALEOmodel.get_array` takes an additional `selectargs::NamedTuple` argument to take 1D or 2D slices from the spatial, spectral and timeseries data. The [`PALEOmodel.FieldArray`](@extref) returned includes default coordinates to plot column (1D) and heatmap (2D) data, these can be overridden by supplying the optional `coords` keyword argument. + +### Examples for a column-based model + +Visualisation of spatial and wavelength-dependent output from the PALEOdev.jl ozone photochemistry example (a single 1D atmospheric column): + +#### 1D column data + julia> plot(title="O3 mixing ratio", output, "atm.O3_mr", (tmodel=[0.0, 0.1, 1.0, 10.0, 100.0, 1000.0], column=1), + swap_xy=true, xscale=:log10, labelattribute=:filter_records) # plots O3 vs default height coordinate + +Here the optional `labelattribute=:filter_records` keyword argument is used to generate plot labels from the `:filter_records` FieldArray attribute, which contains the `tmodel` values used to select the timeseries records. The plot recipe expands +the Vector-valued `tmodel` argument to overlay a sequence of plots. + +This is equivalent to first creating and then plotting a sequence of `FieldArray` objects: + + julia> O3_mr = PALEOmodel.get_array(paleorun.output, "atm.O3_mr", (tmodel=0.0, column=1)) + julia> plot(title="O3 mixing ratio", O3_mr, swap_xy=true, xscale=:log10, labelattribute=:filter_records) + julia> O3_mr = PALEOmodel.get_array(paleorun.output, "atm.O3_mr", (tmodel=0.1, column=1)) + julia> plot!(O3_mr, swap_xy=true, labelattribute=:filter_records) + +The default height coordinate from the model grid can be replaced using the optional `coords` keyword argument, eg + + julia> plot(title="O3 mixing ratio", output, "atm.O3_mr", (tmodel=[0.0, 0.1, 1.0, 10.0, 100.0, 1000.0], column=1), + coords=["p"=>("atm.pmid", "atm.plower", "atm.pupper")], + swap_xy=true, xscale=:log10, yflip=true, yscale=:log10, labelattribute=:filter_records) # plots O3 vs pressure + +The current values in the `modeldata` struct can also be plotted using the same syntax, eg + + julia> plot(title="O2, O3 mixing ratios", modeldata, ["atm.O2_mr", "atm.O3_mr"], (column=1,), + swap_xy=true, xscale=:log10) # plot current value of O2, O3 vs height + + +#### Wavelength-dependent data + julia> plot(title="direct transmittance", output, ["atm.direct_trans"], (tmodel=1e12, column=1, cell=[1, 80]), + ylabel="fraction", labelattribute=:filter_region) # plots vs wavelength + +Here `tmodel=1e12` selects the last model time output, and `column=1, cell=[1, 80]` selects the top and bottom cells within the first (only) 1D column. The `labelattribute=:filter_region` keyword argument is used to generate plot labels from the `:filter_region` FieldArray attribute, which contains the `column` and `cell` values used to select the spatial region. + +### Examples for a 3D GCM-based model + +Visualisation of spatial output from the 3D GENIE transport-matrix example (PALEOdev.jl repository) + +### Horizontal slices across levels + julia> heatmap(paleorun.output, "ocean.O2_conc", (tmodel=1e12, k=1), swap_xy=true) + +Here `k=1` selects a horizontal level corresponding to model grid cells with index k=1, which is the ocean surface in the GENIE grid. + +### Vertical section at constant longitude + julia> heatmap(paleorun.output, "ocean.O2_conc", (tmodel=1e12, i=10), swap_xy=true, mult_y_coord=-1.0) + +Here `i=10` selects a section at longitude corresponding to model grid cells with index i=10. + +## Save and load output + +Model output can be saved and loaded using the [`PALEOmodel.OutputWriters.save_netcdf`](@extref) and [`PALEOmodel.OutputWriters.load_netcdf!`](@extref) methods. + +NB: the [`PALEOmodel.OutputWriters.save_jld2`](@extref) and [`PALEOmodel.OutputWriters.load_jld2!`](@extref) methods are still available, but no longer recommended as these files will not remain readable with future Julia or PALEO versions. + +## Export output to a CSV file + +To write Model output from a single Domain to a CSV file: + + julia> import CSV + julia> CSV.write("copse_land.csv", PB.get_table(paleorun.output, "land")) # all Variables from land Domain + julia> CSV.write("copse_atm.csv", PB.get_table(paleorun.output, "atm")[!, [:tmodel, :pCO2atm, :pO2atm]]) # subset of Variables from atm Domain diff --git a/docs/src/images/PALEO_components_workflow.svg b/docs/src/images/PALEO_components_workflow.svg new file mode 100644 index 0000000..42b28a1 --- /dev/null +++ b/docs/src/images/PALEO_components_workflow.svg @@ -0,0 +1,401 @@ + + + + + + + + + + + + + + YAML + configuration file + + PALEOocean + Reaction + catalog + + custom + Reaction + code + + PALEOboxes + Reaction + catalog + + PALEOboxes + (model coupler) + + model + object + + + + + + + PALEOmodel + (solvers, analysis) + + output + results + - + create Reactions from catalog + - + link variables by name + - + set parameters + - + solve system of ODE + - + compare output to datasets + - + test parameter sensitivity + diff --git a/docs/src/index.md b/docs/src/index.md index 5bef9c1..d990630 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -2,6 +2,6 @@ Introduction and tutorials for the PALEOtoolkit framework. This repository includes minimal examples and small models that demonstrate Julia workflows and how to use the framework to construct and use models. -For further information on PALEOtoolkit components see https://github.com/PALEOtoolkit +See [PALEOtoolkit components and workflow](@ref) for a summary of PALEOtoolkit structure. For further information on PALEOtoolkit components see For installation guide see [Installation and getting started](@ref) diff --git a/examples/CPU/CPU_examples.jl b/examples/CPU/CPU_examples.jl index 084b730..2147214 100644 --- a/examples/CPU/CPU_examples.jl +++ b/examples/CPU/CPU_examples.jl @@ -12,19 +12,25 @@ import PALEOmodel import PALEOcopse @info " ... done" -include("CPU_modular_reactions.jl") -include("CPU_modular_expts.jl") +include("CPU_reactions.jl") +include("CPU_expts.jl") + # baseline steady-state -# model = CPU_expts([]) +model = PB.create_model_from_config( + joinpath(@__DIR__, "CPU_cfg.yaml"), + "CPU_Zhang2020"; + modelpars=Dict(), # optional Dict can be supplied to set top-level (model wide) Parameters +) + # LIP CO2 input -model = CPU_modular_expts([("LIP", 3e18)]) +CPU_expts(model, [("LIP", 3e18)]) # increase E -# model = CPU_modular_expts([("E", 2.0)]) +# CPU_expts(model, [("E", 2.0)]) # increase V -# model = CPU_modular_expts([("V", 2.0)]) +# CPU_expts(model, [("V", 2.0)]) initial_state, modeldata = PALEOmodel.initialize!(model) @@ -56,9 +62,9 @@ println("integrate, ODE") # assemble plots onto screens with 6 subplots gr(size=(1200, 900)) # gr backend (plotly merges captions with multiple panels) -pager=PALEOmodel.PlotPager(6, (legend_background_color=nothing, )) +pager=PALEOmodel.PlotPager(6, (legend_background_color=nothing, margin=(5, :mm))) -plot_CPU_modular(paleorun.output; pager=pager) +plot_CPU(paleorun.output; pager=pager) @info "End $(@__FILE__)" diff --git a/examples/CPU/CPU_expts.jl b/examples/CPU/CPU_expts.jl index 99b5c5d..2282b5a 100644 --- a/examples/CPU/CPU_expts.jl +++ b/examples/CPU/CPU_expts.jl @@ -4,14 +4,8 @@ import PALEOboxes as PB import PALEOmodel import PALEOcopse -function CPU_expts(expts) +function CPU_expts(model, expts) - model = PB.create_model_from_config( - joinpath(@__DIR__, "CPU_cfg.yaml"), - "CPU_Zhang2020"; - modelpars=Dict(), # optional Dict can be supplied to set top-level (model wide) Parameters - ) - ############################################### # choose an 'expt' (a delta to the base model) ############################################### diff --git a/examples/CPU/README.md b/examples/CPU/README.md index 718b695..f0ec754 100644 --- a/examples/CPU/README.md +++ b/examples/CPU/README.md @@ -27,5 +27,5 @@ This will run and plot output (NB: the first run will be slow as Julia JIT compi ## To display model Parameters, Variables, and output. -See `PALEOmodel` [documentation](https://paleotoolkit.github.io/PALEOmodel.jl/) +See [Displaying model configuration and output from the Julia REPL](@ref) diff --git a/examples/CPU_modular/CPU_modular_examples.jl b/examples/CPU_modular/CPU_modular_examples.jl index 0f7869b..398475e 100644 --- a/examples/CPU_modular/CPU_modular_examples.jl +++ b/examples/CPU_modular/CPU_modular_examples.jl @@ -16,15 +16,19 @@ include("CPU_modular_reactions.jl") include("CPU_modular_expts.jl") # baseline steady-state -# model = CPU_modular_expts([]) +model = PB.create_model_from_config( + joinpath(@__DIR__, "CPU_modular_cfg.yaml"), + "CPU_Zhang2020"; + modelpars=Dict(), # optional Dict can be supplied to set top-level (model wide) Parameters +) # LIP CO2 input -model = CPU_modular_expts([("LIP", 3e18)]) +CPU_modular_expts(model, [("LIP", 3e18)]) # increase E -# model = CPU_modular_expts([("E", 2.0)]) +# CPU_modular_expts(model, [("E", 2.0)]) # increase V -# model = CPU_modular_expts([("V", 2.0)]) +# CPU_modular_expts(model, [("V", 2.0)]) initial_state, modeldata = PALEOmodel.initialize!(model) @@ -56,7 +60,7 @@ println("integrate, ODE") # assemble plots onto screens with 6 subplots gr(size=(1200, 900)) # gr backend (plotly merges captions with multiple panels) -pager=PALEOmodel.PlotPager(6, (legend_background_color=nothing, )) +pager=PALEOmodel.PlotPager(6, (legend_background_color=nothing, margin=(5, :mm))) plot_CPU_modular(paleorun.output; pager=pager) diff --git a/examples/CPU_modular/CPU_modular_expts.jl b/examples/CPU_modular/CPU_modular_expts.jl index 25a7258..d4c0bbc 100644 --- a/examples/CPU_modular/CPU_modular_expts.jl +++ b/examples/CPU_modular/CPU_modular_expts.jl @@ -4,14 +4,8 @@ import PALEOboxes as PB import PALEOmodel import PALEOcopse -function CPU_modular_expts(expts) - - model = PB.create_model_from_config( - joinpath(@__DIR__, "CPU_modular_cfg.yaml"), - "CPU_Zhang2020"; - modelpars=Dict(), # optional Dict can be supplied to set top-level (model wide) Parameters - ) - +function CPU_modular_expts(model, expts) + ############################################### # choose an 'expt' (a delta to the base model) ############################################### diff --git a/examples/CPU_modular/README.md b/examples/CPU_modular/README.md index 96693b8..e7b5067 100644 --- a/examples/CPU_modular/README.md +++ b/examples/CPU_modular/README.md @@ -29,5 +29,5 @@ This will run and plot output (NB: the first run will be slow as Julia JIT compi ## To display model Parameters, Variables, and output. -See `PALEOmodel` [documentation](https://paleotoolkit.github.io/PALEOmodel.jl/) +See [Displaying model configuration and output from the Julia REPL](@ref) diff --git a/examples/reservoirs/README.md b/examples/reservoirs/README.md index 0cde708..7d94258 100644 --- a/examples/reservoirs/README.md +++ b/examples/reservoirs/README.md @@ -14,7 +14,7 @@ F = \kappa A \frac{dB}{dt} = F \\ ``` -See `PALEOmodel` [documentation](https://paleotoolkit.github.io/PALEOmodel.jl/) for more information on analysing model output. +See [Displaying model configuration and output from the Julia REPL](@ref) for more information on analysing model output. ## Example 1 A minimal self-contained PALEO reaction