Index: /trunk/doc/pslib/ChangeLogSDRS.tex
===================================================================
--- /trunk/doc/pslib/ChangeLogSDRS.tex	(revision 2069)
+++ /trunk/doc/pslib/ChangeLogSDRS.tex	(revision 2070)
@@ -1,3 +1,3 @@
-%%% $Id: ChangeLogSDRS.tex,v 1.33 2004-10-11 23:43:15 price Exp $
+%%% $Id: ChangeLogSDRS.tex,v 1.34 2004-10-13 02:34:41 eugene Exp $
 
 \subsection{Changes from version 00 to version 01}
@@ -301,12 +301,10 @@
 \end{itemize}
 
-\subsection{Changes from Revision 07 (7 September 2004) to present}
+\subsection{Changes from Revision 07 (7 September 2004) to Revision 08 (12 October 2004)}
 
 \begin{itemize}
-\item Changed format of \code{psLogMsg}, following bug 189: format now
-  has multiple lines.
+\item Changed format of \code{psLogMsg}, following bug 189: format now has multiple lines.
 \item Added configuration file grammar.
-\item Added explanation of \code{psArray *coords} in
-  \code{psMinimizeLMFunc}, and changed \code{psMatrix} to
+\item Added explanation of \code{psArray *coords} in \code{psMinimizeLMFunc}, and changed \code{psMatrix} to
   \code{psImage} in response to bug 191.
 \item Added \code{psTimeTable}.
@@ -321,16 +319,21 @@
 \item Removed \code{psListRemoveNext} and \code{psListRemoveAfter}.
   Removing an item pointed to by an iterator doesn't cause an error.
-\item Added \code{PS_TYPE_STR} and \code{PS_TYPE_BOOL} to
-  \code{psElemType}.
+\item Added \code{psRectangle}
+\item Added \code{PS_TYPE_BOOL} to \code{psElemType}.
+\item Dropped \code{PS_TYPE_OTHER}
+\item Replaced \code{PS_META_IMG} with \code{PS_META_MATH}
+\item Replaced \code{PS_META_ITEM_SET} with \code{PS_META_LIST}
+\item Added \code{psElemType} to \code{psMetadataItem} to specify primitive data types.
+\item Cleaned up the entries in \code{psMetadataType}.
+\item Moved the \code{psList} entry (item set, now list) to the union.
+\item Added a \code{psMetadata} entry to the union.
+\item Added typing contruct and hierarchy to \code{psMetadataParseConfig}
+\item Added FITS I/O section 
 \item Moved \code{psImageReadSection} and \code{psImageWriteSection} to FITS I/O Functions section and modified names.
 \item Moved \code{psMetadataReadHeader} and \code{psMetadataFReadHeader} to FITS I/O Functions section and modified names.
-\item added FITS I/O section 
-\item added \code{psRectangle}
-\item fixed typo: \code{p_psScalar} to \code{psScalar}
-\item renamed psMetadata.data.void to psMetadata.data.data to be consistent with psList, psHash 
-\item replaced \code{PS_META_IMG} with \code{PS_META_MATH}
-\item dropped \code{PS_TYPE_BOOL, PS_TYPE_STR, PS_TYPE_OTHER}
-\item require comment mark in 'multiple' metadata config entry for comments
-\item changed return values for \code{psMetadataParseConfig}
+\item Fixed typo: \code{p_psScalar} to \code{psScalar}
+\item Renamed \code{psMetadata.data.void} to \code{psMetadata.data.data} to be consistent with \code{psList}, \code{psHash} 
+\item Require comment mark in 'multiple' metadata config entry for comments
+\item Changed return values for \code{psMetadataParseConfig}
 \item Added \code{psTimeAlloc}.
 \item Adding \code{errors} to \code{psVectorStats}.
Index: /trunk/doc/pslib/psLibSDRS.tex
===================================================================
--- /trunk/doc/pslib/psLibSDRS.tex	(revision 2069)
+++ /trunk/doc/pslib/psLibSDRS.tex	(revision 2070)
@@ -1,3 +1,3 @@
-%%% $Id: psLibSDRS.tex,v 1.136 2004-10-11 23:43:03 price Exp $
+%%% $Id: psLibSDRS.tex,v 1.137 2004-10-13 02:34:41 eugene Exp $
 \documentclass[panstarrs,spec]{panstarrs}
 
