Skip to content
Interpolation.md

Interpolation

Performs interpolation on input values using a specified dataset and interpolation method.

Takes an input value and produces an output by interpolating within a dataset according to the specified interpolation type. The component creates an interpolator object from the dataset and interpolation parameters, then applies this interpolator to map input values to output values through lookup and interpolation.

Usage

Interpolation(interpolator=dataset_interpolation(interpolation_type, dataset))

Parameters:

NameDescriptionUnitsDefault value
datasetDataset containing the data points to be interpolated
interpolation_typeType of interpolation to be used (e.g., linear, cubic)

Connectors

  • u - This connector represents a real signal as an input to a component (RealInput)

  • y - This connector represents a real signal as an output from a component (RealOutput)

Behavior

@example
using BlockComponents #hide
using ModelingToolkit #hide
@named sys = Interpolation() #hide
full_equations(sys) #hide

Source

dyad
# Performs interpolation on input values using a specified dataset and interpolation method.
#
# Takes an input value and produces an output by interpolating within a dataset according to the
# specified interpolation type. The component creates an interpolator object from the dataset and
# interpolation parameters, then applies this interpolator to map input values to output values
# through lookup and interpolation.
component Interpolation
  # Input value to be used for interpolation lookup
  u = RealInput()
  # Interpolated output value
  y = RealOutput()
  # Dataset containing the data points to be interpolated
  structural parameter dataset::DyadDataset
  # Type of interpolation to be used (e.g., linear, cubic)
  structural parameter interpolation_type::Real
  # Interpolator object created from the dataset and interpolation type
  final parameter interpolator::RealInterpolator = dataset_interpolation(interpolation_type, dataset)
relations
  y = interpolator(u)
end
Flattened Source
dyad
# Performs interpolation on input values using a specified dataset and interpolation method.
#
# Takes an input value and produces an output by interpolating within a dataset according to the
# specified interpolation type. The component creates an interpolator object from the dataset and
# interpolation parameters, then applies this interpolator to map input values to output values
# through lookup and interpolation.
component Interpolation
  # Input value to be used for interpolation lookup
  u = RealInput()
  # Interpolated output value
  y = RealOutput()
  # Dataset containing the data points to be interpolated
  structural parameter dataset::DyadDataset
  # Type of interpolation to be used (e.g., linear, cubic)
  structural parameter interpolation_type::Real
  # Interpolator object created from the dataset and interpolation type
  final parameter interpolator::RealInterpolator = dataset_interpolation(interpolation_type, dataset)
relations
  y = interpolator(u)
metadata {}
end


Test Cases

This is setup code, that must be run before each test case.

julia
using BlockComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames

snapshotsdir = joinpath(dirname(dirname(pathof(BlockComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/BlockComponents/77kIK/test/snapshots"