Interface
SpaceDataModel.jl provides a set of abstractions and generic functions that can be extended by users to create custom implementations. This page documents these interfaces and provides examples of how to use them.
References
- DataAPI.jl: A data-focused namespace for packages to share functions
Metadata
Generic functions to extend for custom data types:
SpaceDataModel.getmeta — Function
getmeta(x)Get metadata for object x. If x does not have metadata, return NoMetadata().
getmeta(x, key, default=nothing)Get metadata value associated with key for object x, or default if key is not present.
SpaceDataModel.setmeta — Function
setmeta(x, key => value, ...; symbolkey => value2, ...)
setmeta(x, dict::AbstractDict)Update metadata for object x for key key to have value value and return x.
SpaceDataModel.setmeta! — Function
setmeta!(x, key => value, ...; symbolkey => value2, ...)
setmeta!(x, dict::AbstractDict)Update metadata for object x in-place and return x. The metadata container must be mutable.
The arguments could be multiple key-value pairs or a dictionary of metadata; keyword arguments are also accepted.
Examples
setmeta!(x, :units => "m/s", :source => "sensor")
setmeta!(x, Dict(:units => "m/s", :quality => "good"))
setmeta!(x; units="m/s", calibrated=true)Throws an error if the metadata is not mutable. Use setmeta for immutable metadata.
Time series
See AbstractDataVariable for what a variable type defines.
SpaceDataModel.mask_invalid — Function
mask_invalid(A; fillval, validmin, validmax, dims = nothing)
mask_invalid(A, checks::ValidityChecks, dims = nothing)Copy of A with elements equal to fillval or outside [validmin, validmax] replaced by NaN; see ValidityChecks for their defaults and forms. Checks with several components apply along dimensions dims, an integer or a range; by default depend_1, the first non-time dimension.
Mask before arithmetic or unit conversion: metadata describes stored values.
Int8/UInt8, Int16/UInt16 and Float16 promote to Float32, wider integers to Float64, so Int64/UInt64 beyond 2^53 compare after rounding. Non-Real arrays are returned unchanged by the keyword form. A PermutedDimsArray gives one with the same permutation.
SpaceDataModel.mask_invalid! — Function
mask_invalid!(B, A; fillval, validmin, validmax, dims = nothing)
mask_invalid!(B, A, checks::ValidityChecks, dims = nothing)mask_invalid written into B, which may be A.
SpaceDataModel.ValidityChecks — Type
ValidityChecks(T, fillval, validmin, validmax)
ValidityChecks(x; fillval, validmin, validmax, dims = nothing)Fill value and valid range [validmin, validmax] of data with Real element type T. Each is a value, a vector of one value per component, or nothing to disable it. For x, T = eltype(x) and each defaults to its schema value (get_schema(x)); a schema vector whose length is not the number of components along dims (by default depend_1) acts as one value if its values are equal, and is dropped otherwise.