Changeset 4540
- Timestamp:
- Jul 12, 2005, 9:12:01 AM (21 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 14 added
- 9 deleted
- 64 edited
-
Makefile.am (modified) (1 diff)
-
astro/Makefile.am (modified) (1 diff)
-
astro/psAstroErrors_en.dat (deleted)
-
astro/psCoord.c (modified) (2 diffs)
-
astro/psTime.c (modified) (2 diffs)
-
astronomy/psCoord.c (modified) (13 diffs)
-
astronomy/psCoord.h (modified) (13 diffs)
-
astronomy/psTime.c (modified) (7 diffs)
-
astronomy/psTime.h (modified) (4 diffs)
-
db/Makefile.am (modified) (1 diff)
-
db/psDB.c (modified) (2 diffs)
-
db/psDB.h (modified) (18 diffs)
-
db/psDBErrors_en.dat (deleted)
-
fft/Makefile.am (modified) (1 diff)
-
fft/fft.i (added)
-
fft/psImageFFT.h (modified) (3 diffs)
-
fft/psVectorFFT.c (modified) (2 diffs)
-
fits/Makefile.am (modified) (1 diff)
-
fits/fits.i (added)
-
fits/psFits.c (modified) (2 diffs)
-
imageops/Makefile.am (modified) (1 diff)
-
imageops/imageops.i (added)
-
imageops/psImageConvolve.c (modified) (9 diffs)
-
imageops/psImageConvolve.h (modified) (3 diffs)
-
imageops/psImageGeomManip.c (modified) (2 diffs)
-
imageops/psImagePixelExtract.c (modified) (2 diffs)
-
imageops/psImagePixelManip.c (modified) (2 diffs)
-
imageops/psImagePixelManip.h (modified) (2 diffs)
-
imageops/psImageStructManip.c (modified) (4 diffs)
-
math/Makefile.am (modified) (1 diff)
-
math/math.i (added)
-
math/psBinaryOp.c (modified) (3 diffs)
-
math/psBinaryOp.h (modified) (2 diffs)
-
math/psFunctions.c (added)
-
math/psFunctions.h (added)
-
math/psMatrix.c (modified) (2 diffs)
-
math/psMinimize.c (modified) (8 diffs)
-
math/psMinimize.h (modified) (14 diffs)
-
math/psPolynomial.c (deleted)
-
math/psPolynomial.h (deleted)
-
math/psRandom.c (modified) (2 diffs)
-
math/psSpline.c (deleted)
-
math/psSpline.h (deleted)
-
math/psStats.c (modified) (11 diffs)
-
math/psStats.h (modified) (5 diffs)
-
math/psUnaryOp.c (modified) (3 diffs)
-
math/psUnaryOp.h (modified) (2 diffs)
-
mathtypes/Makefile.am (modified) (1 diff)
-
mathtypes/mathtypes.i (added)
-
mathtypes/psImage.c (modified) (5 diffs)
-
mathtypes/psImage.h (modified) (9 diffs)
-
mathtypes/psScalar.c (modified) (2 diffs)
-
mathtypes/psScalar.h (modified) (2 diffs)
-
mathtypes/psVector.c (modified) (8 diffs)
-
mathtypes/psVector.h (modified) (5 diffs)
-
psErrorCodes.dat (deleted)
-
psErrorCodes_en.dat (added)
-
psErrorText.h.in (added)
-
psErrorText_en.dat (added)
-
psParseErrorCodes (deleted)
-
pslib_strict.h (modified) (2 diffs)
-
sys/Makefile.am (modified) (1 diff)
-
sys/psConfigure.c (modified) (2 diffs)
-
sys/psErrorCodes.c (modified) (3 diffs)
-
sys/psErrorCodes.h (deleted)
-
sys/psErrorCodes.h.in (added)
-
sys/psLogMsg.c (modified) (2 diffs)
-
sys/psMemory.c (modified) (2 diffs)
-
sys/psString.c (modified) (2 diffs)
-
sys/psTrace.c (modified) (2 diffs)
-
sys/psType.h (modified) (4 diffs)
-
sys/sys.i (added)
-
types/Makefile.am (modified) (1 diff)
-
types/psArray.c (modified) (2 diffs)
-
types/psBitSet.c (modified) (2 diffs)
-
types/psHash.c (modified) (2 diffs)
-
types/psList.c (modified) (2 diffs)
-
types/psLookupTable.c (modified) (2 diffs)
-
types/psMetadata.c (modified) (2 diffs)
-
types/psMetadataConfig.c (modified) (12 diffs)
-
types/psMetadataConfig.h (modified) (5 diffs)
-
types/psPixels.c (modified) (2 diffs)
-
types/types.i (added)
-
xml/Makefile.am (modified) (1 diff)
-
xml/psXML.c (modified) (7 diffs)
-
xml/psXML.h (modified) (2 diffs)
-
xml/xml.i (added)
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) 1 SUBDIRS = $(SRCDIRS) 11 2 12 3 lib_LTLIBRARIES = libpslib.la 13 bin_SCRIPTS = psParseErrorCodes14 4 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 5 libpslib_la_LIBADD = $(SRCSUBLIBS) 22 6 23 7 libpslib_la_SOURCES = psTest.c 24 8 libpslib_la_LDFLAGS = -version-info $(PSLIB_LT_VERSION) 25 9 26 EXTRA_DIST = mainpage.dox psErrorCodes.dat psTest.h psParseErrorCodes 10 11 EXTRA_DIST = mainpage.dox psErrorCodes.dat psTest.h psErrorText.h.in psErrorText_en.dat 12 13 BUILT_SOURCES = psErrorText.h 14 psErrorText.h: psErrorText_$(LANG).dat 15 $(top_srcdir)/psParseErrorCodes --data=$? $@ 27 16 28 17 pslibincludedir = $(includedir) -
trunk/psLib/src/astro/Makefile.am
r4502 r4540 3 3 AM_CFLAGS=$(CFLAGS) -DPS_CONFIG_FILE_DEFAULT=\"$(sysconfdir)/pslib/psTime.config\" 4 4 5 INCLUDES = `echo "$(SRCLIBS} | sed sed "s|\(\\w\+\)|-I\$(top_builddir)/src/\1|g"`6 7 5 noinst_LTLIBRARIES = libpslibastro.la 8 6 libpslibastro_la_SOURCES = \ 9 7 psTime.c \ 10 psCoord.c 11 12 BUILT_SOURCES = psAstroErrors.h 8 psCoord.c 13 9 14 EXTRA_DIST = psAstroErrors_$(LANG).dat astro.i 15 16 psAstroErrors.h: psAstroErrors_$(LANG).dat 17 $(top_srcdir)/src/psParseErrorCodes --data=$? $@ 10 EXTRA_DIST = astro.i 18 11 19 12 pslibincludedir = $(includedir) -
trunk/psLib/src/astro/psCoord.c
r4401 r4540 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.7 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-27 20:38:11$12 * @version $Revision: 1.79 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:00 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 25 25 #include "psError.h" 26 26 #include "psLogMsg.h" 27 #include "psAstronomyErrors.h" 28 #include "psAstrometry.h" 27 #include "psErrorText.h" 29 28 #include "psMatrix.h" 30 29 #include <math.h> -
trunk/psLib/src/astro/psTime.c
r4409 r4540 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.6 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-28 20:17:52$12 * @version $Revision: 1.66 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:00 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 31 31 #include "psString.h" 32 32 #include "psMetadata.h" 33 #include "psMetadata IO.h"33 #include "psMetadataConfig.h" 34 34 #include "psLookupTable.h" 35 35 #include "psConstants.h" 36 #include "ps AstronomyErrors.h"36 #include "psErrorText.h" 37 37 38 38 #include "config.h" -
trunk/psLib/src/astronomy/psCoord.c
r4401 r4540 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.7 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-27 20:38:11$12 * @version $Revision: 1.79 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:00 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 30 30 #include <math.h> 31 31 #include <float.h> 32 /******************************************************************************/33 /* DEFINE STATEMENTS */34 /******************************************************************************/35 32 36 33 // Modified Julian Day 01/01/1900 00:00:00 … … 40 37 #define JULIAN_CENTURY 36525.0 41 38 42 /******************************************************************************/43 /* TYPE DEFINITIONS */44 /******************************************************************************/45 46 // None47 48 /*****************************************************************************/49 /* GLOBAL VARIABLES */50 /*****************************************************************************/51 52 // None53 54 /*****************************************************************************/55 /* FILE STATIC VARIABLES */56 /*****************************************************************************/57 58 // None59 60 /*****************************************************************************/61 /* FUNCTION IMPLEMENTATION - LOCAL */62 /*****************************************************************************/63 64 /*****************************************************************************/65 /* FUNCTION IMPLEMENTATION - PUBLIC */66 /*****************************************************************************/67 39 static void planeFree(psPlane *p) 68 40 { 69 41 // There are non dynamic allocated items 42 } 43 44 static void sphereFree(psSphere *s) 45 { 46 // There are non dynamic allocated items 47 } 48 49 static void planeTransformFree(psPlaneTransform *pt) 50 { 51 psFree(pt->x); 52 psFree(pt->y); 53 } 54 55 static void planeDistortFree(psPlaneDistort *pt) 56 { 57 psFree(pt->x); 58 psFree(pt->y); 59 } 60 61 static void projectionFree(psProjection *p) 62 { 63 // There are no dynamically allocated items 70 64 } 71 65 … … 201 195 } 202 196 203 204 static void sphereFree(psSphere *s)205 {206 // There are non dynamic allocated items207 }208 209 197 psSphere* psSphereAlloc(void) 210 198 { … … 215 203 } 216 204 217 static void planeTransformFree(psPlaneTransform *pt) 218 { 219 psFree(pt->x); 220 psFree(pt->y); 205 psSphereRot* 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 228 psSphereRot* 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; 221 242 } 222 243 … … 260 281 261 282 return (out); 262 }263 264 static void planeDistortFree(psPlaneDistort *pt)265 {266 psFree(pt->x);267 psFree(pt->y);268 283 } 269 284 … … 319 334 320 335 /****************************************************************************** 321 alpha is LONGITUDE322 delta is LATITUDE323 324 alphaP: Take the target pole in the source system; calculate its LONGITUDE325 in the target system. That longitude is alphaP.326 DeltaP: Take the target pole in the source system; calculate its LATITUDE327 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 /******************************************************************************362 336 XXX: We convert Right Ascension angles to the range 0:PI. Is that acceptable? 363 337 XXX: Should we do something for Declination as well? 364 338 *****************************************************************************/ 365 psSphere* psSphere TransformApply(psSphere* out,366 const psSphereTransform* transform,367 const psSphere* coord)339 psSphere* psSphereRotApply(psSphere* out, 340 const psSphereRot* transform, 341 const psSphere* coord) 368 342 { 369 343 PS_ASSERT_PTR_NON_NULL(transform, NULL); … … 371 345 372 346 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 365 psSphereRot* 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 394 psSphereRot *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 406 psSphereRot* psSphereRotICRSToEcliptic(const psTime *time) 395 407 { 396 408 psF64 T; … … 421 433 422 434 // Don't neglect the minus sign on deltaP (bug 244): 423 return (psSphere TransformAlloc(alphaP, deltaP, phiP));424 } 425 426 427 psSphere Transform* psSphereTransformEclipticToICRS(psTime *time)435 return (psSphereRotAlloc(alphaP, deltaP, phiP)); 436 } 437 438 439 psSphereRot* psSphereRotEclipticToICRS(const psTime *time) 428 440 { 429 441 psF64 T; … … 453 465 psF64 phiP = 0.0; 454 466 455 return (psSphere TransformAlloc(alphaP, -deltaP, phiP));467 return (psSphereRotAlloc(alphaP, -deltaP, phiP)); 456 468 } 457 469 458 470 // XXX: This is bug 245: alphaP swaps with phiP from psSphereTransformGalacticToICRS() 459 psSphere Transform* psSphereTransformGalacticToICRS(void)471 psSphereRot* psSphereRotGalacticToICRS(void) 460 472 { 461 473 psF64 alphaP = DEG_TO_RAD(32.93192); … … 463 475 psF64 phiP = DEG_TO_RAD(282.85948); 464 476 465 return (psSphere TransformAlloc(alphaP, deltaP, phiP));466 } 467 468 psSphere Transform* psSphereTransformICRSToGalactic(void)477 return (psSphereRotAlloc(alphaP, deltaP, phiP)); 478 } 479 480 psSphereRot* psSphereRotICRSToGalactic(void) 469 481 { 470 482 psF64 alphaP = DEG_TO_RAD(282.85948); … … 472 484 psF64 phiP = DEG_TO_RAD(32.93192); 473 485 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)); 480 487 } 481 488 … … 837 844 838 845 // Create transform with proper constants 839 psSphere Transform *tmpST = psSphereTransformAlloc(alphaP, deltaP, phiP);846 psSphereRot* tmpST = psSphereRotAlloc(alphaP, deltaP, phiP); 840 847 841 848 // Apply transform to coordinates 842 psSphere *out = psSphere TransformApply(NULL, tmpST, coords);849 psSphere *out = psSphereRotApply(NULL, tmpST, coords); 843 850 844 851 psFree(tmpST); -
trunk/psLib/src/astronomy/psCoord.h
r4401 r4540 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-27 20:38:11$12 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:00 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 24 24 #include "psList.h" 25 25 #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 27 27 28 28 /// @addtogroup CoordinateTransform … … 38 38 typedef struct 39 39 { 40 double x; ///< x position41 double y; ///< y position42 double xErr; ///< Error in x position43 double yErr; ///< Error in y position40 double x; ///< x position 41 double y; ///< y position 42 double xErr; ///< Error in x position 43 double yErr; ///< Error in y position 44 44 } 45 45 psPlane; … … 52 52 * 53 53 */ 54 typedef struct psSphere55 { 56 double r; ///< RA57 double d; ///< Dec58 double rErr; ///< Error in RA59 double dErr; ///< Error in Dec54 typedef struct 55 { 56 double r; ///< RA 57 double d; ///< Dec 58 double rErr; ///< Error in RA 59 double dErr; ///< Error in Dec 60 60 } 61 61 psSphere; 62 63 /** Cubic Coordinate System 64 * 65 */ 66 typedef 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 } 75 psCube; 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 */ 82 typedef 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 } 89 psSphereRot; 62 90 63 91 /** 2D Polynomial Transform … … 94 122 } 95 123 psPlaneDistort; 96 97 /** Spherical Transform Definition98 *99 * We need to be able to convert between ICRS, Galactic and Ecliptic100 * coordinates, and potentially between arbitrary spherical coordinate101 * systems. All of these basic spherical transformations represent rotations102 * of the spherical coordinate reference. We specify a general103 * transformation function which takes a structure, psSphereTransform,104 * defining the transformation between two spherical coordinate systems105 *106 */107 typedef struct108 {109 double alphaP; ///< Longitude of the target system pole in the source system110 double cosDeltaP; ///< Cosine of target pole latitude in the source system111 double sinDeltaP; ///< Sine of target pole latitude in the source system112 double phiP; ///< Longitude of the ascending node in the target system113 }114 psSphereTransform;115 124 116 125 /** Projection type for projection/deprojection … … 167 176 } psSphereOffsetUnit; 168 177 178 #include "psTime.h" 179 169 180 /** Allocates a psPlane 170 181 * … … 178 189 * @return psSphere* resulting sphere structure. 179 190 */ 180 181 191 psSphere* psSphereAlloc(void); 182 192 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 */ 198 psSphereRot* 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 */ 209 psSphereRot* psSphereRotQuat( 210 double q0, 211 double q1, 212 double q2, 213 double q3 214 ); 183 215 184 216 /** Allocates a psPlaneTransform transform. … … 186 218 * @return psPlaneTransform* resulting plane transform 187 219 */ 188 189 220 psPlaneTransform* psPlaneTransformAlloc( 190 221 int n1, ///< The order of the x term in the transform. … … 227 258 ); 228 259 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 241 262 * 242 263 * @return psSphere* resulting coordinate based on transform 243 264 */ 244 psSphere* psSphere TransformApply(265 psSphere* psSphereRotApply( 245 266 psSphere* out, ///< a psSphere to recycle. If NULL, a new one is generated. 246 const psSphere Transform* transform,///< the transform to apply267 const psSphereRot* transform, ///< the transform to apply 247 268 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 */ 276 psSphereRot* 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 */ 286 psSphereRot* psSphereRotInvert( 287 psSphereRot* rot ///< the psSphereRot to invert 248 288 ); 249 289 … … 251 291 * coordinate systems. 252 292 * 253 * @return psSphere Transform*transform for ICRS->Ecliptic coordinate systems254 */ 255 psSphere Transform* psSphereTransformICRSToEcliptic(256 psTime *time///< the time for which the resulting transform will be valid293 * @return psSphereRot* transform for ICRS->Ecliptic coordinate systems 294 */ 295 psSphereRot* psSphereRotICRSToEcliptic( 296 const psTime* time ///< the time for which the resulting transform will be valid 257 297 ); 258 298 … … 260 300 * coordinate systems. 261 301 * 262 * @return psSphere Transform*transform for Ecliptic->ICRS coordinate systems263 */ 264 psSphere Transform* psSphereTransformEclipticToICRS(265 psTime *time///< the time for which the resulting transform will be valid302 * @return psSphereRot* transform for Ecliptic->ICRS coordinate systems 303 */ 304 psSphereRot* psSphereRotEclipticToICRS( 305 const psTime* time ///< the time for which the resulting transform will be valid 266 306 ); 267 307 … … 270 310 * 271 311 */ 272 psSphere Transform* psSphereTransformICRSToGalactic(void);312 psSphereRot* psSphereRotICRSToGalactic(void); 273 313 274 314 /** Creates the appropriate transform for converting from Galactic to ICRS … … 276 316 * 277 317 */ 278 psSphere Transform* psSphereTransformGalacticToICRS(void);318 psSphereRot* psSphereRotGalacticToICRS(void); 279 319 280 320 /** Allocates memory for a psProjection structure -
trunk/psLib/src/astronomy/psTime.c
r4409 r4540 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.6 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-28 20:17:52$12 * @version $Revision: 1.66 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:00 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 887 887 } 888 888 889 structpsSphere* p_psTimeGetPoleCoords(const psTime* time)889 psSphere* p_psTimeGetPoleCoords(const psTime* time) 890 890 { 891 891 psU32 nTables = 3; … … 896 896 psF64 c = 0.0; 897 897 psF64 mjdPred = 0.0; 898 structpsSphere* output = NULL;898 psSphere* output = NULL; 899 899 psLookupStatusType xStatus = PS_LOOKUP_SUCCESS; 900 900 psLookupStatusType yStatus = PS_LOOKUP_SUCCESS; … … 908 908 PS_ASSERT_INT_WITHIN_RANGE(time->nsec,0,(psU32)((1e9)-1),NULL); 909 909 910 if(time->type != PS_TIME_TAI) 911 { 910 if(time->type != PS_TIME_TAI) { 912 911 psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psTime_TYPE_INCORRECT, time->type); 913 912 return NULL; … … 922 921 923 922 // 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) { 926 924 927 925 // Date too earlier for tables. Get default polar coodinate values from metadata, and issue warning. … … 942 940 y = tableMetadataItem->data.F64; 943 941 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) { 946 943 947 944 /* Date too late for tables. Issue warning and use following formulae for predicting … … 1000 997 yp->data.F64[4]*sin(c); 1001 998 1002 } else if(xStatus!=PS_LOOKUP_SUCCESS || yStatus!=PS_LOOKUP_SUCCESS) 1003 { 999 } else if(xStatus!=PS_LOOKUP_SUCCESS || yStatus!=PS_LOOKUP_SUCCESS) { 1004 1000 psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psTime_INTERPOLATION_FAILED); 1005 1001 return NULL; -
trunk/psLib/src/astronomy/psTime.h
r4409 r4540 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-0 6-28 20:17:52$13 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-07-12 19:12:00 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 25 25 26 26 #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 30 28 31 29 /// @addtogroup Time 32 30 /// @{ 33 34 31 35 32 /** Time type. … … 69 66 psTime; 70 67 68 #include "psCoord.h" 69 #include "psImage.h" 71 70 72 71 /** Initialize time data. … … 161 160 * @return psSphere*: Spherical coordinates of Earth's polar axias. 162 161 */ 163 structpsSphere* p_psTimeGetPoleCoords(164 const psTime *time ///< psTime determine polar orientation.165 );162 psSphere* p_psTimeGetPoleCoords( 163 const psTime *time ///< psTime determine polar orientation. 164 ); 166 165 167 166 /** Calculate the number of leapseconds between two times. -
trunk/psLib/src/db/Makefile.am
r4502 r4540 1 1 #Makefile for db functions of psLib 2 2 # 3 INCLUDES = `echo "$(SRCLIBS} | sed sed "s|\(\\w\+\)|-I\$(top_builddir)/src/\1|g"`4 5 3 noinst_LTLIBRARIES = libpslibdb.la 6 4 7 libpslibd ataIO_la_SOURCES = \5 libpslibdb_la_SOURCES = \ 8 6 psDB.c 9 7 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=$? $@ 8 EXTRA_DIST = db.i 16 9 17 10 pslibincludedir = $(includedir) 18 11 pslibinclude_HEADERS = \ 19 psLookupTable.h \20 psFits.h \21 12 psDB.h 22 13 -
trunk/psLib/src/db/psDB.c
r4430 r4540 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 6-29 20:33:37$14 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-07-12 19:12:00 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 35 35 #include "psError.h" 36 36 #include "psString.h" 37 #include "ps FileUtilsErrors.h"37 #include "psErrorText.h" 38 38 39 39 typedef struct -
trunk/psLib/src/db/psDB.h
r4429 r4540 10 10 * @author Joshua Hoblitt 11 11 * 12 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-29 19:43:55$12 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:00 $ 14 14 * 15 15 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 34 34 typedef struct 35 35 { 36 void* mysql; ///< MySQL database handle36 void* mysql; ///< MySQL database handle 37 37 } 38 38 psDB; … … 44 44 */ 45 45 psDB *psDBInit( 46 const char *host, ///< Database server hostname47 const char *user, ///< Database username48 const char *passwd, ///< Database password49 const char *dbname ///< Database namespace46 const char *host, ///< Database server hostname 47 const char *user, ///< Database username 48 const char *passwd, ///< Database password 49 const char *dbname ///< Database namespace 50 50 ); 51 51 … … 53 53 */ 54 54 void psDBCleanup( 55 psDB *dbh ///< Database handle55 psDB *dbh ///< Database handle 56 56 ); 57 57 … … 61 61 */ 62 62 bool psDBCreate( 63 psDB *dbh, ///< Database handle64 const char *dbname ///< New database namespace63 psDB *dbh, ///< Database handle 64 const char *dbname ///< New database namespace 65 65 ); 66 66 … … 70 70 */ 71 71 bool psDBChange( 72 psDB *dbh, ///< Database handle73 const char *dbname ///< Database namespace72 psDB *dbh, ///< Database handle 73 const char *dbname ///< Database namespace 74 74 ); 75 75 … … 79 79 */ 80 80 bool psDBDrop( 81 psDB *dbh, ///< Database handle82 const char *dbname ///< Database namespace81 psDB *dbh, ///< Database handle 82 const char *dbname ///< Database namespace 83 83 ); 84 84 … … 92 92 */ 93 93 bool p_psDBRunQuery( 94 psDB *dbh, ///< Database handle95 const char *format ///< SQL string to execute94 psDB *dbh, ///< Database handle 95 const char *format ///< SQL string to execute 96 96 ); 97 97 … … 117 117 */ 118 118 bool psDBCreateTable( 119 psDB *dbh, ///< Database handle120 const char *tableName, ///< Table name121 const psMetadata *md ///< Column names, types, and indexes119 psDB *dbh, ///< Database handle 120 const char *tableName, ///< Table name 121 const psMetadata *md ///< Column names, types, and indexes 122 122 ); 123 123 … … 140 140 */ 141 141 psArray *psDBSelectColumn( 142 psDB *dbh, ///< Database handle143 const char *tableName, ///< Table name144 const char *col, ///< Column name145 unsigned long long limit ///< Maximum number of elements to return142 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 146 146 ); 147 147 … … 155 155 */ 156 156 psVector *psDBSelectColumnNum( 157 psDB *dbh, ///< Database handle158 const char *tableName, ///< Table name159 const char *col, ///< Column name157 psDB *dbh, ///< Database handle 158 const char *tableName, ///< Table name 159 const char *col, ///< Column name 160 160 psElemType type, ///< Resulting psVector type 161 unsigned long long limit ///< Maximum number of elements to return161 unsigned long long limit ///< Maximum number of elements to return 162 162 ); 163 163 … … 177 177 */ 178 178 psArray *psDBSelectRows( 179 psDB *dbh, ///< Database handle180 const char *tableName, ///< Table name181 const psMetadata *where, ///< Row match criteria182 unsigned long long limit ///< Maximum number of elements to return179 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 183 183 ); 184 184 … … 195 195 */ 196 196 bool psDBInsertOneRow( 197 psDB *dbh, ///< Database handle198 const char *tableName, ///< Table name199 const psMetadata *row ///< Row description197 psDB *dbh, ///< Database handle 198 const char *tableName, ///< Table name 199 const psMetadata *row ///< Row description 200 200 ); 201 201 … … 210 210 */ 211 211 bool psDBInsertRows( 212 psDB *dbh, ///< Database handle213 const char *tableName, ///< Table name214 const psArray *rowSet ///< Set of rows to insert212 psDB *dbh, ///< Database handle 213 const char *tableName, ///< Table name 214 const psArray *rowSet ///< Set of rows to insert 215 215 ); 216 216 … … 223 223 */ 224 224 psArray *psDBDumpRows( 225 psDB *dbh, ///< Database handle226 const char *tableName ///< Table name225 psDB *dbh, ///< Database handle 226 const char *tableName ///< Table name 227 227 ); 228 228 … … 236 236 */ 237 237 psMetadata *psDBDumpCols( 238 psDB *dbh, ///< Database handle239 const char *tableName ///< Table name238 psDB *dbh, ///< Database handle 239 const char *tableName ///< Table name 240 240 ); 241 241 … … 252 252 */ 253 253 psS64 psDBUpdateRows( 254 psDB *dbh, ///< Database handle255 const char *tableName, ///< Table name256 const psMetadata *where, ///< Row match criteria257 const psMetadata *values ///< new field values254 psDB *dbh, ///< Database handle 255 const char *tableName, ///< Table name 256 const psMetadata *where, ///< Row match criteria 257 const psMetadata *values ///< new field values 258 258 ); 259 259 … … 269 269 */ 270 270 psS64 psDBDeleteRows( 271 psDB *dbh, ///< Database handle272 const char *tableName, ///< Table name273 const psMetadata *where, ///< Row match criteria274 unsigned long long limit ///< Maximum number of rows to delete271 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 275 275 ); 276 276 -
trunk/psLib/src/fft/Makefile.am
r4446 r4540 1 #Makefile for dataManipfunctions of psLib1 #Makefile for fft functions of psLib 2 2 # 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) 3 noinst_LTLIBRARIES = libpslibfft.la 15 4 16 noinst_LTLIBRARIES = libpslibdataManip.la 5 libpslibfft_la_SOURCES = \ 6 psImageFFT.c \ 7 psVectorFFT.c 17 8 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=$? $@ 9 EXTRA_DIST = fft.i 26 10 27 11 pslibincludedir = $(includedir) 28 12 pslibinclude_HEADERS = \ 29 psConstants.h \30 psStats.h \31 psFunctions.h \32 psMatrix.h \33 psBinaryOp.h \34 psUnaryOp.h \35 13 psVectorFFT.h \ 36 psMinimize.h \ 37 psRandom.h 14 psImageFFT.h 38 15 -
trunk/psLib/src/fft/psImageFFT.h
r4316 r4540 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-0 6-18 03:13:02$9 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-07-12 19:12:01 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 33 33 psImage* psImageFFT( 34 34 psImage* out, ///< a psImage to recycle. If NULL, a new psImage is made. 35 const psImage* image, ///< the psImage to apply transform to35 const psImage* image, ///< the psImage to apply transform to 36 36 psFFTFlags direction ///< the direction of the transform 37 37 ); … … 79 79 */ 80 80 psImage* psImagePowerSpectrum( 81 psImage* out, ///< a psImage to recycle. If NULL, a new psImage is made.82 const psImage* in ///< the psImage to power spectrum of81 psImage* out, ///< a psImage to recycle. If NULL, a new psImage is made. 82 const psImage* in ///< the psImage to power spectrum of 83 83 ); 84 84 -
trunk/psLib/src/fft/psVectorFFT.c
r3970 r4540 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-0 5-19 02:09:39$7 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-07-12 19:12:01 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 22 22 #include "psLogMsg.h" 23 23 24 #include "ps DataManipErrors.h"24 #include "psErrorText.h" 25 25 26 26 #define P_FFTW_PLAN_RIGOR FFTW_ESTIMATE -
trunk/psLib/src/fits/Makefile.am
r4446 r4540 1 #Makefile for dataIOfunctions of psLib1 #Makefile for fits functions of psLib 2 2 # 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) 3 noinst_LTLIBRARIES = libpslibfits.la 15 4 16 noinst_LTLIBRARIES = libpslibdataIO.la 5 libpslibfits_la_SOURCES = \ 6 psFits.c 17 7 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=$? $@ 8 EXTRA_DIST = fits.i 29 9 30 10 pslibincludedir = $(includedir) 31 11 pslibinclude_HEADERS = \ 32 psLookupTable.h \ 33 psFits.h \ 34 psDB.h 35 12 psFits.h -
trunk/psLib/src/fits/psFits.c
r4392 r4540 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-0 6-25 02:02:05$9 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-07-12 19:12:01 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include "string.h" 19 19 #include "psError.h" 20 #include "ps FileUtilsErrors.h"20 #include "psErrorText.h" 21 21 #include "psImageStructManip.h" 22 22 #include "psMemory.h" -
trunk/psLib/src/imageops/Makefile.am
r4446 r4540 1 #Makefile for image functions of psLib1 #Makefile for image operation functions of psLib 2 2 # 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) 3 noinst_LTLIBRARIES = libpslibimageops.la 15 4 16 noinst_LTLIBRARIES = libpslibimage.la 17 18 libpslibimage_la_SOURCES = \ 19 psImage.c \ 5 libpslibimageops_la_SOURCES = \ 6 psImageConvolve.c \ 7 psImageGeomManip.c \ 20 8 psImagePixelExtract.c \ 21 psImageStructManip.c \22 psImageGeomManip.c \23 9 psImagePixelManip.c \ 24 10 psImageStats.c \ 25 psImageFFT.c \ 26 psImageConvolve.c 11 psImageStructManip.c 27 12 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=$? $@ 13 EXTRA_DIST = imageops.i 33 14 34 15 pslibincludedir = $(includedir) 35 16 pslibinclude_HEADERS = \ 36 psImage.h \ 17 psImageConvolve.h \ 18 psImageGeomManip.h \ 37 19 psImagePixelExtract.h \ 38 psImageStructManip.h \39 psImageGeomManip.h \40 20 psImagePixelManip.h \ 41 21 psImageStats.h \ 42 psImageFFT.h \ 43 psImageConvolve.h 22 psImageStructManip.h -
trunk/psLib/src/imageops/psImageConvolve.c
r4392 r4540 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-0 6-25 02:02:05$7 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-07-12 19:12:01 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 65 65 result->image = psImageAlloc(numCols,numRows,PS_TYPE_KERNEL); 66 66 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; 71 71 for (psS32 i = 0; i < numRows; i++) { 72 72 kernelRows[i] = imageRows[i] - xMin; … … 103 103 psS32 yMax = 0; 104 104 psS32 length = 0; 105 psKernelTypenormalizeTime = 1.0; // fraction of total time for each shift clock105 float normalizeTime = 1.0; // fraction of total time for each shift clock 106 106 psKernel* result = NULL; 107 psKernelType** kernel = NULL;107 float** kernel = NULL; 108 108 109 109 // got non-NULL vectors? … … 170 170 } \ 171 171 \ 172 normalizeTime = 1.0 / ( psKernelType)(tShiftData[length-1]); \172 normalizeTime = 1.0 / (float)(tShiftData[length-1]); \ 173 173 result = psKernelAlloc(xMin,xMax,yMin,yMax); \ 174 174 kernel = result->kernel; \ … … 180 180 y = lastY - yShiftData[i]; \ 181 181 \ 182 kernel[y][x] += ( psKernelType)t / (psKernelType)lastT; \182 kernel[y][x] += (float)t / (float)lastT; \ 183 183 prevT = tShiftData[i]; \ 184 184 } \ … … 216 216 kernel = result->kernel; \ 217 217 \ 218 normalizeTime = 1.0 / ( psKernelType)t; \218 normalizeTime = 1.0 / (float)t; \ 219 219 x = 0; \ 220 220 y = 0; \ 221 221 for (psS32 i = length-1; i >= 0; i--) { \ 222 kernel[y][x] += ( psKernelType)(tShiftData[i]) * normalizeTime; \222 kernel[y][x] += (float)(tShiftData[i]) * normalizeTime; \ 223 223 x -= xShiftData[i]; \ 224 224 y -= yShiftData[i]; \ … … 296 296 psS32 yMin = kernel->yMin; 297 297 psS32 yMax = kernel->yMax; 298 psKernelType** kData = kernel->kernel;298 float** kData = kernel->kernel; 299 299 300 300 // make the output image to the proper size and type … … 399 399 // pad the kernel to the same size of paddedImage 400 400 psImage* paddedKernel = psImageAlloc(paddedCols,paddedRows,PS_TYPE_KERNEL); 401 memset(paddedKernel->data.U8[0],0,sizeof( psKernelType)*numCols*numRows); // zero-out image401 memset(paddedKernel->data.U8[0],0,sizeof(float)*numCols*numRows); // zero-out image 402 402 psS32 yMax = kernel->yMax; 403 403 psS32 xMax = kernel->xMax; … … 407 407 padRow += paddedRows; 408 408 } 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]; 411 411 for (psS32 col = kernel->xMin; col <= xMax; col++) { 412 412 if (col < 0) { -
trunk/psLib/src/imageops/psImageConvolve.h
r4316 r4540 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-0 6-18 03:13:02$9 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-07-12 19:12:01 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 25 25 26 26 /** Kernel Type 27 * 27 * 28 28 * A floating-point data type used for storing kernel data. 29 * 29 * 30 30 */ 31 typedef psF32psKernelType;31 //typedef float psKernelType; 32 32 33 33 /** A convolution kernel */ … … 35 35 { 36 36 psImage* image; ///< Kernel data, in the form of an image 37 psS32xMin; ///< Most negative x index38 psS32yMin; ///< Most negative y index39 psS32xMax; ///< Most positive x index40 psS32yMax; ///< Most positive y index41 psKernelType** kernel;///< Pointer to the kernel data42 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. 43 43 } 44 44 psKernel; -
trunk/psLib/src/imageops/psImageGeomManip.c
r4385 r4540 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-25 00:51:28$12 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:01 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 196 196 } 197 197 198 if (mode < PS_INTERPOLATE_FLAT || mode >= PS_INTERPOLATE_NUM_MODES) {198 if (mode > PS_INTERPOLATE_LANCZOS4_VARIANCE ) { 199 199 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 200 200 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, -
trunk/psLib/src/imageops/psImagePixelExtract.c
r4385 r4540 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-0 6-25 00:51:28$10 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-07-12 19:12:01 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 312 312 } 313 313 314 if (mode < PS_INTERPOLATE_FLAT || mode >= PS_INTERPOLATE_NUM_MODES) {314 if (mode < PS_INTERPOLATE_FLAT ) { 315 315 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 316 316 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, -
trunk/psLib/src/imageops/psImagePixelManip.c
r4385 r4540 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-25 00:51:28$12 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:01 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 185 185 } 186 186 187 psS32psImageOverlaySection(psImage* image,188 const psImage* overlay,189 psS32col0,190 psS32row0,191 const char *op)187 int psImageOverlaySection(psImage* image, 188 const psImage* overlay, 189 int col0, 190 int row0, 191 const char *op) 192 192 { 193 193 psU32 imageNumRows; -
trunk/psLib/src/imageops/psImagePixelManip.h
r4385 r4540 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-0 6-25 00:51:28$10 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-07-12 19:12:01 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 78 78 * function is defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64. 79 79 * 80 * @return psS320 if success, non-zero if failed.80 * @return int 0 if success, non-zero if failed. 81 81 */ 82 psS32psImageOverlaySection(82 int psImageOverlaySection( 83 83 psImage* image, ///< target image 84 84 const psImage* overlay, ///< the overlay image 85 psS32 col0,///< the column to start overlay86 psS32 row0,///< the row to start overlay85 int col0, ///< the column to start overlay 86 int row0, ///< the row to start overlay 87 87 const char *op ///< the operation to perform for overlay 88 88 ); -
trunk/psLib/src/imageops/psImageStructManip.c
r3977 r4540 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-0 5-19 05:18:20$10 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-07-12 19:12:01 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 31 31 { 32 32 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 } 34 44 35 45 if (image == NULL || image->data.V == NULL) { … … 64 74 return NULL; 65 75 } 76 77 78 66 79 psS32 numRows = row1-row0; 67 80 psS32 numCols = col1-col0; … … 94 107 95 108 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; 99 114 *(psS32*)&out->row0 = row0; 100 115 *(psS32*)&out->col0 = col0; -
trunk/psLib/src/math/Makefile.am
r4446 r4540 1 #Makefile for dataManipfunctions of psLib1 #Makefile for math functions of psLib 2 2 # 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) 3 noinst_LTLIBRARIES = libpslibmath.la 15 4 16 noinst_LTLIBRARIES = libpslibdataManip.la 5 libpslibmath_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 17 14 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=$? $@ 15 EXTRA_DIST = math.i 26 16 27 17 pslibincludedir = $(includedir) 28 18 pslibinclude_HEADERS = \ 19 psBinaryOp.h \ 20 psCompare.h \ 29 21 psConstants.h \ 30 psStats.h \ 22 psMatrix.h \ 23 psMinimize.h \ 24 psRandom.h \ 31 25 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 30 30 * @author Robert DeSonia, MHPCC 31 31 * 32 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $33 * @date $Date: 2005-0 6-22 02:05:41 $32 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 33 * @date $Date: 2005-07-12 19:12:01 $ 34 34 * 35 35 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 50 50 #include "psLogMsg.h" 51 51 #include "psConstants.h" 52 #include "ps DataManipErrors.h"52 #include "psErrorText.h" 53 53 54 54 /***************************************************************************** … … 426 426 } 427 427 428 ps PtrpsBinaryOp(psPtr out, const psPtr in1, const char *op, const psPtr in2)428 psMathType* psBinaryOp(psPtr out, const psPtr in1, const char *op, const psPtr in2) 429 429 { 430 430 -
trunk/psLib/src/math/psBinaryOp.h
r4342 r4540 30 30 * @author Robert DeSonia, MHPCC 31 31 * 32 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $33 * @date $Date: 2005-0 6-22 02:05:41 $32 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 33 * @date $Date: 2005-07-12 19:12:01 $ 34 34 * 35 35 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 55 55 * @return psType* : Pointer to either psImage or psVector. 56 56 */ 57 ps Type* psBinaryOp(57 psMathType* psBinaryOp( 58 58 psPtr out, ///< Output type, either psImage or psVector. 59 59 const psPtr in1, ///< First input, either psImage or psVector. -
trunk/psLib/src/math/psMatrix.c
r4388 r4540 21 21 * @author Robert DeSonia, MHPCC 22 22 * 23 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $24 * @date $Date: 2005-0 6-25 01:15:01 $23 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 24 * @date $Date: 2005-07-12 19:12:01 $ 25 25 * 26 26 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 43 43 #include "psMatrix.h" 44 44 #include "psConstants.h" 45 #include "ps DataManipErrors.h"45 #include "psErrorText.h" 46 46 47 47 -
trunk/psLib/src/math/psMinimize.c
r4321 r4540 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.12 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 6-20 22:42:30$11 * @version $Revision: 1.124 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-07-12 19:12:01 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1357 1357 XXX: type F32 is done via vector conversion only. 1358 1358 *****************************************************************************/ 1359 psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* myPoly,1359 psPolynomial1D* psVectorFitPolynomial1D(psPolynomial1D* poly, 1360 1360 const psVector* x, 1361 1361 const psVector* y, 1362 1362 const psVector* yErr) 1363 1363 { 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); 1366 1366 PS_ASSERT_VECTOR_NON_NULL(y, NULL); 1367 1367 PS_ASSERT_VECTOR_NON_EMPTY(y, NULL); … … 1389 1389 if (x == NULL) { 1390 1390 PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n); 1391 if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1391 if (poly->type == PS_POLYNOMIAL_CHEB) { 1392 1392 p_psNormalizeVectorRangeF64(x64Static, -1.0, 1.0); 1393 1393 } … … 1396 1396 PS_ASSERT_VECTOR_TYPE_F32_OR_F64(x, NULL); 1397 1397 PS_VECTOR_CONVERT_F32_TO_F64_STATIC(x, x64, x64Static); 1398 if ( myPoly->type == PS_POLYNOMIAL_CHEB) {1398 if (poly->type == PS_POLYNOMIAL_CHEB) { 1399 1399 p_psNormalizeVectorRangeF64(x64, -1.0, 1.0); 1400 1400 } … … 1405 1405 // Call the appropriate vector fitting routine. 1406 1406 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); 1411 1411 } else { 1412 1412 psError(PS_ERR_BAD_PARAMETER_VALUE, true, … … 1419 1419 } 1420 1420 1421 return( myPoly);1421 return(poly); 1422 1422 } 1423 1423 … … 1432 1432 1433 1433 psMinimization *min = psAlloc(sizeof(psMinimization)); 1434 min->maxIter = maxIter;1435 min->tol = tol;1434 *(int*)&min->maxIter = maxIter; 1435 *(float*)&min->tol = tol; 1436 1436 min->value = 0.0; 1437 1437 min->iter = 0; … … 1993 1993 for (i=0;i<numDims;i++) { 1994 1994 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; 1997 1997 mul = p_psLineMin(&dummyMin, 1998 1998 Q, -
trunk/psLib/src/math/psMinimize.h
r4330 r4540 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.4 8$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-0 6-21 03:01:37$10 * @version $Revision: 1.49 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-07-12 19:12:01 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 38 38 39 39 /** A data structure for minimization routines. 40 * 40 * 41 41 * Contains numerical analysis parameters/values 42 42 */ 43 43 typedef struct 44 44 { 45 psS32 maxIter;///< Convergence limit46 psF32 tol;///< Error Tolerance47 psF32value; ///< Value of function at minimum48 psS32 iter;///< Number of iterations to date49 psF32lastDelta; ///< The last difference for the fit45 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 50 50 } 51 51 psMinimization; 52 52 53 53 /** Allocates a psMinimization structure. 54 * 54 * 55 55 * @return psMinimization* : a new psMinimization struct 56 56 */ … … 74 74 */ 75 75 psPolynomial1D* psVectorFitPolynomial1D( 76 psPolynomial1D* myPoly, ///< Polynomial to fit76 psPolynomial1D* poly, ///< Polynomial to fit 77 77 const psVector* x, ///< Ordinates (or NULL to just use the indices) 78 78 const psVector* y, ///< Coordinates … … 81 81 82 82 /** 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 85 85 * generates the linear splines which satisfy those data points. 86 * 86 * 87 87 * @return psSpline1D*: the calculated one-dimensional splines 88 88 */ … … 96 96 /** Specifies the format of a user-defined function that the general Levenberg- 97 97 * 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, 100 100 * positions, and derivatives. 101 101 */ 102 102 typedef 103 psF64(*psMinimizeLMChi2Func)(103 float (*psMinimizeLMChi2Func)( 104 104 psVector *deriv, ///< derivatives of the function 105 psVector *params,///< the parameters used to evaluate the function106 psVector *x///< positions for evaluation105 const psVector *params, ///< the parameters used to evaluate the function 106 const psVector *x ///< positions for evaluation 107 107 ); 108 108 109 109 /** Minimizes a specified function based on the Levenberg-Marquardt method. 110 * 110 * 111 111 * @return bool: True if successful. 112 112 */ … … 123 123 124 124 /** Use specified alpha, beta, params to generate a new guess for Alpha, Beta, Params 125 * 125 * 126 126 * @return psBool: True if successful. 127 127 */ … … 138 138 139 139 /** Function used to set parameters for generating "best guess" in minimizing Chi-Squared value. 140 * 140 * 141 141 * @return psF64: Chi-squared value for new guess 142 142 */ … … 153 153 /** Specifies the format of a user-defined function that the general Powell 154 154 * minimizer routine will accept. 155 * 156 * @return psF32: the single float value of the function given the parameters155 * 156 * @return float: the single float value of the function given the parameters 157 157 * and coordinate vectors. 158 158 */ 159 159 typedef 160 psF32(*psMinimizePowellFunc)(160 float (*psMinimizePowellFunc)( 161 161 const psVector *params, ///< Parameters used to evaluate the function 162 162 const psArray *coords ///< Coordinates at which to evaluate … … 164 164 165 165 /** Minimizes a specified function based on the Powell method. 166 * 166 * 167 167 * @return bool: True if successful. 168 168 */ … … 177 177 /** Calculates the one-dimensional Gaussian in a format acceptable to the Levenberg- 178 178 * Marquardt minimizer routine. 179 * 179 * 180 180 * @return psVector*: Calculated values 181 181 */ … … 188 188 /** Calculates the one-dimensional Gaussian in a format acceptable to the Powell 189 189 * chi-squared minimizer routine. 190 * 190 * 191 191 * @return psVector*: Calculated values 192 192 */ … … 198 198 /** Specifies the format of a user-defined function that the general Powell chi- 199 199 * squared minimizer routine will accept. 200 * 200 * 201 201 * @return psVector*: Calculated values given the parameters and coordinates. 202 202 */ … … 208 208 209 209 /** Minimizes a specified function based on the Powell chi-squared method. 210 * 210 * 211 211 * @return bool: True is successful. 212 212 */ … … 222 222 223 223 /** Gauss-Jordan numerical solver. 224 * 224 * 225 225 * @return bool: True if successful. 226 226 */ -
trunk/psLib/src/math/psRandom.c
r4330 r4540 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-21 03:01:37$12 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:01 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 31 31 #include "psLogMsg.h" 32 32 #include "psConstants.h" 33 #include "ps DataManipErrors.h"33 #include "psErrorText.h" 34 34 35 35 psU64 p_psRandomGetSystemSeed() -
trunk/psLib/src/math/psStats.c
r4409 r4540 14 14 * stats->binsize 15 15 * 16 * @version $Revision: 1.13 6$ $Name: not supported by cvs2svn $17 * @date $Date: 2005-0 6-28 20:17:52$16 * @version $Revision: 1.137 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2005-07-12 19:12:01 $ 18 18 * 19 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 41 41 #include "psConstants.h" 42 42 43 #include "ps DataManipErrors.h"43 #include "psErrorText.h" 44 44 45 45 /*****************************************************************************/ … … 77 77 psBool p_psGetStatValue(const psStats* stats, psF64 *value) 78 78 { 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)) { 80 81 case PS_STAT_SAMPLE_MEAN: 81 82 *value = stats->sampleMean; … … 658 659 x.data.F32 = iMid - (PS_GAUSS_WIDTH * sigma); 659 660 if ((x.data.F32 >= firstBound) && (x.data.F32 <= lastBound)) { 660 jMin = p_psVectorBinDisect( robustHistogram->bounds, &x);661 jMin = p_psVectorBinDisect( *(psVector* *)&robustHistogram->bounds, &x); 661 662 if (jMin < 0) { 662 663 psError(PS_ERR_UNEXPECTED_NULL, … … 673 674 x.data.F32 = iMid + (PS_GAUSS_WIDTH * sigma); 674 675 if ((x.data.F32 >= firstBound) && (x.data.F32 <= lastBound)) { 675 jMax = p_psVectorBinDisect( robustHistogram->bounds, &x);676 jMax = p_psVectorBinDisect( *(psVector* *)&robustHistogram->bounds, &x); 676 677 if (jMax < 0) { 677 678 psError(PS_ERR_UNEXPECTED_NULL, … … 1705 1706 //Determine id that is okay. 1706 1707 stats->robustMedian = fitQuadraticSearchForYThenReturnX( 1707 robustHistogram->bounds,1708 *(psVector* *)&robustHistogram->bounds, 1708 1709 cumulativeRobustSums, 1709 1710 medianBinNum, … … 1721 1722 //Determine id that is okay. 1722 1723 stats->robustLQ = fitQuadraticSearchForYThenReturnX( 1723 robustHistogram->bounds,1724 *(psVector* *)&robustHistogram->bounds, 1724 1725 cumulativeRobustSums, 1725 1726 LQBinNum, … … 1728 1729 //Determine id that is okay. 1729 1730 stats->robustUQ = fitQuadraticSearchForYThenReturnX( 1730 robustHistogram->bounds,1731 *(psVector* *)&robustHistogram->bounds, 1731 1732 cumulativeRobustSums, 1732 1733 UQBinNum, … … 1812 1813 psMemSetDeallocator(newHist, (psFreeFunc) histogramFree); 1813 1814 newHist->bounds = psVectorAlloc(n + 1, PS_TYPE_F32); 1814 newHist->bounds->n = newHist->bounds->nalloc;1815 *(int *)&newHist->bounds->n = newHist->bounds->nalloc; 1815 1816 1816 1817 // Calculate the bounds for each bin. … … 1859 1860 psMemSetDeallocator(newHist, (psFreeFunc) histogramFree); 1860 1861 newHist->bounds = psVectorAlloc(bounds->n, PS_TYPE_F32); 1861 newHist->bounds->n = newHist->bounds->nalloc;1862 *(int *)&newHist->bounds->n = newHist->bounds->nalloc; 1862 1863 for (i = 0; i < bounds->n; i++) { 1863 1864 newHist->bounds->data.F32[i] = bounds->data.F32[i]; … … 2067 2068 // correct bin number requires a bit more work. 2068 2069 tmpScalar.data.F32 = inF32->data.F32[i]; 2069 binNum = p_psVectorBinDisect( out->bounds, &tmpScalar);2070 binNum = p_psVectorBinDisect( *(psVector* *)&out->bounds, &tmpScalar); 2070 2071 if (binNum < 0) { 2071 2072 psLogMsg(__func__, PS_LOG_WARN, -
trunk/psLib/src/math/psStats.h
r4409 r4540 14 14 * @author GLG, MHPCC 15 15 * 16 * @version $Revision: 1.4 5$ $Name: not supported by cvs2svn $17 * @date $Date: 2005-0 6-28 20:17:52$16 * @version $Revision: 1.46 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2005-07-12 19:12:01 $ 18 18 * 19 19 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 52 52 PS_STAT_USE_RANGE = 0x002000, ///< Range 53 53 PS_STAT_USE_BINSIZE = 0x004000, ///< Binsize 54 PS_STAT_ROBUST_FOR_SAMPLE = 0x008000 ///< Robust for sample54 // PS_STAT_ROBUST_FOR_SAMPLE = 0x008000 ///< Robust for sample 55 55 } psStatsOptions; 56 56 … … 60 60 typedef struct 61 61 { 62 psF64 sampleMean;///< formal mean of sample63 psF64 sampleMedian;///< formal median of sample64 psF64 sampleStdev;///< standard deviation of sample65 psF64 sampleUQ;///< upper quartile of sample66 psF64 sampleLQ;///< lower quartile of sample67 psF64 robustMean;///< robust mean of array68 psF64 robustMedian;///< robust median of array69 psF64 robustMode;///< Robust mode of array70 psF64 robustStdev;///< robust standard deviation of array71 psF64 robustUQ;///< robust upper quartile72 psF64 robustLQ;///< robust lower quartile73 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 mean76 psF64 clippedStdev;///< standard deviation after clipping77 psS32 clippedNvalues;///< Number of data points used for clipped mean: This value is never used.78 psF64 clipSigma;///< Nsigma used for clipping; user input79 psS32 clipIter;///< Number of clipping iterations; user input80 psF64 min;///< minimum data value in array81 psF64 max;///< maximum data value in array82 psF64 binsize;///< binsize for robust fit (input/ouput)83 psStatsOptions options; ///< bitmask of calculated values62 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 84 84 } 85 85 psStats; … … 90 90 */ 91 91 psStats* psVectorStats( 92 psStats* stats, ///< stats structure defines stats to be calculated and how93 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 NULL96 psMaskType maskVal ///< Only mask elements with one of these bits set in maskVector92 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 97 97 ); 98 98 … … 121 121 typedef struct 122 122 { 123 psVector* bounds;///< Bounds for the bins (type F32)123 const psVector* bounds; ///< Bounds for the bins (type F32) 124 124 psVector* nums; ///< Number in each of the bins (INT) 125 psS32 minNum;///< Number below the minimum126 psS32 maxNum;///< Number above the maximum127 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? 128 128 } 129 129 psHistogram; -
trunk/psLib/src/math/psUnaryOp.c
r4409 r4540 30 30 * @author Robert DeSonia, MHPCC 31 31 * 32 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $33 * @date $Date: 2005-0 6-28 20:17:52$32 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 33 * @date $Date: 2005-07-12 19:12:01 $ 34 34 * 35 35 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 51 51 #include "psLogMsg.h" 52 52 #include "psConstants.h" 53 #include "ps DataManipErrors.h"53 #include "psErrorText.h" 54 54 55 55 /***************************************************************************** … … 304 304 } 305 305 306 ps PtrpsUnaryOp(psPtr out, const psPtr in, const char *op)306 psMathType* psUnaryOp(psPtr out, const psPtr in, const char *op) 307 307 { 308 308 #define psUnaryOp_EXIT { \ -
trunk/psLib/src/math/psUnaryOp.h
r4409 r4540 30 30 * @author Robert DeSonia, MHPCC 31 31 * 32 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $33 * @date $Date: 2005-0 6-28 20:17:52$32 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 33 * @date $Date: 2005-07-12 19:12:01 $ 34 34 * 35 35 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 59 59 * @return psType* : Pointer to either psImage or psVector. 60 60 */ 61 ps Type* psUnaryOp(61 psMathType* psUnaryOp( 62 62 psPtr out, ///< Output type, either psImage or psVector. 63 63 const psPtr in, ///< Input, either psImage or psVector. -
trunk/psLib/src/mathtypes/Makefile.am
r4446 r4540 1 #Makefile for collections functions of psLib1 #Makefile for mathtypes functions of psLib 2 2 # 3 noinst_LTLIBRARIES = libpslibmathtypes.la 3 4 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) 5 libpslibmathtypes_la_SOURCES = \ 6 psImage.c \ 7 psScalar.c \ 8 psVector.c 16 9 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=$? $@ 10 EXTRA_DIST = mathtypes.i 36 11 37 12 pslibincludedir = $(includedir) 38 13 pslibinclude_HEADERS = \ 39 psBitSet.h \ 40 psVector.h \ 41 psPixels.h \ 42 psList.h \ 14 psImage.h \ 43 15 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 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.7 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 6-28 20:17:52$11 * @version $Revision: 1.73 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-07-12 19:12:01 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 48 48 } 49 49 50 psImage* psImageAlloc( psU32numCols,51 psU32numRows,50 psImage* psImageAlloc(int numCols, 51 int numRows, 52 52 psElemType type) 53 53 { … … 91 91 } 92 92 93 psRegion psRegionSet( psF32x0,94 psF32x1,95 psF32y0,96 psF32y1)93 psRegion psRegionSet(float x0, 94 float x1, 95 float y0, 96 float y1) 97 97 { 98 98 psRegion out; … … 149 149 150 150 psImage* psImageRecycle(psImage* old, 151 psU32numCols,152 psU32numRows,151 int numCols, 152 int numRows, 153 153 const psElemType type) 154 154 { … … 369 369 } 370 370 371 psC64psImagePixelInterpolate(const psImage* input,372 float x,373 float y,374 const psImage* mask,375 psU32maskVal,376 psC64unexposedValue,377 psImageInterpolateMode mode)371 complex psImagePixelInterpolate(const psImage* input, 372 float x, 373 float y, 374 const psImage* mask, 375 psMaskType maskVal, 376 complex unexposedValue, 377 psImageInterpolateMode mode) 378 378 { 379 379 -
trunk/psLib/src/mathtypes/psImage.h
r4409 r4540 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1. 59$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-0 6-28 20:17:52$13 * @version $Revision: 1.60 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-07-12 19:12:01 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 40 40 PS_INTERPOLATE_LANCZOS3_VARIANCE, ///< Variance version of PS_INTERPOLATE_LANCZOS3 41 41 PS_INTERPOLATE_LANCZOS4_VARIANCE, ///< Variance version of PS_INTERPOLATE_LANCZOS4 42 PS_INTERPOLATE_NUM_MODES ///< enum end-marker; does not coorespond to a interpolation mode42 // PS_INTERPOLATE_NUM_MODES ///< enum end-marker; does not coorespond to a interpolation mode 43 43 } psImageInterpolateMode; 44 44 … … 51 51 typedef struct psImage 52 52 { 53 const ps Type type;///< Image data type and dimension.54 const psU32 numCols;///< Number of columns in image55 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. 58 58 59 59 union { … … 77 77 78 78 psPtr rawDataBuffer; ///< Raw data buffer for Allocating/Freeing Images 79 void *lock; ///< Optional lock for thread safety 79 80 } 80 81 psImage; … … 87 88 typedef struct 88 89 { 89 psF32x0; ///< the first column of the region.90 psF32x1; ///< the last column of the region.91 psF32y0; ///< the first row of the region.92 psF32y1; ///< 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. 93 94 } 94 95 psRegion; … … 103 104 */ 104 105 psImage* 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. 107 108 psElemType type ///< Type of data for image. 108 ); 109 ) 110 ; 109 111 110 112 /** Create a psRegion with the specified attributes. … … 113 115 */ 114 116 psRegion 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. 119 121 ); 120 122 … … 146 148 psImage* psImageRecycle( 147 149 psImage* old, ///< the psImage to recycle by resizing image buffer 148 psU32 numCols,///< the desired number of columns in image149 psU32 numRows,///< the desired number of rows in image150 int numCols, ///< the desired number of columns in image 151 int numRows, ///< the desired number of rows in image 150 152 const psElemType type ///< the desired datatype of the image 151 153 ); 152 154 153 155 /** Copy an image to a new buffer 154 * 156 * 155 157 * @return True if image copied or false if error 156 158 */ … … 195 197 * given x,y doesn't coorespond to a valid image location 196 198 */ 197 psC64psImagePixelInterpolate(199 complex psImagePixelInterpolate( 198 200 const psImage* input, ///< input image for interpolation 199 201 float x, ///< column location to derive value of 200 202 float y, ///< row location ot derive value of 201 203 const psImage* mask, ///< if not NULL, the mask of the input image 202 ps U32 maskVal,///< the mask value203 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. 204 206 psImageInterpolateMode mode ///< interpolation mode 205 207 ); -
trunk/psLib/src/mathtypes/psScalar.c
r4409 r4540 8 8 * @author Ross Harman, MHPCC 9 9 * 10 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-0 6-28 20:17:52$10 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-07-12 19:12:01 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 20 20 #include "psAbort.h" 21 21 22 #include "ps CollectionsErrors.h"22 #include "psErrorText.h" 23 23 24 24 psScalar* psScalarAlloc(complex value, psElemType type) -
trunk/psLib/src/mathtypes/psScalar.h
r4409 r4540 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-0 6-28 20:17:52$13 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-07-12 19:12:01 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 32 32 typedef struct 33 33 { 34 ps Type type;///< Type of data.34 psMathType type; ///< Type of data. 35 35 36 36 union { -
trunk/psLib/src/mathtypes/psVector.c
r4409 r4540 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.4 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 6-28 20:17:52$11 * @version $Revision: 1.46 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-07-12 19:12:01 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 26 26 #include "psCompare.h" 27 27 28 #include "ps CollectionsErrors.h"28 #include "psErrorText.h" 29 29 30 30 typedef struct … … 48 48 // FUNCTION IMPLEMENTATION - PUBLIC 49 49 50 psVector* psVectorAlloc( unsignedlong nalloc, psElemType type)50 psVector* psVectorAlloc( long nalloc, psElemType type) 51 51 { 52 52 psVector* psVec = NULL; … … 67 67 psVec->type.dimen = PS_DIMEN_VECTOR; 68 68 psVec->type.type = type; 69 *( int*)&psVec->nalloc = nalloc;69 *(long*)&psVec->nalloc = nalloc; 70 70 psVec->n = nalloc; 71 71 … … 76 76 } 77 77 78 psVector* psVectorRealloc(psVector* vector, unsignedlong nalloc)78 psVector* psVectorRealloc(psVector* vector, long nalloc) 79 79 { 80 80 psS32 elementSize = 0; … … 93 93 // Realloc after decrementation to avoid accessing freed array elements 94 94 vector->data.U8 = psRealloc(vector->data.U8, nalloc * elementSize); 95 *( int*)&vector->nalloc = nalloc;95 *(long*)&vector->nalloc = nalloc; 96 96 } 97 97 … … 99 99 } 100 100 101 psVector* psVectorRecycle(psVector* vector, unsignedlong nalloc, psElemType type)101 psVector* psVectorRecycle(psVector* vector, long nalloc, psElemType type) 102 102 { 103 103 psS32 byteSize; … … 120 120 if (byteSize > vector->nalloc*PSELEMTYPE_SIZEOF(vector->type.type)) { 121 121 vector->data.U8 = psRealloc(vector->data.U8, byteSize); 122 *( int*)&vector->nalloc = nalloc;122 *(long*)&vector->nalloc = nalloc; 123 123 } 124 124 -
trunk/psLib/src/mathtypes/psVector.h
r4409 r4540 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-0 6-28 20:17:52$13 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-07-12 19:12:01 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 51 51 typedef struct 52 52 { 53 ps Type 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. 56 56 p_psVectorData data; ///< Union for data types. 57 void *lock; ///< Optional lock for thread safety. 57 58 } 58 59 psVector; … … 73 74 */ 74 75 psVector* psVectorAlloc( 75 unsigned long nalloc,///< Total number of elements to make available.76 long nalloc, ///< Total number of elements to make available. 76 77 psElemType type ///< Type of data to be held by vector. 77 ); 78 ) 79 ; 78 80 79 81 /** Reallocate a vector. … … 88 90 psVector* psVectorRealloc( 89 91 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. 91 93 ); 92 94 … … 120 122 ///< taken to preserve the values. 121 123 122 unsigned long nalloc,///< Total number of elements to make available.124 long nalloc, ///< Total number of elements to make available. 123 125 psElemType type ///< the datatype of the returned vector 124 126 ); -
trunk/psLib/src/pslib_strict.h
r4162 r4540 9 9 * @author Eric Van Alst, MHPCC 10 10 * 11 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 6-08 23:40:45$11 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-07-12 19:12:00 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 26 26 #endif // #else 27 27 28 // // System Utilities 29 30 /// @defgroup SysUtils System Utilities 28 /// @defgroup astro Astrometry Functions 31 29 /// @{ 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" 62 32 /// @} 63 33 64 // Collections 65 /// @defgroup DataContainer Data Containers 34 /// @defgroup db Database Functions 66 35 /// @{ 36 #include "psDB.h" 37 /// @} 67 38 68 #include "psType.h" 39 /// @defgroup fft Fourier Functions 40 /// @{ 41 #include "psVectorFFT.h" 42 #include "psImageFFT.h" 43 /// @} 69 44 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 /// @} 73 49 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 /// @} 77 59 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 /// @} 81 72 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 92 74 /// @{ 93 75 #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" 104 78 /// @} 105 79 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" 110 91 /// @} 111 92 112 // Data Manipulation 113 /// @defgroup DataManip Data Manipulation 93 /// @defgroup types Basic Data Types 114 94 /// @{ 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" 143 103 /// @} 144 104 145 // Astronomy 146 /// @defgroup Astronomy Astronomy Functions 105 /// @defgroup xml XML Functions 147 106 /// @{ 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" 183 108 /// @} 184 109 -
trunk/psLib/src/sys/Makefile.am
r4446 r4540 1 #Makefile for sys Utilsfunctions of psLib1 #Makefile for sys functions of psLib 2 2 # 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) 3 noinst_LTLIBRARIES = libpslibsys.la 15 4 16 noinst_LTLIBRARIES = libpslibsysUtils.la 5 libpslibsys_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 17 14 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 15 EXTRA_DIST = sys.i 27 16 28 BUILT_SOURCES = psSysUtilsErrors.h 29 EXTRA_DIST = psSysUtilsErrors.dat psSysUtilsErrors.h sysUtils.i 17 BUILT_SOURCES = psErrorCodes.c 30 18 31 psSysUtilsErrors.h: psSysUtilsErrors.dat 32 $(top_srcdir)/src/psParseErrorCodes --data=$? $@ 19 psErrorCodes.c: ../psErrorCodes_$(LANG).dat psErrorCodes.c.in psErrorCodes.h 20 $(top_srcdir)/psParseErrorCodes --data=../psErrorCodes_$(LANG).dat $@ 21 22 psError.h: psErrorCodes.h 23 24 psErrorCodes.h: ../psErrorCodes_$(LANG).dat psErrorCodes.h.in 25 $(top_srcdir)/psParseErrorCodes --data=../psErrorCodes_$(LANG).dat $@ 33 26 34 27 pslibincludedir = $(includedir) 35 28 pslibinclude_HEADERS = \ 36 psType.h \ 29 psAbort.h \ 30 psConfigure.h \ 31 psError.h \ 32 psErrorCodes.h \ 33 psLogMsg.h \ 37 34 psMemory.h \ 38 ps Error.h\35 psString.h \ 39 36 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 13 13 * @author Robert DeSonia, MHPCC 14 14 * 15 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $16 * @date $Date: 2005-0 6-11 02:19:05$15 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2005-07-12 19:12:01 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 22 22 #include "psError.h" 23 23 #include "psConfigure.h" 24 #include "ps SysUtilsErrors.h"24 #include "psErrorText.h" 25 25 #include "config.h" 26 26 -
trunk/psLib/src/sys/psErrorCodes.c
r4392 r4540 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-0 6-25 02:02:05$9 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-07-12 19:12:01 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 20 20 #include "psMemory.h" 21 21 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" 34 23 35 24 static psErrorDescription staticErrorCodes[] = { 36 25 {PS_ERR_NONE,"not an error"}, 37 26 {PS_ERR_BASE,"base error"}, 38 //~Start {PS_ERR_$1,"$2"},39 27 {PS_ERR_UNKNOWN,"unknown error"}, 40 28 {PS_ERR_IO,"I/O error"}, … … 48 36 {PS_ERR_UNEXPECTED_NULL,"unexpected NULL found"}, 49 37 {PS_ERR_OS_CALL_FAILED,"unexpected result from an OS standard library call"}, 50 //~End51 38 {PS_ERR_N_ERR_CLASSES,"error classes end marker"} 52 39 }; -
trunk/psLib/src/sys/psLogMsg.c
r4367 r4540 12 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.4 7$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 6-23 03:50:29$14 * @version $Revision: 1.48 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-07-12 19:12:01 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 42 42 #include "psTrace.h" 43 43 44 #include "ps SysUtilsErrors.h"44 #include "psErrorText.h" 45 45 46 46 #define MIN_LOG_LEVEL 0 -
trunk/psLib/src/sys/psMemory.c
r4401 r4540 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.5 7$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-0 6-27 20:38:12$10 * @version $Revision: 1.58 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-07-12 19:12:01 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 25 25 #include "psLogMsg.h" 26 26 27 #include "ps SysUtilsErrors.h"27 #include "psErrorText.h" 28 28 29 29 #define P_PS_MEMMAGIC (psPtr )0xdeadbeef // Magic number in psMemBlock header -
trunk/psLib/src/sys/psString.c
r4434 r4540 12 12 * @author Eric Van Alst, MHPCC 13 13 * 14 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 6-30 00:33:36$14 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-07-12 19:12:01 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 25 25 #include "psError.h" 26 26 27 #include "ps SysUtilsErrors.h"27 #include "psErrorText.h" 28 28 29 29 psString psStringCopy(const char *string) -
trunk/psLib/src/sys/psTrace.c
r4409 r4540 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.5 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 6-28 20:17:52$11 * @version $Revision: 1.54 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-07-12 19:12:01 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 51 51 #include "psLogMsg.h" 52 52 53 #include "ps SysUtilsErrors.h"53 #include "psErrorText.h" 54 54 55 55 static p_psComponent* cRoot = NULL; // The root of the trace component -
trunk/psLib/src/sys/psType.h
r4342 r4540 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.3 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-22 02:05:41 $12 * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:01 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 94 94 } psElemType; 95 95 96 /** Enumeration primarily used with metadata which defines a data structure 97 * e.g., list, array, FITS file, etc. 98 */ 99 typedef 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 96 142 #define PS_TYPE_MASK PS_TYPE_U8 /**< the psElemType to use for mask image */ 97 143 #define PS_TYPE_MASK_DATA U8 /**< the data member to use for mask image */ … … 232 278 typedef struct 233 279 { 234 psElemType type; ///< Primitive type.235 psDimen dimen; ///< Dimensionality.280 psElemType type; ///< Primitive type. 281 psDimen dimen; ///< Dimensionality. 236 282 } 237 283 psType; 284 285 typedef struct 286 { 287 psElemType type; ///< The type 288 psDimen dimen; ///< The dimensionality. 289 // psElemType type; ///< The type 290 } 291 psMathType; 238 292 239 293 /** The type of a basic data type … … 245 299 typedef struct 246 300 { 247 ps Typetype; ///< Data type information301 psMathType type; ///< Data type information 248 302 } 249 303 psMath; -
trunk/psLib/src/types/Makefile.am
r4446 r4540 1 #Makefile for collections functions of psLib1 #Makefile for types functions of psLib 2 2 # 3 noinst_LTLIBRARIES = libpslibtypes.la 3 4 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) 5 libpslibtypes_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 16 14 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=$? $@ 15 EXTRA_DIST = types.i 36 16 37 17 pslibincludedir = $(includedir) 38 18 pslibinclude_HEADERS = \ 19 psArray.h \ 39 20 psBitSet.h \ 40 psVector.h \ 41 psPixels.h \ 21 psHash.h \ 42 22 psList.h \ 43 psScalar.h \ 44 psCompare.h \ 45 psArray.h \ 46 psHash.h \ 23 psLookupTable.h \ 47 24 psMetadata.h \ 48 psMetadata IO.h49 25 psMetadataConfig.h \ 26 psPixels.h -
trunk/psLib/src/types/psArray.c
r4392 r4540 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-0 6-25 02:02:04$11 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-07-12 19:12:01 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 28 28 #include "psLogMsg.h" 29 29 30 #include "ps CollectionsErrors.h"30 #include "psErrorText.h" 31 31 32 32 /***************************************************************************** -
trunk/psLib/src/types/psBitSet.c
r4392 r4540 11 11 * @author Robert DeSonia, MHPCC 12 12 * 13 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-0 6-25 02:02:05$13 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-07-12 19:12:01 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 28 28 #include "psString.h" 29 29 30 #include "ps CollectionsErrors.h"30 #include "psErrorText.h" 31 31 32 32 enum { -
trunk/psLib/src/types/psHash.c
r4392 r4540 12 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 6-25 02:02:05$14 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-07-12 19:12:01 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 27 27 #include "psConstants.h" 28 28 29 #include "ps CollectionsErrors.h"29 #include "psErrorText.h" 30 30 31 31 static psHashBucket* hashBucketAlloc(const char *key, psPtr data, psHashBucket* next); -
trunk/psLib/src/types/psList.c
r4392 r4540 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-0 6-25 02:02:05$8 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-07-12 19:12:01 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include "psLogMsg.h" 24 24 25 #include "ps CollectionsErrors.h"25 #include "psErrorText.h" 26 26 27 27 #define ITER_INIT_HEAD ((psPtr )1) // next iteration should return head -
trunk/psLib/src/types/psLookupTable.c
r4392 r4540 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-0 6-25 02:02:05$9 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-07-12 19:12:01 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii … … 25 25 #include "psError.h" 26 26 #include "psLookupTable.h" 27 #include "ps FileUtilsErrors.h"27 #include "psErrorText.h" 28 28 #include "psConstants.h" 29 29 -
trunk/psLib/src/types/psMetadata.c
r4401 r4540 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1. 69$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 6-27 20:38:12$14 * @version $Revision: 1.70 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-07-12 19:12:01 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 36 36 #include "psLookupTable.h" 37 37 #include "psString.h" 38 #include "ps AstronomyErrors.h"38 #include "psErrorText.h" 39 39 #include "psConstants.h" 40 40 #include "psLogMsg.h" -
trunk/psLib/src/types/psMetadataConfig.c
r4432 r4540 1 /** @file psMetadata IO.c1 /** @file psMetadataConfig.c 2 2 * 3 3 * @brief Contains metadata input/output functions. … … 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-30 00:04:12$12 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:01 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 16 16 */ 17 17 18 #include <libxml/parser.h>19 18 #include <fitsio.h> 20 19 #include <string.h> … … 31 30 #include "psVector.h" 32 31 #include "psMetadata.h" 33 #include "psMetadata IO.h"32 #include "psMetadataConfig.h" 34 33 #include "psConstants.h" 35 #include "psAstronomyErrors.h" 36 37 /******************************************************************************/ 38 /* DEFINE STATEMENTS */ 39 /******************************************************************************/ 34 #include "psErrorText.h" 40 35 41 36 /** Check for FITS errors */ … … 59 54 #define MAX_STRING_LENGTH 256 60 55 61 62 /******************************************************************************/63 /* TYPE DEFINITIONS */64 /******************************************************************************/65 66 // None67 68 /*****************************************************************************/69 /* GLOBAL VARIABLES */70 /*****************************************************************************/71 72 // None73 74 /*****************************************************************************/75 /* FILE STATIC VARIABLES */76 /*****************************************************************************/77 78 // None79 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 56 static psMetadata* getMetadataType(char *linePtr); 57 89 58 static psMetadata* setMetadataItem(psMetadata* template, char* linePtr) 90 59 ; 60 91 61 static void parseLevelInfoFree(p_psParseLevelInfo* info); 62 92 63 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); 64 char* linePtr, psS32 lineCount, char* fileName, 65 psBool overwrite); 66 67 static psBool parseMetadataItem(char* keyName, psS32* level, 68 psArray* levelArray, char* linePtr, 69 psS32 lineCount, char* fileName, 70 psMetadataFlags flags); 96 71 97 72 static void parseLevelInfoFree(p_psParseLevelInfo* info) … … 106 81 // Determines if a line is blank (whitespace only) or a commentline. It returns true if so. The input string 107 82 // must be null terminated. 108 psBool ignoreLine(char *inString)83 static psBool ignoreLine(char *inString) 109 84 { 110 85 while(*inString!='\0' && *inString!='#') { … … 121 96 // Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null 122 97 // terminated copy of the original input string. 123 char *cleanString(char *inString, psS32 sLen, psBool ignoreComment)98 static char *cleanString(char *inString, psS32 sLen, psBool ignoreComment) 124 99 { 125 100 char *ptrB = NULL; … … 167 142 168 143 // Count repeat occurances of a single character within a line. The input string must be null terminated. 169 psS32 repeatedChars(char *inString, char ch)144 static psS32 repeatedChars(char *inString, char ch) 170 145 { 171 146 psS32 count = 0; … … 183 158 // Returns cleaned token based on delimiter, but not including delimiter. Also changes the pointer location 184 159 // the beginning of the string. Tokens are newly allocated null terminated strings. 185 char* getToken(char **inString, char *delimiter, psS32 *status, psBool ignoreComment)160 static char* getToken(char **inString, char *delimiter, psS32 *status, psBool ignoreComment) 186 161 { 187 162 char *cleanToken = NULL; … … 217 192 // Returns single parsed value as a double precision number. The input string must be cleaned and null 218 193 // terminated. 219 double parseValue(char *inString, psS32 *status)194 static double parseValue(char *inString, psS32 *status) 220 195 { 221 196 char *end = NULL; … … 233 208 234 209 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are acceptable, parsable variations. */ 235 psBool parseBool(char *inString, psS32 *status)210 static psBool parseBool(char *inString, psS32 *status) 236 211 { 237 212 psBool value = false; … … 250 225 251 226 /** Returns parsed vector filled with with data. The input string must be null terminated. */ 252 psVector* parseVector(char *inString, psElemType elemType, psS32 *status)227 static psVector* parseVector(char *inString, psElemType elemType, psS32 *status) 253 228 { 254 229 char* end = NULL; … … 1138 1113 } 1139 1114 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 pointers1156 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 problems1164 psTagName = psStringCopy((const char*)tagName);1165 1166 // Metadata containter for housing element attributes used by other SAX events1167 htAtts = psHashAlloc(10);1168 1169 1170 // Get tag name1171 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 values1181 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 problems1188 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 metadata1205 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 pointers1237 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 name1254 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 one1261 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 one1281 strValue = psHashLookup(htAtts, "value");1282 1283 /* If metadata item is found, and is not a folder node, and overwrite is allowed, then remove1284 existing and allow switch/case below to add new item. If overwrite is false, then report error. If1285 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 metadata1309 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 switch1360 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 pointers1386 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 name1403 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 one1410 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 remove1432 existing and allow switch/case below to add new item. If overwrite is false, then report error. If1433 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 value1457 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 pointers1482 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 problems1496 psEndTagName = psStringCopy((const char*)tagName);1497 1498 // Compare start and end tag names1499 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 structs1506 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 table1515 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 checks1528 PS_ASSERT_PTR_NON_NULL(fileName, NULL);1529 1530 // Allocate metadata if necessary1531 if (md == NULL) {1532 md = psMetadataAlloc();1533 }1534 1535 // Sax handler initializations1536 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 file1570 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 libxml21576 xmlCleanupParser();1577 xmlMemoryDump();1578 1579 return md;1580 } -
trunk/psLib/src/types/psMetadataConfig.h
r4409 r4540 1 /** @file psMetadata IO.h1 /** @file psMetadataConfig.h 2 2 * 3 3 * @brief Contains metadata input/output functions. … … 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-28 20:17:52$12 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:01 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 16 16 */ 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" 19 21 20 22 /// @addtogroup Metadata … … 22 24 23 25 /** A metadata data structure used in parsing arrays. 24 * 26 * 25 27 * Contains array information and the metadata storage location. 26 28 */ … … 36 38 37 39 /** Allocates a p_psParseLevelInfo structure 38 * 40 * 39 41 * @return p_psParseLevelInfo* : new p_psParseLevelInfo struct 40 42 */ … … 86 88 ); 87 89 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 102 90 /// @} 103 91 -
trunk/psLib/src/types/psPixels.c
r4401 r4540 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-0 6-27 20:38:12$9 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-07-12 19:12:01 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 20 20 21 21 #include "psError.h" 22 #include "ps CollectionsErrors.h"22 #include "psErrorText.h" 23 23 24 24 typedef int(*qsortCompareFcn)(const void *, const void *); -
trunk/psLib/src/xml/Makefile.am
r4446 r4540 1 #Makefile for dataIOfunctions of psLib1 #Makefile for xml functions of psLib 2 2 # 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) 3 noinst_LTLIBRARIES = libpslibxml.la 15 4 16 noinst_LTLIBRARIES = libpslibdataIO.la 5 libpslibxml_la_SOURCES = \ 6 psXML.c 17 7 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=$? $@ 8 EXTRA_DIST = xml.i 29 9 30 10 pslibincludedir = $(includedir) 31 11 pslibinclude_HEADERS = \ 32 psLookupTable.h \ 33 psFits.h \ 34 psDB.h 35 12 psXML.h -
trunk/psLib/src/xml/psXML.c
r4432 r4540 1 /** @file ps MetadataIO.c1 /** @file psXML.c 2 2 * 3 * @brief Contains metadatainput/output functions.3 * @brief Contains XML input/output functions. 4 4 * 5 * This file defines functions to read and write metadata to/from an externalfile.5 * This file defines functions to read metadata from an XML file. 6 6 * 7 * @ingroup Metadata7 * @ingroup XML 8 8 * 9 9 * @author Ross Harman, MHPCC 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-30 00:04:12$12 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:01 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 17 17 18 18 #include <libxml/parser.h> 19 #include <fitsio.h>20 19 #include <string.h> 21 20 #include <ctype.h> 22 21 #include <limits.h> 23 22 24 #include "psAbort.h" 25 #include "psType.h" 23 #include "psXML.h" 26 24 #include "psMemory.h" 27 25 #include "psError.h" 28 26 #include "psString.h" 29 #include "psList.h"30 #include "psHash.h"31 #include "psVector.h"32 #include "psMetadata.h"33 #include "psMetadataIO.h"34 27 #include "psConstants.h" 35 #include "ps AstronomyErrors.h"28 #include "psErrorText.h" 36 29 37 30 /******************************************************************************/ … … 39 32 /******************************************************************************/ 40 33 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 55 34 /** Maximum size of a FITS line */ 56 35 #define FITS_LINE_SIZE 80 … … 59 38 #define MAX_STRING_LENGTH 256 60 39 61 62 /******************************************************************************/63 /* TYPE DEFINITIONS */64 /******************************************************************************/65 66 // None67 68 /*****************************************************************************/69 /* GLOBAL VARIABLES */70 /*****************************************************************************/71 72 // None73 74 /*****************************************************************************/75 /* FILE STATIC VARIABLES */76 /*****************************************************************************/77 78 // None79 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 string107 // 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 null122 // 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 pointer130 ptrB = inString;131 132 // Skip over leading # or whitespace133 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 # characters144 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 sLen159 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 location184 // 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 space192 while((convertChar=strchr(*inString,'\t')) != NULL ) {193 *convertChar = ' ';194 }195 196 // Skip over leading whitespace197 while(isspace(**inString)) {198 (*inString)++;199 }200 201 // Length of token, not including delimiter202 sLen = strcspn(*inString, delimiter);203 if(sLen) {204 205 // Create new, cleaned, and null terminated token206 cleanToken = cleanString(*inString, sLen,ignoreComment);207 208 // Move to end of token209 (*inString) += sLen;210 } else if(**inString!='\0' && sLen==0) {211 *status = 1;212 }213 214 return cleanToken;215 }216 217 40 // Returns single parsed value as a double precision number. The input string must be cleaned and null 218 41 // terminated. 219 double parseValue(char *inString, psS32 *status)42 static double parseValue(char *inString, psS32 *status) 220 43 { 221 44 char *end = NULL; … … 233 56 234 57 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are acceptable, parsable variations. */ 235 psBool parseBool(char *inString, psS32 *status)58 static psBool parseBool(char *inString, psS32 *status) 236 59 { 237 60 psBool value = false; … … 250 73 251 74 /** Returns parsed vector filled with with data. The input string must be null terminated. */ 252 psVector* parseVector(char *inString, psElemType elemType, psS32 *status)75 static psVector* parseVector(char *inString, psElemType elemType, psS32 *status) 253 76 { 254 77 char* end = NULL; … … 332 155 333 156 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 info346 info = (p_psParseLevelInfo*)psAlloc(sizeof(p_psParseLevelInfo));347 348 // If allocation successful then initialize members349 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 deallocator364 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 type381 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 modifiers390 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't491 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 names507 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 found573 while((token = getToken(&linePtr," ",&status,false)) != NULL ) {574 575 // If not allocated then allocate new metadata576 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 read587 tempItem = psMetadataItemAllocStr(token,"","");588 if(tempItem == NULL) {589 psFree(metadataTemplate);590 psFree(token);591 metadataTemplate = NULL;592 break;593 }594 595 // Add item to template596 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 template621 items = template->list->size;622 if(items > 0 ) {623 624 // Allocate metadata625 md = psMetadataAlloc()626 ;627 628 // Point to first item in template629 iter = psListIteratorAlloc(template->630 list,PS_LIST_HEAD,true);631 632 // For each item in template parse line string for values633 for(psS32 i = 0;634 i < items;635 i++) {636 637 // Get template item638 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 line647 token = getToken(&linePtr," ",&status,false);648 if(token != NULL) {649 // Allocate metadata item650 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 metadata658 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 items668 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 type705 strType = getToken(&linePtr, " ", &status,true);706 707 // Check for no type708 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 token715 716 // Check if the keyName specifies a vector and if so use strType token to find vector type717 if(*keyName == '@') {718 mdType = PS_META_VEC;719 // Get the type of vector720 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 types762 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 item769 md = ((p_psParseLevelInfo*)(levelArray->data[*level]))->metadata;770 addStatus = psMetadataAdd(md,PS_LIST_TAIL,keyName,PS_META_META | flags,"",tempMeta);771 // Check for add failure772 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 error782 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 comment804 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 metadata835 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 keys897 // Check for duplicate MULTI lines898 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 info914 nextLevelInfo = p_psParseLevelInfoAlloc();915 // Create new metadata916 nextLevelInfo->metadata = psMetadataAlloc();917 // Save name of metadata918 nextLevelInfo->name = psStringCopy(keyName);919 // Add next level to levelArray920 levelArray = psArrayAdd(levelArray,1,nextLevelInfo);921 psFree(nextLevelInfo);922 // Increment level counter923 (*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 successful933 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 specified963 if(overwrite) {964 flags = PS_META_REPLACE;965 }966 967 // If line is not a comment or blank, then extract data968 if(!ignoreLine(linePtr)) {969 970 // Check for more than one '@' in a line971 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 name978 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 name989 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 succesfully998 if(tempTemplate != NULL) {999 // Access type array1000 typeArray = ((p_psParseLevelInfo*)(levelArray->data[*level]))->typeArray;1001 // Check if type already exists in array1002 for(psS32 k=0; k < typeArray->n; k++) {1003 // Compare type name with the list of current types1004 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 type1014 typeArray = psArrayAdd(typeArray,1,strType);1015 // Add template to array of templates1016 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 list1032 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 metadata1039 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 level1049 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 names1062 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 metadataItem1071 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 name1092 PS_ASSERT_PTR_NON_NULL(fileName,NULL);1093 1094 // Check for NULL nFail1095 PS_ASSERT_PTR_NON_NULL(nFail,NULL);1096 1097 // Attempt to open specified file1098 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 necessary1104 if (md == NULL) {1105 md = psMetadataAlloc();1106 }1107 1108 // Allocate array to store parse level information1109 parseLevelInfoArray = psArrayAlloc(10);1110 parseLevelInfoArray->n = 0;1111 1112 // Set parse level info for the top level1113 topLevelInfo = p_psParseLevelInfoAlloc();1114 topLevelInfo->metadata = psMemIncrRefCounter(md);1115 parseLevelInfoArray = psArrayAdd(parseLevelInfoArray,1,topLevelInfo);1116 psFree(topLevelInfo);1117 1118 // Create reusable line for continuous read1119 line = (char*)psAlloc(MAX_STRING_LENGTH*sizeof(char));1120 1121 // While loop to parse the file1122 while(fgets(line, MAX_STRING_LENGTH, fp) != NULL) {1123 1124 // Initialize variables for new line1125 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 buffer1134 psFree(parseLevelInfoArray);1135 psFree(line);1136 1137 return md;1138 157 } 1139 158 -
trunk/psLib/src/xml/psXML.h
r4409 r4540 1 /** @file ps MetadataIO.h1 /** @file psXML.h 2 2 * 3 * @brief Contains metadata input/outputfunctions.3 * @brief Contains XML functions. 4 4 * 5 * This file defines functions to read and write metadata to/from an externalfile.5 * This file defines functions to read metadata from an XML file. 6 6 * 7 * @ingroup Metadata7 * @ingroup XML 8 8 * 9 9 * @author Ross Harman, MHPCC 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-28 20:17:52$12 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-07-12 19:12:01 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 16 16 */ 17 #ifndef PS_ METADATAIO_H18 #define PS_ METADATAIO_H17 #ifndef PS_XML_H 18 #define PS_XML_H 19 19 20 /// @addtogroup Metadata 20 #include "psMetadata.h" 21 #include "psMetadataConfig.h" 22 23 /// @addtogroup XML 21 24 /// @{ 22 23 /** A metadata data structure used in parsing arrays.24 *25 * Contains array information and the metadata storage location.26 */27 typedef struct28 {29 psArray* nonUniqueKeyArray; ///< non-unique key names30 psArray* typeArray; ///< array of user defined types31 psArray* templateArray; ///< array of user type templates32 psMetadata* metadata; ///< metadata container33 char* name; ///< name of key34 }35 p_psParseLevelInfo;36 37 /** Allocates a p_psParseLevelInfo structure38 *39 * @return p_psParseLevelInfo* : new p_psParseLevelInfo struct40 */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 a46 * provided format. The format is a sprintf format statement with exactly47 * one % formatting command. If the metadata item type is a numeric type,48 * this formatting command must also be numeric, and the type conversion49 * performed to the value to match the format type. If the metadata type is50 * a string, the fromatting command must also be for a string. If the51 * 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 is64 * 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 */94 25 95 26 psMetadata* psMetadataConfigParseXml( … … 102 33 /// @} 103 34 104 #endif // #ifndef PS_ METADATAIO_H35 #endif // #ifndef PS_XML_H
Note:
See TracChangeset
for help on using the changeset viewer.
