CsplineParameters

(class from pyomo.contrib.cspline_external.cspline_parameters)

class pyomo.contrib.cspline_external.cspline_parameters.CsplineParameters(model=None, fptr=None)[source]

Bases: object

__init__(model=None, fptr=None)[source]

Cubic spline parameters class. This can be used to read and write parameters or calculate cubic spline function values and derivatives for testing.

Methods

__init__([model, fptr])

Cubic spline parameters class.

add_linear_extrapolation_segments()

Add a segment on the front and back of the cspline so that any extrapolation will be linear.

dfdx(x)

Get d/dx(f(x))

f(x)

Get f(x)

get_parameters_from_file(fptr)

Read parameters from a file

get_parameters_from_model(m)

Read parameters from a Pyomo model used to calculate them

segment(x)

Get the spline segment containing x.

write_parameters(fptr)

Write parameters to a file

Attributes

n_knots

Number of knots

n_segments

Number of segments

valid

Ensure that the number of knots and cubic parameters is valid

Member Documentation

add_linear_extrapolation_segments()[source]

Add a segment on the front and back of the cspline so that any extrapolation will be linear.

dfdx(x)[source]

Get d/dx(f(x))

Parameters:

x – location, numpy array float

Returns:

df/dx numpy array if x is numpy array or float

f(x)[source]

Get f(x)

Parameters:

x – location, numpy array float

Returns:

f(x) numpy array if x is numpy array or float

get_parameters_from_file(fptr)[source]

Read parameters from a file

get_parameters_from_model(m)[source]

Read parameters from a Pyomo model used to calculate them

segment(x)[source]

Get the spline segment containing x.

Parameters:

x – location, float or numpy array

Returns:

segment(s) containing x, if x is a numpy array a numpy array of integers is returned otherwise return an integer

write_parameters(fptr)[source]

Write parameters to a file

property n_knots

Number of knots

property n_segments

Number of segments

property valid

Ensure that the number of knots and cubic parameters is valid