@@ -30,10 +30,12 @@
 DR & 2004 Mar 29 & Draft \\ \hline
 00 & 2004 Apr 1  & First version, sent to MHPCC \\ \hline
-01 & 2004 May 19 & Extensive modifications, see appendix \\ \hline
+01 & 2004 May 19 & Extensive modifications, see Appendix B \\ \hline
 02 & 2004 Jun 22 & Incorporation of Bugzilla PRs (up to 69) \\ \hline
-03 & 2004 Aug 10 & Adding convolution, splines, chebyshevs \\
-   &             & (modified polynomials), ImageTrim for Phase 2. \\
-   &             & Changed minimization. \\ \hline
-04-- & Various   & See Appendix A for a change log. \\ \hline
+03 & 2004 Jul 06 & \\ \hline
+04 & 2004 Jul 13 & See Appendix B for a change log. \\ \hline
+05 & 2004 Aug 16 & draft for start of cycle 3 \\ \hline
+06 & 2004 Aug 19 & revision for cycle 3 \\ \hline
+07 & 2004 Sep 07 & final for cycle 3 \\ \hline
+08 & 2004 Oct 12 & draft for start of cycle 4 \\
 \RevisionsEnd
 
@@ -1233,4 +1235,5 @@
     PS_TYPE_C32,                        ///< Complex numbers consisting of floats
     PS_TYPE_C64,                        ///< Complex numbers consisting of doubles
+    PS_TYPE_BOOL                        ///< Boolean value
 } psElemType;
 \end{verbatim}
@@ -1386,4 +1389,17 @@
 dimensionality must be 2.  
 
+\subsection{Math Casting}
+
+We define a basic data type which only contains the type information.
+This structure should be used to cast an unknown \code{psMath} data
+structure (\code{psImage}, \code{psVector}, \code{psScalar}) so the
+data type testing may be safely performed.  
+
+\begin{verbatim} 
+typedef struct { 
+    psType type;                        ///< data type information 
+} psMath;
+\end{verbatim}
+
 \subsection{Simple Arrays}
 
@@ -1860,8 +1876,8 @@
 psStats *psVectorStats(psStats *stats,
                        const psVector *in, 
-		       const psVector *errors,
+                       const psVector *errors,
                        const psVector *mask,
                        unsigned int maskVal
-		       );
+                       );
 \end{verbatim}
 %
@@ -3662,16 +3678,17 @@
 \begin{verbatim}
 typedef struct {
-    const int id;                       ///< unique ID for this item
-    const char *name;                   ///< Name of item
+    int id;                             ///< unique ID for this item
+    char *name;                         ///< Name of item
     psMetadataType type;                ///< type of this item
+    psElemType ptype;                   ///< primitive data type
     const union {
-        bool bool;                      ///< boolean value
-        psS32 S32;                      ///< integer value
-        psF32 F32;                      ///< floating value
-        psF64 F64;                      ///< double value
-        void *data;                     ///< other type
+        psS32 S32;                      ///< integer data
+        psF32 F32;                      ///< floating-point data
+        psF64 F64;                      ///< double-precision data
+        void *V;                        ///< other type
+        psList *list;                   ///< psList entry
+        psMetadata *md;                 ///< psMetadata entry
     } data;                             ///< value of metadata
     char *comment;                      ///< optional comment ("", not NULL)
-    psList *items;                      ///< list of psMetadataItems with the same name
 } psMetadataItem;
 \end{verbatim}
@@ -3682,24 +3699,26 @@
 given by the union \code{data}, and may be of type \code{psS32},
 \code{psF32}, \code{psF64}, or an arbitrary rich structure pointed at
-by the \code{void} pointer \code{void}.  A character string comment
+by the \code{void} pointer \code{V}.  A character string comment
 associated with this metadata item may be stored in the element
