IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1691


Ignore:
Timestamp:
Sep 3, 2004, 6:23:50 PM (22 years ago)
Author:
Paul Price
Message:

Specification of configuration files, psMetadataParseConfig.

Location:
trunk/doc/pslib
Files:
2 edited

Legend:

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

    r1690 r1691  
    1 
     1\
    22\subsection{Changes from version 00 to version 01}
    33
     
    256256  dimension.
    257257\item Added \code{psLibVersion} (bug 156).
    258 \item Added specification of iterator (\code{which}) to
    259   \code{psMetadataSetIterator}.
     258\item Added specification of iterator to \code{psMetadataSetIterator}.
    260259\item Replaced \code{which} and \code{where} in \code{psMetadata} and
    261260  \code{psList} functions with \code{iterator} and \code{location},
     
    292291  specify a protocol for \code{stderr,stdout,none}).
    293292\item Leading dot in facility name for \code{psTrace} is optional.
     293\item Specification of configuration file format and parse function,
     294  \code{psMetadataParseConfig}.
    294295\end{itemize}
  • trunk/doc/pslib/psLibSDRS.tex

    r1690 r1691  
    1 %%% $Id: psLibSDRS.tex,v 1.106 2004-09-03 21:22:20 price Exp $
     1%%% $Id: psLibSDRS.tex,v 1.107 2004-09-04 04:23:21 price Exp $
    22\documentclass[panstarrs,spec]{panstarrs}
    33
     
    35183518Read header data from a FITS image file descriptor into a
    35193519\code{psMetadata} structure.
     3520
     3521
     3522\subsubsection{Configuration files}
     3523
     3524It will be necessary for the \PS{} system, in order to load
     3525pre-defined settings, to parse a configuration file into a
     3526\code{psMetadata} structure.  This shall be performed by the
     3527function \code{psMetadataParseConfig}, as described below.
     3528
     3529\begin{verbatim}
     3530int psMetadataParseConfig(psMetadata *md, const char *filename, bool overwrite);
     3531\end{verbatim}
     3532
     3533Given a previously allocated metadata container, \code{md}, and the
     3534name of a configuration file, \code{filename},
     3535\code{psMetadataParseConfig} shall parse the configuration file,
     3536placing the contained key/type/value/comment quads into the metadata,
     3537and returning the number of lines that failed to parse.  Multiple
     3538specifications of a key that haven't been declared (see below) are
     3539overwritten if and only if \code{overwrite} is \code{true}.
     3540
     3541The configuration file shall consist of plain text with
     3542key/type/value/comment quads on separate lines.  Blank lines,
     3543including those consisting solely of whitespace (both spaces and
     3544tabs), shall be ignored, as shall lines that commence with the comment
     3545character (a hash mark, \code{#}), either immediately at the start of
     3546the line, or preceded by whitespace.  The key/type/value/comment quads
     3547shall all lie on a single line, separated by whitespace.
     3548
     3549The key shall be first, possibly preceded on the line by whitespace
     3550which should not form part of the key.
     3551
     3552Next, to assist the casting of the value, shall be a string
     3553identifying the type of the value, which shall correspond to one of
     3554the simple types supported in \code{psMetadata}:
     3555\code{STRING,BOOL,S32,F32,F64}; \code{STR} may be used to abbreviate
     3556\code{STRING}.
     3557
     3558\tbd{May, in the future, require more types, including
     3559\code{U8,S16,C64}, which will necessitate updating the definition of
     3560\code{psMetadata}.}
     3561
     3562The value shall follow the type: strings may consist of multiple
     3563words, and shall have all leading and trailing whitespace removed;
     3564booleans shall simply be either \code{T} or \code{F}.
     3565
     3566Following the value may be an optional comment, preceded by a comment
     3567character (a hash mark, \code{#}), which in the case of a string
     3568value, serves to mark the end of the value, and for other types serves
     3569to identify the comment to the reader.  Only one comment character may
     3570be present on any single line (i.e., neither strings nor comments are
     3571permitted to contain the comment character).  The comment may consist
     3572of multiple words, and shall have leading and trailing whitespace
     3573removed.
     3574
     3575One wrinkle is the specification of vectors.  Keys for which the value
     3576is to be parsed as a vector shall be preceded immediately by a
     3577``vector symbol'', which we choose to be the ``at'' sign, \code{@}.
     3578In this case, the type shall be interpreted as the type for the
     3579vector, which may be any of the signed or unsigned integer or floating
     3580point types (\code{U8,U16,U32,U64,S8,S16,S32,S32,S64,F32,F64}) but not
     3581the complex floating point types; and the value shall consist of
     3582multiple numbers, separated either by a comma or whitespace.  These
     3583values shall populate a \code{psVector} of the appropriate type in the
     3584order in which they appear in the configuration file.
     3585
     3586\tbd{May add complex types, likely to be specified with values such as
     3587\code{1.23+4.56i} in the future.}
     3588
     3589An additional hurdle is the specification of keys that may be
     3590non-unique (such as the \code{COMMENT} keyword in a FITS header).
     3591These keys shall be specified in the configuration file as non-unique
     3592by specifying the key at the start of the line (possibly preceded by
     3593whitespace) and specifying the type as a ``multiple symbol'', which we
     3594choose to be an asterisk, \code{*}.  Everything else on the line shall
     3595be ignored.  A warning shall be produced when a key which has not been
     3596specified to be non-unique is repeated; in this case, the former value
     3597shall be overwritten if \code{overwrite} is \code{true}, otherwise the
     3598line shall be ignored and counted as one that could not be parsed.
     3599
     3600If a line does not conform to the rules laid out here, a warning shall
     3601be generated, it shall be ignored and counted as a line that could not
     3602be parsed.  The total number of lines that were not able to be parsed
     3603(including those that were ignored because \code{overwrite} is
     3604\code{false}, and any other parsing problems, but not including blank
     3605lines and comment lines) shall be returned by the function.
     3606
     3607Here are some examples of lines of a valid configuration file:
     3608\begin{verbatim}
     3609 Double     F64     1.23456789      # This is a comment
     3610Float F32 0.98765#This is a comment too
     3611        String  STR This is the string that forms the value #comment
     3612    #This is a comment line and is to be ignored
     3613boolean     BOOL    T # The value of `boolean' is `true'
     3614
     3615@primes U8  2,3 5 7,11,13 17 #   These are prime numbers
     3616comment * The rest of this line is ignored, but `comment' is set to be non-unique
     3617comment STR This
     3618comment STR      is
     3619comment STR         a
     3620comment STR           non-unique
     3621comment STR                      key
     3622Float F64 1.23456 # This generates a warning, and, if `overwrite' is `false', is ignored
     3623\end{verbatim}
     3624
     3625Of course, a real configuration file should look much nicer to humans
     3626than the above example, but PSLib must be able to parse such ugly
     3627files.
     3628
    35203629
    35213630\subsection{Detector and sky positions}
Note: See TracChangeset for help on using the changeset viewer.