API Reference

Base

IMASdd.infoFunction
info(uloc::AbstractString, extras::Bool=true)

Return information of a node in the IMAS data structure, possibly including extra structures

source
info(@nospecialize(ids::Union{IDS,IDSvector,Type}), field::Symbol)

Return information of a filed of an IDS

source
IMASdd.unitsFunction
units(uloc::String)

Return string with units for a given IDS location

source
units(ids::IDS, field::Symbol)

Return string with units for a given IDS field

source
IMASdd.coordinatesFunction
coordinates(@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

source
IMASdd.time_coordinateFunction
time_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

source
IMASdd.access_logConstant
IMASdd.access_log

IMASdd.access_log.enable = true / false

@show IMASdd.access_log

empty!(IMASdd.access_log) # to reset

Track access to the data dictionary

source
Base.getpropertyFunction
getproperty(@nospecialize(ids::IDS), field::Symbol)

Return IDS value for requested field

source
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

source
Base.isemptyFunction
isempty(@nospecialize(ids::IDSvector))

returns true if IDSvector is empty

source
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

source
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

source
Base.setproperty!Function
Base.setproperty!(ids::IDS, field::Symbol, v; skip_non_coordinates::Bool=false, error_on_missing_coordinates::Bool=true)
source
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)

source
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

source
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.

source
IMASdd.indexFunction
index(@nospecialize(ids::IDSvectorElement))

Returns index of the IDSvectorElement in the parent IDSvector

source
IMASdd.keys_no_missingFunction
keys_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

source
Base.resize!Function
Base.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

source
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

source
Base.deleteat!Function
Base.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

source
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)

source
Base.ismissingFunction
Base.ismissing(@nospecialize(ids::IDS), field::Symbol)

returns true/false if field is missing in IDS

source
Base.diffFunction
Base.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)

source
IMASdd.top_idsFunction
top_ids(@nospecialize(ids::Union{IDS,IDSvector}))

Return top-level IDS in the hierarchy and nothing if top level is not a top-level IDS

source
IMASdd.top_ddFunction
top_dd(@nospecialize(ids::Union{IDS,IDSvector}))

Return top-level dd in the hierarchy, and nothing if top level is not dd

source
Base.parentFunction
parent(@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

source
IMASdd.gotoFunction
goto(@nospecialize(ids::Union{IDS,IDSvector}), loc::String)

Reach location in a given IDS

source
goto(@nospecialize(ids::Union{IDS,IDSvector}), path::Union{AbstractVector,Tuple})

Reach location in a given IDS

source
IMASdd.leavesFunction
leaves(@nospecialize(ids::IDS))

Returns iterator with (filled) leaves in the IDS

source
IMASdd.filled_ids_fieldsFunction
filled_ids_fields(@nospecialize(ids::IDS); eval_expr::Bool=false)

Returns a vector with tuples pointing to all the (ids, field) that have data downstream

source
IMASdd.pathsFunction
paths(@nospecialize(ids::IDS); eval_expr::Bool=false)

Returns the locations in the IDS that have data downstream

source
IMASdd.selective_copy!Function
selective_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
source
IMASdd.selective_delete!Function
selective_delete!(@nospecialize(h_in::IDS), path::Vector{<:AbstractString})

Deletes a path from one IDS

NOTE:

  • the path is a i2p(ulocation)
source

IO

IMASdd.dict2imasFunction
dict2imas(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
source
IMASdd.imas2dictFunction
imas2dict(ids::Union{IDS,IDSvector}; freeze::Bool=true, strict::Bool=false)

Populate Julia structure of dictionaries and vectors with data from IMAS data structure ids

source
IMASdd.json2imasFunction
json2imas(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 missing
  • verbose: print structure hierarchy as it is filled
source
IMASdd.jstr2imasFunction
jstr2imas(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 missing
  • verbose: print structure hierarchy as it is filled
source
IMASdd.imas2jsonFunction
imas2json(@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 expressions
  • strict dumps fields that are strictly in ITER IMAS only
  • kw... arguments are passed to the JSON.print function
source
IMASdd.hdf2imasFunction
hdf2imas(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 the HDF5.h5open function
source
IMASdd.hdf2dict!Function
hdf2dict!(gparent::Union{HDF5.File,HDF5.Group}, ids::AbstractDict)

Load data from a HDF5 file into a dictionary

source
IMASdd.imas2hdfFunction
imas2hdf(@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 the HDF5.h5open function
  • freeze evaluates expressions
  • strict dumps fields that are strictly in ITER IMAS only
source
IMASdd.h5i2imasFunction
h5i2imas(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 the HDF5.h5open function
source
IMASdd.imas2h5iFunction
imas2h5i(
    @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 the HDF5.h5open function
  • freeze evaluates expressions
  • strict dumps fields that are strictly in ITER IMAS only
  • run, shot, hdf5_backend_version arguments are used to set the HDF5 attributes
source

Time

IMASdd.global_timeFunction
global_time(ids::Union{IDS,IDSvector})

Get the dd.global_time of a given IDS

If top-level dd cannot be reached then returns Inf

source
global_time(ids::Union{IDS,IDSvector}, time0::Float64)

Set the dd.global_time of a given IDS

source
IMASdd.set_time_arrayFunction
set_time_array(@nospecialize(ids::IDS), field::Symbol, value)

Set value of a time-dependent array at the dd.global_time

source
set_time_array(@nospecialize(ids::IDS), field::Symbol, time0::Float64, value)

Set value of a time-dependent array at time0

source
IMASdd.get_time_arrayFunction
get_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

source
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
source
IMASdd.@ddtimeMacro
@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)
source
IMASdd.last_timeFunction
last_time(dd::DD)

Returns the last time referenced in all the IDSs dd.XXX.time vectors (including dd.global_time)

source
IMASdd.last_global_timeFunction
last_global_time(dd::DD)

Returns the last time referenced in all the IDSs dd.XXX.time vectors (including dd.global_time)

source
IMASdd.new_timeslice!Function
new_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

source
IMASdd.retime!Function
retime!(ids::IDS, time0::Float64)

Recursively change the time of the last time-slices or last time-depedent vector elements in a IDS

source
IMASdd.get_timesliceFunction
get_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]

source

Math

IMASdd.interp1dFunction
interp1d(x, y, scheme::Symbol=:linear)

One dimensional curve interpolations with scheme [:constant, :linear, :quadratic, :cubic, :pchip, :lagrange]

NOTE: this interpolation method will extrapolate

source
IMASdd.extrap1dFunction
extrap1d(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

source
IMASdd.gradientFunction
gradient(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

source
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

source
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

source