API Reference
Public
SpaceDataModel.AbstractDataVariable — Type
A variable v of a type derived from AbstractDataVariable should at least implement:
Base.parent(v): the parent array of the variable
Optional:
tdimnum(v): the index of the time dimension (timedim,timesderive from it)units(v): the units of the variablegetmeta(v): the metadata of the variablename(v): the name of the variabledims(v, i): the coordinate of thei-th dimension of the variabledims(v, name): the dimension namednameof the variablecoords(v): further coordinates,axes => values(e.g. labels of a dimension)
SpaceDataModel.Archive — Type
Archive(pattern, reader=(paths, t0, t1) -> paths)A source mirroring a URL-per-step archive: remotefiles enumerates, localize caches, reader(paths, t0, t1) opens and returns data over [t0, t1).
Unpublished steps are dropped, a gap being normal; a range publishing nothing throws, since no reader can open an empty file list.
SpaceDataModel.Dataset — Method
Dataset(name, source; selectors=(;), metadata=NoMetadata(), kw...)A named dataset with domains for its selectors and a source that materializes it over a time range via getdata.
selectors maps each selector name to its domain: a single value, a collection, or Any for open. Values are spelled as strings.
name may carry {selector} placeholders, filled when selection pins open domains; a source templates itself the same way.
SpaceDataModel.FilePattern — Type
FilePattern(pattern; cadence=Day(1), kw...)A template for the names of an archive's files, one per cadence.
Text in {} is a placeholder: {t:fmt} renders the step's start through the Dates format fmt ({t:mm-dd}, {t:yyyyjjj} with j for day of year) and {t1:fmt} the last instant it covers, for archives naming both ends. A name without a format is a keyword; {name|U} and {name|L} render its value upper- or lowercased. Everything else is literal.
Keywords may be filled at construction, when specializing, or at the call; every one must be filled before a name is rendered. Filling a keyword with "*" leaves a wildcard for resolve_url to match against the archive's listing.
julia> using Dates
julia> FilePattern("g13_xrs_1m_{t:yyyymm}01_{t1:yyyymmdd}.nc"; cadence=Month(1))(Date(2012, 2))
"g13_xrs_1m_20120201_20120229.nc"SpaceDataModel.FilePattern — Method
Fill keywords and t, giving a URL.
SpaceDataModel.NoMetadata — Type
NoMetadata()Empty, immutable metadata.
SpaceDataModel.OverlayDict — Type
OverlayDict(base, overlay)
OverlayDict{K, V}(base)Dictionary view where overlay entries shadow base; writes update only overlay.
SpaceDataModel.Product — Type
Product(dataset, variable; metadata=NoMetadata(), kw...)A variable of a dataset: with optional layered metadata (e.g. a plot label override).
SpaceDataModel.Registry — Type
Registry(name, datasets; defaults=(;), metadata=NoMetadata(), kw...)A relation of Datasets: rows sharing a selector vocabulary. A mission, an instrument, or any other grouping is a Registry.
SpaceDataModel.SchemaDict — Type
SchemaDict(schema, data)
SchemaDict(schema, pairs::Pair...)Dict tagged with a MetadataSchema, recovered by get_schema.
SpaceDataModel.Transformed — Type
Transformed(f, source; metadata=NoMetadata(), kw...)A derived product: getdata materializes source and applies f to the result.
SpaceDataModel.available — Function
available(x, t0, t1; kwargs...)Times in [t0, t1) at which x has data.
SpaceDataModel.get_schema — Method
get_schema(data)Get the metadata schema for data. Returns the tagged schema if metadata is a SchemaDict, otherwise infers from content ("CATDESC" ⇒ ISTPSchema), falling back to DefaultSchema.
SpaceDataModel.getdata — Function
getdata(x, t0, t1; kwargs...)Materialize x over [t0, t1).
SpaceDataModel.getmeta — Function
getmeta(x, key, default=nothing)Get metadata value associated with key for object x, or default if key is not present.
SpaceDataModel.getmeta — Method
getmeta(x)Get metadata for object x. If x does not have metadata, return NoMetadata().
SpaceDataModel.localize — Method
localize(url; dir=datadir(), update=false) -> String
localize(urls; ntasks=4, kw...) -> Vector{String}Return a local path for each URL, downloading files missing from the cache.
Set the SPACE_DATA_DIR environment variable to override the default cache directory.
Set update = true to force re-download, or a Period to refetch if the local copy is older.
SpaceDataModel.remotefiles — Method
remotefiles(p::FilePattern, t0, t1; refresh=false, version="*", dir=datadir(), kw...) :: Vector{String}URLs of the files over [t0, t1). Steps with no published file are dropped rather than an error, since a gap in an archive is normal.
Keywords fill p's placeholders; version defaults to the * wildcard, picking the highest listed. refresh=true bypasses memoized directory listings.
SpaceDataModel.resolve_url — Method
resolve_url(url; refresh=false, dir=datadir())Concrete URL for url, where each * in the file name is replaced with the highest version field published in the directory, or nothing if the directory lists no such file. When the directory cannot be listed (e.g., the server is down), the highest version cached under dir stands in.
A field matches any width and any separator (e.g., v03, v03.06, v03_01, v1.1.10). A name may carry more than one, as MAVEN's …_v02_r00.cdf does; fields rank left to right.
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.
Private
Base.filter — Method
filter(reg::Registry; selectors...)The rows of reg every supplied selector matches, each with the matched columns pinned.
SpaceDataModel.coords — Method
coords(x)Coordinates of x besides its dims, axes => values with axes a tuple, e.g. the labels of a dimension that has values.
SpaceDataModel.dims — Function
dims(x)
dims(x, i)
dims(x, name)The dimensions of object x, its i-th dimension, or the dimension associated with the given name. A dimension without coordinates is nothing, the default (see AbstractDataVariable for its dims field default).
A dimension may be time-varying or dependent on other dimensions; in such cases, the effective size of the corresponding array dimension ndims can be greater than 1.
SpaceDataModel.mask_invalid! — Method
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.mask_invalid — Method
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.pin — Method
pin(ds, values; complete=false)Pin the open domains of ds named in values and rebuild its name and source with the pinned spellings; untouched domains stay open unless complete=true, which demands every one resolves.
SpaceDataModel.resolve — Method
resolve(data, lookup)Resolve metadata value from data using lookup.
Patterns
"key"/:key: direct metadata lookup("k1", "k2", ...): priority lookup, first hit winsVia(f, lookup):f(data)then resolvelookupon the resultlookup => default: usedefault(ordefault(data)) if lookup missesf::Function: callf(data)
SpaceDataModel.select — Method
select(reg; selectors...)The one dataset of reg every supplied selector matches, with omitted selectors filled from reg.defaults where the dataset carries them.
SpaceDataModel.vocabulary — Method
Selector names any of the registry's datasets carries.