IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 8, 2005, 7:16:41 PM (21 years ago)
Author:
eugene
Message:

more section reorganization

File:
1 edited

Legend:

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

    r4166 r4178  
    1 %%% $Id: psLibSDRS.tex,v 1.270 2005-06-09 00:40:48 eugene Exp $
     1%%% $Id: psLibSDRS.tex,v 1.271 2005-06-09 05:16:41 eugene Exp $
    22\documentclass[panstarrs,spec]{panstarrs}
    33
     
    831831%
    832832\begin{prototype}
    833 void psTrace(const char *facil, int level,...);
     833void psTrace(const char *facil, int level, const char *fmt,...);
     834void psTraceV(const char *facil, int level, const char *fmt, va_list ap);
    834835\end{prototype}
    835836%
    836 where the last argument is a printf-style formatting code and possible
    837 arguments to that formatting statement, to be implemented using the
    838 \code{vprintf} functions.  This command specifies the name of the
    839 facility to which the message belongs (\code{facil}), the trace level
    840 for this message in that facility (\code{level}) and the message
    841 itself.
     837where the \code{fmt} argument is a printf-style formatting code
     838followed by possible arguments to that formatting statement, to be
     839implemented using the \code{vprintf} functions.  This command
     840specifies the name of the facility to which the message belongs
     841(\code{facil}), the trace level for this message in that facility
     842(\code{level}) and the message itself.  The \code{psTraceV} version of
     843the command accepts a \code{va_list} argument list rather than a
     844variable number of arguments.
    842845
    843846The trace level for any facility may be set at any time with the
     
    929932functions, effectively resetting all trace levels to 0.
    930933
    931 
    932 The trace may optionally be written to a file on specifying a filename
    933 with \code{psTraceSetDestination}:
    934 \begin{prototype}
    935 void psTraceSetDestination(FILE *fp);
    936 \end{prototype}
    937 If the \code{fp} is \code{NULL}, then the trace is sent to standard
    938 output, otherwise it is sent to the specified file pointer.
     934The trace may optionally be written to a file or other output
     935destination with \code{psTraceSetDestination}:
     936\begin{prototype}
     937void psTraceSetDestination(int fd);
     938\end{prototype}
     939If the \code{fd} is 0, then the trace is sent to standard output,
     940otherwise it is sent to the specified file descriptor.  A call to
     941\code{psTraceSetDestination} automatically closes the file descriptor.
     942
     943The corresponding function
     944\begin{prototype}
     945int psTraceGetDestination();
     946\end{prototype}
     947returns the current trace destination file descriptor.  If the
     948destination has not been defined by the user, the descriptor for
     949\code{stdout} is returned.
     950
     951The trace output format is controlled with the function:
     952%
     953\begin{prototype}
     954bool psTraceSetFormat(const char *fmt);
     955\end{prototype}
     956%
     957which expects a string consisting of the letters \code{H} (host),
     958\code{L} (level), \code{M} (message), \code{N} (name), and \code{T}
     959(time).  The default is \code{THLNM}, which produces trace messages in
     960the form:
     961\begin{verbatim}
     962YYYY-MM-DD hh:mm:ssZ | hostname | L | name
     963    The message goes here
     964    and is indented by 4 spaces.
     965\end{verbatim}
     966where \code{YYYY}, \code{MM}, \code{DD}, \code{hh}, \code{mm}, and
     967\code{ss} are the year, month (Jan is 01), day of the month, hours
     968(0--23), minutes, and seconds when the trace message was received.  Note
     969that the timestamp is in ISO order, and that the timezone is GMT
     970(hence the \code{Z}).  The \code{hostname} is returned by
     971\code{gethostname}, \code{L} is a character associated with the level
     972(\code{A}, \code{E}, \code{W}, and \code{I} for \code{PS_LOG_ABORT},
     973\code{PS_LOG_ERROR}, \code{PS_LOG_WARN}, and \code{PS_LOG_INFO}
     974respectively. Other levels are represented numerically (\code{5}
     975etc.). The other two fields, \code{facil} and \code{msg}, are the
     976arguments to \code{psTrace}.  The \code{msg} is placed on a new line
     977(allowing the \code{name} to fill the rest of the previous line),
     978with each line indented by 4 spaces.  An example message is:
     979%
     980\begin{verbatim}
     9812004:02:24 20:14:18Z | alibaba.IfA.Hawaii.Edu | I | example.utils.helloWorld
     982    Hello world,
     983    it's me calling.
     984\end{verbatim}
     985%
     986The possible order of the format entries is fixed and not determined
     987by the order of the letters used in \code{psTraceSetFormat}.  Selecting
     988an output format with fewer than the complete set of 5 entries simply
     989removes those entries from the output messages.
     990
     991Specifying a \code{fmt} of \code{NULL} turns off logging (equivalent
     992to calling \code{psLogSetDestination(PS_LOG_TO_NONE)}, whereas if the
     993\code{fmt} is \code{""}, then the format reverts to the default.
    939994
    940995\subsubsection{Message Logging}
     
    9931048%
    9941049\begin{prototype}
    995 bool psLogSetDestination(const char *dest);     
    996 \end{prototype}
    997 %
    998 The destination string consists of a URL in the form
    999 \code{protocol:location}.  The \code{protocol} value may be
    1000 \code{file}, to send the log to a local file named by the value of
    1001 \code{location}.  Future expansion may allow the logger to send
    1002 messages to an IP logger, with a protocol to be defined later.  Three
    1003 other special values are allowed for the \code{dest} parameter
    1004 (without specifying a protocol): \code{stderr} and \code{stdout},
    1005 which write to \code{stderr} and \code{stdout} respectively, and
    1006 \code{none} to turn off logging.
     1050bool psLogSetDestination(int fd);     
     1051\end{prototype}
     1052%
     1053If the \code{fd} is 0, then the log is sent to standard output,
     1054otherwise it is sent to the specified file descriptor.  A call to
     1055\code{psLogSetDestination} automatically closes an open file
     1056descriptor.
     1057
     1058The corresponding function
     1059\begin{prototype}
     1060int psLogGetDestination();
     1061\end{prototype}
     1062returns the current log destination file descriptor.  If the
     1063destination has not been defined by the user, the descriptor for
     1064\code{stdout} is returned.
    10071065
    10081066The output format is controlled with the function:
     
    10491107to calling \code{psLogSetDestination(PS_LOG_TO_NONE)}, whereas if the
    10501108\code{fmt} is \code{""}, then the format reverts to the default.
     1109
     1110The following utility opens an output file descriptor for use by the
     1111trace and log facilities.
     1112\begin{prototype}
     1113int psMessageDestination (const char *dest);
     1114\end{prototype}
     1115%
     1116The destination string consists of a URL in the form
     1117\code{protocol:location}.  The \code{protocol} value may be
     1118\code{file}, to send the log to a local file named by the value of
     1119\code{location}.  Future expansion may allow the logger to send
     1120messages to an IP logger, with a protocol to be defined later.  Three
     1121other special values are allowed for the \code{dest} parameter
     1122(without specifying a protocol): \code{stderr} and \code{stdout},
     1123which return the file descriptors for \code{stderr} and \code{stdout}
     1124respectively, and \code{none} which returns the special descriptor to
     1125turn off logging.
    10511126
    10521127%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    16601735output of this function is a region with negative upper limits
    16611736replaced by their corrected value appropriate to the given image.
     1737
     1738\subsubsection{Image Pixel Lists}
     1739
     1740Usually an image mask is the best way to carry information about what
     1741pixels mean what.  However, in the case where the number of pixels in
     1742which we are interested is limited, it is more efficient to simply
     1743carry a list of pixels.  An example of this is in the image
     1744combination code, where we want to perform an operation on a
     1745relatively small fraction of pixels, and it is inefficient to go
     1746through an entire mask image checking each pixel.
     1747
     1748\begin{datatype}
     1749typedef struct {
     1750    int x;                      // x coordinate
     1751    int y;                      // y coordinate
     1752} psPixelCoord;
     1753
     1754typedef struct {
     1755    psU32 n;                    // Number in use
     1756    const psU32 nalloc;         // Number allocated
     1757    psPixelCoord *data;         // The pixel coordinates
     1758} psPixels;
     1759\end{datatype}
     1760
     1761\begin{prototype}
     1762psPixels *psPixelsAlloc(psU32 nalloc);
     1763psPixels *psPixelsRealloc(psPixels *pixels, psU32 nalloc);
     1764\end{prototype}
     1765
     1766\code{psPixelsAlloc} and \code{psPixelsRealloc} provide dynamic
     1767allocation and reallocation in a manner analogous to those provided
     1768by \code{psVectorAlloc} and \code{psVectorRealloc}.
     1769
     1770\begin{prototype}
     1771psImage *psPixelsToMask(psImage *out, const psPixels *pixels, psRegion region, unsigned int maskVal);
     1772psPixels *psPixelsFromMask(psPixels *out, const psImage *mask, unsigned int maskVal);
     1773\end{prototype}
     1774
     1775\code{psPixelsToMask} shall return an image of type U8 with the
     1776\code{pixels} lying within the specified \code{region} set to the
     1777\code{maskVal}.  The \code{out} image shall be modified if supplied,
     1778or allocated and returned if \code{NULL}.  The size of the output
     1779image shall be \code{region.x1 - region.x0} by \code{region.y1 -
     1780region.y0}, with \code{out->x0 = region.x0} and \code{out->y0 =
     1781region.y0}.  In the event that either of \code{pixels} or
     1782\code{region} are \code{NULL}, the function shall generate an error
     1783and return \code{NULL}.
     1784
     1785\code{psMaskToPixels} shall return a \code{psPixels} containing the
     1786coordinates in the \code{mask} that match the \code{maskVal}.  The
     1787\code{out} pixel list shall be modified if supplied, or allocated and
     1788returned if \code{NULL}.  In the event that \code{mask} is
     1789\code{NULL}, the function shall generate an error and return
     1790\code{NULL}.
     1791
     1792\begin{prototype}
     1793psPixels *psPixelsCopy(psPixels *out, const psPixels *pixels);
     1794psPixels *psPixelsConcatenate(psPixels *out, const psPixels *pixels);
     1795\end{prototype}
     1796
     1797\code{psPixelsCopy} shall copy the contents of \code{pixels} to the
     1798\code{out}.  In the event that \code{out} is \code{NULL}, a new
     1799\code{psPixels} shall be allocated, and the contents of \code{pixels}
     1800simply copied in.  If \code{pixels} is \code{NULL}, the function shall
     1801generate an error and return \code{NULL}.
     1802
     1803\code{psPixelsConcatenate} shall concatenate the \code{pixels} onto
     1804\code{out}.  In the event that \code{out} is \code{NULL}, the function
     1805performs a \code{psPixelsCopy}, returning the copy.  If \code{pixels}
     1806is \code{NULL}, the function shall generate an error and return
     1807\code{NULL}.  The function shall take care to ensure that there are no
     1808duplicate pixels in \code{out} (since the order in which the pixels
     1809are stored is not important, the values may be sorted, allowing the
     1810use of a faster algorithm than a linear scan).
    16621811
    16631812\subsection{Math Casting}
     
    46204769%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    46214770
    4622 \subsection{Image Pixel Lists}
    4623 
    4624 Usually an image mask is the best way to carry information about what
    4625 pixels mean what.  However, in the case where the number of pixels in
    4626 which we are interested is limited, it is more efficient to simply
    4627 carry a list of pixels.  An example of this is in the image
    4628 combination code, where we want to perform an operation on a
    4629 relatively small fraction of pixels, and it is inefficient to go
    4630 through an entire mask image checking each pixel.
    4631 
    4632 \begin{datatype}
    4633 typedef struct {
    4634     int x;                      // x coordinate
    4635     int y;                      // y coordinate
    4636 } psPixelCoord;
    4637 
    4638 typedef struct {
    4639     psU32 n;                    // Number in use
    4640     const psU32 nalloc;         // Number allocated
    4641     psPixelCoord *data;         // The pixel coordinates
    4642 } psPixels;
    4643 \end{datatype}
    4644 
    4645 \begin{prototype}
    4646 psPixels *psPixelsAlloc(psU32 nalloc);
    4647 psPixels *psPixelsRealloc(psPixels *pixels, psU32 nalloc);
    4648 \end{prototype}
    4649 
    4650 \code{psPixelsAlloc} and \code{psPixelsRealloc} provide dynamic
    4651 allocation and reallocation in a manner analogous to those provided
    4652 by \code{psVectorAlloc} and \code{psVectorRealloc}.
    4653 
    4654 \begin{prototype}
    4655 psImage *psPixelsToMask(psImage *out, const psPixels *pixels, psRegion region, unsigned int maskVal);
    4656 psPixels *psPixelsFromMask(psPixels *out, const psImage *mask, unsigned int maskVal);
    4657 \end{prototype}
    4658 
    4659 \code{psPixelsToMask} shall return an image of type U8 with the
    4660 \code{pixels} lying within the specified \code{region} set to the
    4661 \code{maskVal}.  The \code{out} image shall be modified if supplied,
    4662 or allocated and returned if \code{NULL}.  The size of the output
    4663 image shall be \code{region.x1 - region.x0} by \code{region.y1 -
    4664 region.y0}, with \code{out->x0 = region.x0} and \code{out->y0 =
    4665 region.y0}.  In the event that either of \code{pixels} or
    4666 \code{region} are \code{NULL}, the function shall generate an error
    4667 and return \code{NULL}.
    4668 
    4669 \code{psMaskToPixels} shall return a \code{psPixels} containing the
    4670 coordinates in the \code{mask} that match the \code{maskVal}.  The
    4671 \code{out} pixel list shall be modified if supplied, or allocated and
    4672 returned if \code{NULL}.  In the event that \code{mask} is
    4673 \code{NULL}, the function shall generate an error and return
    4674 \code{NULL}.
    4675 
    4676 \begin{prototype}
    4677 psPixels *psPixelsCopy(psPixels *out, const psPixels *pixels);
    4678 psPixels *psPixelsConcatenate(psPixels *out, const psPixels *pixels);
    4679 \end{prototype}
    4680 
    4681 \code{psPixelsCopy} shall copy the contents of \code{pixels} to the
    4682 \code{out}.  In the event that \code{out} is \code{NULL}, a new
    4683 \code{psPixels} shall be allocated, and the contents of \code{pixels}
    4684 simply copied in.  If \code{pixels} is \code{NULL}, the function shall
    4685 generate an error and return \code{NULL}.
    4686 
    4687 \code{psPixelsConcatenate} shall concatenate the \code{pixels} onto
    4688 \code{out}.  In the event that \code{out} is \code{NULL}, the function
    4689 performs a \code{psPixelsCopy}, returning the copy.  If \code{pixels}
    4690 is \code{NULL}, the function shall generate an error and return
    4691 \code{NULL}.  The function shall take care to ensure that there are no
    4692 duplicate pixels in \code{out} (since the order in which the pixels
    4693 are stored is not important, the values may be sorted, allowing the
    4694 use of a faster algorithm than a linear scan).
    4695 
    4696 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4697 
    46984771\subsection{Vector and Image Arithmetic}
    46994772\label{sec:arithmetic}
     
    51325205
    51335206\pagebreak
    5134 \section{Astronomy-Specific Functions}
     5207\section{Astronomy-Related Functions}
    51355208
    51365209The previous sections of this document defined basic functionality
     
    51475220\item Dates and times
    51485221\item Detector and sky positions
    5149 \item Astronomical Image Containers
    51505222\item Astrometry
    51515223\item Photometry
     
    61856257%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
    61866258
    6187 \subsection{Photometry}
    6188 
    6189 \tbd{This section is to be deferred, and for now consists only of
    6190 place holders, with no functional items.}
    6191 
    6192 Photometric observations are performed in an instrumental photometric
    6193 system, and must be related to other photometric systems.  We
    6194 require a data structure which defines a photometric system, as well
    6195 as a structure to define the transformation between photometric
    6196 systems.
    6197 
    6198 The photometric system is defined by the psPhotSystem structure. 
    6199 A photometric system is identified by a human-readable \code{name}
    6200 (ie, SDSS.g, Landolt92.B, GPC1.OTA32.r).  Each photometric system is
    6201 given a unique identifier \code{ID}.  Observations taken with a
    6202 specific camera, detector, and filter represent their own photometric
    6203 system, and it may be necessary to perform transformations between
    6204 these systems.  Photometric systems associated with observations from
    6205 a specific camera/detector/filter combination can be associated with
    6206 those components.
    6207 \begin{datatype}
    6208 typedef struct {
    6209     const int ID;                       ///< ID number for this photometric system
    6210     const char *name;                   ///< Name of photometric system
    6211     const char *camera;                 ///< Camera for photometric system
    6212     const char *filter;                 ///< Filter used for photometric system
    6213     const char *detector;               ///< Detector used for photometric system
    6214 } psPhotSystem;
    6215 \end{datatype}
    6216 
    6217 The following structure defines the transformation between two
    6218 photometric systems.
    6219 \begin{datatype}
    6220 typedef struct {
    6221     psPhotSystem src;                   ///< Source photometric system
    6222     psPhotSystem dst;                   ///< Destination photometric system
    6223     psPhotSystem pP, pM;                ///< Primary color reference
    6224     psPhotSystem sP, sM;                ///< Secondary color reference
    6225     float pA, sA;                       ///< Color offset for references
    6226     psPolynomial3D transform;           ///< Transformation from source to destination
    6227 } psPhotTransform;
    6228 \end{datatype}
    6229 
    6230 The transformation between two photometric systems may depend on the
    6231 airmass of the observation and on the colors of the object of
    6232 interest.  For a specific observation, such a transformations can be
    6233 defined as a polynomial function of the color of the star and the
    6234 airmass of the observations.  If sufficient data exists, the
    6235 transformation between the photometric systems may include more than
    6236 one color, constraining the curvature of the stellar spectral energy
    6237 distributions.  This latter term may be significant for stars which
    6238 are highly reddened, for example.  Derived photometric quantities may
    6239 have been corrected for airmass variations, in which case only color
    6240 terms may be measurable.  The structure defines the transformation
    6241 between a source photometric system (\code{src}) and a target
    6242 photometric system (\code{dst}).  The photometric system of a primary
    6243 color is defined by \code{pP, pM} such that the color is constructed
    6244 as $pP - pM$.  A secondary color is defined by \code{sP, sM}.  For
    6245 both, a reference color is specified (\code{pA, sA}): the polynomial
    6246 transformation terms refer to colors in the form $pP - pM - pA$.  The
    6247 transformation is specified as a 3D polynomial.  For a star of
    6248 magnitude $M_{\rm src}$ in the source photometric system, with
    6249 additional magnitude information in the other systems $M_{\rm pP}$,
    6250 $M_{\rm pM}$, $M_{\rm sP}$, $M_{\rm sM}$, observed at an airmass of
    6251 $z$, the magnitude of the star in the target system $M_{\rm dst}$ is
    6252 given by: $M_{\rm dst} = M_{\rm src} + transform(z, M_{\rm pP} -
    6253 M_{\rm pM} - pA, M_{\rm sP} - M_{\rm sM} - sA)$.
    6254 
    62556259%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    62566260
    62576261%%% Astronomical Images and Astrometry
    6258 \include{psLibSDRS_Astrom}
     6262% \include{psLibSDRS_Astrom}
    62596263
    62606264\subsection{Astronomical objects}
Note: See TracChangeset for help on using the changeset viewer.