IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 9, 2004, 1:22:58 PM (22 years ago)
Author:
Paul Price
Message:

Altered: psPolynomial?D,psPolynomial?D{Alloc,Eval},psDPolynomial?D,psDPolynomial?D{Alloc,Eval}
Added: psKernel,psKernelAlloc,psKernelGenerate,psImageConvolve,psPolynomial?DEvalVector,
psDPolynomial?DEvalVector,psSpline1D,psSpline1DAlloc,psSpline1DAllocGeneric,psSpline1DEval,
psSpline1DEvalVector,psVectorFitSpline1D,psImageTrim

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/pslib/psLibSDRS.tex

    r1415 r1437  
    1 %%% $Id: psLibSDRS.tex,v 1.63 2004-08-07 04:11:59 price Exp $
     1%%% $Id: psLibSDRS.tex,v 1.64 2004-08-09 23:22:58 price Exp $
    22\documentclass[panstarrs,spec]{panstarrs}
    33
     
    323201 & 2004 May 19 & Extensive modifications, see appendix \\ \hline
    333302 & 2004 Jun 22 & Incorporation of Bugzilla PRs (up to 69) \\ \hline
    34 03 & 2004 Aug 06 & Adding convolution, splines, chebyshevs \\
     3403 & 2004 Aug 09 & Adding convolution, splines, chebyshevs \\
    3535   &             & (modified polynomials), ImageTrim for Phase 2 \\ \hline
    3636\RevisionsEnd
     
    18951895and double-precision (for milli-arcsec precision) versions.  We must
    18961896also be able to calculate the errors in the fit coefficients, as well
    1897 as be able to turn on and off each coefficient.  This leads us to
    1898 define the following polynomial types:
     1897as be able to turn on and off each coefficient.
     1898
     1899In addition to general polynomials ($\sum_{i=0}^n a_i x^i$), we also
     1900use Chebyshev polynomials ($\sum_{i=0}^n a_i T_i(x)$), which have
     1901properties which are useful in the modeling of data over a defined
     1902domain.
     1903
     1904This leads us to define the following polynomial types:
    18991905
    19001906\begin{verbatim}
    19011907/** One-dimensional polynomial */
    19021908typedef struct {
     1909    psPolynomialType type;              ///< Polynomial type
    19031910    int n;                              ///< Number of terms
    19041911    float *restrict coeff;              ///< Coefficients
     
    19111918/** Two-dimensional polynomial */
    19121919typedef struct {
     1920    psPolynomialType type;              ///< Polynomial type
    19131921    int nX, nY;                         ///< Number of terms in x and y
    19141922    float *restrict *restrict coeff;    ///< Coefficients
     
    19181926\end{verbatim}
    19191927
    1920 etc., up to four dimensions.  We also define double-precision versions:
     1928etc., up to four dimensions.  \code{psPolynomialType} is an
     1929enumerated type specifying the type of the polynomial: ordinary
     1930or Chebyshev:
     1931
     1932\begin{verbatim}
     1933/** Type of polynomial */
     1934typedef enum {
     1935    PS_POLYNOMIAL_ORD,                  ///< Ordinary polynomial
     1936    PS_POLYNOMIAL_CHEB                  ///< Chebyshev polynomial
     1937} psPolynomialType;
     1938\end{verbatim}
     1939
     1940We also define double-precision versions of the polynomials:
    19211941
    19221942\begin{verbatim}
    19231943/** Double-precision one-dimensional polynomial */
    19241944typedef struct {
     1945    psPolynomialType type;              ///< Polynomial type
    19251946    int n;                              ///< Number of terms
    19261947    double *restrict coeff;             ///< Coefficients
     
    19331954/** Double-precision two-dimensional polynomial */
    19341955typedef struct {
     1956    psPolynomialType type;              ///< Polynomial type
    19351957    int nX, nY;                         ///< Number of terms in x and y
    19361958    double *restrict *restrict coeff;   ///< Coefficients
     
    19461968The constructor and destructor are:
    19471969\begin{verbatim}
    1948 psDPolynomial2D *psDPolynomial2DAlloc(int nX, int nY);
     1970psDPolynomial2D *psDPolynomial2DAlloc(int nX, int nY, psPolynomialType type);
    19491971void p_psDPolynomial2DFree(psDPolynomial2D *restrict myPoly);
    19501972\end{verbatim}
     
    19571979\end{verbatim}
    19581980
     1981In the event that several evaluations are required, we also define:
     1982\begin{verbatim}
     1983psVector *psDPolynomial2DEvalVector(psVector *x, psVector *y, const psDPolynomial2D *restrict myPoly);
     1984\end{verbatim}
     1985If the \code{x} and \code{y} vectors do not match the precision of the
     1986polynomial, the function shall generate a warning, and convert the
     1987vectors to the appropriate precision.  In the event that the \code{x}
     1988and \code{y} vectors are of differing sizes, the function shall
     1989generate a warning, truncate the longer vector to the size of the
     1990shorter, and continue.  The precision of the output \code{psVector}
     1991shall match that of the polynomial.
     1992
     1993\subsubsection{Splines}
     1994
     1995A spline is a popular choice for fitting 1D data, such as overscans,
     1996but we neglected to define them for PSLib.  We now define
     1997one-dimensional cubic splines, \code{psSpline1D}, which shall be
     1998incorporated into PSLib:
     1999
     2000\begin{verbatim}
     2001/** A 1D cubic-spline */
     2002typedef struct {
     2003    int n;                              ///< Number of spline pieces
     2004    psPolynomial1D *spline;             ///< Array of n splines
     2005    float *domains;                     ///< The boundaries between each spline piece.  Size is n+1.
     2006} psSpline1D;
     2007\end{verbatim}
     2008
     2009The \code{psSpline1D} structure consists of an array of \code{n}
     2010polynomials, which are the spline pieces.  Note that this means that
     2011the spline pieces may, in general, be of any order.  \textbf{For the
     2012present, we shall restrict the order of the polynomials to either 1
     2013(linear) or 3 (cubic).}  All the spline pieces shall have the same
     2014order polynomial (the type of polynomial is left to the
     2015implementation).  The \code{domains} member specifies the boundaries
     2016between each spline piece (including the two ends).
     2017
     2018Of course, we require the appropriate constructors and destructor:
     2019\begin{verbatim}
     2020psSpline1D *psSpline1DAlloc(int n, int order, float min, float max);
     2021psSpline1D *psSpline1DAllocGeneric(const psVector *bounds, int order);
     2022\end{verbatim}
     2023
     2024\code{psSpline1DAlloc} shall allocate and return a \code{psSpline1D},
     2025setting the \code{domains} on the basis of the input number of spline
     2026pieces, \code{n}, and the minimum (\code{min}) and maximum
     2027(\code{max}) data values.  The spline pieces shall be of the specified
     2028\code{order}.
     2029
     2030\code{psSpline1DAllocGeneric} shall allocate and return a
     2031\code{psSpline1D}, using the \code{bounds} to define the number of
     2032spline pieces and the \code{domains}.  The spline pieces shall be of
     2033the specified \code{order}.
     2034
     2035Also, as for the polynomials, we require evaluators.  Given a
     2036\code{spline} and ordinate at which to evaluate, \code{x},
     2037\code{psSpline1DEval} shall evaluate and return the value of the
     2038spline at the ordinate.  If the ordinate is outside the bounds, then
     2039the function shall generate a warning, and extrapolate the spline to
     2040the ordinate and return the value.  Similarly,
     2041\code{psSpline1DEvalVector} shall return a vector of evaluated values
     2042for an input vector of ordinates.
     2043
     2044\begin{verbatim}
     2045float psSpline1DEval(const psSpline1D *spline, float x);
     2046psVector *psSpline1DEvalVector(psVector *x, const psSpline1D *spline);
     2047\end{verbatim}
     2048
     2049
    19592050\subsubsection{Gaussians}
    19602051
    19612052Gaussians are used extensively in any data-analysis system, in
    1962 particular to represent a real population distribution.  We require
    1963 a function to evaluate a Gaussian for a given coordinate and one which
     2053particular to represent a real population distribution.  We require a
     2054function to evaluate a Gaussian for a given coordinate and one which
    19642055generates a Gaussian deviate; a collection of data points whose
    1965 distribution obeys a specified Gaussian. 
     2056distribution obeys a specified Gaussian.
    19662057
    19672058The Gaussian evaluation is provide by:
     
    20442135
    20452136\begin{verbatim}
    2046 psPolynomial1D *psVectorFitPolynomial1D(psPolynomial1D myPoly,
    2047                                      const psVector *restrict x,
    2048                                      const psVector *restrict y,
    2049                                      const psVector *restrict yErr);
     2137psPolynomial1D *psVectorFitPolynomial1D(psPolynomial1D *myPoly,
     2138                                        const psVector *restrict x,
     2139                                        const psVector *restrict y,
     2140                                        const psVector *restrict yErr);
    20502141\end{verbatim}
    20512142\code{psVectorFitPolynomial1d} returns the polynomial that best fits the
     
    20582149determined in the assumption that all data errors are equal.  This
    20592150function must be valid only for types \code{psF32}, \code{psF64}.
     2151
     2152\begin{verbatim}
     2153psSpline1D *psVectorFitSpline1D(psSpline1D *mySpline,
     2154                                const psVector *x,
     2155                                const psVector *y,
     2156                                const psVector *yErr);
     2157\end{verbatim}
     2158\code{psVectorFitSpline} shall return the spline that best fits the
     2159given combination of ordinates (\code{x}) and coordinates (\code{y}).
     2160As for \code{psVectorFitPolynomial1D}, if \code{x} is \code{NULL},
     2161then the vector index shall be used as the ordinate; and if
     2162\code{yErr} is \code{NULL}, then all the data errors shall be assumed
     2163to be equal.  This function must be valid only for types \code{psF32},
     2164\code{psF64}.
    20602165
    20612166%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    20962201\code{psS8}, \code{psS16}, \code{psF32}, \code{psF64}, \code{psC32},
    20972202\code{psC64}.
     2203
     2204\begin{verbatim}
     2205psImage *psImageTrim(psImage *image, int x0, int x1, int y0, int y1);
     2206\end{verbatim}
     2207Trim the specified \code{image} in-place, which involves shuffling the
     2208pixels around in memory.  The pixels in the region
     2209\code{[x0:x1,y0:y1]} (inclusive) shall consist the output image.
     2210
     2211The function shall generate an error if the specified region is
     2212outside the bounds of the input image.
    20982213
    20992214\subsubsection{Image Pixel Extractions}
     
    26632778    int xMax, yMax;                     ///< Most positive indices
    26642779    float **kernelRows;                 ///< Pointer to the rows of the kernel data
    2665     float **kernel;                     ///< Pointer to  in the kernel data
     2780    float **kernel;                     ///< Pointer to the kernel data
    26662781} psKernel;
    26672782\end{verbatim}
Note: See TracChangeset for help on using the changeset viewer.