-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from PALEOtoolkit/doc_update
doc update
- Loading branch information
Showing
6 changed files
with
1,029 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ocean3box | ||
PTBClarkson2014 | ||
shelf1D | ||
mitgcm | ||
skeleton_configuration | ||
transport_examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.