When describing underwater environments, we often need to work with quantities that vary with position. Some quantities are constant, while others may vary with depth, range, or 3D position (e.g. sound speed profile, bathymetry, etc). We introduce a consistent representation of fields to help formalize position-dependent quantities.
Interface
Fields that do not vary with position are considered constant, and are represented by scalars. If a field may vary only with depth, but not with horizontal position, it is considered DepthDependent. On the other hand, if it may vary with any positional coordinate, it is considered PositionDependent. Varying fields are represented by data types that are subtypes of the appropriate abstract type (DepthDependent or PositionDependent).
DepthDependent
Quantity that may vary with depth, but not with range (x or y coordinate).
PositionDependent
Quantity that may vary with depth and range (x, y and/or z coordinate).
To get the value of a field at a given position, we use the value function:
value(q)value(q, pos)
Get the value of the varying quantity q at the given position pos. pos may be specified as a (x, y, z) tuple, a (x, z) tuple, or a z value.
Examples
value(q) # get value of a constant quantityvalue(q, -10) # get value of a depth-dependent quantity at z=-10value(q, (1000,-10)) # get value of a position-dependent quantity at x=1000, z=-10value(q, (0,0,-10)) # get value of a position-dependent quantity at (0,0,-10)
We can also check if a field is constant or range-dependent:
is_constant(q)
Return true if the quantity q is a constant, false if it could depend on position.
is_range_dependent(q)
Return true if the quantity q may be range-dependent, false if it is guaranteed to not depend on x or y coordinate.
Fields that only vary with depth are neither constant nor range-dependent.
Some propagation models require knowledge of the extreme values of a field. These can be obtained using the minimum and maximum functions:
minimum(q)
Get the minimum value of a field quantity q.
maximum(q)
Get the maximum value of a field quantity q.
Implementations
Constants
Scalars are trivially constant fields:
let q =1500@show q@showis_constant(q)@showis_range_dependent(q)@showvalue(q)@showvalue(q, -10)@showvalue(q, (1000, -10))@showvalue(q, (0, 0, -10))@showminimum(q)@showmaximum(q)end;
They can be used in environmental descriptions. For example, iso-velocity environments can be described using a constant sound speed:
env =UnderwaterEnvironment(soundspeed=1500)
Sampled fields
Position-dependent fields can be defined using data samples at a set of positions. Values at other positions are obtained by interpolation. The SampledField() function creates a sampled field from a set of data samples:
SampledField(v; x)SampledField(v; z)SampledField(v; x, y)SampledField(v; x, z)SampledField(v; x, y, z)
Create a sampled field from a data v that may depend on position. For 1D fields, the x or z coordinate is required, and v is a vector. For 2D fields, the x and y coordinates or the x and z coordinates are required, and v is a matrix. For 3D fields, the x, y, and z coordinates are required, and v is a 3D array.
Keyword argument interp is used to specify the interpolation method. :linear interpolation is supported for 1D, 2D and 3D fields. For 2D and 3D fields, the data must be sampled on a regular grid. For uniformly sampled 1D fields, :cubic interpolation is also supported.
We can understand how to use SampledField by looking at some examples. Let’s create an environment with a depth-dependent sound speed profile: