Utilities for performing smooth least-squares fits in Python
These scripts include utilities for fitting smooth surfaces to data in a least-squares sense. They operate on the principle of building a design matrix while keeping track of the relationship between degrees of freedom and columns and between data, constraint parameters, and rows. The functionality is built around my pointCollection library (https://www.github.com/smithb/pointCollection.git) which provides data structures for manipulating point data.
The LSsurf module provides two main classes:
-
fd_grid : A class that defines a finite-difference grid, up to an arbitrary number of dimensions. Includes relationships between node indices and a global index that spans multiple grids for a multi-resolution least-squares problem
-
lin_op : A class that defines operators that multiply the values in a fd_grid. Examples include linear interpolations into the grid (2-D and 3-D), averages of grid points, and finite-difference derivatives of grid fields.
** _fd_op : A subclass of lin_op that constructs lin_op objects that perform template operations on a neighborhood of points. Pre-defined subclasses perform derivatives of grid fields.
The main functions of the repository are used in LSsurf/smooth_fit.py, which fits smooth gridded surfaces to pointwise input data. See the smooth_fit_demo.ipynb notebook in the notebooks directory for a demonstration.
To use the functions in this repo, or to run the demo notebook, you'll need (do these in order):
The suitesparse library:
From conda:
conda install suitesparse
On ubuntu/similar linux
apt-get install suitesparse
@Yig's PySPQR repository (This is where you need suitesparse)
https://github.com/yig/PySPQR.git
My pointCollection repository:
https://www.github.com/smithb/pointCollection.git
The LSsurf repositury:
https://www.github.com/smithb/LSsurf.git
For each repository, you'll need to clone the repo (git clone [url to .git file]), then cd to the directory that git makes, and type:
pip install -e .
Good luck!