Skip to content
InterpolationFileTest.md

InterpolationFileTest

Tests time-based interpolation using data from a CSV file.

This component reads data from a specified CSV file and performs linear interpolation, using the current simulation time as the input. The interpolated value is made available through the output variable y. The component utilizes a dataset structure that identifies dependent and independent variables from the CSV file, allowing for flexible time-series data interpolation.

Usage

InterpolationFileTest()

Parameters:

NameDescriptionUnitsDefault value
datasetDataset configuration specifying the CSV file path and variable mappingsDyadDataset("data/interp_square_data.csv", dependent_vars=["data"], independent_var="ts")

Variables

NameDescriptionUnits
yOutput variable that holds the interpolated value

Behavior

interp.u(t)=tinterp.y(t)=y(t)interp.y(t)=interp.interpolator(interp.u(t))

Source

dyad
# Tests time-based interpolation using data from a CSV file.
#
# This component reads data from a specified CSV file and performs linear interpolation, using the
# current simulation time as the input. The interpolated value is made available through the output
# variable `y`. The component utilizes a dataset structure that identifies dependent and independent
# variables from the CSV file, allowing for flexible time-series data interpolation.
test component InterpolationFileTest
  # Interpolation object that performs the actual interpolation calculation
  interp = Interpolation(interpolation_type=LinearInterpolation, dataset=dataset)
  # Dataset configuration specifying the CSV file path and variable mappings
  structural parameter dataset::DyadDataset = DyadDataset("data/interp_square_data.csv", dependent_vars=["data"], independent_var="ts")
  # Output variable that holds the interpolated value
  variable y::Real
relations
  interp.u = time
  interp.y = y
metadata {"Dyad": {"tests": {"case1": {"stop": 0.1, "expect": {"signals": ["y"]}}}}}
end
Flattened Source
dyad
# Tests time-based interpolation using data from a CSV file.
#
# This component reads data from a specified CSV file and performs linear interpolation, using the
# current simulation time as the input. The interpolated value is made available through the output
# variable `y`. The component utilizes a dataset structure that identifies dependent and independent
# variables from the CSV file, allowing for flexible time-series data interpolation.
test component InterpolationFileTest
  # Interpolation object that performs the actual interpolation calculation
  interp = Interpolation(interpolation_type=LinearInterpolation, dataset=dataset)
  # Dataset configuration specifying the CSV file path and variable mappings
  structural parameter dataset::DyadDataset = DyadDataset("data/interp_square_data.csv", dependent_vars=["data"], independent_var="ts")
  # Output variable that holds the interpolated value
  variable y::Real
relations
  interp.u = time
  interp.y = y
metadata {"Dyad": {"tests": {"case1": {"stop": 0.1, "expect": {"signals": ["y"]}}}}}
end


Test Cases

Test Case case1

julia
plt