API Reference
Base
IMASdd.info
— Functioninfo(uloc::AbstractString, extras::Bool=true)
Return information of a node in the IMAS data structure, possibly including extra structures
info(@nospecialize(ids::Union{IDS,IDSvector,Type}), field::Symbol)
Return information of a filed of an IDS
IMASdd.units
— Functionunits(uloc::String)
Return string with units for a given IDS location
units(ids::IDS, field::Symbol)
Return string with units for a given IDS field
IMASdd.coordinates
— Functioncoordinates(@nospecialize(ids::IDS), field::Symbol; coord_leaves::Union{Nothing,Vector{Symbol}}=nothing)
Return two lists, one of coordinate names and the other with their values in the data structure
Coordinate value is nothing
when the data does not have a coordinate
Coordinate value is missing
if the coordinate is missing in the data structure
Use coord_leaves
to override fetching coordinates of a given field
IMASdd.time_coordinate
— Functiontime_coordinate(@nospecialize(ids::IDS), field::Symbol; error_if_not_time_dependent::Bool)
Return index of time coordinate
If error_if_not_time_dependent == false
it will return 0
for arrays that are not time dependent
IMASdd.access_log
— ConstantIMASdd.access_log
IMASdd.access_log.enable = true / false
@show IMASdd.access_log
empty!(IMASdd.access_log) # to reset
Track access to the data dictionary
Base.getproperty
— Functiongetproperty(@nospecialize(ids::IDS), field::Symbol)
Return IDS value for requested field
getproperty(@nospecialize(ids::IDS), field::Symbol, @nospecialize(default::Any))
Return IDS value for requested field or default
if field is missing
NOTE: This is useful because accessing a missing
field in an IDS would raise an error
Base.isempty
— Functionisempty(@nospecialize(ids::IDSvector))
returns true if IDSvector is empty
isempty(@nospecialize(ids::IDS); include_expr::Bool=false, eval_expr::Bool=false)
Returns true if none of the IDS fields downstream have data (or expressions)
NOTE: By default it does not include nor evaluate expressions
isempty(@nospecialize(ids::IDS), field::Symbol; include_expr::Bool=false, eval_expr::Bool=false)
Returns true if the ids field has no data (or expression)
NOTE: By default it does not include nor evaluate expressions
IMASdd.isfrozen
— Functionisfrozen(@nospecialize(ids::IDS))
Returns if the ids has been frozen
Base.setproperty!
— FunctionBase.setproperty!(ids::IDS, field::Symbol, v; skip_non_coordinates::Bool=false, error_on_missing_coordinates::Bool=true)
Base.setproperty!(@nospecialize(ids::IDS), field::Symbol, v::AbstractArray{<:IDS}; skip_non_coordinates::Bool=false, error_on_missing_coordinates::Bool=true)
Handle setproperty of entire vectors of IDS structures at once (ids.field is of type IDSvector)
Base.setproperty!(
@nospecialize(ids::IDS),
field::Symbol,
v::Union{AbstractRange,StaticArraysCore.SVector,StaticArraysCore.MVector};
skip_non_coordinates::Bool=false,
error_on_missing_coordinates::Bool=true
)
Convert abstract ranges and static arrays to vectors
Base.setproperty!(@nospecialize(ids::IDS), field::Symbol, v::AbstractArray; skip_non_coordinates::Bool=false, error_on_missing_coordinates::Bool=true)
Ensures coordinates are set before the data that depends on those coordinates. If skip_non_coordinates
is set, then fields that are not coordinates will be silently skipped.
IMASdd.index
— Functionindex(@nospecialize(ids::IDSvectorElement))
Returns index of the IDSvectorElement in the parent IDSvector
IMASdd.keys_no_missing
— Functionkeys_no_missing(@nospecialize(ids::IDS); include_expr::Bool=true, eval_expr::Bool=false)
Returns generator of fields with data in a IDS
NOTE: By default it includes expressions, but does not evaluate them
Base.resize!
— FunctionBase.resize!(@nospecialize(ids::IDSvector{T}), condition::Pair{String}, conditions::Pair{String}...; wipe::Bool=true, error_multiple_matches::Bool=true) where {T<:IDSvectorElement}
Resize if a set of conditions are not met.
If wipe=true and an entry matching the condition is found, then the content of the matching IDS is emptied.
Either way, the IDS is populated with the conditions.
NOTE: error_multiple_matches
will delete all extra entries matching the conditions.
Returns the selected IDS
resize!(
@nospecialize(ids::IDSvector{T}),
identifier_name::Symbol,
conditions::Pair{String}...;
wipe::Bool=true,
error_multiple_matches::Bool=true
)::T where {T<:IDSvectorElement}
Resize ids if identifier_name
is not found based on index
of index_2_name(ids)
and a set of conditions are not met.
If wipe=true and an entry matching the condition is found, then the content of the matching IDS is emptied.
Either way, the IDS is populated with the conditions.
NOTE: error_multiple_matches
will delete all extra entries matching the conditions.
Returns the selected IDS
Base.deleteat!
— FunctionBase.deleteat!(@nospecialize(ids::T), condition::Pair{String}, conditions::Pair{String}...) where {T<:IDSvector}
If an entry matching the condition is found, then the content of the matching IDS is emptied
deleteat!(@nospecialize(ids::T), identifier_name::Symbol, conditions::Pair{String}...)::T where {T<:IDSvector}
Deletes all entries that match based on index
of index_2_name(ids)
Base.ismissing
— FunctionBase.ismissing(@nospecialize(ids::IDS), field::Symbol)
returns true/false if field is missing in IDS
Base.diff
— FunctionBase.diff(
@nospecialize(ids1::T),
@nospecialize(ids2::T);
tol::Float64=1E-2,
recursive::Bool=true,
verbose::Bool=false) where {T<:IDS}
Compares two IDSs and returns dictionary with differences
NOTE: This function does not evaluate expressions (use freeze()
on the IDSs to compare values instead of functions)
IMASdd.top_ids
— Functiontop_ids(@nospecialize(ids::Union{IDS,IDSvector}))
Return top-level IDS in the hierarchy and nothing
if top level is not a top-level IDS
IMASdd.top_dd
— Functiontop_dd(@nospecialize(ids::Union{IDS,IDSvector}))
Return top-level dd
in the hierarchy, and nothing
if top level is not dd
Base.parent
— Functionparent(@nospecialize(ids::Union{IDS,IDSvector}); IDS_is_absolute_top::Bool=false, error_parent_of_nothing::Bool=true)
Return parent IDS/IDSvector in the hierarchy
If IDS_is_absolute_top=true
then returns nothing
instead of dd()
If error_parent_of_nothing=true
then asking parent(nothing)
will just return nothing
IMASdd.goto
— Functiongoto(@nospecialize(ids::Union{IDS,IDSvector}), loc::String)
Reach location in a given IDS
goto(@nospecialize(ids::Union{IDS,IDSvector}), path::Union{AbstractVector,Tuple})
Reach location in a given IDS
IMASdd.leaves
— Functionleaves(@nospecialize(ids::IDS))
Returns iterator with (filled) leaves in the IDS
IMASdd.filled_ids_fields
— Functionfilled_ids_fields(@nospecialize(ids::IDS); eval_expr::Bool=false)
Returns a vector with tuples pointing to all the (ids, field) that have data downstream
IMASdd.paths
— Functionpaths(@nospecialize(ids::IDS); eval_expr::Bool=false)
Returns the locations in the IDS that have data downstream
IMASdd.selective_copy!
— Functionselective_copy!(@nospecialize(h_in::IDS), @nospecialize(h_out::IDS), path::Vector{<:AbstractString}, time0::Float64)
Copies the content of a path from one IDS to another (if the path exists) at a given time0
NOTE:
- the path is a i2p(ulocation)
- if time0 is NaN then all times are retained
IMASdd.selective_delete!
— Functionselective_delete!(@nospecialize(h_in::IDS), path::Vector{<:AbstractString})
Deletes a path from one IDS
NOTE:
- the path is a i2p(ulocation)
IO
IMASdd.dict2imas
— Functiondict2imas(dct::AbstractDict, @nospecialize(ids::IDS); verbose::Bool=false)
Populate IMAS data structure ids
based on data contained in Julia dictionary dct
.
Arguments
verbose::Bool=false
: print structure hierarchy as it is filled
IMASdd.imas2dict
— Functionimas2dict(ids::Union{IDS,IDSvector}; freeze::Bool=true, strict::Bool=false)
Populate Julia structure of dictionaries and vectors with data from IMAS data structure ids
IMASdd.json2imas
— Functionjson2imas(filename::AbstractString, @nospecialize(ids::IDS)=dd(); error_on_missing_coordinates::Bool=true, verbose::Bool=false)
Load the IMAS data structure from a JSON file with given filename
Arguments
error_on_missing_coordinates
: boolean to raise an error if coordinate is missingverbose
: print structure hierarchy as it is filled
IMASdd.jstr2imas
— Functionjstr2imas(json_string::String, @nospecialize(ids::IDS)=dd(); error_on_missing_coordinates::Bool=true, verbose::Bool=false)
Load the IMAS data structure from a JSON string
Arguments
error_on_missing_coordinates
: boolean to raise an error if coordinate is missingverbose
: print structure hierarchy as it is filled
IMASdd.imas2json
— Functionimas2json(@nospecialize(ids::Union{IDS,IDSvector}), filename::AbstractString; freeze::Bool=true, strict::Bool=false, indent::Int=0, kw...)
Save the IMAS data structure to a JSON file with given filename
.
Arguments
freeze
evaluates expressionsstrict
dumps fields that are strictly in ITER IMAS onlykw...
arguments are passed to theJSON.print
function
IMASdd.hdf2imas
— Functionhdf2imas(filename::AbstractString; error_on_missing_coordinates::Bool=true, kw...)
Load data from a HDF5 file generated by OMAS Python platform (ie. hierarchical HDF5)
Arguments
kw...
arguments are passed to theHDF5.h5open
function
IMASdd.hdf2dict!
— Functionhdf2dict!(gparent::Union{HDF5.File,HDF5.Group}, ids::AbstractDict)
Load data from a HDF5 file into a dictionary
IMASdd.imas2hdf
— Functionimas2hdf(@nospecialize(ids::Union{IDS,IDSvector}), filename::AbstractString; freeze::Bool=true, strict::Bool=false, kw...)
Save the IMAS data structure to a OMAS HDF5 file with given filename
(ie. hierarchical HDF5)
Arguments
kw...
arguments are passed to theHDF5.h5open
functionfreeze
evaluates expressionsstrict
dumps fields that are strictly in ITER IMAS only
IMASdd.h5i2imas
— Functionh5i2imas(filename::AbstractString, @nospecialize(ids::IDS)=dd(); kw...)
Load data from a HDF5 file generated by IMAS platform (ie. tensorized HDF5)
Arguments
kw...
arguments are passed to theHDF5.h5open
function
IMASdd.imas2h5i
— Functionimas2h5i(
@nospecialize(ids::Union{IDS,IDSvector}),
filename::AbstractString;
freeze::Bool=true,
strict::Bool=false,
run::Int=0,
shot::Int=0,
hdf5_backend_version::String="1.0",
kw...
)
Save data to a HDF5 file generated by IMAS platform (ie. tensorized HDF5)
Arguments
kw...
arguments are passed to theHDF5.h5open
functionfreeze
evaluates expressionsstrict
dumps fields that are strictly in ITER IMAS onlyrun
,shot
,hdf5_backend_version
arguments are used to set the HDF5 attributes
Time
IMASdd.global_time
— Functionglobal_time(ids::Union{IDS,IDSvector})
Get the dd.global_time of a given IDS
If top-level dd cannot be reached then returns Inf
global_time(ids::Union{IDS,IDSvector}, time0::Float64)
Set the dd.global_time of a given IDS
IMASdd.set_time_array
— Functionset_time_array(@nospecialize(ids::IDS), field::Symbol, value)
Set value of a time-dependent array at the dd.global_time
set_time_array(@nospecialize(ids::IDS), field::Symbol, time0::Float64, value)
Set value of a time-dependent array at time0
IMASdd.get_time_array
— Functionget_time_array(@nospecialize(ids::IDS{T}), field::Symbol, scheme::Symbol=:linear) where {T<:Real}
Get data from a time-dependent array at the dd.global_time
get_time_array(ids::IDS, field::Symbol, time0::Float64, scheme::Symbol=:linear)
Get data from time dependent array
NOTE: logic for @ddtime array handling:
- interpolation (i)
scheme
between array bounds - constant (c) extrapolation within bounds of time array
- error (e) when time0 is before minimum(time)
For example:
time: -oooo-
data: -o-o--
ddtime: eiiicc
IMASdd.@ddtime
— Macro@ddtime( X.Y )
Get data from time dependent array. Equivalent to:
get_time_array(X, :Y)
and
@ddtime( X.Y = V)
Set data in a time dependent array. Equivalent to:
set_time_array(X, :Y, V)
IMASdd.last_time
— Functionlast_time(dd::DD)
Returns the last time referenced in all the IDSs dd.XXX.time
vectors (including dd.global_time
)
IMASdd.last_global_time
— Functionlast_global_time(dd::DD)
Returns the last time referenced in all the IDSs dd.XXX.time
vectors (including dd.global_time
)
IMASdd.new_timeslice!
— Functionnew_timeslice!(ids::IDS, time0::Float64)
Recursively appends a deepcopy at time time0
of the last time-slice of all time-dependent array structures under a given ids
IMASdd.retime!
— Functionretime!(ids::IDS, time0::Float64)
Recursively change the time of the last time-slices or last time-depedent vector elements in a IDS
IMASdd.get_timeslice
— Functionget_timeslice(@nospecialize(ids::IDS), time0::Float64=global_time(ids), scheme::Symbol=:linear; slice_pulse_schedule::Bool=true)
Returns data at the given time0
(by default at the global_time)
Data is selected from time dependent arrays of structures using closest causal time point.
Data is selected from time dependent arrays using these possible schemes [:constant, :linear, :quadratic, :cubic, :pchip, :lagrange]
Math
IMASdd.interp1d
— Functioninterp1d(x, y, scheme::Symbol=:linear)
One dimensional curve interpolations with scheme [:constant, :linear, :quadratic, :cubic, :pchip, :lagrange]
NOTE: this interpolation method will extrapolate
IMASdd.extrap1d
— Functionextrap1d(itp::DataInterpolations.AbstractInterpolation; first=:extrapolate, last=:extrapolate) where {T<:Real}
first
and last
can be [:extrapolate, :flat, --value--]
affect how the extrapolation is done at the either end of the array
IMASdd.gradient
— Functiongradient(coord::AbstractVector{C}, arr::AbstractVector{A}; method::Symbol=:second_order) where {C<:Real, A<:Real}
The finite difference gradient. The returned gradient has the same shape as the input array.
method
of the gradient can be one of [:backward, :central, :forward, :secondorder, :thirdorder]
For :central
the gradient is computed using second order accurate central differences in the interior points and first order accurate one-sides (forward or backward) differences at the boundaries.
For :second_order
the gradient is computed using second order accurate central differences in the interior points, and 2nd order differences at the boundaries.
For :third_order
the gradient is computed from the cubic spline passing through the points
gradient(coord1::AbstractVector, coord2::AbstractVector, mat::Matrix, dim::Int; method::Symbol=:second_order)
Finite difference method of the gradient: [:backward, :central, :forward, :secondorder, :thirdorder]
Can be applied to either the first (dim=1) or second (dim=2) dimension
gradient(coord1::AbstractVector, coord2::AbstractVector, mat::Matrix; method::Symbol=:second_order)
Finite difference method of the gradient: [:backward, :central, :forward, :secondorder, :thirdorder]
Computes the gradient in both dimensions