Index: trunk/doc/pslib/psLibSDRS.tex
===================================================================
--- trunk/doc/pslib/psLibSDRS.tex	(revision 5457)
+++ trunk/doc/pslib/psLibSDRS.tex	(revision 5459)
@@ -1,3 +1,3 @@
-%%% $Id: psLibSDRS.tex,v 1.351 2005-11-02 03:03:44 price Exp $
+%%% $Id: psLibSDRS.tex,v 1.352 2005-11-02 03:49:53 price Exp $
 \documentclass[panstarrs,spec]{panstarrs}
 
@@ -3892,5 +3892,5 @@
 
 \begin{prototype}
-psFits *psFitsOpen(const char *filename, const char mode);
+psFits *psFitsOpen(const char *filename, const char *mode);
 \end{prototype}
 
@@ -3900,15 +3900,16 @@
 \code{r+}) or \code{w} (create new file for writing).
 
-\begin{prototype}
-psFits *psFitsOpenFD(int fd);
-\end{prototype}
-
-Opens a file descriptor and positions the pointer to the PHU.
-
-\begin{prototype}
-psFits *psFitsOpenStream(FILE *stream);
-\end{prototype}
-
-Opens a stream and positions the pointer to the PHU.
+%%%%
+%%%% psFitsOpenFD and psFitsOpenStream probably can't be implemented
+%%%% using cfitsio without creating temporary files.
+%%%%
+%% \begin{prototype}
+%% psFits *psFitsOpenFD(int fd);
+%% \end{prototype}
+%% Opens a file descriptor and positions the pointer to the PHU.
+%% \begin{prototype}
+%% psFits *psFitsOpenStream(FILE *stream);
+%% \end{prototype}
+%% Opens a stream and positions the pointer to the PHU.
 
 \begin{prototype}
@@ -3936,9 +3937,8 @@
 
 \begin{prototype}
-bool psFitsMoveEnd(psFits *fits);
-\end{prototype}
-
-Moves the pointer to the end of the file, so that a new extension may
-be written.
+bool psFitsMoveLast(psFits *fits);
+\end{prototype}
+
+Moves the pointer to the last extension in the file.
 
 \begin{prototype}
@@ -4070,21 +4070,21 @@
  
 \begin{prototype}
-bool psFitsUpdateImage(psFits *fits, const psImage *input, psRegion region, int z);
+bool psFitsUpdateImage(psFits *fits, const psImage *input, int x0, int y0, int z);
 \end{prototype}
 Write an image section to the open \code{psFits} file pointer.  This
 operation may write a portion of an image over the existing bytes of
-an existing image.  Care must be taken to interpret \code{region},
-which specified the output pixels to be written / over-written.  If
-the combination of \code{region} and the size of \code{psImage *input}
-implies writing pixels outside the existing data area of the image,
-the function shall return an error (ie, if \code{region.x0 + image.nx
->= NAXIS1}, \code{region.y0 + image.ny >= NAXIS2}, or \code{z >=
-NAXIS3}).  This function will only write images of the native FITS
-image types (\code{psU8}, \code{psS16}, \code{psS32}, \code{psF32},
-\code{psF64}).  The user is expected to convert the data type as
-needed with \code{psImageCopy}.  The return value must be 0 for a
-successful operation and 1 for an error.  \tbd{is region in the frame
-of input or of disk image?  how do image coordinates relate to disk
-image coords?}
+an existing image, starting at \code{x0,y0} in the \code{fits} image.
+Note that the origin of the \code{input} must be (0,0), not that of
+any parent (i.e., \code{input->col0,input->row0)}).  Care must be
+taken to interpret region which specifies the output pixels to be
+written / over-written.  If the combination of \code{x0,y0} and the
+size of \code{psImage *input} implies writing pixels outside the
+existing data area of the image, the function shall return an error
+(ie, if \code{x0 + image.nx >= NAXIS1}, \code{y0 + image.ny >=
+NAXIS2}, or \code{z >= NAXIS3}).  This function will only write images
+of the native FITS image types (\code{psU8}, \code{psS16},
+\code{psS32}, \code{psF32}, \code{psF64}).  The user is expected to
+convert the data type as needed with \code{psImageCopy}.  The return
+value must be 0 for a successful operation and 1 for an error.
 
 \begin{prototype}
@@ -4094,12 +4094,25 @@
 Create a new image based on the dimensions specified for the image and
 the requested depth.  The header and image data segments are written
-in the file at the current position of the \code{psFits} pointer.
-This function will only write images of the native FITS image types
-(\code{psU8}, \code{psS16}, \code{psS32}, \code{psF32}, \code{psF64}).
-The user is expected to convert the data type as needed with
-\code{psImageCopy}.  The return value must be 0 for a successful
-operation and 1 for an error.  If \code{extname} is not \code{NULL},
-the \code{EXTNAME} in the \code{header} shall be updated to be
-\code{extname} before writing.
+at the end of the file.  This function will only write images of the
+native FITS image types (\code{psU8}, \code{psS16}, \code{psS32},
+\code{psF32}, \code{psF64}).  The user is expected to convert the data
+type as needed with \code{psImageCopy}.  The return value must be 0
+for a successful operation and 1 for an error.  If \code{extname} is
+not \code{NULL}, the \code{EXTNAME} in the \code{header} shall be
+updated to be \code{extname} before writing.
+
+\begin{prototype}
+bool psFitsInsertImage(psFits *fits, psMetadata *header, const psImage *input, int depth,
+                       const char *extname, bool after);
+\end{prototype}
+
+\code{psFitsInsertImage} behaves in the same manner as
+\code{psFitsWriteImage}, except that the extension is inserted
+according to the value of the boolean \code{after}.  If \code{after}
+is \code{true}, then the extension is inserted after the current
+\code{psFits} pointer; otherwise the extension is inserted before the
+current \code{psFits} pointer.  \textbf{The user should beware that
+this is potentially a very expensive operation in terms of time, since
+the entire file following the inserted extension must be rewritten.}
 
 \subsubsection{FITS Table I/O Functions}
@@ -4171,7 +4184,6 @@
 bool psFitsWriteTable(psFits* fits, const psMetadata *header, const psArray* table); 
 \end{prototype}
-Accepts a \code{psArray} of \code{psMetadata} and writes it to the
-current HDU.  If the current HDU is not a table type, this will fail
-and return FALSE.
+Accepts a \code{psArray} of \code{psMetadata} and writes it to the end
+of the file.
 
 \begin{prototype}
@@ -4181,4 +4193,18 @@
 in the current HDU.  If the current HDU is not a table type, this will
 fail and return FALSE.  
+
+\begin{prototype}
+bool psFitsInsertTable(psFits *fits, const psMetadata *header, const psArray* table,
+                       bool after);
+\end{prototype}
+
+\code{psFitsInsertTable} behaves in the same manner as
+\code{psFitsWriteTable}, except that the extension is inserted
+according to the value of the boolean \code{after}.  If \code{after}
+is \code{true}, then the extension is inserted after the current
+\code{psFits} pointer; otherwise the extension is inserted before the
+current \code{psFits} pointer.  \textbf{The user should beware that
+this is potentially a very expensive operation in terms of time, since
+the entire file following the inserted extension must be rewritten.}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
