Skip to content

NumericalEarth/pynanigans

Repository files navigation

Running Oceananigans from Python

This directory contains examples of running Oceananigans single column models from Python using JuliaCall.

Quick Start

1. Create the conda environment

conda env create -f environment.yml
conda activate oceananigans-python

2. Run the Python script

python single_column_model.py

This should produce

image

3. Or use the Jupyter notebook

jupyter lab single_column_model.ipynb

What happens on first run?

The first time you import juliacall, it will:

  1. Download and install Julia automatically (if not already installed)
  2. Install the required Julia packages (Oceananigans, etc.)

This can take several minutes on the first run. Subsequent runs will be much faster.

Customizing Julia Installation

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.py

Or to use a specific Julia project/environment:

export JULIA_PROJECT=/path/to/your/project
python single_column_model.py

Troubleshooting

Slow first import

The first import of juliacall can take a while as it sets up Julia. Be patient — subsequent imports are fast.

Julia packages not found

If Oceananigans is not installed, you can install it from Python:

from juliacall import Main as jl
jl.seval('using Pkg; Pkg.add("Oceananigans")')

Memory issues

Single column models are lightweight, but if you're running out of memory, try reducing the vertical resolution (Nz) or simulation duration.

Files

  • environment.yml — Conda environment specification
  • single_column_model.py — Python script running a single column model
  • single_column_model.ipynb — Jupyter notebook with interactive visualization
  • README.md — This file

About

Shenanigans and Oceananigans in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published