tomchor / Oceanostics.jl

Diagnostics for Oceananigans
https://tomchor.github.io/Oceanostics.jl/
MIT License
24 stars 8 forks source link

Adds extra methods to some diagnostics for more user control #139

Closed tomchor closed 1 year ago

tomchor commented 1 year ago

A simple way to allow users to circumvent https://github.com/CliMA/Oceananigans.jl/issues/3140

Closes https://github.com/tomchor/Oceanostics.jl/issues/137

Basically (taking the RichardsonNumber as an example) this PR adds an extra function call that returns the desired diagnostic. There's the traditional model-only call:

Ri = RichardsonNumber(model)

And now there will be calls where the variables are explicitly passed:

Ri = RichardsonNumber(model, u, v, w, b)

This allows for more control, which allows for simpler abstract trees if the need arises. For example a user can write

b_bg = (x, y, z, t) -> 1
model = NonhydrostaticModel(; grid, buoyancy=BuoyancyTracer(), tracers=:b,
                            background_fields = (; b = BackgroundField(b_bg),))
u, v, w = model.velocities
b = model.tracers.b
B = model.background_fields.tracers.b

using Oceanostics
Ri = RichardsonNumber(model, u, v, w, Field(b+B))

which returns a simpler tree than

Ri = RichardsonNumber(model, add_background=true)

but produces same result.