Skip to content

Commit

Permalink
Merge pull request #23 from PALEOtoolkit/doc_update
Browse files Browse the repository at this point in the history
doc update
  • Loading branch information
sjdaines authored Jun 17, 2024
2 parents 79ee393 + 99687e7 commit 53aa5b9
Show file tree
Hide file tree
Showing 6 changed files with 1,029 additions and 47 deletions.
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@
[![CI](https://github.com/PALEOtoolkit/PALEOocean.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/PALEOtoolkit/PALEOocean.jl/actions/workflows/CI.yml)
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://PALEOtoolkit.github.io/PALEOocean.jl/dev)

Ocean components for the PALEO biogeochemical model.
Ocean components for the [PALEOtoolkit](https://github.com/PALEOtoolkit) biogeochemical model framework.

The PALEOocean package provides:
- a catalog of ocean circulation models, including low-dimensional box models and GCM transport-matrix representations of the global ocean at resolutions up to 1 deg.
- air-sea exchange
- vertical tracer and light transport
- biological production
- parameterisations of burial fluxes

**NB: work-in-progress - this repo contains initial minimal examples only to test infrastructure.**
## Documentation

## Installation and running a minimal example
Documentation is available online at https://paleotoolkit.github.io/PALEOocean.jl/

### Installation
## Installation

NB: requires Julia 1.6 or later. To check the Julia version:
### Using PALEOocean Reactions from other models

julia> versioninfo()
The PALEOocean Reactions are available to the [PALEOtoolkit](https://github.com/PALEOtoolkit) framework when the registered PALEOocean package is installed and loaded:

Clone this github repository to local directory `PALEOocean`:
julia> Pkg.add("PALEOocean") # install PALEOocean package in the currently active Julia environment
julia> import PALEOocean

from a linux bash prompt or a Windows terminal,
### Running PALEOocean examples

To install and run the PALEOocean examples, clone this github repository to local directory `PALEOocean` and run the examples from the Julia REPL.

Quickstart assuming a recent Julia installation: from a linux bash prompt or a Windows terminal,

$ git clone https://github.com/PALEOtoolkit/PALEOocean.jl.git PALEOocean

Expand All @@ -28,20 +39,7 @@ Julia environment to use the local (downloaded) version of the PALEOocean packag
julia> cd("PALEOocean/examples")
julia> include("setup.jl") # use the local version of PALEOocean packages to allow local modifications

### Running a minimal ocean transport example
Start julia and navigate to the `PALEOocean` folder, then:

julia> cd("PALEOocean/examples")
julia> import Pkg
julia> Pkg.activate(".") # use the PALEOocean/examples environment

julia> cd("transport_examples")
julia> include("PALEO_examples_transport_advect.jl")


## Using PALEOocean Reactions from other models

The PALEOocean Reactions are available to the PALEO framework when the registered PALEOocean package is loaded (without downloading the repository), ie
Examples are in subfolders of `PALEOocean/examples/` and use the `PALEOocean/examples` Julia environment.

julia> Pkg.add("PALEOocean")
julia> import PALEOocean
See [Installation and getting started](https://paleotoolkit.github.io/PALEOtutorials.jl/dev/ExampleInstallConfig/)
in the [PALEOtutorials](https://github.com/PALEOtoolkit/PALEOtutorials.jl) repository for more details including installation and configuration of Julia.
46 changes: 23 additions & 23 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# PALEOocean.jl documentation

## Installation and running the examples
Ocean components for the [PALEOtoolkit](https://github.com/PALEOtoolkit) biogeochemical model framework.

### Installation
The PALEOocean package provides:
- a catalog of ocean circulation models, including low-dimensional box models and GCM transport-matrix representations of the global ocean at resolutions up to 1 deg.
- air-sea exchange
- vertical tracer and light transport
- biological production
- parameterisations of burial fluxes

NB: requires Julia 1.6 or later. To check the Julia version:
## Installation

julia> versioninfo()
### Using PALEOocean Reactions from other models

Clone this github repository to local directory `PALEOocean`: from a linux bash prompt or a Windows terminal,
The PALEOocean Reactions are available to the [PALEOtoolkit](https://github.com/PALEOtoolkit) framework when the registered PALEOocean package is installed and loaded:

$ git clone https://github.com/PALEOtoolkit/PALEOocean.jl.git PALEOcopse
julia> Pkg.add("PALEOocean") # install PALEOocean package in the currently active Julia environment
julia> import PALEOocean

### Running PALEOocean examples

To install and run the PALEOocean examples, clone this github repository to local directory `PALEOocean` and run the examples from the Julia REPL.

Quickstart assuming a recent Julia installation: from a linux bash prompt or a Windows terminal,

$ git clone https://github.com/PALEOtoolkit/PALEOocean.jl.git PALEOocean

Start julia and navigate to the `PALEOocean/examples` folder, and run `setup.jl` to configure the `PALEOocean/examples`
Julia environment to use the local (downloaded) version of the PALEOocean package:

julia> cd("PALEOocean/examples")
julia> include("setup.jl") # use the local version of PALEOocean packages to allow local modifications

### Running a minimal transport example
Start julia and navigate to the `PALEOocean` folder, then:

julia> cd("examples/transport_examples")
julia> import Pkg
julia> Pkg.activate("..") # use the PALEOocean/examples environment

julia> include("PALEO_examples_transport_advect.jl")


## Using PALEOocean Reactions from other models

The PALEO Reactions comprising the PALEOocean models are available when the registered PALEOocean package is loaded (without downloading the repository), ie

julia> Pkg.add("PALEOocean")
julia> import PALEOocean

Examples are in subfolders of `PALEOocean/examples/` and use the `PALEOocean/examples` Julia environment.

See [Installation and getting started](https://paleotoolkit.github.io/PALEOtutorials.jl/dev/ExampleInstallConfig/)
in the [PALEOtutorials](https://github.com/PALEOtoolkit/PALEOtutorials.jl) repository for more details including installation and configuration of Julia.
6 changes: 6 additions & 0 deletions examples/doc_order.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ocean3box
PTBClarkson2014
shelf1D
mitgcm
skeleton_configuration
transport_examples
8 changes: 8 additions & 0 deletions examples/shelf1D/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 1D shelf sea examples and test cases

![Shelf Domains and Processes](images/shelf_domains_processes.svg)
###### Figure 1
*1D shelf configuration Domains and processes. Blue dots: tracers. Red arrows: circulation transport represented as eddy diffusivivity Kz, implmented by [`PALEOocean.Ocean.OceanTransportColumn.ReactionOceanTransportColumn`](@ref). Black arrow: vertical transport, implemented by [`PALEOocean.Ocean.VerticalTransport.ReactionSinkFloat`](@ref)*

## Installation and configuration
These examples require netcdf files defining an annual cycle of physical variables:
- water column eddy diffusivity Kz, temperature, density
Expand Down Expand Up @@ -39,3 +43,7 @@ Oxygenic and anoxygenic phytoplankton populations, with sulphur + methane and ma
julia> include("PALEO_examples_shelf1Dsed.jl")

Coupled water-column - sediment configuration, with single phytoplankton population, sulphur + methane.

## Reading output with python xarray

`Test xarray netcdf.ipynb` demonstrates reading PALEO netcdf output using Python xarray.
216 changes: 216 additions & 0 deletions examples/shelf1D/Test xarray netcdf.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "68667024",
"metadata": {},
"source": [
"# Example reading PALEO netcdf output using python xarray\n",
"\n",
"Generate file 'test.nc' with:\n",
"\n",
" julia> include(\"PALEO_examples_shelf1D_P_O2.jl\")\n",
" julia> PALEOmodel.OutputWriters.save_netcdf(paleorun.output, \"test.nc\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d640c5a0",
"metadata": {},
"outputs": [],
"source": [
"import os"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c9a1bd15",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import xarray as xr"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a5ddcd9d",
"metadata": {},
"outputs": [],
"source": [
"os.getcwd()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "401e5aef",
"metadata": {},
"outputs": [],
"source": [
"# read top-level dataset\n",
"ds = xr.open_dataset(\"test.nc\")\n",
"ds.attrs"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4b80a015",
"metadata": {},
"outputs": [],
"source": [
"# read ocean group (= PALEO Domain ocean) from netcdf file\n",
"ds_ocean = xr.open_dataset(\"test.nc\", group=\"ocean\")\n",
"\n",
"# attach z coordinates (this is not automatic!)\n",
"ds_ocean = ds_ocean.set_coords([\"zmid\", \"zlower\", \"zupper\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8ef1c0ef",
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"ds_ocean"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "11dcd1af",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# timeseries for a scalar variable\n",
"print(ds_ocean[\"O2_total\"])\n",
"ds_ocean[\"O2_total\"].plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "853eb848",
"metadata": {},
"outputs": [],
"source": [
"# split dataset into columns (1 column only here so this could be skipped)\n",
"cells_in_column = ds_ocean[\"cells_in_column\"]\n",
"\n",
"print(\"Icolumn comment:\", ds_ocean[\"Icolumns\"].attrs[\"comment\"]) # zero-based indices of cells from top to bottom ordered by columns\n",
"Icolumns = ds_ocean[\"Icolumns\"].values\n",
"\n",
"ds_ocean_columns = []\n",
"colstartidx = 0\n",
"\n",
"for cidx, clength in enumerate(cells_in_column.values):\n",
" ccells = Icolumns[np.arange(colstartidx, colstartidx + clength)]\n",
" ds_ocean_columns.append(ds_ocean.isel(cells=ccells, columns=cidx))\n",
" colstartidx += clength\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "68d49cf3",
"metadata": {},
"outputs": [],
"source": [
"ds_ocean_columns[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "47459078",
"metadata": {},
"outputs": [],
"source": [
"ds_ocean_columns[0].columnnames.values"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aae8816e",
"metadata": {},
"outputs": [],
"source": [
"print(ds_ocean_columns[0][\"P_conc\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "799531d6",
"metadata": {},
"outputs": [],
"source": [
"ds_ocean_columns[0][\"P_conc\"].dims"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bdc14198",
"metadata": {},
"outputs": [],
"source": [
"ds_ocean_columns[0][\"P_conc\"].coords"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dd95a3fa",
"metadata": {},
"outputs": [],
"source": [
"np.shape(ds_ocean_columns[0][\"P_conc\"].values)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0e87c215",
"metadata": {},
"outputs": [],
"source": [
"ds_ocean_columns[0][\"P_conc\"].sel(tmodel=2.5).plot(y=\"zmid\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 53aa5b9

Please sign in to comment.