This software is copyright 2022 by the University Corporation for Atmospheric Research (UCAR). It is licensed for use according to the standard BSD license:
When citing this software, here is a suggested reference:
This software is written by Gary Granger of the National Center for Atmospheric Research (NCAR), sponsored by the National Science Foundation (NSF). The algorithm is based on the cubic spline described by Katsuyuki Ooyama in Montly Weather Review, Vol 115, October 1987. This implementation has benefited from comparisons with a previous FORTRAN implementation by James L. Franklin, NOAA/Hurricane Research Division.
The source should be available for download from github here:
The generated documentation may also be online here:
For an overview of the library and its usage, see the documentation for the BSplineBase class.
There is no documentation (as yet) on any of the mathematical details of the implementation. Refer to the Ooyama article, and there may be some notes in the source.
The HTML documentation is generated from the source files by Doxygen (http://www.doxygen.org). Thanks to Dimitri for a great tool.
Restore the explicit destructor so BSplineBase.h can be used by itself when explicit instantiations will be linked from a library.
Fix missing assignment operator bug in BSplineBase. Thanks to @AlexRockliff for reporting it.
Add simple automated test which compares sample outputs against baseline.
The two obsolete version methods were merged into one, BSplineBase::Version(), and the method reports useful information even when the library is used as headers only, without compiling. There are no changes to the spline computation.
Documentation changes for migrating to github.
Change the license to BSD and update some of the documentation.
The source tree was rearranged to make it a little more comprehensible to outside users. The DLL build functionality was removed, as it just doesn't seem necessary to add this complication. The Makefile build system was replaced with Scons (http://www.scons.org).
The driver program was renamed to bspline.
This release builds against GCC 4.0. Names in the BSplineBase template base class needed to be declared in the BSpline subclass scope, now that GCC enforces the standard rule about non-template-type-dependent names being resolved when templates are declared.
The driver program now takes an optional third command-line argument for setting the boundary condition type.
There is an R script for generating plots of several combinations of the cutoff and boundary condition options to the driver program. See Samples for details.
This release updates the code to compile with GCC 3.2, which enforces more standards compliance like the use of 'typename'. Also the GNU libstdc++ no longer uses pointers as vector iterators, so occurences of vector<>::begin() have been replaced with &(vector[0])
Lastly, in this release the C++ filename extension has been changed from cxx to cpp.
The Tests/Data directory contains several sample data files for the driver program. The sample.txt file contains an example of dropsonde data. From that file, three fields have been extracted into separate files:
Each file is a simple text format with two columns. The first column is time, the second is the field measurement. This is the format which the example driver program expects. Any text file with alternating X and Y values will work in the driver program.
To run the driver program, pipe the data into the standard input, and pass the step
, cutoff
, and boundary-condition
options on the command line.
For example:
The driver produces two output files:
The R (http://www.r-project.org) script runs the driver program on the sample temperatures over a range of boundary conditions and cutoff frequencies. The results are plotted in 6 PNG images.
Cutoff | BC 0 | BC 1 | BC 2 |
---|---|---|---|
5 | plot-spline-temps-5-0.png | plot-spline-temps-5-1.png | plot-spline-temps-5-2.png |
30 | plot-spline-temps-30-0.png | plot-spline-temps-30-1.png | plot-spline-temps-30-2.png |
Note that for boundary condition 0, the endpoints are not at zero as might be expected. The spline algorithm first removes the mean from the input data to improve the matrix calculations, and the mean is added back in when evaluating the spline at any point. Thus the endpoints for boundary condition 0 will actually be the mean value of the input range. If you need to force the endpoints to be zero, remove the mean from the data before computing the spline, or else change the source code for computing the spline.
This is a C++ implementation of a cubic b-spline least squares and derivative constraint algorithm. See the documentation for the BSplineBase class (in BSpline/BSplineBase.h) for details.
This work was done for meteorological research at the University Corporation for Atmospheric Research (http://www.ucar.edu/). There is no warranty of any kind. Please see the COPYRIGHT file.
As the implementation itself is entirely template code, it is not necessary to build the library separately. The template implementation can be included directly. The templates can also be compiled for the usual float and double types into their own object modules and library (DLL on Win32). See the documentation for details.
The distribution contains two parts. The b-spline code itself is contained in the BSpline/ directory, while test data and the C++ test driver program are under the Tests directory. There are MS Studio solution and projects files which should build the library for floats and doubles. On UNIX, the software is compiled with SCons (http://www.scons.org/). Run scons -u
to build the library and also the C++ driver program.
To install the code into an include directory, all of the *.cpp and *.h files in BSpline/ must be copied into the include directory.
I'd be happy to try to answer any questions, and certainly happy to hear about any bugs or improvements.