IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 284


Ignore:
Timestamp:
Mar 22, 2004, 7:21:01 PM (22 years ago)
Author:
Paul Price
Message:

First-pass hack for grammar and style. Still need to deal with the
issues of tabs, and standardise the sections in this document with the
.h files.

File:
1 edited

Legend:

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

    r276 r284  
    1010\organization{Institute for Astronomy}
    1111\version{DR}
    12 \docnumber{PSDC-xxx-xxx}
     12\docnumber{PSDC-430-007}
    1313% note the use of the docnumber & version number:
    1414% the complete PSDC document number is given by
     
    2424\RevisionsStart
    2525% version     Date         Description
    26 \theversion & 2003 Mar 11 & Hacking \\
     26\theversion & 2003 Mar 11-- & Draft \\
    2727\RevisionsEnd
    2828
     
    3838%a regular \code{\label}, but defines the hyperlink too).
    3939
    40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     40%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     41%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     42%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4343
    4444\section{\PS{} Library (PSLib)}
     
    5858\end{itemize}
    5959
    60 Below we sketch out approximately 120 APIs which specify the required
     60Below we sketch out approximately 200~APIs which specify the required
    6161capabilities.
    6262
    63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     63%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     64%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     65%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    6666
    6767\section{System Utilities}
     
    7373
    7474The \PS{} software system will need a level of memory management
    75 placed between the operating system (malloc/free) and the high level
    76 routines (e.g. \code{psMetaDataAlloc}).
     75placed between the operating system (\code{malloc}/\code{free}) and
     76the high level routines (e.g.\ \code{psMetaDataAlloc}).
    7777
    7878This layer is in addition to the possibility that specific heavily
     
    8080but as we have specified that all user-level objects be allocated via
    8181\code{typeAlloc/typeFree} functions, we will easily be able to
    82 implement such functionality without impacting on the facilities
     82implement such functionality without impacting the facilities
    8383described here.
    8484
     
    103103
    104104\item
    105   We need to provide a mechanism for tracking and fixing memory
    106   leaks.  While it is possible to do this by linking with external
    107   libraries (\tbd{reference}), it is convenient to do so within the
    108   \PS{} framework.
     105  We need to provide a mechanism for tracking and fixing memory leaks.
     106  While it is possible to do this by linking with external libraries
     107  (e.g.\ Electric Fence, \href{gnu.org}), it is convenient to do so
     108  within the \PS{} framework.
    109109
    110110\item
     
    126126The previous section laid out a number of desiderata for a memory
    127127management system.  Rather than implement our own heap-manager at this
    128 stage of the project, I propose that we put in place a sufficient
    129 set of data structures and APIs, but initially implement only
    130 a simple subset (e.g. that we not implement a multi-bucket memory
    131 manager that takes in 100Mb chunks from the system and performs
    132 sophisticated defragmentation and garbage collection).
     128stage of the project, we propose to put in place a sufficient set of
     129data structures and APIs, but initially implement only a simple subset
     130(e.g.\ that we not implement a multi-bucket memory manager that takes
     131in 100Mb chunks from the system and performs sophisticated
     132defragmentation and garbage collection).
    133133
    134134Subject to agreement with the IfA, some of the functions proposed
     
    184184The types and function prototypes for the part of the memory API
    185185concerned with allocating and freeing memory are given in table
    186 \ref{tabUsageAPI}).
     186\ref{tabUsageAPI}.
    187187
    188188N.b.
    189189\begin{itemize}
    190190\item
    191   The functions \code{psAlloc}, \code{psRealloc}, and
    192   \code{psFree} are defined, and are required to be equivalent to
    193   \code{p_psAlloc}, \code{p_psRealloc}, and \code{p_psFree}
    194   with the final two arguments \code{"(unknown)"} and \code{0}.
     191  The functions \code{psAlloc}, \code{psRealloc}, and \code{psFree}
     192  are defined, and are required to be equivalent to \code{p_psAlloc},
     193  \code{p_psRealloc}, and \code{p_psFree} with the final two arguments
     194  \code{__FILE__} and \code{__LINE__}.
    195195
    196196  In the descriptions that follow, I shall not distinguish between the
     
    211211\item
    212212  In all cases, application code will call
    213   \code{p_\{psAlloc,psRealloc,psFree\}} via the macros defined above.
     213  \CODE|p_{psAlloc,psRealloc,psFree}| via the macros defined above.
    214214 
    215215\item
     
    229229 
    230230\item
    231   Where practical and efficient, the memory manager shall call
    232   the routine registered using the \code{psMemProblemSetCB}
    233   (see section \ref{secMemAdvanced})
    234   whenever a corrupted block of memory is discovered. For example,
    235   doubly-freed blocks can be detected by checking \code{psMemBlock.refcntr}.
     231  Where practical and efficient, the memory manager shall call the
     232  routine registered using the \code{psMemProblemSetCB} (see section
     233  \ref{secMemAdvanced}) whenever a corrupted block of memory is
     234  discovered. For example, doubly-freed blocks can be detected by
     235  checking \code{psMemBlock.refcntr}.
    236236
    237237\item
    238238  There is no \code{psCalloc} function. Initialisation of data is
    239239  almost always more complex than setting all bytes to 0.
     240  Correspondingly, the system call \code{calloc} should be disabled
     241  using the pre-processor.
    240242\end{itemize}
    241243
     
    284286\begin{tabular}{ll|l}
    285287\textbf{type} &  \textbf{Name} & \textbf{Function of callback} \\
    286 psMemProblemCallback & psMemProblemSetCB &
     288\code{psMemProblemCallback} & \code{psMemProblemSetCB} &
    287289Called when a problem is detected with data being managed on the heap \\
    288 psMemExhaustedCallback & psMemExhaustedSetCB &
     290\code{psMemExhaustedCallback} & \code{psMemExhaustedSetCB} &
    289291Called when \code{psAlloc} is unable to satisfy a memory request. \\
    290 psMemCallback & psMemAllocateSetCB &
     292\code{psMemCallback} & \code{psMemAllocateSetCB} &
    291293Callback is called when the \code{psMemBlock} with a specified ID is
    292294allocated. \\
    293 psMemCallback & psMemFreeSetCB &
     295\code{psMemCallback} & \code{psMemFreeSetCB} &
    294296Callback is called when the \code{psMemBlock} with a specified ID is
    295297freed. \\
     
    310312
    311313\item
    312   \code{psMemGetId} returns the current value of \code{psMemBlock.id}.
     314  \code{psMemGetId} returns the next identification number to be
     315  assigned to a \code{psMemBlock.id}.
    313316
    314317\item
     
    414417}
    415418\end{verbatim}
    416 \begin{caption}{An example of reference counting}
    417   \hlabel{tabReferenceCounting}
    418   An example of using reference counting
    419 \end{caption}
     419\caption{An example of reference counting}
    420420\end{table}
    421421
     
    443443\subsection{Tracing and Logging}
    444444
    445 This document defines the \PS{} Tracing and Logging APIs; the former
     445This section defines the \PS{} Tracing and Logging APIs; the former
    446446refers to debug information that we wish to be able to turn on and off
    447447without recompiling (although it will \emph{not} be available in
     
    683683The fields included in the log message may be controlled using \code{psSetLogFormat} which
    684684expects a string consisting of the letters \code{H} (host), \code{L} (level), \code{M} (message),
    685 \code{N} (name), and \code{T} (time).  The default is \code{HLMNT}.
    686 
    687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     685\code{N} (name), and \code{T} (time).  The default is \code{THLNM}, as shown above.
     686
     687%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    688688
    689689\section{Data Containers}
     
    768768If \code{psDlistFree}'s argument \code{elemFree} is NULL, the
    769769list should be deleted, but not the elements on it (although their
    770 \code{refcounter}'s should be decremented).
     770\code{refcounter}s should be decremented).
    771771
    772772Iteration over all elements of the list is provided by the functions:
     
    781781many iteration cursors should be used; it must currently always be \code{0}.
    782782
    783 Explicit traversal of the list using the \code{psDlistElem}'s
     783Explicit traversal of the list using the \code{psDlistElem}s
    784784\code{prev} and \code{next} pointers is also supported.
    785785
     
    793793\subsection{The \PS{} Array types}
    794794
    795 \begin{table}
    796   \begin{verbatim}
    797   \end{verbatim}
    798   \begin{caption}{The array creation macros defined in \file{psArray.h}}
    799     \hlabel{tabPsArray}
    800   \end{caption}
    801 \end{table}
    802 
    803795\subsubsection{Arrays of Simple Types}
    804796
    805 Any \PS/ datatype \code{psType} may be associated with an array type
     797Any \PS{} datatype \code{psType} may be associated with an array type
    806798\code{psTypeArray}:
    807799\begin{verbatim}
     
    825817from \file{psArray.h} (table \ref{tabPsArray}),
    826818\code{PS_DECLARE_ARRAY_TYPE(psType)} and
    827 \code{PS_CREATE_ARRAY_TYPE(psType)}.  The former defines the typedef
     819\code{PS_CREATE_ARRAY_TYPE(psType)}.  The former defines the \code{typedef}
    828820and declares the prototypes (and is thus suitable for use in a
    829821header file); the latter generates the code for the three functions
    830 \code{psType(Alloc|Realloc|Free} (and should thus appear in exactly one
     822\code{psType(Alloc|Realloc|Free)} (and should thus appear in exactly one
    831823source file for a given type).
    832824
     
    866858declares the prototypes (and is thus suitable for use in a header
    867859file) and the latter generates the code for the three functions
    868 \code{psType(Alloc|Realloc|Free} (and should thus appear in exactly one
     860\code{psType(Alloc|Realloc|Free)} (and should thus appear in exactly one
    869861source file for a given type).
    870862
     
    881873\hlabel{secArrayVoidPtr}
    882874
    883 Arrays of \code{void *} are different, as the need an explicitly-specified
     875Arrays of \code{void *} are different, as they need an explicitly-specified
    884876destructor.
    885877
    886 \file{psArray.h} shall specify a type \code{psVoidPtrArray} that
    887 behaves in all respects as if it had been created with:
     878We require a type \code{psVoidPtrArray} that behaves in all respects
     879as if it had been created with:
    888880\begin{verbatim}
    889881typedef void *psVoidPtr;
     
    10111003
    10121004The routine \code{psHashInsert} must provide a non-NULL \code{itemFree}
    1013 argument if it wishes to change the value previously inserted keys;
     1005argument if it wishes to change the value for previously inserted keys;
    10141006if \code{itemFree} is NULL attempting to insert a pre-existing key
    10151007is an error, and the routine will return NULL.  If  \code{psHashInsert}
     
    10231015
    10241016\subsection{Miscellaneous Utilities}
    1025 
    1026 The API for miscellaneous \PS{} utilities is provided by \file{psMisc.h}
    1027 which shall be included by \file{psUtils.h}.
    10281017
    10291018\begin{table}
     
    10531042\code{psStringCopy} shall allocate and return a copy of the input string.
    10541043
    1055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1044%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1045%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1046%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    10581047
    10591048\section{Data manipulation}
     
    10721061\end{itemize}
    10731062
    1074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1063%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    10751064
    10761065\subsection{Bit masks}
     
    11031092\begin{itemize}
    11041093\item Set a bit;
    1105 \item Check if a bit is set;
    1106 \item \code{OR} two bit masks; and
    1107 \item \code{AND} two bit masks.
     1094\item Check if a bit is set; and
     1095\item \code{OR}, \code{AND} and \code{XOR} two bit masks.
    11081096\end{itemize}
    11091097The corresponding APIs are defined below.
     
    11361124\end{verbatim}
    11371125
    1138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1126%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    11391127
    11401128\subsection{Vector and Image Arithmetic}
    11411129
    11421130We will need to be able to perform various operations on vectors and
    1143 matrices, e.g.\ dividing one image by another, subtracting a vector
     1131images, e.g.\ dividing one image by another, subtracting a vector
    11441132from an image, etc.  Both binary operations and unary operations are
    11451133required.
     
    11731161
    11741162It is desirable to use the same functions for both vectors and
    1175 matrices, so inputs are \code{void*}; this necessitates that vectors
    1176 and matrices each have a type element at a pre-determined and constant
     1163images, so inputs are \code{void*}; this necessitates that vectors
     1164and images each have a type element at a pre-determined and constant
    11771165location in the \code{struct}.  It is further desirable to allow
    11781166scalar values to be used within these functions, which requires the
     
    12161204Note that the \code{psUnaryOp} is performed on \code{B} in-place.
    12171205
    1218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1206%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    12191207
    12201208\subsection{Sorting}
     
    12431231\end{verbatim}
    12441232
    1245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1246 
    1247 \subsection{Statistics}
     1233%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1234
     1235\subsection{Statistics Functions}
     1236
     1237\subsubsection{Array Statistics}
    12481238
    12491239We require a very general statistics function, which, given an array
     
    12841274\end{verbatim}
    12851275
     1276The \code{psStats} structure is defined with entries for each of the
     1277desired statistical quantities:
     1278
     1279\begin{verbatim}
     1280/** generic statistics structure */
     1281typedef struct {
     1282    double sampleMean;                  //<! formal mean of sample
     1283    double sampleMedian;                //<! formal median of sample
     1284    double sampleMode;                  //!< Formal mode of sample
     1285    double sampleStdev;                 //<! standard deviation of sample
     1286    double sampleUQ;                    //<! upper quartile of sample
     1287    double sampleLQ;                    //<! lower quartile of sample
     1288    double robustMean;                  //<! robust mean of array
     1289    double robustMeanError;             //<! error on robust mean
     1290    int    robustMeanNvalues;           //<! number of measurements used for robust mean
     1291    double robustMedian;                //<! robust median of array
     1292    double robustMedianError;           //<! error on robust median
     1293    int    robustMedianNvalues;         //<! number of measurements used for robust median
     1294    double robustMode;                  //!< Robust mode of array
     1295    double robustModeErr;               //!< Error in robust mode
     1296    int    robustModeNvalues;           //!< Number of measurements used for robust mode
     1297    double robustStdev;                 //<! robust standard deviation of array
     1298    double robustUQ;                    //<! robust upper quartile
     1299    double robustLQ;                    //<! robust lower quartile
     1300    double clippedMean;                 //<! Nsigma clipped mean
     1301    double clippedMeanError;            //<! error on clipped mean
     1302    int    clippedMeanNvalues;          //<! number of data points used for clipped mean
     1303    double clippedStdev;                //!< standard deviation after clipping
     1304    double clipSigma;                   //<! Nsigma used for clipping; user input
     1305    int    clipIter;                    //!< Number of clipping iterations; user input
     1306    double min;                         //<! minimum data value in array
     1307    double max;                         //<! maximum data value in array
     1308    int    nValues;                     //<! number of data values in array
     1309    psStatsOptions options;             //<! bitmask of calculated values
     1310} psStats;
     1311\end{verbatim}
     1312
     1313\subsubsection{Histograms}
    12861314
    12871315We also require to be able to generate histograms, given a list of
     
    13311359\end{verbatim}
    13321360
    1333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1361%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    13341362
    13351363\subsection{Matrix operations and linear algebra}
     
    14191447and column operations.
    14201448
    1421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1449%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    14221450
    14231451\subsection{(Fast) Fourier Transforms}
     
    14521480\end{verbatim}
    14531481
    1454 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1482%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    14551483
    14561484\subsection{General functions}
     
    15351563
    15361564\begin{verbatim}
    1537 /** Evaluate 3D polynomial (double precision) */
     1565/** Evaluate 2D polynomial (double precision) */
    15381566double
    1539 psEvalDPolynomial3D(double x,           //!< Value x at which to evaluate
     1567psEvalDPolynomial2D(double x,           //!< Value x at which to evaluate
    15401568                    double y,           //!< Value y at which to evaluate
    1541                     double z,           //!< Value z at which to evaluate
    1542                     const psDPolynomial3D *restrict myPoly //!< Coefficients for the polynomial
     1569                    const psDPolynomial2D *restrict myPoly //!< Coefficients for the polynomial
    15431570                    );
    15441571\end{verbatim}
    15451572
    1546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1573%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    15471574
    15481575\subsection{Minimisation and fitting routines}
     
    15511578specifically minimise $\chi^2$ given a list of data with associated
    15521579errors, and a function that will analytically determine the polynomial
    1553 that goes through all the specified points.  The APIs are:
     1580fit by least-squares.  The APIs are:
    15541581
    15551582\begin{verbatim}
     
    15831610\end{verbatim}
    15841611
    1585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1587 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1612%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1613%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1614%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    15881615
    15891616\section{Astronomy-Specific Functions}
     
    16071634These are each dealt with below.
    16081635
    1609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1610 
     1636%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    16111637\subsection{Image handling}
    1612 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1613 
    1614 \subsection{Basic Images}
    16151638
    16161639The most important data product produced by the telescope is an image.
     
    16801703\end{verbatim}
    16811704
    1682 Free the memory associated with a specific image.  \note{does this
    1683   free the input structure or just the allocated elements?}  Free the
    1684   children of the image if they exist.
     1705Free the memory associated with a specific image, including the pixel
     1706data. Free the children of the image if they exist.
    16851707\begin{verbatim}
    16861708void
    1687 psImageFree (psImage *image)            ///< free this image
    1688 \end{verbatim}
    1689 
    1690 Free the memory associated with the children of a specific image. 
     1709psImageFree(psImage *restrict image     ///< free this image
     1710    );
     1711\end{verbatim}
     1712
     1713Free only the pixels for a specified image.
     1714\begin{verbatim}
     1715psImage *
     1716psImageFreePixels(psImage *restrict image //!< Image whose pixels are to be freed
     1717    );
     1718\end{verbatim}
     1719
     1720Free the memory associated with the children of a specific image,
     1721returning the number of children freed.
    16911722\begin{verbatim}
    16921723int
    1693 psImageFreeChildren (psImage *image)    ///< free children of this image
     1724psImageFreeChildren(const psImage *image ///< free children of this image
     1725    );
    16941726\end{verbatim}
    16951727
     
    17261758width \code{dw} about this vector.  The input region is collapsed in
    17271759the perpendicular direction, and each element of the output vector
    1728 represents a pixel-sized boxes, where the value is derived from the
     1760represents pixel-sized boxes, where the value is derived from the
    17291761statistics of the pixels interpolated along the perpendicular
    17301762direction.  The statistic used to derive the output vector value is
     
    17681800
    17691801Rebin image to new scale.  A new image is constructed in which the
    1770 dimensions are reduced by a factor of \code{scale}.  The output image
    1771 represents a one-to-one mapping of the pixels in the input image,
    1772 except for edge effects.  Each pixel in the output image is derived
    1773 from the statistics of the corresponding input image pixels based on
    1774 the statistics specified by \code{psStats stats}.
    1775 \tbd{interpolation?}
     1802dimensions are reduced by a factor of \code{scale} $\le 1$ (it is an
     1803error for \code{scale} $> 1$).  The output image represents a
     1804one-to-one mapping of the pixels in the input image, except for edge
     1805effects.  Each pixel in the output image is derived from the
     1806statistics of the corresponding input image pixels based on the
     1807statistics specified by \code{psStats stats}.  \tbd{interpolation?}
    17761808\begin{verbatim}
    17771809psImage *
     
    17861818pixels should be set of \tbd{value}.  The center of rotation is always
    17871819the center pixel of the image.  The rotation is specified in the sense
    1788 that a positive value is a clock-wise rotation. 
     1820that a positive angle is an anti-clockwise rotation. 
    17891821\begin{verbatim}
    17901822psImage *
     
    17951827Shift image by an arbitrary number of pixels (\code{dx,dy}) in either
    17961828direction.  If the shift values are fractional, the output pixel
    1797 values shoul interpolate between the input pixel values.  The output
     1829values should interpolate between the input pixel values.  The output
    17981830image has the same dimensions as the input image.  Pixels which fall
    17991831off the edge of the output image are loast.  Newly exposed pixels are
     
    18531885
    18541886Read an image or subimage from a named file.  This function is a
    1855 wrapper to the FITS library function.  The input parameters allow or a
    1856 subimage to be read.  The starting pixel of the region is specified by
    1857 \code{x,y}, while the dimensions of the requested region are specified
    1858 by \code{nx,ny}.  A value of -1 for these two parameters specifies the
    1859 full array of the requested image.  If the native image is a cube, the
    1860 value of z specifies the requested slice of the image.  The data is
    1861 read from the extension specified by extname (matching the EXTNAME
    1862 keyword) or by the extnum value (with -1 representing the PHU, 0 the
    1863 first extension, etc).  This function must return an error if any of
    1864 the specified parameters are out of range for the data in the image
    1865 file, if the specified image file does not exist.  \tbd{what do we do
    1866 with a 0D or 1D image?}
     1887wrapper to the FITS library function.  The input parameters allow a
     1888full image or a subimage to be read.  The starting pixel of the region
     1889is specified by \code{x,y}, while the dimensions of the requested
     1890region are specified by \code{nx,ny}.  A value of -1 for these two
     1891parameters specifies the full array of the requested image.  If the
     1892native image is a cube, the value of z specifies the requested slice
     1893of the image.  The data is read from the extension specified by
     1894extname (matching the EXTNAME keyword) or by the extnum value (with -1
     1895representing the PHU, 0 the first extension, etc).  This function must
     1896generate an error and return \code{NULL} if any of the specified
     1897parameters are out of range for the data in the image file, if the
     1898specified image file does not exist, or the image on disk is zero- or
     1899one-dimensional.
    18671900\begin{verbatim}
    18681901psImage *
     
    18931926\end{verbatim}
    18941927
     1928\TBD{The use of \code{FILE*} to carry around the file descriptor is to be reviewed.}
     1929
    18951930Write an image section to named file, which may exist.  This
    18961931operatation may write a portion of an image over the existing bytes of
    18971932an existing image.  If the file does not exist, it should be created.
    1898 If the specified extention does not exist, it should be created.  If
     1933If the specified extension does not exist, it should be created.  If
    18991934an extension is specified and no PHU exists, a basic PHU should be
    19001935created. 
     
    19051940                     int y,             ///< starting y coord of region           
    19061941                     int z,             ///< plane of interest                     
    1907                      char *extname,     ///< MEF extension name ("PHU" for primary header)                         
     1942                     char *extname,     ///< MEF extension name ("PHU" for primary header)
    19081943                     char *filename)    ///< file to write data to                 
    19091944\end{verbatim}
     
    19201955\end{verbatim}
    19211956
     1957\TBD{The use of \code{FILE*} to carry around the file descriptor is to be reviewed.}
     1958
    19221959Read header data from a FITS image file into a \code{psMetaData}
    19231960structure.  If the named extension does not exist, the function should
     
    19411978\end{verbatim}
    19421979
    1943 Perform a 2-D FFT on the specified image.
     1980Perform a 2-D FFT on the specified image.  The returned image is of
     1981type \code{psComplex}.
    19441982\begin{verbatim}
    19451983psImage *
     
    19601998\end{verbatim}
    19611999
    1962 Clip NaN image pixels to given value.  Pixels with NaN or Inf values
    1963 are set to the specified value.
     2000Clip NaN image pixels to given value.  Pixels with NaN, +Inf or -Inf
     2001values are set to the specified value.  Returns the number of clipped
     2002pixels.
    19642003\begin{verbatim}
    19652004int
     
    20452084Plane is a four-dimensional polynomial, in order to account for any
    20462085possible dependencies in the astrometry on the stellar magnitude and
    2047 colour; the latter serves as a check for charge transfer
     2086colour; the former serves as a check for charge transfer
    20482087inefficiencies, while the latter will correct chromatic refraction,
    20492088both through the atmosphere and the corrector lenses.
     
    20582097
    20592098A frame is the result of a single read of a cell (or a portion
    2060 thereof).  It contains a pointer to the data pixels with a
    2061 separate pointer to the overscan pixels, and additional pointers to
    2062 the objects found in the frame, and the frame metadata.  It also
    2063 contains the offset from the lower-left corner of the chip, in the
    2064 case that the CCD was windowed.
     2099thereof).  It contains a pointer to the pixel data, a separate pointer
     2100to the overscan pixels, and additional pointers to the objects found
     2101in the frame, and the frame metadata.  It also contains the offset
     2102from the lower-left corner of the chip, in the case that the CCD was
     2103windowed.
    20652104
    20662105\begin{verbatim}
     
    26192658on both).
    26202659
    2621 We are using the standard \PS{} doubly-linked list types \code{psDlist} and  \code{psHash}
    2622 (see \href{file:utils#psDlist}{utils.pdf:psDlist} and \href{file:utils#psHash}{utils.pdf:psHash} for details).
    2623 For example:
     2660We are using the standard \PS{} doubly-linked list types
     2661\code{psDlist} and \code{psHash}.  For example:
    26242662\begin{verbatim}
    26252663    for (int i = 0; i < 10; i += 5) {
     
    26552693
    26562694The \code{psMetaDataItem} struct includes a name.  This name should be of
    2657 the form \code{name1.name2.name3$\cdots$}, e.g.\hfil\break
     2695the form \code{name1.name2.name3}$\cdots$, e.g.\hfil\break
    26582696\null\qquad\qquad\code{IPP.phase1.ota12.biassec}.
    26592697
     
    27322770/** A point in 2-D space, with errors.
    27332771 */
    2734 typedef struct {
    2735     union {
    2736         double x;                               //!< x position
    2737         double r;                               //!< x position
    2738     } x;
    2739     union {
    2740         double xErr;                            //!< Error in x position
    2741         double rErr;                            //!< Error in x position
    2742     } dx;
    2743     union {
    2744         double y;                               //!< y position
    2745         double d;                               //!< y position
    2746     } y;
    2747     union {
    2748         double yErr;                            //!< Error in y position
    2749         double dErr;                            //!< Error in y position
    2750     } dy;
     2772typedef union {
     2773    struct {
     2774        double x;                       //!< x position
     2775        double y;                       //!< y position
     2776        double xErr;                    //!< Error in x position
     2777        double yErr;                    //!< Error in y position
     2778    } xy;
     2779    struct {
     2780        double r;                       //!< RA
     2781        double d;                       //!< Dec
     2782        double rErr;                    //!< Error in RA
     2783        double dErr;                    //!< Error in Dec
     2784    } rd;
    27512785} psCoord;
    27522786\end{verbatim}
     
    28112845psGetOffset(const psCoord *restrict position1, //!< Position 1
    28122846            const psCoord *restrict position2, //!< Position 2
    2813             char *system)
    2814 ;
     2847            const char *type            //!< Type of offset: Linear, Spherical/Arcsec, Spherical/Degreees etc
     2848    );
    28152849\end{verbatim}
    28162850
     
    28202854psApplyOffset(const psCoord *restrict position, //!< Position
    28212855              const psCoord *restrict offset, //!< Offset
    2822               char *system)
    2823 ;
     2856              const char *type          //!< Type of offset: Linear, Spherical/Arcsec, Spherical/Degreees etc
     2857    );
    28242858\end{verbatim}
    28252859
     
    29042938
    29052939
    2906 Photometric observations are performed in a photometric system, and
    2907 are must be related to other photometric systems.  We require a data
    2908 structure which defines a photometric system, as well as a structure
    2909 to define the transformation between photometric systems. 
     2940Photometric observations are performed in an instrumental photometric
     2941system, and must be related to other photometric systems.  We
     2942require a data structure which defines a photometric system, as well
     2943as a structure to define the transformation between photometric
     2944systems.
    29102945
    29112946The photometric system is defined by the psPhotSystem structure. 
     
    29202955\begin{verbatim}
    29212956typedef struct {
    2922     int ID;
    2923     char *name;
    2924     char *camera;
    2925     char *filter;
    2926     char *detector;
     2957    int ID;                             //!< ID number for this photometric system
     2958    char *name;                         //!< Name of photometric system
     2959    char *camera;                       //!< Camera for photometric system
     2960    char *filter;                       //!< Filter used for photometric system
     2961    char *detector;                     //!< Detector used for photometric system
    29272962} psPhotSystem;
    29282963\end{verbatim}
     
    29322967\begin{verbatim}
    29332968typedef struct {
    2934     psPhotSystem src;
    2935     psPhotSystem dst;
    2936     psPhotSystem pP, pM;        ///< Colour reference
    2937     psPhotSystem sP, sM;        ///< Colour reference
    2938     float pA, sA;               ///<
    2939     psPolynomial3D transform;   
     2969    psPhotSystem src;                   //!< Source photometric system
     2970    psPhotSystem dst;                   //!< Destination photometric system
     2971    psPhotSystem pP, pM;                ///< Primary colour reference
     2972    psPhotSystem sP, sM;                ///< Secondary colour reference
     2973    float pA, sA;                       ///< Colour offset for primary and secondary references
     2974    psPolynomial3D transform;           //!< Transformation from source to destination
    29402975} psPhotTransform;
    29412976\end{verbatim}
     
    29442979airmass of the observation and on the colors of the object of
    29452980interest.  For a specific observation, such a transformations can be
    2946 defined as a polynomial function of the color the star and the airmass
    2947 of the observations.  If sufficient data exists, the transformation
    2948 between the photometric systems may include more than one color,
    2949 constraining the curvature of the stellar spectral energy
     2981defined as a polynomial function of the color of the star and the
     2982airmass of the observations.  If sufficient data exists, the
     2983transformation between the photometric systems may include more than
     2984one color, constraining the curvature of the stellar spectral energy
    29502985distributions.  This latter term may be significant for stars which
    29512986are highly reddened, for example.  Derived photometric quantities may
     
    29632998$M_{\rm pM}$, $M_{\rm sP}$, $M_{\rm sM}$, observed at an airmass of
    29642999$z$, the magnitude of the star in the target system $M_{\rm dst}$ is
    2965 given by:
    2966 $M_{\rm dst} = M_{\rm src} + transform(z, M_{\rm pP} - M_{\rm pM} - pA, M_{\rm sP} - M_{\rm sM} - sA)$
     3000given by: $M_{\rm dst} = M_{\rm src} + transform(z, M_{\rm pP} -
     3001M_{\rm pM} - pA, M_{\rm sP} - M_{\rm sM} - sA)$.
    29673002
    29683003%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset for help on using the changeset viewer.