-\code{comment}. The \code{type} entry specifies the type of the data
-being represented, given by the enumerated type \code{psMetadataType}:
-\begin{verbatim}
-typedef enum {                          ///< type of data.item is:
-    PS_META_ITEM_SET = 0,               ///< NULL; metadata is in psMetadataType.items
-    PS_META_BOOL,                       ///< bool (.bool)
-    PS_META_S32,                        ///< int (.S32)
-    PS_META_F32,                        ///< float (.F32)
-    PS_META_F64,                        ///< double (.F64)
-    PS_META_STR,                        ///< string (.data)
-    PS_META_MATH,                       ///< psScalar, psVector, psImage (.data)
-    PS_META_JPEG,                       ///< JPEG (.data)
-    PS_META_PNG,                        ///< PNG (.data)
-    PS_META_ASTROM,                     ///< astrometric coefficients (.data)
-    PS_META_UNKNOWN,                    ///< other (.data)
+\code{comment}. The \code{type} entry specifies how to interpret the
+type of the data being represented, given by the enumerated type
+\code{psMetadataType}:
+%
+\begin{verbatim}
+typedef enum {                          ///< type of item.data is:
+    PS_META_PRIMITIVE,                  ///< primitive type: use item.ptype
+    PS_META_LIST,                       ///< psList; use item.data.list (used for non-unique data)
+    PS_META_META,                       ///< psMetadata: use item.data.list
+    PS_META_STR,                        ///< string (item.data.V)
+    PS_META_MATH,                       ///< psScalar, psVector, psImage (item.data.V)
+    PS_META_JPEG,                       ///< JPEG (item.data)
+    PS_META_PNG,                        ///< PNG (item.data)
+    PS_META_ASTROM,                     ///< astrometric coefficients (item.data)
+    PS_META_UNKNOWN,                    ///< other (item.data)
     PS_META_NTYPE                       ///< Number of types; must be last
 } psMetadataType;
 \end{verbatim}
+If the data is a PSLib primitive data value, the primitive data type
+is given by the value of \code{ptype}.
 
 A collection of metadata is represented by the \code{psMetadata} structure:
@@ -3963,5 +3982,5 @@
 \begin{verbatim}
 Double     F64     1.23456789      # This is a comment
-Float    F32 0.98765#This is a comment too
+Float    F32 0.98765 # This is a comment too
 String  STR This is the string that forms the value #comment
 
@@ -3983,4 +4002,30 @@
 than the above example, but PSLib must be able to parse such ugly
 files.
+
+We extend \code{psMetadataParseConfig} to allow a modest tree
+structure by defining a reserved keyword \code{TYPE}.  Any line in the
+config file which starts with the word \code{TYPE} shall be
+interpretted as defining a new valid type.  The defined type name
+follows the word \code{TYPE}, and is in turn followed by an arbitrary
+number of words.  These words are to be interpreted as the names of an
+embedded \code{psMetadata} entry, where the values are given on any
+line which (following the \code{TYPE} definition) employs the new type
+name.  For example, a new type may be defined as:
+\begin{verbatim}
+TYPE      CELL   EXTNAME   BIASSEC  CHIP
+CELL.00   CELL   CCD00     BSEC-00  CHIP.00
+CELL.01   CELL   CCD01     BSEC-01  CHIP.00
+\end{verbatim}
+
+When \code{psMetadataParseConfig} encounters the \code{TYPE} line, it
+should construct a \code{psMetadata} container and fill it with
+\code{psMetadataItems} having the names \code{EXTNAME, BIASSEC, CHIP},
+with type \code{PS_META_STR}, but data allocated.  When it next
+encounters an entry of type \code{CELL}, it should then use the given
+name (e.g., \code{CELL.00}) for the \code{psMetadataItem}, and copy
+the \code{psMetadata} data onto the \code{psMetadataItem.data.md}
+entry, filling in the values from the rest of the line (\code{CCD00,
+BSEC-00, CHIP.00}).  This hierarchical structure is illustrated in
+Figure~\ref{fig:metadata}.
 
 A BNF-like grammar of the configuration file is contained in
@@ -4039,11 +4084,11 @@
 \begin{verbatim}
 bool psFitsWriteHeader(psMetadata *output, const char *filename);
-bool psFitsReadHeaderPtr(psMetadata *output, const psFits *fd);
-\end{verbatim}
-Write metadata into the header of a FITS image file.  \tbd{where?}
-\tbd{consistency check?}  \tbd{function to remove non-FITS header
-entries?}  The header is written to the end of the given file.
-\tbd{Allow for overwriting a specific header? dangerous in anycase:
-the header and data must agree for the file to be valid...}
+bool psFitsWriteHeaderPtr(psMetadata *output, const psFits *fd);
+\end{verbatim}
+Write metadata into the header of a FITS image file.  The header is
+written to the end of the given file.  \tbd{Allow for overwriting a
+specific header? dangerous in anycase: the header and data must agree
+for the file to be valid...}  \tbd{consistency check?}  \tbd{function
+to remove non-FITS header entries?}
 
 \subsubsection{FITS Image I/O Functions}
