Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoStrouwen committed Sep 23, 2023
1 parent 95cf997 commit e555198
Show file tree
Hide file tree
Showing 26 changed files with 1,692 additions and 1,506 deletions.
2 changes: 2 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
style = "sciml"
format_markdown = true
37 changes: 15 additions & 22 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
The DataInterpolations.jl package is licensed under the MIT "Expat" License:

> Copyright (c) 2018: University of Maryland, Center for Translational Medicine.
>
>
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
>
>
> of this software and associated documentation files (the "Software"), to deal
>
>
> in the Software without restriction, including without limitation the rights
>
>
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
>
>
> copies of the Software, and to permit persons to whom the Software is
>
>
> furnished to do so, subject to the following conditions:
>
>
>
>
> The above copyright notice and this permission notice shall be included in all
>
>
> copies or substantial portions of the Software.
>
>
>
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
>
>
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>
>
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
>
>
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
>
>
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
>
>
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
>
>
> SOFTWARE.
>
>
54 changes: 24 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
[![codecov](https://codecov.io/gh/SciML/DataInterpolations.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/SciML/DataInterpolations.jl)
[![CI](https://github.com/SciML/DataInterpolations.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/SciML/DataInterpolations.jl/actions/workflows/CI.yml)

[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)


DataInterpolations.jl is a library for performing interpolations of one-dimensional data. By
"data interpolations" we mean techniques for interpolating possibly noisy data, and thus
some methods are mixtures of regressions with interpolations (i.e. do not hit the data
Expand All @@ -23,7 +22,7 @@ All interpolation objects act as functions. Thus for example, using an interpola
```julia
u = rand(5)
t = 0:4
interp = LinearInterpolation(u,t)
interp = LinearInterpolation(u, t)
interp(3.5) # Gives the linear interpolation value at t=3.5
```

Expand Down Expand Up @@ -52,45 +51,40 @@ interp[4] # Gives the 4th value of u
In all cases, `u` an `AbstractVector` of values and `t` is an `AbstractVector` of timepoints
corresponding to `(u,t)` pairs.

- `ConstantInterpolation(u,t)` - A piecewise constant interpolation.

- `LinearInterpolation(u,t)` - A linear interpolation.

- `QuadraticInterpolation(u,t)` - A quadratic interpolation.

- `LagrangeInterpolation(u,t,n)` - A Lagrange interpolation of order `n`.

- `QuadraticSpline(u,t)` - A quadratic spline interpolation.

- `CubicSpline(u,t)` - A cubic spline interpolation.

- `AkimaInterpolation(u, t)` - Akima spline interpolation provides a smoothing effect and is computationally efficient.

- `BSplineInterpolation(u,t,d,pVec,knotVec)` - An interpolation B-spline. This is a B-spline which hits each of the data points. The argument choices are:
- `d` - degree of B-spline
- `pVec` - Symbol to Parameters Vector, `pVec = :Uniform` for uniform spaced parameters and `pVec = :ArcLen` for parameters generated by chord length method.
- `knotVec` - Symbol to Knot Vector, `knotVec = :Uniform` for uniform knot vector, `knotVec = :Average` for average spaced knot vector.

- `BSplineApprox(u,t,d,h,pVec,knotVec)` - A regression B-spline which smooths the fitting curve. The argument choices are the same as the `BSplineInterpolation`, with the additional parameter `h<length(t)` which is the number of control points to use, with smaller `h` indicating more smoothing.
- `ConstantInterpolation(u,t)` - A piecewise constant interpolation.

- `LinearInterpolation(u,t)` - A linear interpolation.
- `QuadraticInterpolation(u,t)` - A quadratic interpolation.
- `LagrangeInterpolation(u,t,n)` - A Lagrange interpolation of order `n`.
- `QuadraticSpline(u,t)` - A quadratic spline interpolation.
- `CubicSpline(u,t)` - A cubic spline interpolation.
- `AkimaInterpolation(u, t)` - Akima spline interpolation provides a smoothing effect and is computationally efficient.
- `BSplineInterpolation(u,t,d,pVec,knotVec)` - An interpolation B-spline. This is a B-spline which hits each of the data points. The argument choices are:

+ `d` - degree of B-spline
+ `pVec` - Symbol to Parameters Vector, `pVec = :Uniform` for uniform spaced parameters and `pVec = :ArcLen` for parameters generated by chord length method.
+ `knotVec` - Symbol to Knot Vector, `knotVec = :Uniform` for uniform knot vector, `knotVec = :Average` for average spaced knot vector.
- `BSplineApprox(u,t,d,h,pVec,knotVec)` - A regression B-spline which smooths the fitting curve. The argument choices are the same as the `BSplineInterpolation`, with the additional parameter `h<length(t)` which is the number of control points to use, with smaller `h` indicating more smoothing.

## Extension Methods

The follow methods require extra dependencies and will be loaded as package extensions.

- `Curvefit(u,t,m,p,alg)` - An interpolation which is done by fitting a user-given functional form `m(t,p)` where `p` is the vector of parameters. The user's input `p` is a an initial value for a least-square fitting, `alg` is the algorithm choice to use for optimize the cost function (sum of squared deviations) via `Optim.jl` and optimal `p`s are used in the interpolation. Requires `using RegularizationTools`
- `Curvefit(u,t,m,p,alg)` - An interpolation which is done by fitting a user-given functional form `m(t,p)` where `p` is the vector of parameters. The user's input `p` is a an initial value for a least-square fitting, `alg` is the algorithm choice to use for optimize the cost function (sum of squared deviations) via `Optim.jl` and optimal `p`s are used in the interpolation. Requires `using RegularizationTools`

## Plotting

DataInterpolations.jl is tied into the Plots.jl ecosystem, by way of RecipesBase.
DataInterpolations.jl is tied into the Plots.jl ecosystem, by way of RecipesBase.
Any interpolation can be plotted using the `plot` command (or any other), since they have type recipes associated with them.

For convenience, and to allow keyword arguments to propagate properly, DataInterpolations.jl also defines several series types, corresponding to different interpolations.

The series types defined are:
- `:linear_interp`
- `:quadratic_interp`
- `:lagrange_interp`
- `:quadratic_spline`
- `:cubic_spline`

- `:linear_interp`
- `:quadratic_interp`
- `:lagrange_interp`
- `:quadratic_spline`
- `:cubic_spline`

By and large, these accept the same keywords as their function counterparts.
12 changes: 4 additions & 8 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ using Documenter, DataInterpolations

ENV["GKSwstype"] = "100"

makedocs(
modules = [DataInterpolations],
makedocs(modules = [DataInterpolations],
sitename = "DataInterpolations.jl",
clean = true,
doctest = false,
linkcheck = true,
warnonly = [:missing_docs],
format = Documenter.HTML(
assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/DataInterpolations/stable/",
),
pages = ["index.md", "Methods" => "methods.md", "Interface" => "interface.md"],
)
format = Documenter.HTML(assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/DataInterpolations/stable/"),
pages = ["index.md", "Methods" => "methods.md", "Interface" => "interface.md"])

deploydocs(repo = "github.com/SciML/DataInterpolations.jl"; push_preview = true)
52 changes: 23 additions & 29 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ some methods are mixtures of regressions with interpolations (i.e. do not hit th
points exactly, smoothing out the lines). This library can be used to fill in intermediate
data points in applications like timeseries data.


## Installation

To install LinearSolve.jl, use the Julia package manager:
To install DataInterpolations.jl, use the Julia package manager:

```julia
using Pkg
Expand All @@ -21,46 +20,41 @@ Pkg.add("DataInterpolations")
In all cases, `u` an `AbstractVector` of values and `t` is an `AbstractVector` of timepoints
corresponding to `(u,t)` pairs.

- `ConstantInterpolation(u,t)` - A piecewise constant interpolation.

- `LinearInterpolation(u,t)` - A linear interpolation.

- `QuadraticInterpolation(u,t)` - A quadratic interpolation.

- `LagrangeInterpolation(u,t,n)` - A Lagrange interpolation of order `n`.

- `QuadraticSpline(u,t)` - A quadratic spline interpolation.

- `CubicSpline(u,t)` - A cubic spline interpolation.
- `ConstantInterpolation(u,t)` - A piecewise constant interpolation.

- `AkimaInterpolation(u, t)` - Akima spline interpolation provides a smoothing effect and is computationally efficient.

- `BSplineInterpolation(u,t,d,pVec,knotVec)` - An interpolation B-spline. This is a B-spline which hits each of the data points. The argument choices are:
- `d` - degree of B-spline
- `pVec` - Symbol to Parameters Vector, `pVec = :Uniform` for uniform spaced parameters and `pVec = :ArcLen` for parameters generated by chord length method.
- `knotVec` - Symbol to Knot Vector, `knotVec = :Uniform` for uniform knot vector, `knotVec = :Average` for average spaced knot vector.

- `BSplineApprox(u,t,d,h,pVec,knotVec)` - A regression B-spline which smooths the fitting curve. The argument choices are the same as the `BSplineInterpolation`, with the additional parameter `h<length(t)` which is the number of control points to use, with smaller `h` indicating more smoothing.
- `LinearInterpolation(u,t)` - A linear interpolation.
- `QuadraticInterpolation(u,t)` - A quadratic interpolation.
- `LagrangeInterpolation(u,t,n)` - A Lagrange interpolation of order `n`.
- `QuadraticSpline(u,t)` - A quadratic spline interpolation.
- `CubicSpline(u,t)` - A cubic spline interpolation.
- `AkimaInterpolation(u, t)` - Akima spline interpolation provides a smoothing effect and is computationally efficient.
- `BSplineInterpolation(u,t,d,pVec,knotVec)` - An interpolation B-spline. This is a B-spline which hits each of the data points. The argument choices are:

+ `d` - degree of B-spline
+ `pVec` - Symbol to Parameters Vector, `pVec = :Uniform` for uniform spaced parameters and `pVec = :ArcLen` for parameters generated by chord length method.
+ `knotVec` - Symbol to Knot Vector, `knotVec = :Uniform` for uniform knot vector, `knotVec = :Average` for average spaced knot vector.
- `BSplineApprox(u,t,d,h,pVec,knotVec)` - A regression B-spline which smooths the fitting curve. The argument choices are the same as the `BSplineInterpolation`, with the additional parameter `h<length(t)` which is the number of control points to use, with smaller `h` indicating more smoothing.

## Extension Methods

The follow methods require extra dependencies and will be loaded as package extensions.

- `Curvefit(u,t,m,p,alg)` - An interpolation which is done by fitting a user-given functional form `m(t,p)` where `p` is the vector of parameters. The user's input `p` is a an initial value for a least-square fitting, `alg` is the algorithm choice to use for optimize the cost function (sum of squared deviations) via `Optim.jl` and optimal `p`s are used in the interpolation. Requires `using RegularizationTools`
- `Curvefit(u,t,m,p,alg)` - An interpolation which is done by fitting a user-given functional form `m(t,p)` where `p` is the vector of parameters. The user's input `p` is a an initial value for a least-square fitting, `alg` is the algorithm choice to use for optimize the cost function (sum of squared deviations) via `Optim.jl` and optimal `p`s are used in the interpolation. Requires `using RegularizationTools`

## Plotting

DataInterpolations.jl is tied into the Plots.jl ecosystem, by way of RecipesBase.
DataInterpolations.jl is tied into the Plots.jl ecosystem, by way of RecipesBase.
Any interpolation can be plotted using the `plot` command (or any other), since they have type recipes associated with them.

For convenience, and to allow keyword arguments to propagate properly, DataInterpolations.jl also defines several series types, corresponding to different interpolations.

The series types defined are:
- `:linear_interp`
- `:quadratic_interp`
- `:lagrange_interp`
- `:quadratic_spline`
- `:cubic_spline`

- `:linear_interp`
- `:quadratic_interp`
- `:lagrange_interp`
- `:quadratic_spline`
- `:cubic_spline`

By and large, these accept the same keywords as their function counterparts.

Expand Down Expand Up @@ -136,4 +130,4 @@ file and the
[project]($link_project)
file.
""")
```
```
8 changes: 5 additions & 3 deletions docs/src/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ We will use `CubicSpline` method for demonstration but the API is same for all t
A = CubicSpline(u, t)
# For interpolation do, A(t)
A(100.0)
A(100.0)
```

!!! note

The values computed beyond the range of the time points provided during interpolation will not be reliable as these methods only perform well within the range and the first/last piece polynomial fit is extrapolated on either sides which might not reflect the true nature of the data.

## Derivatives

Derivatives of the interpolated curves can also be computed at any point for all the methods.
Derivatives of the interpolated curves can also be computed at any point for all the methods.

We will continue with the above example, but the API is same for all the methods.

Expand Down Expand Up @@ -60,4 +61,5 @@ DataInterpolations.integral(A, 1.0, 5.0)
```

!!! note
If the times provided in the integral goes beyond the range of the time points provided during interpolation, it uses extrapolation methods to compute the values and hence the integral can be misrepsentative and might not reflect the true nature of the data.

If the times provided in the integral goes beyond the range of the time points provided during interpolation, it uses extrapolation methods to compute the values and hence the integral can be misrepsentative and might not reflect the true nature of the data.
Loading

0 comments on commit e555198

Please sign in to comment.