Utilities
Useful utilities for TMI.
Missing docstring for TMI.cellarea
. Check Documenter's build log for details.
Missing docstring for TMI.cellvolume
. Check Documenter's build log for details.
Missing docstring for TMI.layerthickness
. Check Documenter's build log for details.
Missing docstring for TMI.zonalgriddist
. Check Documenter's build log for details.
Missing docstring for TMI.surfacepatch
. Check Documenter's build log for details.
TMI.nearestneighbormask
— Functionfunction nearestneighbormask
Make a 3D tracer field that is 1 at location
of nearest neighbor, 0 elsewhere
Arguments
loc
: location in a 3-tuple (lon,lat,depth)γ
: TMI.grid
Output
δ
: nearest neighbor mask 3D field
TMI.nearestneighbor
— Functionfunction nearestneighbor(loc,γ)
return the Cartesian index and linear index
of the nearest N neighbors
Arguments
loc
: 3-tuple of lon,lat,depth locationγ
: TMI.grid
Output
Inn
: Cartesian indices of nearest neighbor
#- Rnn
: linear indices of nearest neighbor, Removed from code
Missing docstring for TMI.horizontaldistance
. Check Documenter's build log for details.
Base.zeros
— Functionfunction zeros(γ::Grid,name=:none,longname="unknown",units="unknown")::Field
initialize tracer field on TMI grid
using a Field struct and constructor
Arguments
γ
::TMI.Grid
Output
d
::Field, 3d tracer field with NaN on dry points
function zeros(dim::Int64,dimval::Int64,γ::Grid,name::Symbol,longname::String,units::String)::BoundaryCondition
Initialize boundary condition with zeroes
Arguments
dim
:dimval
γ::Grid
name::Symbol
longname::String
units::String
Output
b::BoundaryCondition
function zeros(wet,ltype=Float64)
initialize tracer field on TMI grid
This version will give an array
Arguments
wet
::BitArray mask of ocean pointsltype
:: optional type argument, default=Float64
Output
d
:: 3d tracer field with NaN on dry points
Base.ones
— Functionfunction ones(dim::Int64,dimval::Int64,γ::Grid)::BoundaryCondition
Initialize boundary condition with ones
function ones(γ::Grid,name=:none,longname="unknown",units="unknown")::Field
initialize tracer field of ones on TMI grid
using a Field struct and constructor
Arguments
γ
::TMI.Grid
Output
d
::Field, 3d tracer field with NaN on dry points
TMI.tracerinit
— Functionfunction tracerinit(wet,vec,I)
initialize tracer field on TMI grid
perhaps better to have a tracer struct and constructor
Arguments
wet
:: BitArray mask of ocean pointsvec
:: vector of values at wet pointsI
:: Cartesian Index for vector
Output
field
:: 3d tracer field with NaN on dry points
Missing docstring for TMI.maximum
. Check Documenter's build log for details.
Missing docstring for TMI.minimum
. Check Documenter's build log for details.
Missing docstring for `TMI.
TMI.+ TMI.* TMI.dot`. Check Documenter's build log for details.
Missing docstring for TMI.setsource
. Check Documenter's build log for details.
Base.vec
— Functionfunction vec(u)
Turn a collection of controls into a vector
for use with Optim.jl.
An in-place version of this function would be handy.
TMI.unvec!
— Functionfunction unvec!(u,uvec)
Undo the operations by vec(u)
Needs to update u because attributes of
u need to be known at runtime.
TMI.unvec
— Functionfunction unvec(u,uvec)
Replace u with new u
Undo the operations by vec(u)
Needs to update u because attributes of
u need to be known at runtime.
Missing docstring for TMI.surface_oxygensaturation
. Check Documenter's build log for details.
Missing docstring for TMI.oxygen
. Check Documenter's build log for details.
TMI.synthetic_observations
— Functionfunction synthetic_observations(TMIversion,variable)
Synthetic observations that are a contaminated version of real observations
This version: gridded observations
Arguments
TMIversion::String
: version of TMI water-mass/circulation modelvariable::String
: variable name to use as template
Output
y
: contaminated observations on 3D gridW⁻
: appropriate weighting (inverse covariance) matrix for these observations,θtrue
: real observations, 3D field
function synthetic_observations(TMIversion,variable,locs)
Synthetic observations that are a contaminated version of real observations
This version: observations with random (uniform) spatial sampling
Arguments
TMIversion::String
: version of TMI water-mass/circulation modelvariable::String
: variable name to use as templateN
: number of observations
Output
y
: contaminated observations on 3D gridW⁻
: appropriate weighting (inverse covariance) matrix for these observations,ytrue
: uncontaminated observations, 3D fieldlocs
: 3-tuples of locations for observationswis
: weighted indices for interpolation to locs sites
TMI.observe
— Functionfunction observe
Take a observation at location given by weights wis
function observe(c,loc,γ)
Extend the TMI.observe method to use locations rather than weighted interpolations.
TMI.gobserve
— Functionfunction gobserve(gy::Vector{T},c::Field{T},wis,γ) where T <: Real
ADJOINT Take a observation at location given by weights wis
Arguments not symmetric with `observe` due to splat operator
Missing docstring for TMI.location_obs
. Check Documenter's build log for details.
Missing docstring for TMI.costfunction_gridded_obs
. Check Documenter's build log for details.
Missing docstring for TMI.costfunction_gridded_obs!
. Check Documenter's build log for details.
TMI.costfunction_point_obs
— Functionfunction costfunction_point_obs(uvec::Vector{T},Alu,b₀::BoundaryCondition{T},u₀::BoundaryCondition{T},y::Vector{T},Wⁱ::Diagonal{T, Vector{T}},wis,locs,Q⁻,γ::Grid;q=nothing,r=1.0) where T <: Real
Squared model-data misfit for pointwise data.
Controls are a vector input for Optim.jl.
Core numerics handled by `costfunction_point_obs`.
Arguments
uvec
: controls, vector formatAlu
: LU decomposition of water-mass matrixb
: boundary conditiony
: pointwise observationsWⁱ
: inverse of W weighting matrix for observationswis
: weights for interpolation (data sampling, E)locs
: data locations (lon,lat,depth)Q⁻
: weights for control vectorγ
: grid
Optional
q::Field
: interior sourcer::Number
: scalar factor for source
Output
J
: cost function of sum of squared misfitsgJ
: derivative of cost function wrt to controls
TMI.costfunction_point_obs!
— Functionfunction costfunction_point_obs!(J,guvec,uvec::Vector{T},Alu,b₀::BoundaryCondition{T},u₀::BoundaryCondition{T},y::Vector{T},Wⁱ::Diagonal{T, Vector{T}},wis,locs,Q⁻,γ::Grid) where T <: Real
squared model-data misfit for pointwise data
controls are a vector input for Optim.jl
Issue #1: couldn't figure out how to nest with costfunction_obs!
Arguments
J
: cost function of sum of squared misfitsguvec
: derivative of cost function wrt to controlsuvec
: controls, vector formatAlu
: LU decomposition of water-mass matrixb
: boundary conditiony
: pointwise observationsWⁱ
: inverse of W weighting matrix for observationswis
: weights for interpolation (data sampling, E)locs
: data locations (lon,lat,depth)Q⁻
: weights for control vectorγ
: grid
TMI.steadyinversion
— Functionfunction steadyinversion(Alu,b;q=nothing,r=1.0)
invert for a steady-state tracer distribution
Arguments
Alu
: LU decomposition of water-mass matrixb
: boundary condition, assumed to be surface boundary conditionγ
::Grid
Optional Arguments
q
: interior sources/sinks of phosphater
: stochiometric ratio of tracer:phosphate
Output
c
::Field, steady-state tracer distribution
TMI.gsteadyinversion
— Functionfunction gsteadyinversion(gc,Alu,b;q=nothing,r=1.0)
ADJOINT invert for a steady-state tracer distribution
Arguments
Alu
: LU decomposition of water-mass matrixb
: BoundaryConditionγ
::Grid
Optional Arguments
q
: interior sources/sinks of phosphater
: stochiometric ratio of tracer:phosphate
Output
c
::Field, steady-state tracer distribution
TMI.wetlocation
— Functionfunction wetlocation(γ)
Get (lon,lat,depth) tuples of wet locations.
Allow a location to be wet if at least one out of 8 nearby gridpoints is wet.
Certainly "wet" gridpoints could be defined more strictly.
Arguments
γ
: TMI.grid
Output
loc
: lon,lat,depth
Missing docstring for TMI.iswet
. Check Documenter's build log for details.