IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4540


Ignore:
Timestamp:
Jul 12, 2005, 9:12:01 AM (21 years ago)
Author:
desonia
Message:

massive restructuring of codebase.

Location:
trunk/psLib/src
Files:
14 added
9 deleted
64 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/Makefile.am

    r4235 r4540  
    1 SUBDIRS = astronomy collections dataManip dataIO image sysUtils
    2 
    3 INCLUDES = \
    4         -I$(top_srcdir)/src/astronomy \
    5         -I$(top_srcdir)/src/collections \
    6         -I$(top_srcdir)/src/dataManip \
    7         -I$(top_srcdir)/src/dataIO \
    8         -I$(top_srcdir)/src/image \
    9         -I$(top_srcdir)/src/sysUtils \
    10         $(all_includes)
     1SUBDIRS = $(SRCDIRS)
    112
    123lib_LTLIBRARIES = libpslib.la
    13 bin_SCRIPTS = psParseErrorCodes
    144
    15 libpslib_la_LIBADD = \
    16         $(top_builddir)/src/astronomy/libpslibastronomy.la \
    17         $(top_builddir)/src/collections/libpslibcollections.la \
    18         $(top_builddir)/src/dataManip/libpslibdataManip.la \
    19         $(top_builddir)/src/dataIO/libpslibdataIO.la \
    20         $(top_builddir)/src/image/libpslibimage.la \
    21         $(top_builddir)/src/sysUtils/libpslibsysUtils.la
     5libpslib_la_LIBADD = $(SRCSUBLIBS)
    226
    237libpslib_la_SOURCES = psTest.c
    248libpslib_la_LDFLAGS = -version-info $(PSLIB_LT_VERSION)
    259
    26 EXTRA_DIST = mainpage.dox psErrorCodes.dat psTest.h psParseErrorCodes
     10
     11EXTRA_DIST = mainpage.dox psErrorCodes.dat psTest.h psErrorText.h.in psErrorText_en.dat
     12
     13BUILT_SOURCES = psErrorText.h
     14psErrorText.h: psErrorText_$(LANG).dat
     15        $(top_srcdir)/psParseErrorCodes --data=$? $@
    2716
    2817pslibincludedir = $(includedir)
  • trunk/psLib/src/astro/Makefile.am

    r4502 r4540  
    33AM_CFLAGS=$(CFLAGS) -DPS_CONFIG_FILE_DEFAULT=\"$(sysconfdir)/pslib/psTime.config\"
    44
    5 INCLUDES = `echo "$(SRCLIBS} | sed sed "s|\(\\w\+\)|-I\$(top_builddir)/src/\1|g"`
    6 
    75noinst_LTLIBRARIES = libpslibastro.la
    86libpslibastro_la_SOURCES = \
    97        psTime.c \
    10         psCoord.c
    11        
    12 BUILT_SOURCES = psAstroErrors.h
     8        psCoord.c
    139
    14 EXTRA_DIST = psAstroErrors_$(LANG).dat astro.i
    15 
    16 psAstroErrors.h: psAstroErrors_$(LANG).dat
    17         $(top_srcdir)/src/psParseErrorCodes --data=$? $@
     10EXTRA_DIST = astro.i
    1811
    1912pslibincludedir = $(includedir)
  • trunk/psLib/src/astro/psCoord.c

    r4401 r4540  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.78 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-06-27 20:38:11 $
     12*  @version $Revision: 1.79 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-07-12 19:12:00 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psError.h"
    2626#include "psLogMsg.h"
    27 #include "psAstronomyErrors.h"
    28 #include "psAstrometry.h"
     27#include "psErrorText.h"
    2928#include "psMatrix.h"
    3029#include <math.h>
  • trunk/psLib/src/astro/psTime.c

    r4409 r4540  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-06-28 20:17:52 $
     12 *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-07-12 19:12:00 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3131#include "psString.h"
    3232#include "psMetadata.h"
    33 #include "psMetadataIO.h"
     33#include "psMetadataConfig.h"
    3434#include "psLookupTable.h"
    3535#include "psConstants.h"
    36 #include "psAstronomyErrors.h"
     36#include "psErrorText.h"
    3737
    3838#include "config.h"
  • trunk/psLib/src/astronomy/psCoord.c

    r4401 r4540  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.78 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-06-27 20:38:11 $
     12*  @version $Revision: 1.79 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-07-12 19:12:00 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3030#include <math.h>
    3131#include <float.h>
    32 /******************************************************************************/
    33 /*  DEFINE STATEMENTS                                                         */
    34 /******************************************************************************/
    3532
    3633// Modified Julian Day 01/01/1900 00:00:00
     
    4037#define JULIAN_CENTURY 36525.0
    4138
    42 /******************************************************************************/
    43 /*  TYPE DEFINITIONS                                                          */
    44 /******************************************************************************/
    45 
    46 // None
    47 
    48 /*****************************************************************************/
    49 /*  GLOBAL VARIABLES                                                         */
    50 /*****************************************************************************/
    51 
    52 // None
    53 
    54 /*****************************************************************************/
    55 /*  FILE STATIC VARIABLES                                                    */
    56 /*****************************************************************************/
    57 
    58 // None
    59 
    60 /*****************************************************************************/
    61 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    62 /*****************************************************************************/
    63 
    64 /*****************************************************************************/
    65 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    66 /*****************************************************************************/
    6739static void planeFree(psPlane *p)
    6840{
    6941    // There are non dynamic allocated items
     42}
     43
     44static void sphereFree(psSphere *s)
     45{
     46    // There are non dynamic allocated items
     47}
     48
     49static void planeTransformFree(psPlaneTransform *pt)
     50{
     51    psFree(pt->x);
     52    psFree(pt->y);
     53}
     54
     55static void planeDistortFree(psPlaneDistort *pt)
     56{
     57    psFree(pt->x);
     58    psFree(pt->y);
     59}
     60
     61static void projectionFree(psProjection *p)
     62{
     63    // There are no dynamically allocated items
    7064}
    7165
     
    201195}
    202196
    203 
    204 static void sphereFree(psSphere *s)
    205 {
    206     // There are non dynamic allocated items
    207 }
    208 
    209197psSphere* psSphereAlloc(void)
    210198{
     
    215203}
    216204
    217 static void planeTransformFree(psPlaneTransform *pt)
    218 {
    219     psFree(pt->x);
    220     psFree(pt->y);
     205psSphereRot* psSphereRotAlloc(double alphaP,
     206                              double deltaP,
     207                              double phiP)
     208{
     209    psSphereRot* rot = psAlloc(sizeof(psSphereRot));
     210
     211    double cosDelta = cos(deltaP);
     212    double halfPhi = phiP / 2.0;
     213    double sinHalfPhi = sin(halfPhi);
     214
     215    // equations are directly from ADD
     216    double vx = cosDelta*cos(alphaP);
     217    double vy = cosDelta*sin(alphaP);
     218    double vz = sin(deltaP);
     219
     220    rot->q0 = vx*sinHalfPhi;
     221    rot->q1 = vy*sinHalfPhi;
     222    rot->q2 = vz*sinHalfPhi;
     223    rot->q3 = cos(halfPhi);
     224
     225    return rot;
     226}
     227
     228psSphereRot* psSphereRotQuat(double q0,
     229                             double q1,
     230                             double q2,
     231                             double q3)
     232{
     233    psSphereRot* rot = psAlloc(sizeof(psSphereRot));
     234
     235    double len = sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3);
     236    rot->q0 = q0 / len;
     237    rot->q1 = q1 / len;
     238    rot->q2 = q2 / len;
     239    rot->q3 = q3 / len;
     240
     241    return rot;
    221242}
    222243
     
    260281
    261282    return (out);
    262 }
    263 
    264 static void planeDistortFree(psPlaneDistort *pt)
    265 {
    266     psFree(pt->x);
    267     psFree(pt->y);
    268283}
    269284
     
    319334
    320335/******************************************************************************
    321 alpha is LONGITUDE
    322 delta is LATITUDE
    323  
    324     alphaP: Take the target pole in the source system; calculate its LONGITUDE
    325      in the target system.  That longitude is alphaP.
    326     DeltaP: Take the target pole in the source system; calculate its LATITUDE
    327      in the target system.  That longitude is deltaP.
    328     phiP:   This is the LONGITUDE of the ascending node in the target system.
    329  *****************************************************************************/
    330 psSphereTransform* psSphereTransformAlloc(psF64 alphaP,
    331         psF64 deltaP,
    332         psF64 phiP)
    333 {
    334     psSphereTransform* tmp = (psSphereTransform* ) psAlloc(sizeof(psSphereTransform));
    335 
    336     tmp->cosDeltaP = cos(deltaP);
    337     tmp->sinDeltaP = sin(deltaP);
    338     tmp->alphaP = alphaP;
    339     tmp->phiP = phiP;
    340 
    341     return (tmp);
    342 }
    343 
    344 /******************************************************************************
    345 XXX: Private Function.
    346  
    347 piNormalize(): take an input angle in radians and convert it to the range 0:2*PI.
    348  *****************************************************************************/
    349 psF32 piNormalize(psF32 angle)
    350 {
    351     while (angle < FLT_EPSILON) {
    352         angle+=M_PI*2;
    353     }
    354 
    355     while (angle >= (M_PI*2)) {
    356         angle-=M_PI*2;
    357     }
    358     return(angle);
    359 }
    360 
    361 /******************************************************************************
    362336XXX: We convert Right Ascension angles to the range 0:PI.  Is that acceptable?
    363337XXX: Should we do something for Declination as well?
    364338 *****************************************************************************/
    365 psSphere* psSphereTransformApply(psSphere* out,
    366                                  const psSphereTransform* transform,
    367                                  const psSphere* coord)
     339psSphere* psSphereRotApply(psSphere* out,
     340                           const psSphereRot* transform,
     341                           const psSphere* coord)
    368342{
    369343    PS_ASSERT_PTR_NON_NULL(transform, NULL);
     
    371345
    372346    if (out == NULL) {
    373         out = (psSphere* ) psAlloc(sizeof(psSphere));
    374     }
    375 
    376     psF64 alpha = coord->r;
    377     psF64 delta = coord->d;
    378     psF64 alphaMinusAlphaP = alpha - transform->alphaP;
    379 
    380     psF64 eq55 = (sin(delta) * transform->cosDeltaP) -
    381                  (cos(delta) * transform->sinDeltaP * sin(alphaMinusAlphaP));
    382     psF64 eq56 = (cos(delta) * transform->cosDeltaP * sin(alphaMinusAlphaP)) +
    383                  (sin(delta) * transform->sinDeltaP);
    384     psF64 eq57 = cos(delta) * cos(alphaMinusAlphaP);
    385 
    386     psF64 theta = asin(eq55);
    387     psF64 phi = atan2(eq56, eq57) + transform->phiP;
    388     out->r = piNormalize(phi);
    389     out->d = theta;
    390 
    391     return(out);
    392 }
    393 
    394 psSphereTransform* psSphereTransformICRSToEcliptic(psTime *time)
     347        out = psSphereAlloc();
     348    }
     349
     350
     351    // apply the transform by creating a new psSphereRot from the input coord
     352    // and combining it with the input transform (see ADD)
     353    psSphereRot* coordRot = psSphereRotAlloc(coord->r, coord->d, 0);
     354    coordRot->q3 = 0.0;
     355    coordRot = psSphereRotCombine(coordRot, transform, coordRot);
     356    // N.B., we can recycle coordRot right away due to the implementation of
     357    // psSphereRotCombine puts the values of coordRot in a local variable first
     358
     359    out->r = atan2(coordRot->q1,coordRot->q0);
     360    out->d = atan2(coordRot->q2,sqrt(coordRot->q1*coordRot->q1+coordRot->q0*coordRot->q0));
     361
     362    return out;
     363}
     364
     365psSphereRot* psSphereRotCombine(psSphereRot* out,
     366                                const psSphereRot* rot1,
     367                                const psSphereRot* rot2)
     368{
     369    PS_ASSERT_PTR_NON_NULL(rot1, NULL);
     370    PS_ASSERT_PTR_NON_NULL(rot2, NULL);
     371
     372    if (out == NULL) {
     373        out = (psSphereRot* ) psAlloc(sizeof(psSphereRot));
     374    }
     375
     376    double a0 = rot1->q0;
     377    double a1 = rot1->q1;
     378    double a2 = rot1->q2;
     379    double a3 = rot1->q3;
     380    double b0 = rot2->q0;
     381    double b1 = rot2->q1;
     382    double b2 = rot2->q2;
     383    double b3 = rot2->q3;
     384
     385    // following came from ADD
     386    out->q0 = b3*a0 + b2*a1 - b1*a2 + b0*a3;
     387    out->q1 = b3*a1 - b2*a0 + b1*a3 + b0*a2;
     388    out->q2 = b3*a2 + b2*a3 + b1*a0 - b0*a1;
     389    out->q3 = b3*a3 - b3*a2 - b1*a1 - b0*a0;
     390
     391    return out;
     392}
     393
     394psSphereRot *psSphereRotInvert(psSphereRot *rot)
     395{
     396    PS_ASSERT_PTR_NON_NULL(rot, NULL);
     397
     398    double norm = sqrt(rot->q0*rot->q0 + rot->q1*rot->q1 + rot->q2*rot->q2 + rot->q3*rot->q3);
     399    rot->q1 = -rot->q1 / norm;
     400    rot->q2 = -rot->q2 / norm;
     401    rot->q3 = -rot->q3 / norm;
     402
     403    return rot;
     404}
     405
     406psSphereRot* psSphereRotICRSToEcliptic(const psTime *time)
    395407{
    396408    psF64 T;
     
    421433
    422434    // Don't neglect the minus sign on deltaP (bug 244):
    423     return (psSphereTransformAlloc(alphaP, deltaP, phiP));
    424 }
    425 
    426 
    427 psSphereTransform* psSphereTransformEclipticToICRS(psTime *time)
     435    return (psSphereRotAlloc(alphaP, deltaP, phiP));
     436}
     437
     438
     439psSphereRot* psSphereRotEclipticToICRS(const psTime *time)
    428440{
    429441    psF64 T;
     
    453465    psF64 phiP = 0.0;
    454466
    455     return (psSphereTransformAlloc(alphaP, -deltaP, phiP));
     467    return (psSphereRotAlloc(alphaP, -deltaP, phiP));
    456468}
    457469
    458470// XXX: This is bug 245: alphaP swaps with phiP from psSphereTransformGalacticToICRS()
    459 psSphereTransform* psSphereTransformGalacticToICRS(void)
     471psSphereRot* psSphereRotGalacticToICRS(void)
    460472{
    461473    psF64 alphaP = DEG_TO_RAD(32.93192);
     
    463475    psF64 phiP = DEG_TO_RAD(282.85948);
    464476
    465     return (psSphereTransformAlloc(alphaP, deltaP, phiP));
    466 }
    467 
    468 psSphereTransform* psSphereTransformICRSToGalactic(void)
     477    return (psSphereRotAlloc(alphaP, deltaP, phiP));
     478}
     479
     480psSphereRot* psSphereRotICRSToGalactic(void)
    469481{
    470482    psF64 alphaP = DEG_TO_RAD(282.85948);
     
    472484    psF64 phiP = DEG_TO_RAD(32.93192);
    473485
    474     return (psSphereTransformAlloc(alphaP, deltaP, phiP));
    475 }
    476 
    477 void projectionFree(psProjection *p)
    478 {
    479     // There are no dynamically allocated items
     486    return (psSphereRotAlloc(alphaP, deltaP, phiP));
    480487}
    481488
     
    837844
    838845    // Create transform with proper constants
    839     psSphereTransform *tmpST = psSphereTransformAlloc(alphaP, deltaP, phiP);
     846    psSphereRot* tmpST = psSphereRotAlloc(alphaP, deltaP, phiP);
    840847
    841848    // Apply transform to coordinates
    842     psSphere *out = psSphereTransformApply(NULL, tmpST, coords);
     849    psSphere *out = psSphereRotApply(NULL, tmpST, coords);
    843850
    844851    psFree(tmpST);
  • trunk/psLib/src/astronomy/psCoord.h

    r4401 r4540  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-06-27 20:38:11 $
     12*  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-07-12 19:12:00 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2424#include "psList.h"
    2525#include "psFunctions.h"
    26 #include "psTime.h"
     26// N.B. inclusion of psTime.h was done to after the typedefs to handle cross-dependency of typedefs
    2727
    2828/// @addtogroup CoordinateTransform
     
    3838typedef struct
    3939{
    40     double x;                   ///< x position
    41     double y;                   ///< y position
    42     double xErr;                ///< Error in x position
    43     double yErr;                ///< Error in y position
     40    double x;                          ///< x position
     41    double y;                          ///< y position
     42    double xErr;                       ///< Error in x position
     43    double yErr;                       ///< Error in y position
    4444}
    4545psPlane;
     
    5252 *
    5353 */
    54 typedef struct psSphere
    55 {
    56     double r;                   ///< RA
    57     double d;                   ///< Dec
    58     double rErr;                ///< Error in RA
    59     double dErr;                ///< Error in Dec
     54typedef struct
     55{
     56    double r;                          ///< RA
     57    double d;                          ///< Dec
     58    double rErr;                       ///< Error in RA
     59    double dErr;                       ///< Error in Dec
    6060}
    6161psSphere;
     62
     63/** Cubic Coordinate System
     64 *
     65 */
     66typedef struct
     67{
     68    double x;                          ///< cos (DEC) cos (RA)
     69    double y;                          ///< cos (DEC) sic (RA)
     70    double z;                          ///< sin (DEC)
     71    double xErr;                       ///< Error in x
     72    double yErr;                       ///< Error in y
     73    double zErr;                       ///< Error in z
     74}
     75psCube;
     76
     77/** Spherical rotations represent coordinate transformation in 3-D, as well as
     78 *  the effects of precession and nutation.  The structure contains the
     79 *  elements of a quaternion to represent the spherical rotational.
     80 *
     81 */
     82typedef struct
     83{
     84    double q0;                         ///< first element of the quaternion
     85    double q1;                         ///< second element of the quaternion
     86    double q2;                         ///< third element of the quaternion
     87    double q3;                         ///< fourth element of the quaternion
     88}
     89psSphereRot;
    6290
    6391/** 2D Polynomial Transform
     
    94122}
    95123psPlaneDistort;
    96 
    97 /** Spherical Transform Definition
    98  *
    99  *  We need to be able to convert between ICRS, Galactic and Ecliptic
    100  *  coordinates, and potentially between arbitrary spherical coordinate
    101  *  systems. All of these basic spherical transformations represent rotations
    102  *  of the spherical coordinate reference. We specify a general
    103  *  transformation function which takes a structure, psSphereTransform,
    104  *  defining the transformation between two spherical coordinate systems
    105  *
    106  */
    107 typedef struct
    108 {
    109     double alphaP;                    ///< Longitude of the target system pole in the source system
    110     double cosDeltaP;                 ///< Cosine of target pole latitude in the source system
    111     double sinDeltaP;                 ///< Sine of target pole latitude in the source system
    112     double phiP;                      ///< Longitude of the ascending node in the target system
    113 }
    114 psSphereTransform;
    115124
    116125/** Projection type for projection/deprojection
     
    167176} psSphereOffsetUnit;
    168177
     178#include "psTime.h"
     179
    169180/** Allocates a psPlane
    170181 *
     
    178189 *  @return psSphere*     resulting sphere structure.
    179190 */
    180 
    181191psSphere* psSphereAlloc(void);
    182192
     193/** psSphereRot allocator which defines the rotation in terms of the coordinate
     194 *  of the pole and the rotation about that pole.
     195 *
     196 *  @return psSphereRot*       Newly allocated psSphereRot object
     197 */
     198psSphereRot* psSphereRotAlloc(
     199    double alphaP,
     200    double deltaP,
     201    double phiP
     202);
     203
     204/** psSphereRot allocator which defines the rotation from the elements of the
     205 *  quaternion.
     206 *
     207 *  @return psSphereRot*       Newly allocated psSphereRot object
     208 */
     209psSphereRot* psSphereRotQuat(
     210    double q0,
     211    double q1,
     212    double q2,
     213    double q3
     214);
    183215
    184216/** Allocates a psPlaneTransform transform.
     
    186218 *  @return psPlaneTransform*     resulting plane transform
    187219 */
    188 
    189220psPlaneTransform* psPlaneTransformAlloc(
    190221    int n1,                            ///< The order of the x term in the transform.
     
    227258);
    228259
    229 /** Allocator for psSphereTransform
    230  *
    231  *  @return psSphereTransform*         newly allocated struct
    232  */
    233 
    234 psSphereTransform* psSphereTransformAlloc(
    235     double alphaP,                      ///< north pole latitude
    236     double deltaP,                      ///< north pole longitude?
    237     double phiP                         ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).
    238 );
    239 
    240 /** Applies the psSphereTransform transform for a specified coordinate
     260
     261/** Applies the psSphereRot transform for a specified coordinate
    241262 *
    242263 *  @return psSphere*      resulting coordinate based on transform
    243264 */
    244 psSphere* psSphereTransformApply(
     265psSphere* psSphereRotApply(
    245266    psSphere* out,                     ///< a psSphere to recycle.  If NULL, a new one is generated.
    246     const psSphereTransform* transform,///< the transform to apply
     267    const psSphereRot* transform,      ///< the transform to apply
    247268    const psSphere* coord              ///< the coordinate to apply the transform above.x
     269);
     270
     271/** Combines two rotations to produce a single rotation which is equivalent of
     272 *  applying the first rotation and then the second.
     273 *
     274 *  @return psSphereRot*               new psSphereRot transform
     275 */
     276psSphereRot* psSphereRotCombine(
     277    psSphereRot* out,
     278    const psSphereRot* rot1,
     279    const psSphereRot* rot2
     280);
     281
     282/** Inverts a psSphereRot's rotation.
     283 *
     284 *  @return psSphereRot*               The inverted psSphereRot
     285 */
     286psSphereRot* psSphereRotInvert(
     287    psSphereRot* rot                   ///< the psSphereRot to invert
    248288);
    249289
     
    251291 *  coordinate systems.
    252292 *
    253  *  @return psSphereTransform*     transform for ICRS->Ecliptic coordinate systems
    254  */
    255 psSphereTransform* psSphereTransformICRSToEcliptic(
    256     psTime *time                        ///< the time for which the resulting transform will be valid
     293 *  @return psSphereRot*               transform for ICRS->Ecliptic coordinate systems
     294 */
     295psSphereRot* psSphereRotICRSToEcliptic(
     296    const psTime* time                 ///< the time for which the resulting transform will be valid
    257297);
    258298
     
    260300 *  coordinate systems.
    261301 *
    262  *  @return psSphereTransform*     transform for Ecliptic->ICRS coordinate systems
    263  */
    264 psSphereTransform* psSphereTransformEclipticToICRS(
    265     psTime *time                        ///< the time for which the resulting transform will be valid
     302 *  @return psSphereRot*               transform for Ecliptic->ICRS coordinate systems
     303 */
     304psSphereRot* psSphereRotEclipticToICRS(
     305    const psTime* time                 ///< the time for which the resulting transform will be valid
    266306);
    267307
     
    270310 *
    271311 */
    272 psSphereTransform* psSphereTransformICRSToGalactic(void);
     312psSphereRot* psSphereRotICRSToGalactic(void);
    273313
    274314/** Creates the appropriate transform for converting from Galactic to ICRS
     
    276316 *
    277317 */
    278 psSphereTransform* psSphereTransformGalacticToICRS(void);
     318psSphereRot* psSphereRotGalacticToICRS(void);
    279319
    280320/** Allocates memory for a psProjection structure
  • trunk/psLib/src/astronomy/psTime.c

    r4409 r4540  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-06-28 20:17:52 $
     12 *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-07-12 19:12:00 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    887887}
    888888
    889 struct psSphere* p_psTimeGetPoleCoords(const psTime* time)
     889psSphere* p_psTimeGetPoleCoords(const psTime* time)
    890890{
    891891    psU32 nTables = 3;
     
    896896    psF64 c = 0.0;
    897897    psF64 mjdPred = 0.0;
    898     struct psSphere* output = NULL;
     898    psSphere* output = NULL;
    899899    psLookupStatusType xStatus = PS_LOOKUP_SUCCESS;
    900900    psLookupStatusType yStatus = PS_LOOKUP_SUCCESS;
     
    908908    PS_ASSERT_INT_WITHIN_RANGE(time->nsec,0,(psU32)((1e9)-1),NULL);
    909909
    910     if(time->type != PS_TIME_TAI)
    911     {
     910    if(time->type != PS_TIME_TAI) {
    912911        psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psTime_TYPE_INCORRECT, time->type);
    913912        return NULL;
     
    922921
    923922    // Value could not be found through table lookup and interpolation
    924     if(xStatus==PS_LOOKUP_PAST_TOP && yStatus==PS_LOOKUP_PAST_TOP)
    925     {
     923    if(xStatus==PS_LOOKUP_PAST_TOP && yStatus==PS_LOOKUP_PAST_TOP) {
    926924
    927925        // Date too earlier for tables. Get default polar coodinate values from metadata, and issue warning.
     
    942940        y = tableMetadataItem->data.F64;
    943941
    944     } else if(xStatus==PS_LOOKUP_PAST_BOTTOM && yStatus==PS_LOOKUP_PAST_BOTTOM)
    945     {
     942    } else if(xStatus==PS_LOOKUP_PAST_BOTTOM && yStatus==PS_LOOKUP_PAST_BOTTOM) {
    946943
    947944        /* Date too late for tables. Issue warning and use following formulae for predicting
     
    1000997            yp->data.F64[4]*sin(c);
    1001998
    1002     } else if(xStatus!=PS_LOOKUP_SUCCESS || yStatus!=PS_LOOKUP_SUCCESS)
    1003     {
     999    } else if(xStatus!=PS_LOOKUP_SUCCESS || yStatus!=PS_LOOKUP_SUCCESS) {
    10041000        psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psTime_INTERPOLATION_FAILED);
    10051001        return NULL;
  • trunk/psLib/src/astronomy/psTime.h

    r4409 r4540  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-06-28 20:17:52 $
     13 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-07-12 19:12:00 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2525
    2626#include "psType.h"
    27 #include "psImage.h"
    28 
    29 struct psSphere;
     27// N.B. inclusion of psCoord.h was done to after the typedefs to handle cross-dependency of typedefs
    3028
    3129/// @addtogroup Time
    3230/// @{
    33 
    3431
    3532/** Time type.
     
    6966psTime;
    7067
     68#include "psCoord.h"
     69#include "psImage.h"
    7170
    7271/** Initialize time data.
     
    161160 *  @return  psSphere*: Spherical coordinates of Earth's polar axias.
    162161 */
    163 struct psSphere* p_psTimeGetPoleCoords(
    164                 const psTime *time      ///< psTime determine polar orientation.
    165             );
     162psSphere* p_psTimeGetPoleCoords(
     163    const psTime *time      ///< psTime determine polar orientation.
     164);
    166165
    167166/** Calculate the number of leapseconds between two times.
  • trunk/psLib/src/db/Makefile.am

    r4502 r4540  
    11#Makefile for db functions of psLib
    22#
    3 INCLUDES = `echo "$(SRCLIBS} | sed sed "s|\(\\w\+\)|-I\$(top_builddir)/src/\1|g"`
    4 
    53noinst_LTLIBRARIES = libpslibdb.la
    64
    7 libpslibdataIO_la_SOURCES = \
     5libpslibdb_la_SOURCES = \
    86        psDB.c
    97
    10 
    11 BUILT_SOURCES = psDBErrors.h
    12 EXTRA_DIST = psDBErrors_en.dat db.i
    13 
    14 psFileUtilsErrors.h: psFileUtilsErrors.dat
    15         $(top_srcdir)/src/psParseErrorCodes --data=$? $@
     8EXTRA_DIST = db.i
    169
    1710pslibincludedir = $(includedir)
    1811pslibinclude_HEADERS = \
    19         psLookupTable.h \
    20         psFits.h \
    2112        psDB.h
    2213
  • trunk/psLib/src/db/psDB.c

    r4430 r4540  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-06-29 20:33:37 $
     14 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-07-12 19:12:00 $
    1616 *
    1717 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    3535#include "psError.h"
    3636#include "psString.h"
    37 #include "psFileUtilsErrors.h"
     37#include "psErrorText.h"
    3838
    3939typedef struct
  • trunk/psLib/src/db/psDB.h

    r4429 r4540  
    1010 *  @author Joshua Hoblitt
    1111 *
    12  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-06-29 19:43:55 $
     12 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-07-12 19:12:00 $
    1414 *
    1515 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    3434typedef struct
    3535{
    36     void* mysql;   ///< MySQL database handle
     36    void* mysql;                       ///< MySQL database handle
    3737}
    3838psDB;
     
    4444 */
    4545psDB *psDBInit(
    46     const char *host,                   ///< Database server hostname
    47     const char *user,                   ///< Database username
    48     const char *passwd,                 ///< Database password
    49     const char *dbname                  ///< Database namespace
     46    const char *host,                  ///< Database server hostname
     47    const char *user,                  ///< Database username
     48    const char *passwd,                ///< Database password
     49    const char *dbname                 ///< Database namespace
    5050);
    5151
     
    5353 */
    5454void psDBCleanup(
    55     psDB *dbh                           ///< Database handle
     55    psDB *dbh                          ///< Database handle
    5656);
    5757
     
    6161 */
    6262bool psDBCreate(
    63     psDB *dbh,                          ///< Database handle
    64     const char *dbname                  ///< New database namespace
     63    psDB *dbh,                         ///< Database handle
     64    const char *dbname                 ///< New database namespace
    6565);
    6666
     
    7070 */
    7171bool psDBChange(
    72     psDB *dbh,                          ///< Database handle
    73     const char *dbname                  ///< Database namespace
     72    psDB *dbh,                         ///< Database handle
     73    const char *dbname                 ///< Database namespace
    7474);
    7575
     
    7979 */
    8080bool psDBDrop(
    81     psDB *dbh,                          ///< Database handle
    82     const char *dbname                  ///< Database namespace
     81    psDB *dbh,                         ///< Database handle
     82    const char *dbname                 ///< Database namespace
    8383);
    8484
     
    9292 */
    9393bool p_psDBRunQuery(
    94     psDB *dbh,                          ///< Database handle
    95     const char *format                  ///< SQL string to execute
     94    psDB *dbh,                         ///< Database handle
     95    const char *format                 ///< SQL string to execute
    9696);
    9797
     
    117117 */
    118118bool psDBCreateTable(
    119     psDB *dbh,                          ///< Database handle
    120     const char *tableName,              ///< Table name
    121     const psMetadata *md                ///< Column names, types, and indexes
     119    psDB *dbh,                         ///< Database handle
     120    const char *tableName,             ///< Table name
     121    const psMetadata *md               ///< Column names, types, and indexes
    122122);
    123123
     
    140140 */
    141141psArray *psDBSelectColumn(
    142     psDB *dbh,                          ///< Database handle
    143     const char *tableName,              ///< Table name
    144     const char *col,                    ///< Column name
    145     unsigned long long limit                   ///< Maximum number of elements to return
     142    psDB *dbh,                         ///< Database handle
     143    const char *tableName,             ///< Table name
     144    const char *col,                   ///< Column name
     145    unsigned long long limit           ///< Maximum number of elements to return
    146146);
    147147
     
    155155 */
    156156psVector *psDBSelectColumnNum(
    157     psDB *dbh,                          ///< Database handle
    158     const char *tableName,              ///< Table name
    159     const char *col,                    ///< Column name
     157    psDB *dbh,                         ///< Database handle
     158    const char *tableName,             ///< Table name
     159    const char *col,                   ///< Column name
    160160    psElemType type,                   ///< Resulting psVector type
    161     unsigned long long limit            ///< Maximum number of elements to return
     161    unsigned long long limit           ///< Maximum number of elements to return
    162162);
    163163
     
    177177 */
    178178psArray *psDBSelectRows(
    179     psDB *dbh,                          ///< Database handle
    180     const char *tableName,              ///< Table name
    181     const psMetadata *where,            ///< Row match criteria
    182     unsigned long long limit            ///< Maximum number of elements to return
     179    psDB *dbh,                         ///< Database handle
     180    const char *tableName,             ///< Table name
     181    const psMetadata *where,           ///< Row match criteria
     182    unsigned long long limit           ///< Maximum number of elements to return
    183183);
    184184
     
    195195 */
    196196bool psDBInsertOneRow(
    197     psDB *dbh,                          ///< Database handle
    198     const char *tableName,              ///< Table name
    199     const psMetadata *row               ///< Row description
     197    psDB *dbh,                         ///< Database handle
     198    const char *tableName,             ///< Table name
     199    const psMetadata *row              ///< Row description
    200200);
    201201
     
    210210 */
    211211bool psDBInsertRows(
    212     psDB *dbh,                          ///< Database handle
    213     const char *tableName,              ///< Table name
    214     const psArray *rowSet                     ///< Set of rows to insert
     212    psDB *dbh,                         ///< Database handle
     213    const char *tableName,             ///< Table name
     214    const psArray *rowSet              ///< Set of rows to insert
    215215);
    216216
     
    223223 */
    224224psArray *psDBDumpRows(
    225     psDB *dbh,                          ///< Database handle
    226     const char *tableName               ///< Table name
     225    psDB *dbh,                         ///< Database handle
     226    const char *tableName              ///< Table name
    227227);
    228228
     
    236236 */
    237237psMetadata *psDBDumpCols(
    238     psDB *dbh,                          ///< Database handle
    239     const char *tableName               ///< Table name
     238    psDB *dbh,                         ///< Database handle
     239    const char *tableName              ///< Table name
    240240);
    241241
     
    252252 */
    253253psS64 psDBUpdateRows(
    254     psDB *dbh,                          ///< Database handle
    255     const char *tableName,              ///< Table name
    256     const psMetadata *where,            ///< Row match criteria
    257     const psMetadata *values            ///< new field values
     254    psDB *dbh,                         ///< Database handle
     255    const char *tableName,             ///< Table name
     256    const psMetadata *where,           ///< Row match criteria
     257    const psMetadata *values           ///< new field values
    258258);
    259259
     
    269269 */
    270270psS64 psDBDeleteRows(
    271     psDB *dbh,                          ///< Database handle
    272     const char *tableName,              ///< Table name
    273     const psMetadata *where,            ///< Row match criteria
    274     unsigned long long limit            ///< Maximum number of rows to delete
     271    psDB *dbh,                         ///< Database handle
     272    const char *tableName,             ///< Table name
     273    const psMetadata *where,           ///< Row match criteria
     274    unsigned long long limit           ///< Maximum number of rows to delete
    275275);
    276276
  • trunk/psLib/src/fft/Makefile.am

    r4446 r4540  
    1 #Makefile for dataManip functions of psLib
     1#Makefile for fft functions of psLib
    22#
    3 INCLUDES = \
    4         -I$(top_srcdir)/src/astro \
    5         -I$(top_srcdir)/src/db \
    6         -I$(top_srcdir)/src/fft \
    7         -I$(top_srcdir)/src/fits \
    8         -I$(top_srcdir)/src/imageops \
    9         -I$(top_srcdir)/src/math \
    10         -I$(top_srcdir)/src/mathtypes \
    11         -I$(top_srcdir)/src/sys \
    12         -I$(top_srcdir)/src/types \
    13         -I$(top_srcdir)/src/xml \
    14         $(all_includes)
     3noinst_LTLIBRARIES = libpslibfft.la
    154
    16 noinst_LTLIBRARIES = libpslibdataManip.la
     5libpslibfft_la_SOURCES = \
     6        psImageFFT.c \
     7        psVectorFFT.c
    178
    18 libpslibdataManip_la_SOURCES = psUnaryOp.c psBinaryOp.c psStats.c \
    19                 psFunctions.c psMatrix.c psVectorFFT.c psMinimize.c psRandom.c
    20 
    21 BUILT_SOURCES = psDataManipErrors.h
    22 EXTRA_DIST = psDataManipErrors.dat psDataManipErrors.h dataManip.i
    23 
    24 psDataManipErrors.h: psDataManipErrors.dat
    25         $(top_srcdir)/src/psParseErrorCodes --data=$? $@
     9EXTRA_DIST = fft.i
    2610
    2711pslibincludedir = $(includedir)
    2812pslibinclude_HEADERS = \
    29         psConstants.h \
    30         psStats.h  \
    31         psFunctions.h \
    32         psMatrix.h \
    33     psBinaryOp.h \
    34     psUnaryOp.h \
    3513        psVectorFFT.h \
    36         psMinimize.h \
    37         psRandom.h
     14        psImageFFT.h
    3815
  • trunk/psLib/src/fft/psImageFFT.h

    r4316 r4540  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-06-18 03:13:02 $
     9 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-07-12 19:12:01 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3333psImage* psImageFFT(
    3434    psImage* out,                      ///< a psImage to recycle.  If NULL, a new psImage is made.
    35     const psImage* image,                 ///< the psImage to apply transform to
     35    const psImage* image,              ///< the psImage to apply transform to
    3636    psFFTFlags direction               ///< the direction of the transform
    3737);
     
    7979 */
    8080psImage* psImagePowerSpectrum(
    81     psImage* out,                       ///< a psImage to recycle.  If NULL, a new psImage is made.
    82     const psImage* in                   ///< the psImage to power spectrum of
     81    psImage* out,                      ///< a psImage to recycle.  If NULL, a new psImage is made.
     82    const psImage* in                  ///< the psImage to power spectrum of
    8383);
    8484
  • trunk/psLib/src/fft/psVectorFFT.c

    r3970 r4540  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-05-19 02:09:39 $
     7 *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-07-12 19:12:01 $
    99 *
    1010 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2222#include "psLogMsg.h"
    2323
    24 #include "psDataManipErrors.h"
     24#include "psErrorText.h"
    2525
    2626#define P_FFTW_PLAN_RIGOR FFTW_ESTIMATE
  • trunk/psLib/src/fits/Makefile.am

    r4446 r4540  
    1 #Makefile for dataIO functions of psLib
     1#Makefile for fits functions of psLib
    22#
    3 INCLUDES = \
    4         -I$(top_srcdir)/src/astro \
    5         -I$(top_srcdir)/src/db \
    6         -I$(top_srcdir)/src/fft \
    7         -I$(top_srcdir)/src/fits \
    8         -I$(top_srcdir)/src/imageops \
    9         -I$(top_srcdir)/src/math \
    10         -I$(top_srcdir)/src/mathtypes \
    11         -I$(top_srcdir)/src/sys \
    12         -I$(top_srcdir)/src/types \
    13         -I$(top_srcdir)/src/xml \
    14         $(all_includes)
     3noinst_LTLIBRARIES = libpslibfits.la
    154
    16 noinst_LTLIBRARIES = libpslibdataIO.la
     5libpslibfits_la_SOURCES = \
     6        psFits.c
    177
    18 libpslibdataIO_la_SOURCES = \
    19         psLookupTable.c \
    20         psFits.c \
    21         psDB.c
    22 
    23 
    24 BUILT_SOURCES = psFileUtilsErrors.h
    25 EXTRA_DIST = psFileUtilsErrors.dat psFileUtilsErrors.h dataIO.i
    26 
    27 psFileUtilsErrors.h: psFileUtilsErrors.dat
    28         $(top_srcdir)/src/psParseErrorCodes --data=$? $@
     8EXTRA_DIST = fits.i
    299
    3010pslibincludedir = $(includedir)
    3111pslibinclude_HEADERS = \
    32         psLookupTable.h \
    33         psFits.h \
    34         psDB.h
    35 
     12        psFits.h
  • trunk/psLib/src/fits/psFits.c

    r4392 r4540  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-06-25 02:02:05 $
     9 *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-07-12 19:12:01 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1818#include "string.h"
    1919#include "psError.h"
    20 #include "psFileUtilsErrors.h"
     20#include "psErrorText.h"
    2121#include "psImageStructManip.h"
    2222#include "psMemory.h"
  • trunk/psLib/src/imageops/Makefile.am

    r4446 r4540  
    1 #Makefile for image functions of psLib
     1#Makefile for image operation functions of psLib
    22#
    3 INCLUDES = \
    4         -I$(top_srcdir)/src/astro \
    5         -I$(top_srcdir)/src/db \
    6         -I$(top_srcdir)/src/fft \
    7         -I$(top_srcdir)/src/fits \
    8         -I$(top_srcdir)/src/imageops \
    9         -I$(top_srcdir)/src/math \
    10         -I$(top_srcdir)/src/mathtypes \
    11         -I$(top_srcdir)/src/sys \
    12         -I$(top_srcdir)/src/types \
    13         -I$(top_srcdir)/src/xml \
    14         $(all_includes)
     3noinst_LTLIBRARIES = libpslibimageops.la
    154
    16 noinst_LTLIBRARIES = libpslibimage.la
    17 
    18 libpslibimage_la_SOURCES = \
    19         psImage.c \
     5libpslibimageops_la_SOURCES = \
     6        psImageConvolve.c \
     7        psImageGeomManip.c \
    208        psImagePixelExtract.c \
    21         psImageStructManip.c \
    22         psImageGeomManip.c \
    239        psImagePixelManip.c \
    2410        psImageStats.c \
    25         psImageFFT.c \
    26         psImageConvolve.c
     11        psImageStructManip.c
    2712
    28 BUILT_SOURCES = psImageErrors.h
    29 EXTRA_DIST = psImageErrors.dat psImageErrors.h image.i
    30 
    31 psImageErrors.h: psImageErrors.dat
    32         $(top_srcdir)/src/psParseErrorCodes --data=$? $@
     13EXTRA_DIST = imageops.i
    3314
    3415pslibincludedir = $(includedir)
    3516pslibinclude_HEADERS = \
    36         psImage.h \
     17        psImageConvolve.h \
     18        psImageGeomManip.h \
    3719        psImagePixelExtract.h \
    38         psImageStructManip.h \
    39         psImageGeomManip.h \
    4020        psImagePixelManip.h \
    4121        psImageStats.h \
    42         psImageFFT.h \
    43         psImageConvolve.h
     22        psImageStructManip.h
  • trunk/psLib/src/imageops/psImageConvolve.c

    r4392 r4540  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-06-25 02:02:05 $
     7 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-07-12 19:12:01 $
    99 *
    1010 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6565    result->image = psImageAlloc(numCols,numRows,PS_TYPE_KERNEL);
    6666    memset(result->image->rawDataBuffer,0,numCols*numRows*PSELEMTYPE_SIZEOF(PS_TYPE_KERNEL));
    67     result->p_kernelRows = psAlloc(sizeof(psKernelType*)*numRows);
    68 
    69     psKernelType** kernelRows = result->p_kernelRows;
    70     psKernelType** imageRows = result->image->data.PS_TYPE_KERNEL_DATA;
     67    result->p_kernelRows = psAlloc(sizeof(float*)*numRows);
     68
     69    float** kernelRows = result->p_kernelRows;
     70    float** imageRows = result->image->data.PS_TYPE_KERNEL_DATA;
    7171    for (psS32 i = 0; i < numRows; i++) {
    7272        kernelRows[i] = imageRows[i] - xMin;
     
    103103    psS32 yMax = 0;
    104104    psS32 length = 0;
    105     psKernelType normalizeTime = 1.0;  // fraction of total time for each shift clock
     105    float normalizeTime = 1.0;  // fraction of total time for each shift clock
    106106    psKernel* result = NULL;
    107     psKernelType** kernel = NULL;
     107    float** kernel = NULL;
    108108
    109109    // got non-NULL vectors?
     
    170170        } \
    171171        \
    172         normalizeTime = 1.0 / (psKernelType)(tShiftData[length-1]); \
     172        normalizeTime = 1.0 / (float)(tShiftData[length-1]); \
    173173        result = psKernelAlloc(xMin,xMax,yMin,yMax); \
    174174        kernel = result->kernel; \
     
    180180            y = lastY - yShiftData[i]; \
    181181            \
    182             kernel[y][x] += (psKernelType)t / (psKernelType)lastT; \
     182            kernel[y][x] += (float)t / (float)lastT; \
    183183            prevT = tShiftData[i]; \
    184184        } \
     
    216216        kernel = result->kernel; \
    217217        \
    218         normalizeTime = 1.0 / (psKernelType)t; \
     218        normalizeTime = 1.0 / (float)t; \
    219219        x = 0; \
    220220        y = 0; \
    221221        for (psS32 i = length-1; i >= 0; i--) { \
    222             kernel[y][x] += (psKernelType)(tShiftData[i]) * normalizeTime; \
     222            kernel[y][x] += (float)(tShiftData[i]) * normalizeTime; \
    223223            x -= xShiftData[i]; \
    224224            y -= yShiftData[i]; \
     
    296296    psS32 yMin = kernel->yMin;
    297297    psS32 yMax = kernel->yMax;
    298     psKernelType** kData = kernel->kernel;
     298    float** kData = kernel->kernel;
    299299
    300300    // make the output image to the proper size and type
     
    399399        // pad the kernel to the same size of paddedImage
    400400        psImage* paddedKernel = psImageAlloc(paddedCols,paddedRows,PS_TYPE_KERNEL);
    401         memset(paddedKernel->data.U8[0],0,sizeof(psKernelType)*numCols*numRows); // zero-out image
     401        memset(paddedKernel->data.U8[0],0,sizeof(float)*numCols*numRows); // zero-out image
    402402        psS32 yMax = kernel->yMax;
    403403        psS32 xMax = kernel->xMax;
     
    407407                padRow += paddedRows;
    408408            }
    409             psKernelType* padData = paddedKernel->data.PS_TYPE_KERNEL_DATA[padRow];
    410             psKernelType* kernelRow = kernel->kernel[row];
     409            float* padData = paddedKernel->data.PS_TYPE_KERNEL_DATA[padRow];
     410            float* kernelRow = kernel->kernel[row];
    411411            for (psS32 col = kernel->xMin; col <= xMax; col++) {
    412412                if (col < 0) {
  • trunk/psLib/src/imageops/psImageConvolve.h

    r4316 r4540  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-06-18 03:13:02 $
     9 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-07-12 19:12:01 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2525
    2626/** Kernel Type
    27  * 
     27 *
    2828 *  A floating-point data type used for storing kernel data.
    29  * 
     29 *
    3030 */
    31 typedef psF32 psKernelType;
     31//typedef float psKernelType;
    3232
    3333/** A convolution kernel */
     
    3535{
    3636    psImage* image;                    ///< Kernel data, in the form of an image
    37     psS32 xMin;                          ///< Most negative x index
    38     psS32 yMin;                          ///< Most negative y index
    39     psS32 xMax;                          ///< Most positive x index
    40     psS32 yMax;                          ///< Most positive y index
    41     psKernelType** kernel;             ///< Pointer to the kernel data
    42     psKernelType** p_kernelRows;       ///< Pointer to the rows of the kernel data; not intended for user use.
     37    int xMin;                          ///< Most negative x index
     38    int yMin;                          ///< Most negative y index
     39    int xMax;                          ///< Most positive x index
     40    int yMax;                          ///< Most positive y index
     41    float** kernel;                    ///< Pointer to the kernel data
     42    float** p_kernelRows;              ///< Pointer to the rows of the kernel data; not intended for user use.
    4343}
    4444psKernel;
  • trunk/psLib/src/imageops/psImageGeomManip.c

    r4385 r4540  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-06-25 00:51:28 $
     12 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-07-12 19:12:01 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    196196    }
    197197
    198     if (mode < PS_INTERPOLATE_FLAT || mode >= PS_INTERPOLATE_NUM_MODES) {
     198    if (mode > PS_INTERPOLATE_LANCZOS4_VARIANCE ) {
    199199        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    200200                PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED,
  • trunk/psLib/src/imageops/psImagePixelExtract.c

    r4385 r4540  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-06-25 00:51:28 $
     10 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-07-12 19:12:01 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    312312    }
    313313
    314     if (mode < PS_INTERPOLATE_FLAT || mode >= PS_INTERPOLATE_NUM_MODES) {
     314    if (mode < PS_INTERPOLATE_FLAT ) {
    315315        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    316316                PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED,
  • trunk/psLib/src/imageops/psImagePixelManip.c

    r4385 r4540  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-06-25 00:51:28 $
     12 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-07-12 19:12:01 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    185185}
    186186
    187 psS32 psImageOverlaySection(psImage* image,
    188                             const psImage* overlay,
    189                             psS32 col0,
    190                             psS32 row0,
    191                             const char *op)
     187int psImageOverlaySection(psImage* image,
     188                          const psImage* overlay,
     189                          int col0,
     190                          int row0,
     191                          const char *op)
    192192{
    193193    psU32 imageNumRows;
  • trunk/psLib/src/imageops/psImagePixelManip.h

    r4385 r4540  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-06-25 00:51:28 $
     10 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-07-12 19:12:01 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7878 *  function is defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64.
    7979 *
    80  *  @return psS32         0 if success, non-zero if failed.
     80 *  @return int         0 if success, non-zero if failed.
    8181 */
    82 psS32 psImageOverlaySection(
     82int psImageOverlaySection(
    8383    psImage* image,                    ///< target image
    8484    const psImage* overlay,            ///< the overlay image
    85     psS32 col0,                        ///< the column to start overlay
    86     psS32 row0,                        ///< the row to start overlay
     85    int col0,                          ///< the column to start overlay
     86    int row0,                          ///< the row to start overlay
    8787    const char *op                     ///< the operation to perform for overlay
    8888);
  • trunk/psLib/src/imageops/psImageStructManip.c

    r3977 r4540  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-05-19 05:18:20 $
     10 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-07-12 19:12:01 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3131{
    3232    psU32 elementSize;          // size of image element in bytes
    33     psU32 inputColOffset;       // offset in bytes to first subset pixel in input row
     33    psS32 inputColOffset;       // offset in bytes to first subset pixel in input row
     34
     35    if ( col0 < 0 || row0 < 0 ) {
     36        //        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     37        //                PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID);
     38        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     39                PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
     40                col0, col1-1, row0, row1-1,
     41                image->numCols-1, image->numRows-1);
     42        return NULL;
     43    }
    3444
    3545    if (image == NULL || image->data.V == NULL) {
     
    6474        return NULL;
    6575    }
     76
     77
     78
    6679    psS32 numRows = row1-row0;
    6780    psS32 numCols = col1-col0;
     
    94107
    95108    out->data.V = psRealloc(out->data.V,sizeof(psPtr)*numRows); // resize row pointer array
    96     *(psType*)&out->type = image->type;
    97     *(psU32*)&out->numCols = numCols;
    98     *(psU32*)&out->numRows = numRows;
     109    *(psMathType*)&out->type = image->type;
     110    //    *(psU32*)&out->numCols = numCols;
     111    //    *(psU32*)&out->numRows = numRows;
     112    *(psS32*)&out->numCols = numCols;
     113    *(psS32*)&out->numRows = numRows;
    99114    *(psS32*)&out->row0 = row0;
    100115    *(psS32*)&out->col0 = col0;
  • trunk/psLib/src/math/Makefile.am

    r4446 r4540  
    1 #Makefile for dataManip functions of psLib
     1#Makefile for math functions of psLib
    22#
    3 INCLUDES = \
    4         -I$(top_srcdir)/src/astro \
    5         -I$(top_srcdir)/src/db \
    6         -I$(top_srcdir)/src/fft \
    7         -I$(top_srcdir)/src/fits \
    8         -I$(top_srcdir)/src/imageops \
    9         -I$(top_srcdir)/src/math \
    10         -I$(top_srcdir)/src/mathtypes \
    11         -I$(top_srcdir)/src/sys \
    12         -I$(top_srcdir)/src/types \
    13         -I$(top_srcdir)/src/xml \
    14         $(all_includes)
     3noinst_LTLIBRARIES = libpslibmath.la
    154
    16 noinst_LTLIBRARIES = libpslibdataManip.la
     5libpslibmath_la_SOURCES = \
     6        psBinaryOp.c \
     7        psCompare.c \
     8        psMatrix.c \
     9        psMinimize.c \
     10        psRandom.c \
     11        psFunctions.c \
     12        psStats.c \
     13        psUnaryOp.c
    1714
    18 libpslibdataManip_la_SOURCES = psUnaryOp.c psBinaryOp.c psStats.c \
    19                 psFunctions.c psMatrix.c psVectorFFT.c psMinimize.c psRandom.c
    20 
    21 BUILT_SOURCES = psDataManipErrors.h
    22 EXTRA_DIST = psDataManipErrors.dat psDataManipErrors.h dataManip.i
    23 
    24 psDataManipErrors.h: psDataManipErrors.dat
    25         $(top_srcdir)/src/psParseErrorCodes --data=$? $@
     15EXTRA_DIST = math.i
    2616
    2717pslibincludedir = $(includedir)
    2818pslibinclude_HEADERS = \
     19        psBinaryOp.h \
     20        psCompare.h \
    2921        psConstants.h \
    30         psStats.h  \
     22        psMatrix.h \
     23        psMinimize.h \
     24        psRandom.h \
    3125        psFunctions.h \
    32         psMatrix.h \
    33     psBinaryOp.h \
    34     psUnaryOp.h \
    35         psVectorFFT.h \
    36         psMinimize.h \
    37         psRandom.h
    38 
     26        psStats.h \
     27        psUnaryOp.h
  • trunk/psLib/src/math/psBinaryOp.c

    r4342 r4540  
    3030 *  @author Robert DeSonia, MHPCC
    3131 *
    32  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    33  *  @date $Date: 2005-06-22 02:05:41 $
     32 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     33 *  @date $Date: 2005-07-12 19:12:01 $
    3434 *
    3535 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5050#include "psLogMsg.h"
    5151#include "psConstants.h"
    52 #include "psDataManipErrors.h"
     52#include "psErrorText.h"
    5353
    5454/*****************************************************************************
     
    426426}
    427427
    428 psPtr psBinaryOp(psPtr out, const psPtr in1, const char *op, const psPtr in2)
     428psMathType* psBinaryOp(psPtr out, const psPtr in1, const char *op, const psPtr in2)
    429429{
    430430
  • trunk/psLib/src/math/psBinaryOp.h

    r4342 r4540  
    3030 *  @author Robert DeSonia, MHPCC
    3131 *
    32  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    33  *  @date $Date: 2005-06-22 02:05:41 $
     32 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     33 *  @date $Date: 2005-07-12 19:12:01 $
    3434 *
    3535 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5555 *  @return  psType* : Pointer to either psImage or psVector.
    5656 */
    57 psType* psBinaryOp(
     57psMathType* psBinaryOp(
    5858    psPtr out,                         ///< Output type, either psImage or psVector.
    5959    const psPtr in1,                   ///< First input, either psImage or psVector.
  • trunk/psLib/src/math/psMatrix.c

    r4388 r4540  
    2121 *  @author Robert DeSonia, MHPCC
    2222 *
    23  *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
    24  *  @date $Date: 2005-06-25 01:15:01 $
     23 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
     24 *  @date $Date: 2005-07-12 19:12:01 $
    2525 *
    2626 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4343#include "psMatrix.h"
    4444#include "psConstants.h"
    45 #include "psDataManipErrors.h"
     45#include "psErrorText.h"
    4646
    4747
  • trunk/psLib/src/math/psMinimize.c

    r4321 r4540  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.123 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-06-20 22:42:30 $
     11 *  @version $Revision: 1.124 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-07-12 19:12:01 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    13571357XXX: type F32 is done via vector conversion only.
    13581358 *****************************************************************************/
    1359 psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* myPoly,
     1359psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* poly,
    13601360                                        const psVector* x,
    13611361                                        const psVector* y,
    13621362                                        const psVector* yErr)
    13631363{
    1364     PS_ASSERT_POLY_NON_NULL(myPoly, NULL);
    1365     PS_ASSERT_INT_NONNEGATIVE(myPoly->n, NULL);
     1364    PS_ASSERT_POLY_NON_NULL(poly, NULL);
     1365    PS_ASSERT_INT_NONNEGATIVE(poly->n, NULL);
    13661366    PS_ASSERT_VECTOR_NON_NULL(y, NULL);
    13671367    PS_ASSERT_VECTOR_NON_EMPTY(y, NULL);
     
    13891389    if (x == NULL) {
    13901390        PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n);
    1391         if (myPoly->type == PS_POLYNOMIAL_CHEB) {
     1391        if (poly->type == PS_POLYNOMIAL_CHEB) {
    13921392            p_psNormalizeVectorRangeF64(x64Static, -1.0, 1.0);
    13931393        }
     
    13961396        PS_ASSERT_VECTOR_TYPE_F32_OR_F64(x, NULL);
    13971397        PS_VECTOR_CONVERT_F32_TO_F64_STATIC(x, x64, x64Static);
    1398         if (myPoly->type == PS_POLYNOMIAL_CHEB) {
     1398        if (poly->type == PS_POLYNOMIAL_CHEB) {
    13991399            p_psNormalizeVectorRangeF64(x64, -1.0, 1.0);
    14001400        }
     
    14051405    // Call the appropriate vector fitting routine.
    14061406    psPolynomial1D *rc = NULL;
    1407     if (myPoly->type == PS_POLYNOMIAL_CHEB) {
    1408         rc = vectorFitPolynomial1DCheby(myPoly, x64, y64, yErr64);
    1409     } else if (myPoly->type == PS_POLYNOMIAL_ORD) {
    1410         rc = vectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64);
     1407    if (poly->type == PS_POLYNOMIAL_CHEB) {
     1408        rc = vectorFitPolynomial1DCheby(poly, x64, y64, yErr64);
     1409    } else if (poly->type == PS_POLYNOMIAL_ORD) {
     1410        rc = vectorFitPolynomial1DOrd(poly, x64, y64, yErr64);
    14111411    } else {
    14121412        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     
    14191419    }
    14201420
    1421     return(myPoly);
     1421    return(poly);
    14221422}
    14231423
     
    14321432
    14331433    psMinimization *min = psAlloc(sizeof(psMinimization));
    1434     min->maxIter = maxIter;
    1435     min->tol = tol;
     1434    *(int*)&min->maxIter = maxIter;
     1435    *(float*)&min->tol = tol;
    14361436    min->value = 0.0;
    14371437    min->iter = 0;
     
    19931993        for (i=0;i<numDims;i++) {
    19941994            if (myParamMask->data.U8[i] == 0) {
    1995                 dummyMin.maxIter = PS_MINIMIZE_POWELL_LINEMIN_MAX_ITERATIONS;
    1996                 dummyMin.tol = PS_MINIMIZE_POWELL_LINEMIN_ERROR_TOLERANCE;
     1995                *(int*)&dummyMin.maxIter = PS_MINIMIZE_POWELL_LINEMIN_MAX_ITERATIONS;
     1996                *(float*)&dummyMin.tol = PS_MINIMIZE_POWELL_LINEMIN_ERROR_TOLERANCE;
    19971997                mul = p_psLineMin(&dummyMin,
    19981998                                  Q,
  • trunk/psLib/src/math/psMinimize.h

    r4330 r4540  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-06-21 03:01:37 $
     10 *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-07-12 19:12:01 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3838
    3939/** A data structure for minimization routines.
    40  * 
     40 *
    4141 *  Contains numerical analysis parameters/values
    4242 */
    4343typedef struct
    4444{
    45     psS32 maxIter;                     ///< Convergence limit
    46     psF32 tol;                         ///< Error Tolerance
    47     psF32 value;                       ///< Value of function at minimum
    48     psS32 iter;                        ///< Number of iterations to date
    49     psF32 lastDelta;                   ///< The last difference for the fit
     45    const int maxIter;                 ///< Convergence limit
     46    const float tol;                   ///< Error Tolerance
     47    float value;                       ///< Value of function at minimum
     48    int iter;                          ///< Number of iterations to date
     49    float lastDelta;                   ///< The last difference for the fit
    5050}
    5151psMinimization;
    5252
    5353/** Allocates a psMinimization structure.
    54  * 
     54 *
    5555 *  @return psMinimization* :   a new psMinimization struct
    5656*/
     
    7474 */
    7575psPolynomial1D* psVectorFitPolynomial1D(
    76     psPolynomial1D* myPoly,            ///< Polynomial to fit
     76    psPolynomial1D* poly,            ///< Polynomial to fit
    7777    const psVector* x,                 ///< Ordinates (or NULL to just use the indices)
    7878    const psVector* y,                 ///< Coordinates
     
    8181
    8282/** Derive a one-dimensional spline fit.
    83  *   
    84  *  Given a psSpline1D data structure and a set of x,y vectors, this routine 
     83 *
     84 *  Given a psSpline1D data structure and a set of x,y vectors, this routine
    8585 *  generates the linear splines which satisfy those data points.
    86  * 
     86 *
    8787 *  @return psSpline1D*:  the calculated one-dimensional splines
    8888 */
     
    9696/** Specifies the format of a user-defined function that the general Levenberg-
    9797 *  Marquardt minimizer routine will accept.
    98  * 
    99  *  @return psF64:   the single float value of the function given the parameters,
     98 *
     99 *  @return float:   the single float value of the function given the parameters,
    100100 *       positions, and derivatives.
    101101 */
    102102typedef
    103 psF64 (*psMinimizeLMChi2Func)(
     103float (*psMinimizeLMChi2Func)(
    104104    psVector *deriv,                   ///< derivatives of the function
    105     psVector *params,                  ///< the parameters used to evaluate the function
    106     psVector *x                        ///< positions for evaluation
     105    const psVector *params,            ///< the parameters used to evaluate the function
     106    const psVector *x                  ///< positions for evaluation
    107107);
    108108
    109109/** Minimizes a specified function based on the Levenberg-Marquardt method.
    110  * 
     110 *
    111111 *  @return bool:   True if successful.
    112112 */
     
    123123
    124124/** Use specified alpha, beta, params to generate a new guess for Alpha, Beta, Params
    125  * 
     125 *
    126126 *  @return psBool:   True if successful.
    127127 */
     
    138138
    139139/** Function used to set parameters for generating "best guess" in minimizing Chi-Squared value.
    140  * 
     140 *
    141141 *  @return psF64:    Chi-squared value for new guess
    142142 */
     
    153153/** Specifies the format of a user-defined function that the general Powell
    154154 *  minimizer routine will accept.
    155  * 
    156  *  @return psF32:   the single float value of the function given the parameters
     155 *
     156 *  @return float:   the single float value of the function given the parameters
    157157 *      and coordinate vectors.
    158158*/
    159159typedef
    160 psF32 (*psMinimizePowellFunc)(
     160float (*psMinimizePowellFunc)(
    161161    const psVector *params,            ///< Parameters used to evaluate the function
    162162    const psArray *coords              ///< Coordinates at which to evaluate
     
    164164
    165165/** Minimizes a specified function based on the Powell method.
    166  * 
     166 *
    167167 *  @return bool:   True if successful.
    168168 */
     
    177177/** Calculates the one-dimensional Gaussian in a format acceptable to the Levenberg-
    178178 *  Marquardt minimizer routine.
    179  * 
     179 *
    180180 *  @return psVector*:    Calculated values
    181181 */
     
    188188/** Calculates the one-dimensional Gaussian in a format acceptable to the Powell
    189189 *  chi-squared minimizer routine.
    190  * 
     190 *
    191191 *  @return psVector*:   Calculated values
    192192 */
     
    198198/** Specifies the format of a user-defined function that the general Powell chi-
    199199 *  squared minimizer routine will accept.
    200  * 
     200 *
    201201 *  @return psVector*:    Calculated values given the parameters and coordinates.
    202202*/
     
    208208
    209209/** Minimizes a specified function based on the Powell chi-squared method.
    210  * 
     210 *
    211211 *  @return bool:   True is successful.
    212212 */
     
    222222
    223223/** Gauss-Jordan numerical solver.
    224  * 
     224 *
    225225 *  @return bool:   True if successful.
    226226 */
  • trunk/psLib/src/math/psRandom.c

    r4330 r4540  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-06-21 03:01:37 $
     12*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-07-12 19:12:01 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3131#include "psLogMsg.h"
    3232#include "psConstants.h"
    33 #include "psDataManipErrors.h"
     33#include "psErrorText.h"
    3434
    3535psU64 p_psRandomGetSystemSeed()
  • trunk/psLib/src/math/psStats.c

    r4409 r4540  
    1414 *      stats->binsize
    1515 *
    16  *  @version $Revision: 1.136 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2005-06-28 20:17:52 $
     16 *  @version $Revision: 1.137 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2005-07-12 19:12:01 $
    1818 *
    1919 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4141#include "psConstants.h"
    4242
    43 #include "psDataManipErrors.h"
     43#include "psErrorText.h"
    4444
    4545/*****************************************************************************/
     
    7777psBool p_psGetStatValue(const psStats* stats, psF64 *value)
    7878{
    79     switch (stats->options & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) {
     79    //    switch (stats->options & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) {
     80    switch (stats->options & ~(PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE)) {
    8081    case PS_STAT_SAMPLE_MEAN:
    8182        *value = stats->sampleMean;
     
    658659        x.data.F32 = iMid - (PS_GAUSS_WIDTH * sigma);
    659660        if ((x.data.F32 >= firstBound) && (x.data.F32 <= lastBound)) {
    660             jMin = p_psVectorBinDisect(robustHistogram->bounds, &x);
     661            jMin = p_psVectorBinDisect( *(psVector* *)&robustHistogram->bounds, &x);
    661662            if (jMin < 0) {
    662663                psError(PS_ERR_UNEXPECTED_NULL,
     
    673674        x.data.F32 = iMid + (PS_GAUSS_WIDTH * sigma);
    674675        if ((x.data.F32 >= firstBound) && (x.data.F32 <= lastBound)) {
    675             jMax = p_psVectorBinDisect(robustHistogram->bounds, &x);
     676            jMax = p_psVectorBinDisect( *(psVector* *)&robustHistogram->bounds, &x);
    676677            if (jMax < 0) {
    677678                psError(PS_ERR_UNEXPECTED_NULL,
     
    17051706        //Determine id that is okay.
    17061707        stats->robustMedian = fitQuadraticSearchForYThenReturnX(
    1707                                   robustHistogram->bounds,
     1708                                  *(psVector* *)&robustHistogram->bounds,
    17081709                                  cumulativeRobustSums,
    17091710                                  medianBinNum,
     
    17211722        //Determine id that is okay.
    17221723        stats->robustLQ = fitQuadraticSearchForYThenReturnX(
    1723                               robustHistogram->bounds,
     1724                              *(psVector* *)&robustHistogram->bounds,
    17241725                              cumulativeRobustSums,
    17251726                              LQBinNum,
     
    17281729        //Determine id that is okay.
    17291730        stats->robustUQ = fitQuadraticSearchForYThenReturnX(
    1730                               robustHistogram->bounds,
     1731                              *(psVector* *)&robustHistogram->bounds,
    17311732                              cumulativeRobustSums,
    17321733                              UQBinNum,
     
    18121813    psMemSetDeallocator(newHist, (psFreeFunc) histogramFree);
    18131814    newHist->bounds = psVectorAlloc(n + 1, PS_TYPE_F32);
    1814     newHist->bounds->n = newHist->bounds->nalloc;
     1815    *(int *)&newHist->bounds->n = newHist->bounds->nalloc;
    18151816
    18161817    // Calculate the bounds for each bin.
     
    18591860    psMemSetDeallocator(newHist, (psFreeFunc) histogramFree);
    18601861    newHist->bounds = psVectorAlloc(bounds->n, PS_TYPE_F32);
    1861     newHist->bounds->n = newHist->bounds->nalloc;
     1862    *(int *)&newHist->bounds->n = newHist->bounds->nalloc;
    18621863    for (i = 0; i < bounds->n; i++) {
    18631864        newHist->bounds->data.F32[i] = bounds->data.F32[i];
     
    20672068                    // correct bin number requires a bit more work.
    20682069                    tmpScalar.data.F32 = inF32->data.F32[i];
    2069                     binNum = p_psVectorBinDisect(out->bounds, &tmpScalar);
     2070                    binNum = p_psVectorBinDisect( *(psVector* *)&out->bounds, &tmpScalar);
    20702071                    if (binNum < 0) {
    20712072                        psLogMsg(__func__, PS_LOG_WARN,
  • trunk/psLib/src/math/psStats.h

    r4409 r4540  
    1414 *  @author GLG, MHPCC
    1515 *
    16  *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2005-06-28 20:17:52 $
     16 *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2005-07-12 19:12:01 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5252    PS_STAT_USE_RANGE =  0x002000,          ///< Range
    5353    PS_STAT_USE_BINSIZE = 0x004000,         ///< Binsize
    54     PS_STAT_ROBUST_FOR_SAMPLE = 0x008000    ///< Robust for sample
     54    //    PS_STAT_ROBUST_FOR_SAMPLE = 0x008000    ///< Robust for sample
    5555} psStatsOptions;
    5656
     
    6060typedef struct
    6161{
    62     psF64 sampleMean;          ///< formal mean of sample
    63     psF64 sampleMedian;        ///< formal median of sample
    64     psF64 sampleStdev;         ///< standard deviation of sample
    65     psF64 sampleUQ;            ///< upper quartile of sample
    66     psF64 sampleLQ;            ///< lower quartile of sample
    67     psF64 robustMean;          ///< robust mean of array
    68     psF64 robustMedian;        ///< robust median of array
    69     psF64 robustMode;          ///< Robust mode of array
    70     psF64 robustStdev;         ///< robust standard deviation of array
    71     psF64 robustUQ;            ///< robust upper quartile
    72     psF64 robustLQ;            ///< robust lower quartile
    73     psS32 robustN50;           ///< Number of points in Gaussian fit.  XXX: This is currently never set.
    74     psS32 robustNfit;          ///< The number of points between the quartiles.
    75     psF64 clippedMean;         ///< Nsigma clipped mean
    76     psF64 clippedStdev;        ///< standard deviation after clipping
    77     psS32 clippedNvalues;      ///< Number of data points used for clipped mean:  This value is never used.
    78     psF64 clipSigma;           ///< Nsigma used for clipping; user input
    79     psS32 clipIter;            ///< Number of clipping iterations; user input
    80     psF64 min;                 ///< minimum data value in array
    81     psF64 max;                 ///< maximum data value in array
    82     psF64 binsize;             ///< binsize for robust fit (input/ouput)
    83     psStatsOptions options;    ///< bitmask of calculated values
     62    double sampleMean;                 ///< formal mean of sample
     63    double sampleMedian;               ///< formal median of sample
     64    double sampleStdev;                ///< standard deviation of sample
     65    double sampleUQ;                   ///< upper quartile of sample
     66    double sampleLQ;                   ///< lower quartile of sample
     67    double robustMean;                 ///< robust mean of array
     68    double robustMedian;               ///< robust median of array
     69    double robustMode;                 ///< Robust mode of array
     70    double robustStdev;                ///< robust standard deviation of array
     71    double robustUQ;                   ///< robust upper quartile
     72    double robustLQ;                   ///< robust lower quartile
     73    int robustN50;                     ///< Number of points in Gaussian fit.  XXX: This is currently never set.
     74    int robustNfit;                    ///< The number of points between the quartiles.
     75    double clippedMean;                ///< Nsigma clipped mean
     76    double clippedStdev;               ///< standard deviation after clipping
     77    int clippedNvalues;                ///< Number of data points used for clipped mean:  This value is never used.
     78    double clipSigma;                  ///< Nsigma used for clipping; user input
     79    int clipIter;                      ///< Number of clipping iterations; user input
     80    double min;                        ///< minimum data value in array
     81    double max;                        ///< maximum data value in array
     82    double binsize;                    ///< binsize for robust fit (input/ouput)
     83    psStatsOptions options;            ///< bitmask of calculated values
    8484}
    8585psStats;
     
    9090 */
    9191psStats* psVectorStats(
    92     psStats* stats,          ///< stats structure defines stats to be calculated and how
    93     const psVector* in,      ///< Vector to be analysed.
    94     const psVector* errors,  ///< Errors.
    95     const psVector* mask,    ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL
    96     psMaskType maskVal       ///< Only mask elements with one of these bits set in maskVector
     92    psStats* stats,                    ///< stats structure defines stats to be calculated and how
     93    const psVector* in,                ///< Vector to be analysed.
     94    const psVector* errors,            ///< Errors.
     95    const psVector* mask,              ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL
     96    psMaskType maskVal                 ///< Only mask elements with one of these bits set in maskVector
    9797);
    9898
     
    121121typedef struct
    122122{
    123     psVector* bounds;                  ///< Bounds for the bins (type F32)
     123    const psVector* bounds;            ///< Bounds for the bins (type F32)
    124124    psVector* nums;                    ///< Number in each of the bins (INT)
    125     psS32 minNum;                      ///< Number below the minimum
    126     psS32 maxNum;                      ///< Number above the maximum
    127     psBool uniform;                    ///< Is it a uniform distribution?
     125    int minNum;                        ///< Number below the minimum
     126    int maxNum;                        ///< Number above the maximum
     127    bool uniform;                      ///< Is it a uniform distribution?
    128128}
    129129psHistogram;
  • trunk/psLib/src/math/psUnaryOp.c

    r4409 r4540  
    3030 *  @author Robert DeSonia, MHPCC
    3131 *
    32  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    33  *  @date $Date: 2005-06-28 20:17:52 $
     32 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     33 *  @date $Date: 2005-07-12 19:12:01 $
    3434 *
    3535 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5151#include "psLogMsg.h"
    5252#include "psConstants.h"
    53 #include "psDataManipErrors.h"
     53#include "psErrorText.h"
    5454
    5555/*****************************************************************************
     
    304304}
    305305
    306 psPtr psUnaryOp(psPtr out, const psPtr in, const char *op)
     306psMathType* psUnaryOp(psPtr out, const psPtr in, const char *op)
    307307{
    308308    #define psUnaryOp_EXIT { \
  • trunk/psLib/src/math/psUnaryOp.h

    r4409 r4540  
    3030 *  @author Robert DeSonia, MHPCC
    3131 *
    32  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    33  *  @date $Date: 2005-06-28 20:17:52 $
     32 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     33 *  @date $Date: 2005-07-12 19:12:01 $
    3434 *
    3535 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5959 *  @return  psType* : Pointer to either psImage or psVector.
    6060 */
    61 psType* psUnaryOp(
     61psMathType* psUnaryOp(
    6262    psPtr out,                         ///< Output type, either psImage or psVector.
    6363    const psPtr in,                    ///< Input, either psImage or psVector.
  • trunk/psLib/src/mathtypes/Makefile.am

    r4446 r4540  
    1 #Makefile for collections functions of psLib
     1#Makefile for mathtypes functions of psLib
    22#
     3noinst_LTLIBRARIES = libpslibmathtypes.la
    34
    4 INCLUDES = \
    5         -I$(top_srcdir)/src/astro \
    6         -I$(top_srcdir)/src/db \
    7         -I$(top_srcdir)/src/fft \
    8         -I$(top_srcdir)/src/fits \
    9         -I$(top_srcdir)/src/imageops \
    10         -I$(top_srcdir)/src/math \
    11         -I$(top_srcdir)/src/mathtypes \
    12         -I$(top_srcdir)/src/sys \
    13         -I$(top_srcdir)/src/types \
    14         -I$(top_srcdir)/src/xml \
    15         $(all_includes)
     5libpslibmathtypes_la_SOURCES = \
     6        psImage.c \
     7        psScalar.c \
     8        psVector.c
    169
    17 noinst_LTLIBRARIES = libpslibcollections.la
    18 
    19 libpslibcollections_la_SOURCES = \
    20         psBitSet.c \
    21         psVector.c \
    22         psPixels.c \
    23         psList.c \
    24         psScalar.c \
    25         psCompare.c \
    26         psArray.c \
    27         psHash.c \
    28         psMetadata.c \
    29         psMetadataIO.c
    30 
    31 BUILT_SOURCES = psCollectionsErrors.h
    32 EXTRA_DIST = psCollectionsErrors.dat psCollectionsErrors.h collections.i
    33 
    34 psCollectionsErrors.h:psCollectionsErrors.dat
    35         $(top_srcdir)/src/psParseErrorCodes --data=$? $@
     10EXTRA_DIST = mathtypes.i
    3611
    3712pslibincludedir = $(includedir)
    3813pslibinclude_HEADERS = \
    39         psBitSet.h \
    40         psVector.h \
    41         psPixels.h \
    42         psList.h \
     14        psImage.h \
    4315        psScalar.h \
    44         psCompare.h \
    45         psArray.h \
    46         psHash.h \
    47         psMetadata.h \
    48         psMetadataIO.h
    49 
     16        psVector.h
  • trunk/psLib/src/mathtypes/psImage.c

    r4409 r4540  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.72 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-06-28 20:17:52 $
     11 *  @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-07-12 19:12:01 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4848}
    4949
    50 psImage* psImageAlloc(psU32 numCols,
    51                       psU32 numRows,
     50psImage* psImageAlloc(int numCols,
     51                      int numRows,
    5252                      psElemType type)
    5353{
     
    9191}
    9292
    93 psRegion psRegionSet(psF32 x0,
    94                      psF32 x1,
    95                      psF32 y0,
    96                      psF32 y1)
     93psRegion psRegionSet(float x0,
     94                     float x1,
     95                     float y0,
     96                     float y1)
    9797{
    9898    psRegion out;
     
    149149
    150150psImage* psImageRecycle(psImage* old,
    151                         psU32 numCols,
    152                         psU32 numRows,
     151                        int numCols,
     152                        int numRows,
    153153                        const psElemType type)
    154154{
     
    369369}
    370370
    371 psC64 psImagePixelInterpolate(const psImage* input,
    372                               float x,
    373                               float y,
    374                               const psImage* mask,
    375                               psU32 maskVal,
    376                               psC64 unexposedValue,
    377                               psImageInterpolateMode mode)
     371complex psImagePixelInterpolate(const psImage* input,
     372                                float x,
     373                                float y,
     374                                const psImage* mask,
     375                                psMaskType maskVal,
     376                                complex unexposedValue,
     377                                psImageInterpolateMode mode)
    378378{
    379379
  • trunk/psLib/src/mathtypes/psImage.h

    r4409 r4540  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-06-28 20:17:52 $
     13 *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-07-12 19:12:01 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4040    PS_INTERPOLATE_LANCZOS3_VARIANCE,  ///< Variance version of PS_INTERPOLATE_LANCZOS3
    4141    PS_INTERPOLATE_LANCZOS4_VARIANCE,  ///< Variance version of PS_INTERPOLATE_LANCZOS4
    42     PS_INTERPOLATE_NUM_MODES           ///< enum end-marker; does not coorespond to a interpolation mode
     42    //    PS_INTERPOLATE_NUM_MODES           ///< enum end-marker; does not coorespond to a interpolation mode
    4343} psImageInterpolateMode;
    4444
     
    5151typedef struct psImage
    5252{
    53     const psType type;                 ///< Image data type and dimension.
    54     const psU32 numCols;               ///< Number of columns in image
    55     const psU32 numRows;               ///< Number of rows in image.
    56     const psS32 col0;                  ///< Column position relative to parent.
    57     const psS32 row0;                  ///< Row position relative to parent.
     53    const psMathType type;             ///< Image data type and dimension.
     54    const int numCols;                 ///< Number of columns in image
     55    const int numRows;                 ///< Number of rows in image.
     56    const int col0;                    ///< Column position relative to parent.
     57    const int row0;                    ///< Row position relative to parent.
    5858
    5959    union {
     
    7777
    7878    psPtr rawDataBuffer;               ///< Raw data buffer for Allocating/Freeing Images
     79    void *lock;                        ///< Optional lock for thread safety
    7980}
    8081psImage;
     
    8788typedef struct
    8889{
    89     psF32 x0;                         ///< the first column of the region.
    90     psF32 x1;                         ///< the last column of the region.
    91     psF32 y0;                         ///< the first row of the region.
    92     psF32 y1;                         ///< the last row of the region.
     90    float x0;                         ///< the first column of the region.
     91    float x1;                         ///< the last column of the region.
     92    float y0;                         ///< the first row of the region.
     93    float y1;                         ///< the last row of the region.
    9394}
    9495psRegion;
     
    103104 */
    104105psImage* psImageAlloc(
    105     psU32 numCols,                     ///< Number of rows in image.
    106     psU32 numRows,                     ///< Number of columns in image.
     106    int numCols,                       ///< Number of rows in image.
     107    int numRows,                       ///< Number of columns in image.
    107108    psElemType type                    ///< Type of data for image.
    108 );
     109)
     110;
    109111
    110112/** Create a psRegion with the specified attributes.
     
    113115 */
    114116psRegion psRegionSet(
    115     psF32 x0,                         ///< the first column of the region.
    116     psF32 x1,                         ///< the last column of the region + 1.
    117     psF32 y0,                         ///< the first row of the region.
    118     psF32 y1                          ///< the last row of the region + 1.
     117    float x0,                          ///< the first column of the region.
     118    float x1,                          ///< the last column of the region + 1.
     119    float y0,                          ///< the first row of the region.
     120    float y1                           ///< the last row of the region + 1.
    119121);
    120122
     
    146148psImage* psImageRecycle(
    147149    psImage* old,                      ///< the psImage to recycle by resizing image buffer
    148     psU32 numCols,                     ///< the desired number of columns in image
    149     psU32 numRows,                     ///< the desired number of rows in image
     150    int numCols,                       ///< the desired number of columns in image
     151    int numRows,                       ///< the desired number of rows in image
    150152    const psElemType type              ///< the desired datatype of the image
    151153);
    152154
    153155/** Copy an image to a new buffer
    154  * 
     156 *
    155157 *  @return True if image copied or false if error
    156158 */
     
    195197 *                   given x,y doesn't coorespond to a valid image location
    196198 */
    197 psC64 psImagePixelInterpolate(
     199complex psImagePixelInterpolate(
    198200    const psImage* input,              ///< input image for interpolation
    199201    float x,                           ///< column location to derive value of
    200202    float y,                           ///< row location ot derive value of
    201203    const psImage* mask,               ///< if not NULL, the mask of the input image
    202     psU32 maskVal,              ///< the mask value
    203     psC64 unexposedValue,              ///< return value if x,y location is not in image.
     204    psMaskType maskVal,                ///< the mask value
     205    complex unexposedValue,            ///< return value if x,y location is not in image.
    204206    psImageInterpolateMode mode        ///< interpolation mode
    205207);
  • trunk/psLib/src/mathtypes/psScalar.c

    r4409 r4540  
    88 *  @author Ross Harman, MHPCC
    99 *
    10  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-06-28 20:17:52 $
     10 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-07-12 19:12:01 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2020#include "psAbort.h"
    2121
    22 #include "psCollectionsErrors.h"
     22#include "psErrorText.h"
    2323
    2424psScalar* psScalarAlloc(complex value, psElemType type)
  • trunk/psLib/src/mathtypes/psScalar.h

    r4409 r4540  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-06-28 20:17:52 $
     13 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-07-12 19:12:01 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3232typedef struct
    3333{
    34     psType type;                ///< Type of data.
     34    psMathType type;            ///< Type of data.
    3535
    3636    union {
  • trunk/psLib/src/mathtypes/psVector.c

    r4409 r4540  
    99*  @author Robert DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-06-28 20:17:52 $
     11*  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-07-12 19:12:01 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2626#include "psCompare.h"
    2727
    28 #include "psCollectionsErrors.h"
     28#include "psErrorText.h"
    2929
    3030typedef struct
     
    4848// FUNCTION IMPLEMENTATION - PUBLIC
    4949
    50 psVector* psVectorAlloc(unsigned long nalloc, psElemType type)
     50psVector* psVectorAlloc( long nalloc, psElemType type)
    5151{
    5252    psVector* psVec = NULL;
     
    6767    psVec->type.dimen = PS_DIMEN_VECTOR;
    6868    psVec->type.type = type;
    69     *(int*)&psVec->nalloc = nalloc;
     69    *(long*)&psVec->nalloc = nalloc;
    7070    psVec->n = nalloc;
    7171
     
    7676}
    7777
    78 psVector* psVectorRealloc(psVector* vector, unsigned long nalloc)
     78psVector* psVectorRealloc(psVector* vector, long nalloc)
    7979{
    8080    psS32 elementSize = 0;
     
    9393        // Realloc after decrementation to avoid accessing freed array elements
    9494        vector->data.U8 = psRealloc(vector->data.U8, nalloc * elementSize);
    95         *(int*)&vector->nalloc = nalloc;
     95        *(long*)&vector->nalloc = nalloc;
    9696    }
    9797
     
    9999}
    100100
    101 psVector* psVectorRecycle(psVector* vector, unsigned long nalloc, psElemType type)
     101psVector* psVectorRecycle(psVector* vector, long nalloc, psElemType type)
    102102{
    103103    psS32 byteSize;
     
    120120    if (byteSize > vector->nalloc*PSELEMTYPE_SIZEOF(vector->type.type)) {
    121121        vector->data.U8 = psRealloc(vector->data.U8, byteSize);
    122         *(int*)&vector->nalloc = nalloc;
     122        *(long*)&vector->nalloc = nalloc;
    123123    }
    124124
  • trunk/psLib/src/mathtypes/psVector.h

    r4409 r4540  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-06-28 20:17:52 $
     13 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-07-12 19:12:01 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5151typedef struct
    5252{
    53     psType type;                       ///< Type of data.
    54     int n;                             ///< Number of elements in use.
    55     const int nalloc;                  ///< Total number of elements available.
     53    psMathType type;                       ///< Type of data.
     54    long n;                            ///< Number of elements in use.
     55    const long nalloc;                 ///< Total number of elements available.
    5656    p_psVectorData data;               ///< Union for data types.
     57    void *lock;                        ///< Optional lock for thread safety.
    5758}
    5859psVector;
     
    7374 */
    7475psVector* psVectorAlloc(
    75     unsigned long nalloc,              ///< Total number of elements to make available.
     76    long nalloc,                       ///< Total number of elements to make available.
    7677    psElemType type                    ///< Type of data to be held by vector.
    77 );
     78)
     79;
    7880
    7981/** Reallocate a vector.
     
    8890psVector* psVectorRealloc(
    8991    psVector* vector,                  ///< Vector to reallocate.
    90     unsigned long nalloc               ///< Total number of elements to make available.
     92    long nalloc                        ///< Total number of elements to make available.
    9193);
    9294
     
    120122    ///< taken to preserve the values.
    121123
    122     unsigned long nalloc,              ///< Total number of elements to make available.
     124    long nalloc,                       ///< Total number of elements to make available.
    123125    psElemType type                    ///< the datatype of the returned vector
    124126);
  • trunk/psLib/src/pslib_strict.h

    r4162 r4540  
    99*  @author Eric Van Alst, MHPCC
    1010*
    11 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-06-08 23:40:45 $
     11*  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-07-12 19:12:00 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2626#endif // #else
    2727
    28 // // System Utilities
    29 
    30 /// @defgroup SysUtils System Utilities
     28/// @defgroup astro Astrometry Functions
    3129/// @{
    32 
    33 /** @defgroup MemoryManagement Memory Management Utilities
    34  *
    35  *  This is the generic memory management system put inbetween the user's high level code and the OS-level
    36  *  memory allocation routines.  This system adds such features as callback routines for memory error events,
    37  *  tracing capabilities, and reference counting.
    38  *
    39  *  @ingroup SysUtils
    40  */
    41 
    42 #include "fitsio.h"
    43 
    44 #include "psMemory.h"
    45 
    46 /// @defgroup LogTrace Tracing and Logging
    47 /// @ingroup SysUtils
    48 #include "psLogMsg.h"
    49 #include "psTrace.h"
    50 
    51 /// @defgroup ErrorHandling Error Handling
    52 /// @ingroup SysUtils
    53 #include "psAbort.h"
    54 #include "psError.h"
    55 
    56 #include "psString.h"
    57 
    58 /// @defgroup Configure Configure psLib
    59 /// @ingroup SysUtils
    60 #include "psConfigure.h"
    61 
     30#include "psTime.h"
     31#include "psCoord.h"
    6232/// @}
    6333
    64 // Collections
    65 /// @defgroup DataContainer Data Containers
     34/// @defgroup db Database Functions
    6635/// @{
     36#include "psDB.h"
     37/// @}
    6738
    68 #include "psType.h"
     39/// @defgroup fft Fourier Functions
     40/// @{
     41#include "psVectorFFT.h"
     42#include "psImageFFT.h"
     43/// @}
    6944
    70 /// @defgroup LinkedList Linked List
    71 /// @ingroup DataContainer
    72 #include "psList.h"
     45/// @defgroup fits FITS I/O Functions
     46/// @{
     47#include "psFits.h"
     48/// @}
    7349
    74 /// @defgroup HashTable Hash Table
    75 /// @ingroup DataContainer
    76 #include "psHash.h"
     50/// @defgroup imageops Image Operations
     51/// @{
     52#include "psImageConvolve.h"
     53#include "psImageGeomManip.h"
     54#include "psImagePixelExtract.h"
     55#include "psImagePixelManip.h"
     56#include "psImageStats.h"
     57#include "psImageStructManip.h"
     58/// @}
    7759
    78 /// @defgroup Scalar Scalar
    79 /// @ingroup DataContainer
    80 #include "psScalar.h"
     60/// @defgroup math Math Functions
     61/// @{
     62#include "psBinaryOp.h"
     63#include "psCompare.h"
     64#include "psConstants.h"
     65#include "psMatrix.h"
     66#include "psMinimize.h"
     67#include "psRandom.h"
     68#include "psFunctions.h"
     69#include "psStats.h"
     70#include "psUnaryOp.h"
     71/// @}
    8172
    82 /// @defgroup Vector Vector Container
    83 /// @ingroup DataContainer
    84 #include "psVector.h"
    85 
    86 /// @defgroup Array Array Container
    87 /// @ingroup DataContainer
    88 #include "psArray.h"
    89 
    90 /// @defgroup Image Image Container
    91 /// @ingroup DataContainer
     73/// @defgroup mathtypes Mathematical Data Objects
    9274/// @{
    9375#include "psImage.h"
    94 #include "psImagePixelExtract.h"
    95 #include "psImageStructManip.h"
    96 #include "psImageGeomManip.h"
    97 #include "psImagePixelManip.h"
    98 #include "psImageConvolve.h"
    99 
    100 /// @defgroup ImageStats Image Statistical Functions
    101 /// @ingroup Image
    102 #include "psImageStats.h"
    103 
     76#include "psScalar.h"
     77#include "psVector.h"
    10478/// @}
    10579
    106 /// @defgroup BitSet Bit Set Container
    107 /// @ingroup DataContainer
    108 #include "psBitSet.h"
    109 
     80/// @defgroup sys System-Level Functions
     81/// @{
     82#include "psAbort.h"
     83#include "psConfigure.h"
     84#include "psError.h"
     85#include "psErrorCodes.h"
     86#include "psLogMsg.h"
     87#include "psMemory.h"
     88#include "psString.h"
     89#include "psTrace.h"
     90#include "psType.h"
    11091/// @}
    11192
    112 // Data Manipulation
    113 /// @defgroup DataManip Data Manipulation
     93/// @defgroup types Basic Data Types
    11494/// @{
    115 
    116 /// @defgroup Compare Comparison Functions
    117 /// @ingroup DataManip
    118 #include "psCompare.h"
    119 
    120 /// @defgroup Stats Statistic Functions
    121 /// @ingroup DataManip
    122 #include "psStats.h"
    123 
    124 /// @defgroup Matrix Matrix Operations
    125 /// @ingroup DataManip
    126 #include "psMatrix.h"
    127 
    128 /// @defgroup MatrixArithmetic Matrix Arithmetic Operations
    129 /// @ingroup DataManip
    130 #include "psBinaryOp.h"
    131 #include "psUnaryOp.h"
    132 
    133 #include "psRandom.h"
    134 
    135 /// @defgroup Transform Fourier Transform Operations
    136 /// @ingroup DataManip
    137 #include "psVectorFFT.h"
    138 #include "psImageFFT.h"
    139 
    140 #include "psFunctions.h"
    141 #include "psMinimize.h"
    142 
     95#include "psArray.h"
     96#include "psBitSet.h"
     97#include "psHash.h"
     98#include "psList.h"
     99#include "psLookupTable.h"
     100#include "psMetadata.h"
     101#include "psMetadataConfig.h"
     102#include "psPixels.h"
    143103/// @}
    144104
    145 // Astronomy
    146 /// @defgroup Astronomy Astronomy Functions
     105/// @defgroup xml XML Functions
    147106/// @{
    148 
    149 /// @defgroup CoordinateTransform Coordinate Functions
    150 /// @ingroup Astronomy
    151 #include "psCoord.h"
    152 
    153 /// @defgroup Photometry Photometry
    154 /// @ingroup Astronomy
    155 #include "psPhotometry.h"
    156 
    157 /// @defgroup Time Time Functions
    158 /// @ingroup Astronomy
    159 #include "psTime.h"
    160 
    161 /// @defgroup Metadata Metadata Functions
    162 /// @ingroup Astronomy
    163 #include "psMetadata.h"
    164 #include "psMetadataIO.h"
    165 
    166 /// @defgroup AstroImage Astrometry Functions
    167 /// @ingroup Astronomy
    168 #include "psAstrometry.h"
    169 #include "psConstants.h"
    170 #include "psDB.h"
    171 
    172 /// @}
    173 
    174 // FileUtils
    175 /// @defgroup FileUtils File Utilities
    176 /// @{
    177 #include "psFits.h"
    178 
    179 /// @defgroup LookupTable Lookup Table
    180 /// @ingroup FileUtils
    181 #include "psLookupTable.h"
    182 
     107#include "psXML.h"
    183108/// @}
    184109
  • trunk/psLib/src/sys/Makefile.am

    r4446 r4540  
    1 #Makefile for sysUtils functions of psLib
     1#Makefile for sys functions of psLib
    22#
    3 INCLUDES = \
    4         -I$(top_srcdir)/src/astro \
    5         -I$(top_srcdir)/src/db \
    6         -I$(top_srcdir)/src/fft \
    7         -I$(top_srcdir)/src/fits \
    8         -I$(top_srcdir)/src/imageops \
    9         -I$(top_srcdir)/src/math \
    10         -I$(top_srcdir)/src/mathtypes \
    11         -I$(top_srcdir)/src/sys \
    12         -I$(top_srcdir)/src/types \
    13         -I$(top_srcdir)/src/xml \
    14         $(all_includes)
     3noinst_LTLIBRARIES = libpslibsys.la
    154
    16 noinst_LTLIBRARIES = libpslibsysUtils.la
     5libpslibsys_la_SOURCES = \
     6        psAbort.c \
     7        psConfigure.c  \
     8        psError.c      \
     9        psErrorCodes.c \
     10        psLogMsg.c     \
     11        psMemory.c     \
     12        psString.c     \
     13        psTrace.c
    1714
    18 libpslibsysUtils_la_SOURCES = \
    19         psMemory.c     \
    20         psError.c      \
    21         psTrace.c      \
    22         psLogMsg.c     \
    23         psAbort.c      \
    24         psString.c     \
    25         psConfigure.c  \
    26         psErrorCodes.c
     15EXTRA_DIST = sys.i
    2716
    28 BUILT_SOURCES = psSysUtilsErrors.h
    29 EXTRA_DIST = psSysUtilsErrors.dat psSysUtilsErrors.h sysUtils.i
     17BUILT_SOURCES = psErrorCodes.c
    3018
    31 psSysUtilsErrors.h: psSysUtilsErrors.dat
    32         $(top_srcdir)/src/psParseErrorCodes --data=$? $@
     19psErrorCodes.c: ../psErrorCodes_$(LANG).dat psErrorCodes.c.in psErrorCodes.h
     20        $(top_srcdir)/psParseErrorCodes --data=../psErrorCodes_$(LANG).dat $@
     21
     22psError.h: psErrorCodes.h
     23
     24psErrorCodes.h: ../psErrorCodes_$(LANG).dat psErrorCodes.h.in
     25        $(top_srcdir)/psParseErrorCodes --data=../psErrorCodes_$(LANG).dat $@
    3326
    3427pslibincludedir = $(includedir)
    3528pslibinclude_HEADERS = \
    36         psType.h       \
     29        psAbort.h \
     30        psConfigure.h  \
     31        psError.h      \
     32        psErrorCodes.h \
     33        psLogMsg.h     \
    3734        psMemory.h     \
    38         psError.h      \
     35        psString.h     \
    3936        psTrace.h      \
    40         psLogMsg.h     \
    41         psAbort.h      \
    42         psString.h     \
    43         psConfigure.h  \
    44         psErrorCodes.h
    45 
     37        psType.h
  • trunk/psLib/src/sys/psConfigure.c

    r4214 r4540  
    1313 *  @author Robert DeSonia, MHPCC
    1414 *
    15  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2005-06-11 02:19:05 $
     15 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2005-07-12 19:12:01 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2222#include "psError.h"
    2323#include "psConfigure.h"
    24 #include "psSysUtilsErrors.h"
     24#include "psErrorText.h"
    2525#include "config.h"
    2626
  • trunk/psLib/src/sys/psErrorCodes.c

    r4392 r4540  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-06-25 02:02:05 $
     9 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-07-12 19:12:01 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2020#include "psMemory.h"
    2121
    22 #include "psSysUtilsErrors.h"
    23 
    24 /* N.B., lines between '//~Start' and '//~End' are automatic generated from
    25  * the template following the '//~Start'.  The template is used to generate
    26  * the other lines by, for each error class in psErrorCodes.dat, the following
    27  * substitutions are made:
    28  *     $1  The error code name (first word in the psErrorCodes.dat lines)
    29  *     $2  The error description (rest of the line in psErrorCodes.dat)
    30  *     $n  The order of the source line in psErrorCodes.dat (comments excluded)
    31  *
    32  * DO NOT EDIT THE LINES BETWEEN //~Start and //~End!  ANY CHANGES WILL BE OVERWRITTEN.
    33  */
     22#include "psErrorText.h"
    3423
    3524static psErrorDescription staticErrorCodes[] = {
    3625            {PS_ERR_NONE,"not an error"},
    3726            {PS_ERR_BASE,"base error"},
    38             //~Start    {PS_ERR_$1,"$2"},
    3927            {PS_ERR_UNKNOWN,"unknown error"},
    4028            {PS_ERR_IO,"I/O error"},
     
    4836            {PS_ERR_UNEXPECTED_NULL,"unexpected NULL found"},
    4937            {PS_ERR_OS_CALL_FAILED,"unexpected result from an OS standard library call"},
    50             //~End
    5138            {PS_ERR_N_ERR_CLASSES,"error classes end marker"}
    5239        };
  • trunk/psLib/src/sys/psLogMsg.c

    r4367 r4540  
    1212 *  @author GLG, MHPCC
    1313 *
    14  *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-06-23 03:50:29 $
     14 *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-07-12 19:12:01 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4242#include "psTrace.h"
    4343
    44 #include "psSysUtilsErrors.h"
     44#include "psErrorText.h"
    4545
    4646#define MIN_LOG_LEVEL 0
  • trunk/psLib/src/sys/psMemory.c

    r4401 r4540  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.57 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-06-27 20:38:12 $
     10*  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2005-07-12 19:12:01 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psLogMsg.h"
    2626
    27 #include "psSysUtilsErrors.h"
     27#include "psErrorText.h"
    2828
    2929#define P_PS_MEMMAGIC (psPtr )0xdeadbeef   // Magic number in psMemBlock header
  • trunk/psLib/src/sys/psString.c

    r4434 r4540  
    1212 *  @author Eric Van Alst, MHPCC
    1313 *
    14  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-06-30 00:33:36 $
     14 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-07-12 19:12:01 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psError.h"
    2626
    27 #include "psSysUtilsErrors.h"
     27#include "psErrorText.h"
    2828
    2929psString psStringCopy(const char *string)
  • trunk/psLib/src/sys/psTrace.c

    r4409 r4540  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-06-28 20:17:52 $
     11 *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-07-12 19:12:01 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5151#include "psLogMsg.h"
    5252
    53 #include "psSysUtilsErrors.h"
     53#include "psErrorText.h"
    5454
    5555static p_psComponent* cRoot = NULL; // The root of the trace component
  • trunk/psLib/src/sys/psType.h

    r4342 r4540  
    1010*  @author Ross Harman, MHPCC
    1111*
    12 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-06-22 02:05:41 $
     12*  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-07-12 19:12:01 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    9494} psElemType;
    9595
     96/** Enumeration primarily used with metadata which defines a data structure
     97 *  e.g., list, array, FITS file, etc.
     98*/
     99typedef enum {
     100    PS_DATA_S32  = PS_TYPE_S32,        ///< psS32
     101    PS_DATA_F32  = PS_TYPE_F32,        ///< psF32
     102    PS_DATA_F64  = PS_TYPE_F64,        ///< psF64
     103    PS_DATA_BOOL = PS_TYPE_BOOL,       ///< psBool
     104    PS_DATA_STRING = 0x10000,          ///< psString (char *)
     105    PS_DATA_ARRAY,                     ///< psArray
     106    PS_DATA_BITSET,                    ///< psBitSet
     107    PS_DATA_CELL,                      ///< psCell
     108    PS_DATA_CHIP,                      ///< psChip
     109    PS_DATA_CUBE,                      ///< psCube
     110    PS_DATA_FITS,                      ///< psFits
     111    PS_DATA_HASH,                      ///< psHash
     112    PS_DATA_HISTOGRAM,                 ///< psHistogram
     113    PS_DATA_IMAGE,                     ///< psImage
     114    PS_DATA_KERNEL,                    ///< psKernel
     115    PS_DATA_LIST,                      ///< psList
     116    PS_DATA_LOOKUPTABLE,               ///< psLookupTable
     117    PS_DATA_METADATA,                  ///< psMetadata
     118    PS_DATA_METADATAITEM,              ///< psMetadataItem
     119    PS_DATA_MINIMIZATION,              ///< psMinimization
     120    PS_DATA_PIXELS,                    ///< psPixels
     121    PS_DATA_PLANE,                     ///< psPlane
     122    PS_DATA_PLANEDISTORT,              ///< psPlaneDistort
     123    PS_DATA_PLANETRANSFORM,            ///< psPlaneTransform
     124    PS_DATA_POLYNOMIAL1D,              ///< psPolynomial1D
     125    PS_DATA_POLYNOMIAL2D,              ///< psPolynomial2D
     126    PS_DATA_POLYNOMIAL3D,              ///< psPolynomial3D
     127    PS_DATA_POLYNOMIAL4D,              ///< psPolynomial4D
     128    PS_DATA_PROJECTION,                ///< psProjection
     129    PS_DATA_READOUT,                   ///< psReadout
     130    PS_DATA_REGION,                    ///< psRegion
     131    PS_DATA_SCALAR,                    ///< psScalar
     132    PS_DATA_SPHERE,                    ///< psSphere
     133    PS_DATA_SPHERETRANSFORM,           ///< psSphereTransform
     134    PS_DATA_SPLINE1D,                  ///< psSpline1D
     135    PS_DATA_STATS,                     ///< psStats
     136    PS_DATA_TIME,                      ///< psTime
     137    PS_DATA_VECTOR,                    ///< psVector
     138    PS_DATA_UNKNOWN,                   ///< Other data of an unknown type
     139    PS_DATA_METADATA_MULTI             ///< Used internally for metadata; not a 'real' type
     140} psDataType;
     141
    96142#define PS_TYPE_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
    97143#define PS_TYPE_MASK_DATA U8           /**< the data member to use for mask image */
     
    232278typedef struct
    233279{
    234     psElemType type;            ///< Primitive type.
    235     psDimen dimen;              ///< Dimensionality.
     280    psElemType type;                   ///< Primitive type.
     281    psDimen dimen;                     ///< Dimensionality.
    236282}
    237283psType;
     284
     285typedef struct
     286{
     287    psElemType type;                   ///< The type
     288    psDimen dimen;                     ///< The dimensionality.
     289    //    psElemType type;                   ///< The type
     290}
     291psMathType;
    238292
    239293/** The type of a basic data type
     
    245299typedef struct
    246300{
    247     psType type;              ///< Data type information
     301    psMathType type;              ///< Data type information
    248302}
    249303psMath;
  • trunk/psLib/src/types/Makefile.am

    r4446 r4540  
    1 #Makefile for collections functions of psLib
     1#Makefile for types functions of psLib
    22#
     3noinst_LTLIBRARIES = libpslibtypes.la
    34
    4 INCLUDES = \
    5         -I$(top_srcdir)/src/astro \
    6         -I$(top_srcdir)/src/db \
    7         -I$(top_srcdir)/src/fft \
    8         -I$(top_srcdir)/src/fits \
    9         -I$(top_srcdir)/src/imageops \
    10         -I$(top_srcdir)/src/math \
    11         -I$(top_srcdir)/src/mathtypes \
    12         -I$(top_srcdir)/src/sys \
    13         -I$(top_srcdir)/src/types \
    14         -I$(top_srcdir)/src/xml \
    15         $(all_includes)
     5libpslibtypes_la_SOURCES = \
     6        psArray.c \
     7        psBitSet.c \
     8        psHash.c \
     9        psList.c \
     10        psLookupTable.c \
     11        psMetadata.c \
     12        psMetadataConfig.c \
     13        psPixels.c
    1614
    17 noinst_LTLIBRARIES = libpslibcollections.la
    18 
    19 libpslibcollections_la_SOURCES = \
    20         psBitSet.c \
    21         psVector.c \
    22         psPixels.c \
    23         psList.c \
    24         psScalar.c \
    25         psCompare.c \
    26         psArray.c \
    27         psHash.c \
    28         psMetadata.c \
    29         psMetadataIO.c
    30 
    31 BUILT_SOURCES = psCollectionsErrors.h
    32 EXTRA_DIST = psCollectionsErrors.dat psCollectionsErrors.h collections.i
    33 
    34 psCollectionsErrors.h:psCollectionsErrors.dat
    35         $(top_srcdir)/src/psParseErrorCodes --data=$? $@
     15EXTRA_DIST = types.i
    3616
    3717pslibincludedir = $(includedir)
    3818pslibinclude_HEADERS = \
     19        psArray.h \
    3920        psBitSet.h \
    40         psVector.h \
    41         psPixels.h \
     21        psHash.h \
    4222        psList.h \
    43         psScalar.h \
    44         psCompare.h \
    45         psArray.h \
    46         psHash.h \
     23        psLookupTable.h \
    4724        psMetadata.h \
    48         psMetadataIO.h
    49 
     25        psMetadataConfig.h \
     26        psPixels.h
  • trunk/psLib/src/types/psArray.c

    r4392 r4540  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-06-25 02:02:04 $
     11 *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-07-12 19:12:01 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2828#include "psLogMsg.h"
    2929
    30 #include "psCollectionsErrors.h"
     30#include "psErrorText.h"
    3131
    3232/*****************************************************************************
  • trunk/psLib/src/types/psBitSet.c

    r4392 r4540  
    1111 *  @author Robert DeSonia, MHPCC
    1212 *
    13  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-06-25 02:02:05 $
     13 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-07-12 19:12:01 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2828#include "psString.h"
    2929
    30 #include "psCollectionsErrors.h"
     30#include "psErrorText.h"
    3131
    3232enum {
  • trunk/psLib/src/types/psHash.c

    r4392 r4540  
    1212*  @author GLG, MHPCC
    1313*
    14 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2005-06-25 02:02:05 $
     14*  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2005-07-12 19:12:01 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "psConstants.h"
    2828
    29 #include "psCollectionsErrors.h"
     29#include "psErrorText.h"
    3030
    3131static psHashBucket* hashBucketAlloc(const char *key, psPtr data, psHashBucket* next);
  • trunk/psLib/src/types/psList.c

    r4392 r4540  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-06-25 02:02:05 $
     8 *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-07-12 19:12:01 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "psLogMsg.h"
    2424
    25 #include "psCollectionsErrors.h"
     25#include "psErrorText.h"
    2626
    2727#define ITER_INIT_HEAD ((psPtr )1)         // next iteration should return head
  • trunk/psLib/src/types/psLookupTable.c

    r4392 r4540  
    77*  @author Ross Harman, MHPCC
    88*
    9 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2005-06-25 02:02:05 $
     9*  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2005-07-12 19:12:01 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
     
    2525#include "psError.h"
    2626#include "psLookupTable.h"
    27 #include "psFileUtilsErrors.h"
     27#include "psErrorText.h"
    2828#include "psConstants.h"
    2929
  • trunk/psLib/src/types/psMetadata.c

    r4401 r4540  
    1212*  @author Ross Harman, MHPCC
    1313*
    14 *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2005-06-27 20:38:12 $
     14*  @version $Revision: 1.70 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2005-07-12 19:12:01 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3636#include "psLookupTable.h"
    3737#include "psString.h"
    38 #include "psAstronomyErrors.h"
     38#include "psErrorText.h"
    3939#include "psConstants.h"
    4040#include "psLogMsg.h"
  • trunk/psLib/src/types/psMetadataConfig.c

    r4432 r4540  
    1 /** @file  psMetadataIO.c
     1/** @file  psMetadataConfig.c
    22*
    33*  @brief Contains metadata input/output functions.
     
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-06-30 00:04:12 $
     12*  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-07-12 19:12:01 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1616*/
    1717
    18 #include <libxml/parser.h>
    1918#include <fitsio.h>
    2019#include <string.h>
     
    3130#include "psVector.h"
    3231#include "psMetadata.h"
    33 #include "psMetadataIO.h"
     32#include "psMetadataConfig.h"
    3433#include "psConstants.h"
    35 #include "psAstronomyErrors.h"
    36 
    37 /******************************************************************************/
    38 /*  DEFINE STATEMENTS                                                         */
    39 /******************************************************************************/
     34#include "psErrorText.h"
    4035
    4136/** Check for FITS errors */
     
    5954#define MAX_STRING_LENGTH 256
    6055
    61 
    62 /******************************************************************************/
    63 /*  TYPE DEFINITIONS                                                          */
    64 /******************************************************************************/
    65 
    66 // None
    67 
    68 /*****************************************************************************/
    69 /*  GLOBAL VARIABLES                                                         */
    70 /*****************************************************************************/
    71 
    72 // None
    73 
    74 /*****************************************************************************/
    75 /*  FILE STATIC VARIABLES                                                    */
    76 /*****************************************************************************/
    77 
    78 // None
    79 
    80 /*****************************************************************************/
    81 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    82 /*****************************************************************************/
    83 
    84 static void saxEndElement(void *ctx, const xmlChar *tagName);
    85 static void initVectorXml(void *ctx, char *tagName);
    86 static void initMetadataItemXml(void *ctx, char *tagName);
    87 static void saxStartElement(void *ctx, const xmlChar *tagName, const xmlChar **atts);
    8856static psMetadata* getMetadataType(char *linePtr);
     57
    8958static psMetadata* setMetadataItem(psMetadata* template, char* linePtr)
    9059;
     60
    9161static void parseLevelInfoFree(p_psParseLevelInfo* info);
     62
    9263static psBool parseLine(psS32* level,   psArray* levelArray,
    93                         char*  linePtr, psS32 lineCount,     char* fileName, psBool overwrite);
    94 static psBool parseMetadataItem(char* keyName, psS32* level,     psArray* levelArray,
    95                                 char* linePtr, psS32  lineCount, char*    fileName,    psMetadataFlags flags);
     64                        char*  linePtr, psS32 lineCount, char* fileName,
     65                        psBool overwrite);
     66
     67static psBool parseMetadataItem(char* keyName, psS32* level,
     68                                psArray* levelArray, char* linePtr,
     69                                psS32 lineCount, char* fileName,
     70                                psMetadataFlags flags);
    9671
    9772static void parseLevelInfoFree(p_psParseLevelInfo* info)
     
    10681// Determines if a line is blank (whitespace only) or a commentline. It returns true if so. The input string
    10782// must be null terminated.
    108 psBool ignoreLine(char *inString)
     83static psBool ignoreLine(char *inString)
    10984{
    11085    while(*inString!='\0' && *inString!='#') {
     
    12196//  Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null
    12297//  terminated copy of the original input string.
    123 char *cleanString(char *inString, psS32 sLen, psBool ignoreComment)
     98static char *cleanString(char *inString, psS32 sLen, psBool ignoreComment)
    12499{
    125100    char *ptrB = NULL;
     
    167142
    168143// Count repeat occurances of a single character within a line. The input string must be null terminated.
    169 psS32 repeatedChars(char *inString, char ch)
     144static psS32 repeatedChars(char *inString, char ch)
    170145{
    171146    psS32 count = 0;
     
    183158// Returns cleaned token based on delimiter, but not including delimiter. Also changes the pointer location
    184159// the beginning of the string. Tokens are newly allocated null terminated strings.
    185 char* getToken(char **inString, char *delimiter, psS32 *status, psBool ignoreComment)
     160static char* getToken(char **inString, char *delimiter, psS32 *status, psBool ignoreComment)
    186161{
    187162    char *cleanToken = NULL;
     
    217192// Returns single parsed value as a double precision number. The input string must be cleaned and null
    218193// terminated.
    219 double parseValue(char *inString, psS32 *status)
     194static double parseValue(char *inString, psS32 *status)
    220195{
    221196    char *end = NULL;
     
    233208
    234209/** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are acceptable, parsable variations. */
    235 psBool parseBool(char *inString, psS32 *status)
     210static psBool parseBool(char *inString, psS32 *status)
    236211{
    237212    psBool value = false;
     
    250225
    251226/** Returns parsed vector filled with with data. The input string must be null terminated. */
    252 psVector* parseVector(char *inString, psElemType elemType, psS32 *status)
     227static psVector* parseVector(char *inString, psElemType elemType, psS32 *status)
    253228{
    254229    char*      end       = NULL;
     
    11381113}
    11391114
    1140 
    1141 static void saxStartElement(void *ctx, const xmlChar *tagName, const xmlChar **atts)
    1142 {
    1143     psU64 i = 0;
    1144     char* psTagName = NULL;
    1145     char *psAttName = NULL;
    1146     char *psAttValue = NULL;
    1147     const xmlChar *attName = NULL;
    1148     const xmlChar *attValue = NULL;
    1149     psMetadata* md = NULL;
    1150     psHash* htAtts = NULL;
    1151     xmlParserCtxtPtr ctxt = NULL;
    1152     xmlParserInputPtr input = NULL;
    1153 
    1154 
    1155     // Get and check initial data pointers
    1156     ctxt = (xmlParserCtxtPtr)ctx;
    1157     PS_ASSERT_GENERAL_PTR_NON_NULL(ctxt, return);
    1158     md = (psMetadata*)ctxt->sax->_private;
    1159     PS_ASSERT_GENERAL_PTR_NON_NULL(md, return);
    1160     input = (xmlParserInputPtr)ctxt->input;
    1161     PS_ASSERT_GENERAL_PTR_NON_NULL(input, return);
    1162 
    1163     // Copy XML strings to psStrings to avoid libxml2/psLib memory corruption problems
    1164     psTagName = psStringCopy((const char*)tagName);
    1165 
    1166     // Metadata containter for housing element attributes used by other SAX events
    1167     htAtts = psHashAlloc(10);
    1168 
    1169 
    1170     // Get tag name
    1171     if(psTagName != NULL) {
    1172         psHashAdd(htAtts, "tagName", psTagName);
    1173     } else {
    1174         PS_ASSERT_GENERAL_PTR_NON_NULL(psTagName, return);
    1175         psFree(htAtts);
    1176         psFree(psTagName);
    1177         return;
    1178     }
    1179 
    1180     // Get all attribute names and attribute values
    1181     if(atts != NULL) {
    1182         attName = atts[i++];
    1183         attValue = atts[i++];
    1184         while(attName != NULL) {
    1185             if(attValue != NULL) {
    1186 
    1187                 // Copy XML strings to psStrings to avoid libxml2/psLib memory corruption problems
    1188                 psAttName = psStringCopy((const char*)attName);
    1189                 psAttValue = psStringCopy((const char*)attValue);
    1190                 psHashAdd(htAtts, psAttName, psAttValue);
    1191                 psFree(psAttName);
    1192                 psFree(psAttValue);
    1193             } else {
    1194                 PS_ASSERT_GENERAL_PTR_NON_NULL(psAttValue, return);
    1195                 psFree(htAtts);
    1196                 psFree(psTagName);
    1197                 return;
    1198             }
    1199             attName = atts[i++];
    1200             attValue = atts[i++];
    1201         }
    1202     }
    1203 
    1204     // Add attributes to metadata
    1205 
    1206     psMetadataAdd(md, PS_LIST_TAIL, "htAtts",
    1207                   PS_META_HASH | PS_META_DUPLICATE_OK,
    1208                   NULL, htAtts);
    1209 
    1210     psFree(psTagName);
    1211     psFree(htAtts);
    1212 
    1213     return;
    1214 }
    1215 
    1216 static void initMetadataItemXml(void *ctx, char *tagName)
    1217 {
    1218     psBool overwrite = false;
    1219     psBool tempBool = false;
    1220     psS32 status = 0;
    1221     psU32 lineNumber = 0;
    1222     psF64 tempDbl = 0.0;
    1223     psS32 tempInt = 0.0;
    1224     psMetadataType mdType = PS_META_UNKNOWN;
    1225     char *fileName = NULL;
    1226     char *strName = NULL;
    1227     char *strType = NULL;
    1228     char *strValue = NULL;
    1229     psMetadata* md = NULL;
    1230     psHash* htAtts = NULL;
    1231     psMetadataItem *metadataItem = NULL;
    1232     xmlParserCtxtPtr ctxt = NULL;
    1233     xmlParserInputPtr input = NULL;
    1234 
    1235 
    1236     // Get and check initial data pointers
    1237     ctxt = (xmlParserCtxtPtr)ctx;
    1238     PS_ASSERT_GENERAL_PTR_NON_NULL(ctxt, return);
    1239     md = (psMetadata*)ctxt->sax->_private;
    1240     PS_ASSERT_GENERAL_PTR_NON_NULL(md, return);
    1241     input = (xmlParserInputPtr)ctxt->input;
    1242     PS_ASSERT_GENERAL_PTR_NON_NULL(input, return);
    1243     metadataItem = psMetadataLookup(md, "htAtts");
    1244     PS_ASSERT_GENERAL_PTR_NON_NULL(metadataItem, return);
    1245     PS_ASSERT_GENERAL_PTR_NON_NULL(metadataItem->data.list, return);
    1246     metadataItem = (psMetadataItem*)psListGet(metadataItem->data.list,PS_LIST_TAIL);
    1247     htAtts = (psHash*)metadataItem->data.list;
    1248     PS_ASSERT_GENERAL_PTR_NON_NULL(htAtts, return);
    1249     fileName = (char*)input->filename;
    1250     PS_ASSERT_GENERAL_PTR_NON_NULL(fileName, return);
    1251     lineNumber = input->line;
    1252 
    1253     // Get attribute name
    1254     strName = psHashLookup(htAtts, "name");
    1255     if(strName == NULL) {
    1256         psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_NO_NAME, lineNumber, fileName);
    1257         return;
    1258     }
    1259 
    1260     // Get attribute type, if there is one
    1261     strType = psHashLookup(htAtts, "psType");
    1262     if(strType!= NULL) {
    1263         if(xmlStrEqual(BAD_CAST strType, BAD_CAST "psString")) {
    1264             mdType = PS_META_STR;
    1265         } else if(xmlStrEqual(BAD_CAST strType, BAD_CAST "psBool")) {
    1266             mdType = PS_META_BOOL;
    1267         } else if(xmlStrEqual(BAD_CAST strType, BAD_CAST "psS32")) {
    1268             mdType = PS_META_S32;
    1269         } else if(xmlStrEqual(BAD_CAST strType, BAD_CAST "psF32")) {
    1270             mdType = PS_META_F32;
    1271         } else if(xmlStrEqual(BAD_CAST strType, BAD_CAST "psF64")) {
    1272             mdType = PS_META_F64;
    1273         } else {
    1274             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_TYPE_INVALID_LINE_FILE, strType, lineNumber,
    1275                     fileName);
    1276             return;
    1277         }
    1278     }
    1279 
    1280     // Get attribute value, if there is one
    1281     strValue = psHashLookup(htAtts, "value");
    1282 
    1283     /* If metadata item is found, and is not a folder node, and overwrite is allowed, then remove
    1284     existing and allow switch/case below to add new item. If overwrite is false, then report error. If
    1285     found item is folder node, then psMetadataAdd will automatically add a new child. */
    1286     metadataItem = psMetadataLookup(md, "overwrite");
    1287     if(metadataItem != NULL) {
    1288         overwrite = parseBool((char*)strValue, &status);
    1289         if(status) {
    1290             status = 0;
    1291             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, strName, strType,
    1292                     lineNumber, fileName);
    1293         }
    1294         metadataItem = psMetadataLookup(md, strName);
    1295         if(metadataItem != NULL) {
    1296             if(metadataItem->type != PS_META_LIST) {
    1297                 if(overwrite) {
    1298                     psMetadataRemove(md, INT_MIN, strName);
    1299                 } else {
    1300                     psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM, strName, lineNumber,
    1301                             fileName);
    1302                     return;
    1303                 }
    1304             }
    1305         }
    1306     }
    1307 
    1308     // Create metadata item and add to metadata
    1309     switch(mdType) {
    1310     case PS_META_LIST:
    1311         psMetadataAdd(md, PS_LIST_TAIL, strName,
    1312                       mdType | PS_META_DUPLICATE_OK,
    1313                       NULL, NULL);
    1314         break;
    1315     case PS_META_STR:
    1316         psMetadataAdd(md, PS_LIST_TAIL, strName,
    1317                       mdType | PS_META_DUPLICATE_OK,
    1318                       NULL, strValue);
    1319         break;
    1320     case PS_META_BOOL:
    1321         tempBool = parseBool((char*)strValue, &status);
    1322         if(!status) {
    1323             psMetadataAdd(md, PS_LIST_TAIL, strName,
    1324                           mdType | PS_META_DUPLICATE_OK,
    1325                           NULL, tempBool);
    1326         } else {
    1327             status = 0;
    1328             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, strName, strType,
    1329                     lineNumber, fileName);
    1330         }
    1331         break;
    1332     case PS_META_S32:
    1333         tempInt = (psS32)parseValue((char*)strValue, &status);
    1334         if(!status) {
    1335             psMetadataAdd(md, PS_LIST_TAIL, strName,
    1336                           mdType | PS_META_DUPLICATE_OK,
    1337                           NULL, tempInt);
    1338         } else {
    1339             status = 0;
    1340             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, strName, strType,
    1341                     lineNumber, fileName);
    1342         }
    1343         break;
    1344     case PS_META_F32:
    1345     case PS_META_F64:
    1346         tempDbl = parseValue((char*)strValue, &status);
    1347         if(!status) {
    1348             psMetadataAdd(md, PS_LIST_TAIL, strName,
    1349                           mdType | PS_META_DUPLICATE_OK,
    1350                           NULL, tempDbl);
    1351         } else {
    1352             status = 0;
    1353             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, strName, strType,
    1354                     lineNumber, fileName);
    1355         }
    1356         break;
    1357     default:
    1358         psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID, strType, lineNumber, fileName);
    1359     } // End switch
    1360 
    1361     return;
    1362 }
    1363 
    1364 
    1365 static void initVectorXml(void *ctx, char *tagName)
    1366 {
    1367     bool overwrite = false;
    1368     psS32 status = 0;
    1369     psU32 lineNumber = 0;
    1370     psElemType pType = 0;
    1371     char *strName = NULL;
    1372     char *strType = NULL;
    1373     char *strValue = NULL;
    1374     char *fileName = NULL;
    1375     psMetadataItem *table = NULL;
    1376     psMetadataItem *tables = NULL;
    1377     psMetadataItem *metadataItem = NULL;
    1378     psVector *vec = NULL;
    1379     psMetadata* md = NULL;
    1380     psHash* htAtts = NULL;
    1381     xmlParserCtxtPtr ctxt = NULL;
    1382     xmlParserInputPtr input = NULL;
    1383 
    1384 
    1385     // Get and check initial data pointers
    1386     ctxt = (xmlParserCtxtPtr)ctx;
    1387     PS_ASSERT_GENERAL_PTR_NON_NULL(ctxt, return);
    1388     md = (psMetadata*)ctxt->sax->_private;
    1389     PS_ASSERT_GENERAL_PTR_NON_NULL(md, return);
    1390     input = (xmlParserInputPtr)ctxt->input;
    1391     PS_ASSERT_GENERAL_PTR_NON_NULL(input, return);
    1392     tables = psMetadataLookup(md, "htAtts");
    1393     PS_ASSERT_GENERAL_PTR_NON_NULL(tables, return);
    1394     PS_ASSERT_GENERAL_PTR_NON_NULL(tables->data.list, return);
    1395     table = (psMetadataItem*)psListGet(tables->data.list,PS_LIST_TAIL);
    1396     htAtts = (psHash*)table->data.list;
    1397     PS_ASSERT_GENERAL_PTR_NON_NULL(htAtts, return);
    1398     fileName = (char*)input->filename;
    1399     PS_ASSERT_GENERAL_PTR_NON_NULL(fileName, return);
    1400     lineNumber = input->line;
    1401 
    1402     // Get attribute name
    1403     strName = psHashLookup(htAtts, "name");
    1404     if(strName == NULL) {
    1405         psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_NO_NAME, lineNumber, fileName);
    1406         return;
    1407     }
    1408 
    1409     // Get attribute type, if there is one
    1410     strType = psHashLookup(htAtts, "psType");
    1411     if(strType!= NULL) {
    1412         if(xmlStrEqual(BAD_CAST strType, BAD_CAST "psBool")) {
    1413             pType = PS_TYPE_U8;
    1414         } else if(xmlStrEqual(BAD_CAST strType, BAD_CAST "psS32")) {
    1415             pType = PS_TYPE_S32;
    1416         } else if(xmlStrEqual(BAD_CAST strType, BAD_CAST "psF32")) {
    1417             pType = PS_TYPE_F32;
    1418         } else if(xmlStrEqual(BAD_CAST strType, BAD_CAST "psF64")) {
    1419             pType = PS_TYPE_F64;
    1420         } else {
    1421             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_TYPE_INVALID_LINE_FILE, strName, lineNumber,
    1422                     fileName);
    1423             return;
    1424         }
    1425     }
    1426 
    1427     strValue = psHashLookup(htAtts, "value");
    1428     PS_ASSERT_GENERAL_PTR_NON_NULL(strValue, return);
    1429 
    1430 
    1431     /* If metadata item is found, and is not a folder node, and overwrite is allowed, then remove
    1432     existing and allow switch/case below to add new item. If overwrite is false, then report error. If
    1433     found item is folder node, then psMetadataAdd will automatically add a new child. */
    1434     metadataItem = psMetadataLookup(md, "overwrite");
    1435     if(metadataItem != NULL) {
    1436         overwrite = parseBool((char*)strValue, &status);
    1437         if(status) {
    1438             status = 0;
    1439             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, strName, strType,
    1440                     input->line, input->filename);
    1441         }
    1442         metadataItem = psMetadataLookup(md, strName);
    1443         if(metadataItem != NULL) {
    1444             if(metadataItem->type != PS_META_LIST) {
    1445                 if(overwrite) {
    1446                     psMetadataRemove(md, INT_MIN, strName);
    1447                 } else {
    1448                     psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM, strName, lineNumber,
    1449                             fileName);
    1450                     return;
    1451                 }
    1452             }
    1453         }
    1454     }
    1455 
    1456     // Get value
    1457     vec = parseVector((char*)strValue, pType, &status);
    1458     if(!status) {
    1459         psMetadataAdd(md, PS_LIST_TAIL, strName+1,
    1460                       PS_META_VEC | PS_META_DUPLICATE_OK,
    1461                       NULL, vec);
    1462     } else {
    1463         psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, strName, strType,
    1464                 lineNumber, fileName);
    1465     }
    1466     psFree(vec);
    1467 }
    1468 
    1469 static void saxEndElement(void *ctx, const xmlChar *tagName)
    1470 {
    1471     char *psStartTagName = NULL;
    1472     char *psEndTagName = NULL;
    1473     psMetadata* md = NULL;
    1474     psHash* htAtts = NULL;
    1475     psMetadataItem *table = NULL;
    1476     psMetadataItem *tables = NULL;
    1477     xmlParserCtxtPtr ctxt = NULL;
    1478     xmlParserInputPtr input = NULL;
    1479 
    1480 
    1481     // Get and check initial data pointers
    1482     ctxt = (xmlParserCtxtPtr)ctx;
    1483     PS_ASSERT_GENERAL_PTR_NON_NULL(ctxt, return);
    1484     md = (psMetadata*)ctxt->sax->_private;
    1485     PS_ASSERT_GENERAL_PTR_NON_NULL(md, return);
    1486     input = (xmlParserInputPtr)ctxt->input;
    1487     PS_ASSERT_GENERAL_PTR_NON_NULL(input, return);
    1488     tables = psMetadataLookup(md, "htAtts");
    1489     PS_ASSERT_GENERAL_PTR_NON_NULL(tables, return);
    1490     PS_ASSERT_GENERAL_PTR_NON_NULL(tables->data.list, return);
    1491     table = (psMetadataItem*)psListGet(tables->data.list,PS_LIST_TAIL);
    1492     htAtts = (psHash*)table->data.list;
    1493     PS_ASSERT_GENERAL_PTR_NON_NULL(htAtts, return);
    1494 
    1495     // Copy XML strings to psStrings to avoid libxml2/psLib memory corruption problems
    1496     psEndTagName = psStringCopy((const char*)tagName);
    1497 
    1498     // Compare start and end tag names
    1499     psStartTagName = psHashLookup(htAtts, "tagName");
    1500     PS_ASSERT_GENERAL_PTR_NON_NULL(psStartTagName, return);
    1501     if(strcmp(psEndTagName, psStartTagName)) {
    1502         psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_TAG_MISMATCH, psStartTagName, psEndTagName);
    1503     }
    1504 
    1505     // Initialize psLib structs
    1506     if(!strcmp(psEndTagName, "psMetadataItem")) {
    1507         initMetadataItemXml(ctx, psEndTagName);
    1508     } else if(!strcmp(psEndTagName, "psVector")) {
    1509         initVectorXml(ctx, psEndTagName);
    1510     } else if(strcmp(psEndTagName, "psRoot")) {
    1511         psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_TAG_UNKNOWN, psEndTagName);
    1512     }
    1513 
    1514     // Free temporary metadata item and its hash table
    1515     psListRemove(tables->data.list, PS_LIST_TAIL);
    1516 
    1517     psFree(psEndTagName);
    1518 
    1519     return;
    1520 }
    1521 
    1522 psMetadata*  psMetadataConfigParseXml(psMetadata* md, psU32 *nFail, const char *fileName, psBool overwrite)
    1523 {
    1524     xmlSAXHandler saxHandler;
    1525 
    1526 
    1527     // Error checks
    1528     PS_ASSERT_PTR_NON_NULL(fileName, NULL);
    1529 
    1530     // Allocate metadata if necessary
    1531     if (md == NULL) {
    1532         md = psMetadataAlloc();
    1533     }
    1534 
    1535     // Sax handler initializations
    1536     saxHandler.internalSubset           = NULL;
    1537     saxHandler.isStandalone             = NULL;
    1538     saxHandler.hasInternalSubset        = NULL;
    1539     saxHandler.hasExternalSubset        = NULL;
    1540     saxHandler.resolveEntity            = NULL;
    1541     saxHandler.getEntity                = NULL;
    1542     saxHandler.entityDecl               = NULL;
    1543     saxHandler.notationDecl             = NULL;
    1544     saxHandler.attributeDecl            = NULL;
    1545     saxHandler.elementDecl              = NULL;
    1546     saxHandler.unparsedEntityDecl       = NULL;
    1547     saxHandler.setDocumentLocator       = NULL;
    1548     saxHandler.startDocument            = NULL;
    1549     saxHandler.endDocument              = NULL;
    1550     saxHandler.startElement             = saxStartElement;
    1551     saxHandler.endElement               = saxEndElement;
    1552     saxHandler.reference                = NULL;
    1553     saxHandler.characters               = NULL;
    1554     saxHandler.ignorableWhitespace      = NULL;
    1555     saxHandler.processingInstruction    = NULL;
    1556     saxHandler.comment                  = NULL;
    1557     saxHandler.warning                  = xmlParserError;
    1558     saxHandler.error                    = xmlParserError;
    1559     saxHandler.fatalError               = xmlParserError;
    1560     saxHandler.getParameterEntity       = NULL;
    1561     saxHandler.cdataBlock               = NULL;
    1562     saxHandler.externalSubset           = NULL;
    1563     saxHandler.initialized              = 1;
    1564     saxHandler._private                 = md;
    1565     saxHandler.startElementNs           = NULL;
    1566     saxHandler.endElementNs             = NULL;
    1567     saxHandler.serror                   = NULL;
    1568 
    1569     // Parse XML file
    1570     if (xmlSAXUserParseFile(&saxHandler, NULL, fileName)) {
    1571         psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED, fileName);
    1572         return NULL;
    1573     }
    1574 
    1575     // Parser and memory cleanups for libxml2
    1576     xmlCleanupParser();
    1577     xmlMemoryDump();
    1578 
    1579     return md;
    1580 }
  • trunk/psLib/src/types/psMetadataConfig.h

    r4409 r4540  
    1 /** @file  psMetadataIO.h
     1/** @file  psMetadataConfig.h
    22 *
    33 *  @brief Contains metadata input/output functions.
     
    1010 *  @author Robert DeSonia, MHPCC
    1111 *
    12  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-06-28 20:17:52 $
     12 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-07-12 19:12:01 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1616 */
    17 #ifndef PS_METADATAIO_H
    18 #define PS_METADATAIO_H
     17#ifndef PS_METADATACONFIG_H
     18#define PS_METADATACONFIG_H
     19
     20#include "psMetadata.h"
    1921
    2022/// @addtogroup Metadata
     
    2224
    2325/** A metadata data structure used in parsing arrays.
    24  * 
     26 *
    2527 *  Contains array information and the metadata storage location.
    2628*/
     
    3638
    3739/** Allocates a p_psParseLevelInfo structure
    38  *   
     40 *
    3941 *  @return p_psParseLevelInfo* :   new p_psParseLevelInfo struct
    4042 */
     
    8688);
    8789
    88 /** Read XML metadata configuration file.
    89  *
    90  *  Loads pre-defined XML settings by parsing a configuration file into a psMetadata structure.
    91  *
    92  *  @return psMetadata* : Resulting metadata from read.
    93  */
    94 
    95 psMetadata*  psMetadataConfigParseXml(
    96     psMetadata* md,                    ///< Resulting metadata from read.
    97     psU32 *nFail,                      ///< Number of failed lines.
    98     const char *fileName,              ///< Name of file to read.
    99     psBool overwrite                   ///< Allow overwrite of duplicate specifications.
    100 );
    101 
    10290/// @}
    10391
  • trunk/psLib/src/types/psPixels.c

    r4401 r4540  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-06-27 20:38:12 $
     9 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-07-12 19:12:01 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2020
    2121#include "psError.h"
    22 #include "psCollectionsErrors.h"
     22#include "psErrorText.h"
    2323
    2424typedef int(*qsortCompareFcn)(const void *, const void *);
  • trunk/psLib/src/xml/Makefile.am

    r4446 r4540  
    1 #Makefile for dataIO functions of psLib
     1#Makefile for xml functions of psLib
    22#
    3 INCLUDES = \
    4         -I$(top_srcdir)/src/astro \
    5         -I$(top_srcdir)/src/db \
    6         -I$(top_srcdir)/src/fft \
    7         -I$(top_srcdir)/src/fits \
    8         -I$(top_srcdir)/src/imageops \
    9         -I$(top_srcdir)/src/math \
    10         -I$(top_srcdir)/src/mathtypes \
    11         -I$(top_srcdir)/src/sys \
    12         -I$(top_srcdir)/src/types \
    13         -I$(top_srcdir)/src/xml \
    14         $(all_includes)
     3noinst_LTLIBRARIES = libpslibxml.la
    154
    16 noinst_LTLIBRARIES = libpslibdataIO.la
     5libpslibxml_la_SOURCES = \
     6        psXML.c
    177
    18 libpslibdataIO_la_SOURCES = \
    19         psLookupTable.c \
    20         psFits.c \
    21         psDB.c
    22 
    23 
    24 BUILT_SOURCES = psFileUtilsErrors.h
    25 EXTRA_DIST = psFileUtilsErrors.dat psFileUtilsErrors.h dataIO.i
    26 
    27 psFileUtilsErrors.h: psFileUtilsErrors.dat
    28         $(top_srcdir)/src/psParseErrorCodes --data=$? $@
     8EXTRA_DIST = xml.i
    299
    3010pslibincludedir = $(includedir)
    3111pslibinclude_HEADERS = \
    32         psLookupTable.h \
    33         psFits.h \
    34         psDB.h
    35 
     12        psXML.h
  • trunk/psLib/src/xml/psXML.c

    r4432 r4540  
    1 /** @file  psMetadataIO.c
     1/** @file  psXML.c
    22*
    3 *  @brief Contains metadata input/output functions.
     3*  @brief Contains XML input/output functions.
    44*
    5 *  This file defines functions to read and write metadata to/from an external file.
     5*  This file defines functions to read metadata from an XML file.
    66*
    7 *  @ingroup Metadata
     7*  @ingroup XML
    88*
    99*  @author Ross Harman, MHPCC
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-06-30 00:04:12 $
     12*  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-07-12 19:12:01 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1717
    1818#include <libxml/parser.h>
    19 #include <fitsio.h>
    2019#include <string.h>
    2120#include <ctype.h>
    2221#include <limits.h>
    2322
    24 #include "psAbort.h"
    25 #include "psType.h"
     23#include "psXML.h"
    2624#include "psMemory.h"
    2725#include "psError.h"
    2826#include "psString.h"
    29 #include "psList.h"
    30 #include "psHash.h"
    31 #include "psVector.h"
    32 #include "psMetadata.h"
    33 #include "psMetadataIO.h"
    3427#include "psConstants.h"
    35 #include "psAstronomyErrors.h"
     28#include "psErrorText.h"
    3629
    3730/******************************************************************************/
     
    3932/******************************************************************************/
    4033
    41 /** Check for FITS errors */
    42 #define FITS_ERROR(STRING,PS_ERROR)                                                                          \
    43 fits_get_errstatus(status, fitsErr);                                                                         \
    44 psError(PS_ERR_IO,true, STRING, PS_ERROR, fitsErr);                                                          \
    45 status = 0;                                                                                                  \
    46 fits_close_file(fd, &status);                                                                                \
    47 if(status){                                                                                                  \
    48     fits_get_errstatus(status, fitsErr);                                                                     \
    49     psError(PS_ERR_IO,true, "Couldn't close FITS file. FITS error: %s", fitsErr);                            \
    50 }                                                                                                            \
    51 status = 0;                                                                                                  \
    52 psFree(output);                                                                                              \
    53 return NULL;
    54 
    5534/** Maximum size of a FITS line */
    5635#define FITS_LINE_SIZE 80
     
    5938#define MAX_STRING_LENGTH 256
    6039
    61 
    62 /******************************************************************************/
    63 /*  TYPE DEFINITIONS                                                          */
    64 /******************************************************************************/
    65 
    66 // None
    67 
    68 /*****************************************************************************/
    69 /*  GLOBAL VARIABLES                                                         */
    70 /*****************************************************************************/
    71 
    72 // None
    73 
    74 /*****************************************************************************/
    75 /*  FILE STATIC VARIABLES                                                    */
    76 /*****************************************************************************/
    77 
    78 // None
    79 
    80 /*****************************************************************************/
    81 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    82 /*****************************************************************************/
    83 
    84 static void saxEndElement(void *ctx, const xmlChar *tagName);
    85 static void initVectorXml(void *ctx, char *tagName);
    86 static void initMetadataItemXml(void *ctx, char *tagName);
    87 static void saxStartElement(void *ctx, const xmlChar *tagName, const xmlChar **atts);
    88 static psMetadata* getMetadataType(char *linePtr);
    89 static psMetadata* setMetadataItem(psMetadata* template, char* linePtr)
    90 ;
    91 static void parseLevelInfoFree(p_psParseLevelInfo* info);
    92 static psBool parseLine(psS32* level,   psArray* levelArray,
    93                         char*  linePtr, psS32 lineCount,     char* fileName, psBool overwrite);
    94 static psBool parseMetadataItem(char* keyName, psS32* level,     psArray* levelArray,
    95                                 char* linePtr, psS32  lineCount, char*    fileName,    psMetadataFlags flags);
    96 
    97 static void parseLevelInfoFree(p_psParseLevelInfo* info)
    98 {
    99     psFree(info->nonUniqueKeyArray);
    100     psFree(info->typeArray);
    101     psFree(info->templateArray);
    102     psFree(info->name);
    103     psFree(info->metadata);
    104 }
    105 
    106 // Determines if a line is blank (whitespace only) or a commentline. It returns true if so. The input string
    107 // must be null terminated.
    108 psBool ignoreLine(char *inString)
    109 {
    110     while(*inString!='\0' && *inString!='#') {
    111         if(!isspace(*inString)) {
    112             return false;
    113         }
    114         inString++;
    115     }
    116 
    117     return true;
    118 }
    119 
    120 
    121 //  Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null
    122 //  terminated copy of the original input string.
    123 char *cleanString(char *inString, psS32 sLen, psBool ignoreComment)
    124 {
    125     char *ptrB = NULL;
    126     char *ptrE = NULL;
    127     char *cleaned = NULL;
    128 
    129     // Initialize begining of string pointer
    130     ptrB = inString;
    131 
    132     // Skip over leading # or whitespace
    133     if(ignoreComment) {
    134         while (isspace(*ptrB) || *ptrB=='#') {
    135             ptrB++;
    136         }
    137     } else {
    138         while (isspace(*ptrB)) {
    139             ptrB++;
    140         }
    141     }
    142 
    143     // Skip over trailing whitespace, null terminators, and # characters
    144     ptrE = inString + sLen;
    145     if(ignoreComment) {
    146         while(isspace(*ptrE) || *ptrE=='\0' || *ptrE=='#') {
    147             ptrE--;
    148         }
    149     } else {
    150         while(isspace(*ptrE) || *ptrE=='\0') {
    151             ptrE--;
    152         }
    153     }
    154 
    155     // Length, sLen, does not include '\0'
    156     sLen = ptrE - ptrB + 1;
    157 
    158     // Adds '\0' to end of string and +1 to sLen
    159     if(sLen < 0 ) {
    160         cleaned = NULL;
    161     } else {
    162         cleaned = psStringNCopy(ptrB, sLen);
    163     }
    164 
    165     return cleaned;
    166 }
    167 
    168 // Count repeat occurances of a single character within a line. The input string must be null terminated.
    169 psS32 repeatedChars(char *inString, char ch)
    170 {
    171     psS32 count = 0;
    172 
    173     while(*inString!='\0') {
    174         if(*inString == ch) {
    175             count++;
    176         }
    177         inString++;
    178     }
    179 
    180     return count;
    181 }
    182 
    183 // Returns cleaned token based on delimiter, but not including delimiter. Also changes the pointer location
    184 // the beginning of the string. Tokens are newly allocated null terminated strings.
    185 char* getToken(char **inString, char *delimiter, psS32 *status, psBool ignoreComment)
    186 {
    187     char *cleanToken = NULL;
    188     char *convertChar = NULL;
    189     psS32 sLen = 0;
    190 
    191     // Convert tab characters to white space
    192     while((convertChar=strchr(*inString,'\t')) != NULL ) {
    193         *convertChar = ' ';
    194     }
    195 
    196     // Skip over leading whitespace
    197     while(isspace(**inString)) {
    198         (*inString)++;
    199     }
    200 
    201     // Length of token, not including delimiter
    202     sLen = strcspn(*inString, delimiter);
    203     if(sLen) {
    204 
    205         // Create new, cleaned, and null terminated token
    206         cleanToken = cleanString(*inString, sLen,ignoreComment);
    207 
    208         // Move to end of token
    209         (*inString) += sLen;
    210     } else if(**inString!='\0' && sLen==0) {
    211         *status = 1;
    212     }
    213 
    214     return cleanToken;
    215 }
    216 
    21740// Returns single parsed value as a double precision number. The input string must be cleaned and null
    21841// terminated.
    219 double parseValue(char *inString, psS32 *status)
     42static double parseValue(char *inString, psS32 *status)
    22043{
    22144    char *end = NULL;
     
    23356
    23457/** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are acceptable, parsable variations. */
    235 psBool parseBool(char *inString, psS32 *status)
     58static psBool parseBool(char *inString, psS32 *status)
    23659{
    23760    psBool value = false;
     
    25073
    25174/** Returns parsed vector filled with with data. The input string must be null terminated. */
    252 psVector* parseVector(char *inString, psElemType elemType, psS32 *status)
     75static psVector* parseVector(char *inString, psElemType elemType, psS32 *status)
    25376{
    25477    char*      end       = NULL;
     
    332155
    333156    return vec;
    334 }
    335 
    336 /*****************************************************************************/
    337 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    338 /*****************************************************************************/
    339 
    340 p_psParseLevelInfo* p_psParseLevelInfoAlloc(void)
    341 {
    342 
    343     p_psParseLevelInfo* info = NULL;
    344 
    345     // Allocate memory for parse level info
    346     info = (p_psParseLevelInfo*)psAlloc(sizeof(p_psParseLevelInfo));
    347 
    348     // If allocation successful then initialize members
    349     if(info != NULL) {
    350 
    351         info->nonUniqueKeyArray = psArrayAlloc(10);
    352         info->nonUniqueKeyArray->n = 0;
    353 
    354         info->typeArray = psArrayAlloc(10);
    355         info->typeArray->n = 0;
    356 
    357         info->templateArray = psArrayAlloc(10);
    358         info->templateArray->n = 0;
    359 
    360         info->metadata = NULL;
    361         info->name = NULL;
    362 
    363         // Set memory deallocator
    364         psMemSetDeallocator(info,(psFreeFunc)parseLevelInfoFree);
    365     }
    366     return info;
    367 }
    368 
    369 bool psMetadataItemPrint(FILE * fd, const char *format, const psMetadataItem* item)
    370 {
    371     psMetadataType type;
    372     psBool success = true;
    373 
    374     PS_ASSERT_PTR_NON_NULL(fd, success);
    375     PS_ASSERT_PTR_NON_NULL(format, success);
    376     PS_ASSERT_PTR_NON_NULL(item, success);
    377 
    378     type = item->type;
    379 
    380     // determining the format type
    381     char* fType = strchr(format,'%');
    382     if (fType == NULL) {
    383         // well, the format contains no reference to the metadataItem's data:
    384         // that is truly trival to do!
    385         fprintf(fd,format);
    386         return success;
    387     }
    388 
    389     // skip over any format modifiers
    390     const char* formatEnd = format+strlen(format);
    391     while ( (fType < formatEnd) &&
    392         (strchr(" +-01234567890.$#, hlL",*(++fType)) != NULL) ) {}
    393 
    394     #define METADATAITEM_NUMERIC_CAST(FORMAT_TYPE) { \
    395         switch(type) { \
    396         case PS_META_BOOL: \
    397             fprintf(fd, format, (FORMAT_TYPE) item->data.B); \
    398             break; \
    399         case PS_META_S32: \
    400             fprintf(fd,format,(FORMAT_TYPE)  item->data.S32); \
    401             break; \
    402         case PS_META_F32: \
    403             fprintf(fd, format,(FORMAT_TYPE)  item->data.F32); \
    404             break; \
    405         case PS_META_F64: \
    406             fprintf(fd, format,(FORMAT_TYPE) item->data.F64); \
    407             break; \
    408         default: \
    409             psError(PS_ERR_BAD_PARAMETER_TYPE,true, \
    410                     PS_ERRORTEXT_psMetadata_METATYPE_INVALID, (int)type); \
    411             success = false; \
    412         } \
    413     }
    414 
    415     switch(*fType) {
    416     case 'd':
    417     case 'i':
    418     case 'c':
    419         METADATAITEM_NUMERIC_CAST(int)
    420         break;
    421     case 'o':
    422     case 'u':
    423     case 'x':
    424     case 'X':
    425         METADATAITEM_NUMERIC_CAST(unsigned int)
    426         break;
    427     case 'e':
    428     case 'E':
    429     case 'f':
    430     case 'F':
    431     case 'g':
    432     case 'G':
    433     case 'a':
    434     case 'A':
    435         METADATAITEM_NUMERIC_CAST(double)
    436         break;
    437     case 's':
    438         if (type == PS_META_STR) {
    439             fprintf(fd,format,(char*)item->data.V);
    440         } else {
    441             psError(PS_ERR_BAD_PARAMETER_TYPE,true,
    442                     PS_ERRORTEXT_psMetadata_METATYPE_INVALID, (int)type);
    443             success = false;
    444         }
    445         break;
    446     case 'p':
    447         fprintf(fd,format,item->data.V);
    448         break;
    449     default:
    450         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    451                 PS_ERRORTEXT_psMetadata_FORMAT_INVALID, *fType);
    452         break;
    453     }
    454 
    455     return success;
    456 }
    457 
    458 
    459 psMetadata* psMetadataReadHeader(psMetadata* output, char *extName, psS32 extNum, char *fileName)
    460 {
    461     psBool tempBool;
    462     psBool success;
    463     char keyType;
    464     char keyName[FITS_LINE_SIZE];
    465     char keyValue[FITS_LINE_SIZE];
    466     char keyComment[FITS_LINE_SIZE];
    467     char fitsErr[MAX_STRING_LENGTH];
    468     psS32 i;
    469     psS32 hduType = 0;
    470     psS32 status = 0;
    471     psS32 numKeys = 0;
    472     psS32 keyNum = 0;
    473     fitsfile *fd = NULL;
    474 
    475     PS_ASSERT_PTR_NON_NULL(fileName,NULL);
    476 
    477     fits_open_file(&fd, fileName, READONLY, &status);
    478     if(fd == NULL || status != 0) {
    479         FITS_ERROR("FITS error while opening file: %s %s", fileName);
    480         return NULL;
    481     }
    482 
    483     if (extName == NULL && extNum < 1) {
    484         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    485                 PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE,
    486                 extNum);
    487         return NULL;
    488     }
    489 
    490     // Allocate metadata if user didn't
    491     if (output == NULL) {
    492         output = psMetadataAlloc();
    493     }
    494 
    495     // Move to user designated HDU number or HDU name in FITS file. HDU numbers starts at one.
    496     if (extName != NULL) {
    497         if (fits_movnam_hdu(fd, ANY_HDU, extName, 0, &status) != 0) {
    498             FITS_ERROR("FITS error while locating header %s: %s", extName);
    499         }
    500     } else {
    501         if (fits_movabs_hdu(fd, extNum, &hduType, &status) != 0) {
    502             FITS_ERROR("FITS error while locating header %d: %s", extNum);
    503         }
    504     }
    505 
    506     // Get number of key names
    507     if (fits_get_hdrpos(fd, &numKeys, &keyNum, &status) != 0) {
    508         FITS_ERROR("FITS error while reading key %d: %s", keyNum);
    509     }
    510 
    511     // Get each key name. Keywords start at one.
    512     for (i = 1; i <= numKeys; i++) {
    513         if (fits_read_keyn(fd, i, keyName, keyValue, keyComment, &status) != 0) {
    514             FITS_ERROR("FITS error while reading key %d: %s", keyNum);
    515         }
    516         if (fits_get_keytype(keyValue, &keyType, &status) != 0) {
    517             fits_get_errstatus(status, fitsErr);
    518             if (status != VALUE_UNDEFINED) {
    519                 FITS_ERROR("FITS error while determining key %d type: %s", keyNum);
    520             } else {
    521                 // Some keywords are still valid if they don't have a type (like COMMENTS and HISTORY)
    522                 keyType = 'C';
    523                 status = 0;
    524             }
    525         }
    526 
    527         switch (keyType) {
    528         case 'I':
    529             success = psMetadataAdd(output, PS_LIST_TAIL, keyName,
    530                                     PS_META_S32 | PS_META_DUPLICATE_OK,
    531                                     keyComment, atoi(keyValue));
    532             break;
    533         case 'F':
    534             success = psMetadataAdd(output, PS_LIST_TAIL, keyName,
    535                                     PS_META_F64 | PS_META_DUPLICATE_OK,
    536                                     keyComment, atof(keyValue));
    537             break;
    538         case 'C':
    539             success = psMetadataAdd(output, PS_LIST_TAIL, keyName,
    540                                     PS_META_STR | PS_META_DUPLICATE_OK,
    541                                     keyComment, keyValue);
    542             break;
    543         case 'L':
    544             tempBool = (keyValue[0] == 'T') ? 1 : 0;
    545             success = psMetadataAdd(output, PS_LIST_TAIL, keyName,
    546                                     PS_META_BOOL | PS_META_DUPLICATE_OK,
    547                                     keyComment, tempBool);
    548             break;
    549         case 'U':
    550         case 'X':
    551         default:
    552             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID, keyType);
    553             return output;
    554         }
    555 
    556         if (!success) {
    557             psError(PS_ERR_UNKNOWN, false, PS_ERRORTEXT_psMetadataIO_ADD_FAILED, keyName);
    558             return output;
    559         }
    560     }
    561 
    562     return output;
    563 }
    564 
    565 static psMetadata* getMetadataType(char* linePtr)
    566 {
    567     psMetadata*     metadataTemplate = NULL;
    568     psS32           status           = 0;
    569     char*           token            = NULL;
    570     psMetadataItem* tempItem         = NULL;
    571 
    572     // Loop through line and generate metadata items for each token found
    573     while((token = getToken(&linePtr," ",&status,false)) != NULL ) {
    574 
    575         // If not allocated then allocate new metadata
    576         if(metadataTemplate == NULL) {
    577             metadataTemplate = psMetadataAlloc();
    578         }
    579 
    580         // Look for comment indicator #
    581         if(strstr(token,"#") != 0) {
    582             psFree(token);
    583             break;
    584         }
    585 
    586         // Create metadata item to represent token read
    587         tempItem = psMetadataItemAllocStr(token,"","");
    588         if(tempItem == NULL) {
    589             psFree(metadataTemplate);
    590             psFree(token);
    591             metadataTemplate = NULL;
    592             break;
    593         }
    594 
    595         // Add item to template
    596         if(!psMetadataAddItem(metadataTemplate, tempItem, PS_LIST_TAIL, PS_META_DEFAULT)) {
    597             psFree(metadataTemplate);
    598             psFree(tempItem);
    599             psFree(token);
    600             metadataTemplate = NULL;
    601             break;
    602         }
    603         psFree(tempItem);
    604         psFree(token);
    605     }
    606 
    607     return metadataTemplate;
    608 }
    609 
    610 static psMetadata* setMetadataItem(psMetadata* template, char* linePtr)
    611 {
    612     psMetadata*      md           = NULL;
    613     psS32            items        = 0;
    614     char*            token        = NULL;
    615     psS32            status       = 0;
    616     psMetadataItem*  mdItem       = NULL;
    617     psMetadataItem*  templateItem = NULL;
    618     psListIterator*  iter         = NULL;
    619 
    620     // Determine the number of items in template
    621     items = template->list->size;
    622     if(items > 0 ) {
    623 
    624         // Allocate metadata
    625         md = psMetadataAlloc()
    626              ;
    627 
    628         // Point to first item in template
    629         iter = psListIteratorAlloc(template->
    630                                    list,PS_LIST_HEAD,true);
    631 
    632         // For each item in template parse line string for values
    633         for(psS32 i = 0;
    634                 i < items;
    635                 i++) {
    636 
    637             // Get template item
    638             templateItem = psListGetAndIncrement(iter)
    639                            ;
    640             if(templateItem == NULL) {
    641                 psFree(md);
    642                 md = NULL;
    643                 break;
    644             }
    645 
    646             // Get the next token on the line
    647             token = getToken(&linePtr," ",&status,false);
    648             if(token != NULL) {
    649                 // Allocate metadata item
    650                 mdItem = psMetadataItemAllocStr(templateItem->name,templateItem->comment,token);
    651                 if(mdItem == NULL) {
    652                     psFree(md);
    653                     md = NULL;
    654                     psFree(token);
    655                     break;
    656                 }
    657                 // Add item to metadata
    658                 if(!psMetadataAddItem(md, mdItem, PS_LIST_TAIL, PS_META_DEFAULT)) {
    659                     psFree(md);
    660                     md = NULL;
    661                     psFree(mdItem);
    662                     psFree(token);
    663                     break;
    664                 }
    665                 psFree(mdItem);
    666             } else {
    667                 // Missing items
    668                 psFree(md);
    669                 md = NULL;
    670                 break;
    671             }
    672 
    673             psFree(token);
    674         }
    675         psFree(iter);
    676     }
    677     return md;
    678 }
    679 
    680 psBool parseMetadataItem(char* keyName, psS32* level,     psArray* levelArray,
    681                          char* linePtr, psS32  lineCount, char*    fileName,   psMetadataFlags flags)
    682 {
    683     psBool               returnValue   = true;
    684     psBool               addStatus     = false;
    685     psMetadataType       mdType        = PS_META_UNKNOWN;
    686     psElemType           vectorType    = PS_TYPE_S8;
    687     char*                strType       = NULL;
    688     char*                strValue      = NULL;
    689     char*                strComment    = NULL;
    690     psS32                status        = 0;
    691     psMetadata*          md            = NULL;
    692     psF64                tempDbl       = 0.0;
    693     psBool               tempBool      = false;
    694     psS32                tempInt       = 0;
    695     psVector*            tempVec       = NULL;
    696     char*                tempStr       = NULL;
    697     psArray*             nonUniqueKeys = NULL;
    698     psBool               typeFound     = false;
    699     psArray*             typeArray     = NULL;
    700     psArray*             templateArray = NULL;
    701     psMetadata*          tempMeta      = NULL;
    702     p_psParseLevelInfo*  nextLevelInfo = NULL;
    703 
    704     // Get the metadata item type
    705     strType = getToken(&linePtr, " ", &status,true);
    706 
    707     // Check for no type
    708     if(strType==NULL) {
    709         psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, "type",lineCount,
    710                 fileName);
    711         returnValue = false;
    712     } else {
    713 
    714         // Set metadata type based on type token
    715 
    716         // Check if the keyName specifies a vector and if so use strType token to find vector type
    717         if(*keyName == '@') {
    718             mdType = PS_META_VEC;
    719             // Get the type of vector
    720             if(!strncmp(strType, "U8", 2)) {
    721                 vectorType = PS_TYPE_U8;
    722             } else if (!strncmp(strType,"U16",3)) {
    723                 vectorType = PS_TYPE_U16;
    724             } else if (!strncmp(strType,"U32",3)) {
    725                 vectorType = PS_TYPE_U32;
    726             } else if (!strncmp(strType,"U64",3)) {
    727                 vectorType = PS_TYPE_U64;
    728             } else if (!strncmp(strType,"S8",2)) {
    729                 vectorType = PS_TYPE_S8;
    730             } else if (!strncmp(strType,"S16",3)) {
    731                 vectorType = PS_TYPE_S16;
    732             } else if (!strncmp(strType,"S32",3)) {
    733                 vectorType = PS_TYPE_S32;
    734             } else if (!strncmp(strType,"S64",3)) {
    735                 vectorType = PS_TYPE_S64;
    736             } else if (!strncmp(strType,"F32",3)) {
    737                 vectorType = PS_TYPE_F32;
    738             } else if (!strncmp(strType,"F64",3)) {
    739                 vectorType = PS_TYPE_F64;
    740             } else {
    741                 psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, "", keyName,
    742                         strType, lineCount, fileName);
    743                 psFree(strType);
    744                 return false;
    745             }
    746         } else if(!strncmp(strType, "STR", 3)) {
    747             mdType = PS_META_STR;
    748         } else if(!strncmp(strType, "BOOL", 4)) {
    749             mdType = PS_META_BOOL;
    750         } else if(!strncmp(strType, "S32", 3)) {
    751             mdType = PS_META_S32;
    752         } else if(!strncmp(strType, "F32", 3)) {
    753             mdType = PS_META_F32;
    754         } else if(!strncmp(strType, "F64", 3)) {
    755             mdType = PS_META_F64;
    756         } else if(!strncmp(strType, "MULTI", 5)) {
    757             mdType = PS_META_MULTI;
    758         } else if(!strncmp(strType, "METADATA", 8)) {
    759             mdType = PS_META_META;
    760         } else {
    761             // Search through user types
    762             typeArray = ((p_psParseLevelInfo*)(levelArray->data[*level]))->typeArray;
    763             templateArray = ((p_psParseLevelInfo*)(levelArray->data[*level]))->templateArray;
    764             for(psS32 k = 0; k < typeArray->n; k++) {
    765                 if(strcmp(strType,(char*)typeArray->data[k]) == 0) {
    766                     tempMeta = setMetadataItem((psMetadata*)templateArray->data[k],linePtr);
    767                     if(tempMeta != NULL) {
    768                         // Add metadata item
    769                         md = ((p_psParseLevelInfo*)(levelArray->data[*level]))->metadata;
    770                         addStatus = psMetadataAdd(md,PS_LIST_TAIL,keyName,PS_META_META | flags,"",tempMeta);
    771                         // Check for add failure
    772                         if (! addStatus) {
    773                             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM,
    774                                     keyName, lineCount, fileName);
    775                             psFree(strType);
    776                             psFree(tempMeta);
    777                             return false;
    778                         }
    779                         psFree(tempMeta);
    780                     } else {
    781                         // Metadata type read error
    782                         psError(PS_ERR_IO,true,PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,
    783                                 keyName,lineCount,fileName);
    784                         psFree(strType);
    785                         return false;
    786                     }
    787                     typeFound = true;
    788                     break;
    789                 }
    790             }
    791             if(!typeFound) {
    792                 psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
    793                         strType, lineCount,fileName);
    794                 psFree(strType);
    795                 return false;
    796             } else {
    797                 psFree(strType);
    798                 return true;
    799             }
    800         }
    801     }
    802 
    803     // If type is not MULTI or META then get the value and comment
    804     if((mdType != PS_META_MULTI) && (mdType != PS_META_META)) {
    805         // Get the metadata item value if there is one.
    806         status = 0;
    807         strValue = getToken(&linePtr, "#", &status,true);
    808         if(status) {
    809             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, "value", lineCount,
    810                     fileName);
    811             psFree(strType);
    812             psFree(strValue);
    813             return false;
    814         }
    815         if(strValue==NULL) {
    816             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, "value", lineCount,
    817                     fileName);
    818             psFree(strType);
    819             psFree(strValue);
    820             return false;
    821         }
    822         // Not all lines will have comments, so NULL is ok.
    823         status = 0;
    824         strComment = getToken(&linePtr,"~", &status,true);
    825         if(status) {
    826             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, "comment", lineCount,
    827                     fileName);
    828             psFree(strType);
    829             psFree(strValue);
    830             psFree(strComment);
    831         }
    832     }
    833 
    834     // Need to add item to metadata so get pointer to metadata
    835     status = 0;
    836     md = ((p_psParseLevelInfo*)(levelArray->data[*level]))->metadata;
    837     nonUniqueKeys = ((p_psParseLevelInfo*)(levelArray->data[*level]))->nonUniqueKeyArray;
    838     switch(mdType) {
    839     case PS_META_STR:
    840         addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName,
    841                                   mdType | flags,
    842                                   strComment, strValue);
    843         break;
    844     case PS_META_BOOL:
    845         tempBool = parseBool(strValue, &status);
    846         if(!status) {
    847             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName,
    848                                       mdType | flags,
    849                                       strComment, tempBool);
    850         } else {
    851             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName,
    852                     strType, lineCount, fileName);
    853             returnValue = false;
    854         }
    855         break;
    856     case PS_META_F32:
    857     case PS_META_F64:
    858         tempDbl = parseValue(strValue, &status);
    859         if(!status) {
    860             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName,
    861                                       mdType | flags,
    862                                       strComment, tempDbl);
    863         } else {
    864             psError(PS_ERR_IO, true,
    865                     PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName, strType, lineCount,
    866                     fileName);
    867             returnValue = false;
    868         }
    869         break;
    870     case PS_META_S32:
    871         tempInt = (psS32)parseValue(strValue, &status);
    872         if(!status) {
    873             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName,
    874                                       mdType | flags,
    875                                       strComment, tempInt);
    876         } else {
    877             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName,
    878                     strType, lineCount, fileName);
    879             returnValue = false;
    880         }
    881         break;
    882     case PS_META_VEC:
    883         tempVec = parseVector(strValue, vectorType, &status);
    884         if(!status) {
    885             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName+1,
    886                                       mdType | flags,
    887                                       strComment, tempVec);
    888         } else {
    889             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_PARSE_FAILED, strValue, keyName,
    890                     strType, lineCount, fileName);
    891             returnValue = false;
    892         }
    893         psFree(tempVec);
    894         break;
    895     case PS_META_MULTI:
    896         // Add key to non-unique array of keys
    897         // Check for duplicate MULTI lines
    898         addStatus = true;
    899         for(psS32 k=0; k < nonUniqueKeys->n; k++) {
    900             if(strcmp(keyName,(char*)nonUniqueKeys->data[k]) == 0) {
    901                 psError(PS_ERR_IO,true,PS_ERRORTEXT_psMetadataIO_DUPLICATE_MULTI,
    902                         lineCount,fileName);
    903                 psFree(strType);
    904                 return false;
    905             }
    906         }
    907         tempStr = psStringCopy(keyName);
    908         nonUniqueKeys = psArrayAdd(nonUniqueKeys,0,tempStr);
    909         addStatus = true;
    910         psFree(tempStr);
    911         break;
    912     case PS_META_META:
    913         // Create next level info
    914         nextLevelInfo = p_psParseLevelInfoAlloc();
    915         // Create new metadata
    916         nextLevelInfo->metadata = psMetadataAlloc();
    917         // Save name of metadata
    918         nextLevelInfo->name = psStringCopy(keyName);
    919         // Add next level to levelArray
    920         levelArray = psArrayAdd(levelArray,1,nextLevelInfo);
    921         psFree(nextLevelInfo);
    922         // Increment level counter
    923         (*level)++;
    924         addStatus = true;
    925         break;
    926     default:
    927         psError(PS_ERR_IO,true,PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
    928                 lineCount,fileName);
    929         break;
    930     }
    931 
    932     // Check if the add status was successful
    933     if (! addStatus) {
    934         //        psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_OVERWRITE_ITEM, keyName, lineCount,
    935         //                fileName);
    936         returnValue = false;
    937     }
    938 
    939     psFree(strComment);
    940     psFree(strValue);
    941     psFree(strType);
    942 
    943     return returnValue;
    944 }
    945 
    946 psBool parseLine(psS32* level,     psArray* levelArray, char*  linePtr,
    947                  psS32  lineCount, char*    fileName,   psBool overwrite)
    948 {
    949     psBool              returnValue    = true;
    950     psMetadataFlags     flags          = PS_META_DEFAULT;
    951     char*               keyName        = NULL;
    952     psS32               status         = 0;
    953     psS32               limit          = 0;
    954     psMetadata*         tempTemplate   = NULL;
    955     char*               strType        = NULL;
    956     psArray*            typeArray      = NULL;
    957     psArray*            templateArray  = NULL;
    958     p_psParseLevelInfo* upperLevelInfo = NULL;
    959     p_psParseLevelInfo* lowerLevelInfo = NULL;
    960     psBool              addStatus      = 0;
    961 
    962     // Set flags if overwrite specified
    963     if(overwrite) {
    964         flags = PS_META_REPLACE;
    965     }
    966 
    967     // If line is not a comment or blank, then extract data
    968     if(!ignoreLine(linePtr)) {
    969 
    970         // Check for more than one '@' in a line
    971         if(repeatedChars(linePtr, '@') > 1) {
    972             psError(PS_ERR_IO, true,
    973                     PS_ERRORTEXT_psMetadataIO_FILE_MULTIPLE_CHAR, '@', lineCount, fileName);
    974             return false;
    975         }
    976 
    977         // Get metadata item name
    978         keyName = getToken(&linePtr, " ", &status,true);
    979         if(status) {
    980             psError(PS_ERR_IO, true,
    981                     PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL, "keyName", lineCount, fileName);
    982             psFree(keyName);
    983             return false;
    984         }
    985 
    986         // Check for special keyName values "TYPE", "END"
    987         if(strcmp(keyName,"TYPE") == 0 ) {
    988             // Get the type name
    989             strType = getToken(&linePtr," ",&status,true);
    990             if(strType == NULL) {
    991                 psError(PS_ERR_IO,true,PS_ERRORTEXT_psMetadataIO_FILE_ELEMENT_NULL,"type",lineCount,
    992                         fileName);
    993                 psFree(keyName);
    994                 return false;
    995             }
    996             tempTemplate = getMetadataType(linePtr);
    997             // Check if type was parsed succesfully
    998             if(tempTemplate != NULL) {
    999                 // Access type array
    1000                 typeArray = ((p_psParseLevelInfo*)(levelArray->data[*level]))->typeArray;
    1001                 // Check if type already exists in array
    1002                 for(psS32 k=0; k < typeArray->n; k++) {
    1003                     // Compare type name with the list of current types
    1004                     if(strcmp(strType,(char*)typeArray->data[k]) == 0) {
    1005                         psError(PS_ERR_IO,true,PS_ERRORTEXT_psMetadataIO_TYPE_DUPLICATE,
    1006                                 strType,lineCount,fileName);
    1007                         psFree(tempTemplate);
    1008                         psFree(keyName);
    1009                         psFree(strType);
    1010                         return false;
    1011                     }
    1012                 }
    1013                 // Add key name to array of type
    1014                 typeArray = psArrayAdd(typeArray,1,strType);
    1015                 // Add template to array of templates
    1016                 templateArray = ((p_psParseLevelInfo*)(levelArray->data[*level]))->templateArray;
    1017                 templateArray = psArrayAdd(templateArray,1,tempTemplate);
    1018                 psFree(tempTemplate);
    1019             } else {
    1020                 psError(PS_ERR_IO,true,PS_ERRORTEXT_psMetadataIO_FILE_TYPE_INVALID,
    1021                         strType,lineCount,fileName);
    1022                 psFree(keyName);
    1023                 psFree(strType);
    1024                 return false;
    1025             }
    1026             psFree(strType);
    1027         } else if (strcmp(keyName,"END") == 0 ) {
    1028             if(*level > 0) {
    1029                 upperLevelInfo = ((p_psParseLevelInfo*)(levelArray->data[*level-1]));
    1030                 lowerLevelInfo = ((p_psParseLevelInfo*)(levelArray->data[*level]));
    1031                 // Check name in nonunique list
    1032                 for(psS32 k=0; k < upperLevelInfo->nonUniqueKeyArray->n; k++) {
    1033                     if(strcmp(upperLevelInfo->nonUniqueKeyArray->data[k],lowerLevelInfo->name) == 0) {
    1034                         flags = PS_META_DUPLICATE_OK;
    1035                         break;
    1036                     }
    1037                 }
    1038                 // Add metadata to upper level metadata
    1039                 addStatus = psMetadataAdd(upperLevelInfo->metadata,
    1040                                           PS_LIST_TAIL,lowerLevelInfo->name,
    1041                                           PS_META_META | flags,
    1042                                           "",
    1043                                           lowerLevelInfo->metadata);
    1044                 if(!addStatus) {
    1045                     psFree(keyName);
    1046                     return false;
    1047                 } else {
    1048                     // Remove lower info level
    1049                     if(!psArrayRemove(levelArray,levelArray->data[*level])) {
    1050                         psFree(keyName);
    1051                         return false;
    1052                     }
    1053                     psFree(lowerLevelInfo);
    1054                     (*level)--;
    1055                 }
    1056             } else {
    1057                 psFree(keyName);
    1058                 return false;
    1059             }
    1060         } else {
    1061             // Check if key name present in array of non-unique key names
    1062             limit = ((p_psParseLevelInfo*)(levelArray->data[*level]))->nonUniqueKeyArray->n;
    1063             for(psS32 k=0; k < limit; k++) {
    1064                 char* name = (char*)((p_psParseLevelInfo*)
    1065                                      (levelArray->data[*level]))->nonUniqueKeyArray->data[k];
    1066                 if(strcmp(name,keyName) == 0) {
    1067                     flags = PS_META_DUPLICATE_OK;
    1068                 }
    1069             }
    1070             // Parse metadataItem
    1071             if(!parseMetadataItem(keyName,level, levelArray, linePtr, lineCount, fileName, flags)) {
    1072                 psFree(keyName);
    1073                 return false;
    1074             }
    1075         }
    1076         psFree(keyName);
    1077     }
    1078     return returnValue;
    1079 }
    1080 
    1081 psMetadata* psMetadataConfigParse(psMetadata* md, unsigned int *nFail, const char *fileName, bool overwrite)
    1082 {
    1083     FILE*               fp                   = NULL;
    1084     char*               line                 = NULL;
    1085     char*               linePtr              = NULL;
    1086     psArray*            parseLevelInfoArray  = NULL;
    1087     psS32               lineCount            = 0;
    1088     psS32               nestingLevel         = 0;
    1089     p_psParseLevelInfo* topLevelInfo         = NULL;
    1090 
    1091     // Check for NULL file name
    1092     PS_ASSERT_PTR_NON_NULL(fileName,NULL);
    1093 
    1094     // Check for NULL nFail
    1095     PS_ASSERT_PTR_NON_NULL(nFail,NULL);
    1096 
    1097     // Attempt to open specified file
    1098     if((fp=fopen(fileName, "r")) == NULL) {
    1099         psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_FILE_OPEN_FAILED, fileName);
    1100         return NULL;
    1101     }
    1102 
    1103     // Allocate metadata if necessary
    1104     if (md == NULL) {
    1105         md = psMetadataAlloc();
    1106     }
    1107 
    1108     // Allocate array to store parse level information
    1109     parseLevelInfoArray = psArrayAlloc(10);
    1110     parseLevelInfoArray->n = 0;
    1111 
    1112     // Set parse level info for the top level
    1113     topLevelInfo = p_psParseLevelInfoAlloc();
    1114     topLevelInfo->metadata = psMemIncrRefCounter(md);
    1115     parseLevelInfoArray = psArrayAdd(parseLevelInfoArray,1,topLevelInfo);
    1116     psFree(topLevelInfo);
    1117 
    1118     // Create reusable line for continuous read
    1119     line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));
    1120 
    1121     // While loop to parse the file
    1122     while(fgets(line, MAX_STRING_LENGTH, fp) != NULL) {
    1123 
    1124         // Initialize variables for new line
    1125         linePtr = line;
    1126         lineCount++;
    1127 
    1128         if(!parseLine(&nestingLevel,parseLevelInfoArray,linePtr,lineCount,(char*)fileName,overwrite)) {
    1129             (*nFail)++;
    1130         }
    1131     }
    1132 
    1133     // Free parse array and line buffer
    1134     psFree(parseLevelInfoArray);
    1135     psFree(line);
    1136 
    1137     return md;
    1138157}
    1139158
  • trunk/psLib/src/xml/psXML.h

    r4409 r4540  
    1 /** @file  psMetadataIO.h
     1/** @file  psXML.h
    22 *
    3  *  @brief Contains metadata input/output functions.
     3 *  @brief Contains XML functions.
    44 *
    5  *  This file defines functions to read and write metadata to/from an external file.
     5 *  This file defines functions to read metadata from an XML file.
    66 *
    7  *  @ingroup Metadata
     7 *  @ingroup XML
    88 *
    99 *  @author Ross Harman, MHPCC
    1010 *  @author Robert DeSonia, MHPCC
    1111 *
    12  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-06-28 20:17:52 $
     12 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-07-12 19:12:01 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1616 */
    17 #ifndef PS_METADATAIO_H
    18 #define PS_METADATAIO_H
     17#ifndef PS_XML_H
     18#define PS_XML_H
    1919
    20 /// @addtogroup Metadata
     20#include "psMetadata.h"
     21#include "psMetadataConfig.h"
     22
     23/// @addtogroup XML
    2124/// @{
    22 
    23 /** A metadata data structure used in parsing arrays.
    24  * 
    25  *  Contains array information and the metadata storage location.
    26 */
    27 typedef struct
    28 {
    29     psArray*    nonUniqueKeyArray;     ///< non-unique key names
    30     psArray*    typeArray;             ///< array of user defined types
    31     psArray*    templateArray;         ///< array of user type templates
    32     psMetadata* metadata;              ///< metadata container
    33     char*       name;                  ///< name of key
    34 }
    35 p_psParseLevelInfo;
    36 
    37 /** Allocates a p_psParseLevelInfo structure
    38  *   
    39  *  @return p_psParseLevelInfo* :   new p_psParseLevelInfo struct
    40  */
    41 p_psParseLevelInfo* p_psParseLevelInfoAlloc(void);
    42 
    43 /** Print metadata item to file.
    44  *
    45  *  Metadata items may be printed to an open file descriptor based on a
    46  *  provided format. The format is a sprintf format statement with exactly
    47  *  one % formatting command. If the metadata item type is a numeric type,
    48  *  this formatting command must also be numeric, and the type conversion
    49  *  performed to the value to match the format type. If the metadata type is
    50  *  a string, the fromatting command must also be for a string. If the
    51  *  metadata type is any other data type, printing is not allowed.
    52  *
    53  * @return psMetadataItem* : Pointer metadata item.
    54  */
    55 bool psMetadataItemPrint(
    56     FILE * fd,                         ///< Pointer to file to write metadata item.
    57     const char *format,                ///< Format to print metadata item.
    58     const psMetadataItem* item         ///< Metadata item to print.
    59 );
    60 
    61 /** Read metadata header.
    62  *
    63  *  Read a metadata header from file. If the file is not found, an error is
    64  *  reported.
    65  *
    66  *  @return psMetadata* : Pointer to resulting metadata.
    67  */
    68 psMetadata* psMetadataReadHeader(
    69     psMetadata* output,                ///< Resulting metadata from read.
    70     char *extName,                     ///< File name extension string.
    71     psS32 extNum,                      ///< File name extension number. Starts at 1.
    72     char *fileName                     ///< Name of file to read.
    73 );
    74 
    75 /** Read metadata configuration file.
    76  *
    77  *  Loads pre-defined settings by parsing a configuration file into a psMetadata structure.
    78  *
    79  *  @return psMetadata* : Resulting metadata from read.
    80  */
    81 psMetadata* psMetadataConfigParse(
    82     psMetadata* md,                    ///< Resulting metadata from read.
    83     unsigned int *nFail,               ///< Number of failed lines.
    84     const char *fileName,              ///< Name of file to read.
    85     bool overwrite                     ///< Allow overwrite of duplicate specifications.
    86 );
    87 
    88 /** Read XML metadata configuration file.
    89  *
    90  *  Loads pre-defined XML settings by parsing a configuration file into a psMetadata structure.
    91  *
    92  *  @return psMetadata* : Resulting metadata from read.
    93  */
    9425
    9526psMetadata*  psMetadataConfigParseXml(
     
    10233/// @}
    10334
    104 #endif // #ifndef PS_METADATAIO_H
     35#endif // #ifndef PS_XML_H
Note: See TracChangeset for help on using the changeset viewer.