This (now archived) repo was originally developed to prototype the workflow for running Oceananigans from python. It is no longer developed. For another "pynanigans" useful for analyzing Oceananigans output with python, see: https://github.com/tomchor/pynanigans .
Also note that Oceananigans has built-in utilities for manipulating, differentiating, computing, and visualizing Field and
FieldTimeSeries in Julia and with Makie, which are available both online (during simulations) as well as for post-processing.
The documentation for Field is here: https://clima.github.io/OceananigansDocumentation/stable/fields
and we welcome contributions to both the docs and functionality!
This directory contains examples of running Oceananigans single column models from Python using JuliaCall.
conda env create -f environment.yml
conda activate oceananigans-pythonpython single_column_model.pyThis should produce
jupyter lab single_column_model.ipynbThe first time you import juliacall, it will:
- Download and install Julia automatically (if not already installed)
- Install the required Julia packages (Oceananigans, etc.)
This can take several minutes on the first run. Subsequent runs will be much faster.
If you already have Julia installed and want JuliaCall to use it, set the environment variable before running Python:
export PYTHON_JULIACALL_EXE=/path/to/julia
python single_column_model.pyOr to use a specific Julia project/environment:
export JULIA_PROJECT=/path/to/your/project
python single_column_model.pyThe first import of juliacall can take a while as it sets up Julia.
Be patient — subsequent imports are fast.
If Oceananigans is not installed, you can install it from Python:
from juliacall import Main as jl
jl.seval('using Pkg; Pkg.add("Oceananigans")')Single column models are lightweight, but if you're running out of memory,
try reducing the vertical resolution (Nz) or simulation duration.
environment.yml— Conda environment specificationsingle_column_model.py— Python script running a single column modelsingle_column_model.ipynb— Jupyter notebook with interactive visualizationREADME.md— This file