Changeset 753
- Timestamp:
- May 20, 2004, 6:12:37 PM (22 years ago)
- Location:
- trunk/archive/pslib
- Files:
-
- 26 edited
-
include/psAstrom.h (modified) (7 diffs)
-
include/psBitset.h (modified) (3 diffs)
-
include/psDateTime.h (modified) (5 diffs)
-
include/psDlist.h (modified) (1 diff)
-
include/psError.h (modified) (1 diff)
-
include/psFFT.h (modified) (3 diffs)
-
include/psFunctions.h (modified) (9 diffs)
-
include/psImage.h (modified) (3 diffs)
-
include/psLib.h (modified) (1 diff)
-
include/psLogMsg.h (modified) (1 diff)
-
include/psMath.h (modified) (4 diffs)
-
include/psMatrix.h (modified) (2 diffs)
-
include/psMemory.h (modified) (2 diffs)
-
include/psMetadata.h (modified) (5 diffs)
-
include/psMinimize.h (modified) (3 diffs)
-
include/psPosition.h (modified) (6 diffs)
-
include/psStats.h (modified) (4 diffs)
-
include/psVector.h (modified) (1 diff)
-
src/Metadata/metadata.c (modified) (9 diffs)
-
src/Utils/Makefile (modified) (1 diff)
-
src/Utils/dlist.c (modified) (2 diffs)
-
src/Utils/error.c (modified) (4 diffs)
-
src/Utils/logmsg.c (modified) (2 diffs)
-
src/Utils/memory.c (modified) (17 diffs)
-
src/Utils/misc.c (modified) (1 diff)
-
src/Utils/vector.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/pslib/include/psAstrom.h
r704 r753 79 79 80 80 psMetadata *md; ///< FPA-level metadata 81 psPlaneDistort ion*TPtoFP; ///< Transformation term from82 psPlaneDistort ion*FPtoTP; ///< Transformation term from81 psPlaneDistort *TPtoFP; ///< Transformation term from 82 psPlaneDistort *FPtoTP; ///< Transformation term from 83 83 psFixedPattern *pattern; ///< Fixed pattern residual offsets 84 84 const psExposure *exp; ///< information about this exposure … … 96 96 97 97 psMetadata *md; ///< Chip-level metadata 98 psPlane CoordXform *chipToFPA; ///< Transformations from chip coordinates to FPA coordinates99 psPlane CoordXform *FPAtoChip; ///< Transformations from FPA coordinates to chip98 psPlaneTransform *chipToFPA; ///< Transformations from chip coordinates to FPA coordinates 99 psPlaneTransform *FPAtoChip; ///< Transformations from FPA coordinates to chip 100 100 101 101 struct psFPA *parentFPA; ///< FPA which contains this chip … … 110 110 psMetadata *md; ///< Cell-level metadata 111 111 112 psPlane CoordXform *cellToChip; ///< Transformations from cell coordinates to chip coordinates113 psPlane CoordXform *cellToFPA; ///< Transformations from cell coordinates to FPA coordinates114 psPlane CoordXform *cellToSky; ///< Quick and Dirty transformations from cell coordinates to sky112 psPlaneTransform *cellToChip; ///< Transformations from cell coordinates to chip coordinates 113 psPlaneTransform *cellToFPA; ///< Transformations from cell coordinates to FPA coordinates 114 psPlaneTransform *cellToSky; ///< Quick and Dirty transformations from cell coordinates to sky 115 115 116 116 struct psChip *parentChip; ///< chip which contains this cell … … 134 134 /*** Calculating and applying astrometric solutions ***/ 135 135 136 /** Return the cell in FPA which contains the given FPA coordinates */ 137 psCell * 138 psCellInFPA(psCell *out, ///< Cell to return, or NULL 139 const psPlane *coord, ///< Coordinate in FPA 140 const psFPA *fpa) ///< FPA description 141 ; 142 143 136 144 /** returns Chip in FPA which contains the given FPA coordinate */ 137 145 psChip * 138 146 psChipInFPA (psChip *out, ///< Chip to return, or NULL 139 const psPlane Coord*coord, ///< coordinate in FPA140 const psFPA *fpa ///< FPA description141 );147 const psPlane *coord, ///< coordinate in FPA 148 const psFPA *fpa) ///< FPA description 149 ; 142 150 143 151 /** returns Cell in Chip which contains the given chip coordinate */ 144 152 psCell * 145 153 psCellInChip(psCell *out, ///< Cell to return, or NULL 146 const psPlaneCoord *coord, ///< coordinate in chip 147 const psChip *chip ///< chip description 148 ); 149 150 /** Return the cell in FPA which contains the given FPA coordinates */ 151 psCell * 152 psCellInFPA(psCell *out, ///< Cell to return, or NULL 153 const psPlaneCoord *coord, ///< Coordinate in FPA 154 const psFPA *fpa ///< FPA description 155 ); 156 154 const psPlane *coord, ///< coordinate in chip 155 const psChip *chip) ///< chip description 156 ; 157 158 /************ conversions low -> high ****************/ 159 /** converts the specified Cell coord to the coord on the parent Chip */ 160 psPlane * 161 psCoordCelltoChip (psPlane *out, ///< Coordinates to return, or NULL 162 const psPlane *in, ///< input Cell coordinate 163 const psCell *cell) ///< Cell description 164 ; 165 166 /** converts the specified Chip coord to the coord on the parent FPA */ 167 psPlane * 168 psCoordChiptoFPA (psPlane *out, ///< Coordinates to return, or NULL 169 const psPlane *in, ///< input Chip coordinate 170 const psChip *chip) ///< Chip description 171 ; 172 173 /** Convert focal plane coords to tangent plane coordinates */ 174 psPlane * 175 psCoordFPAToTP(psPlane *out, ///< Coordinates to return, or NULL 176 const psPlane *in, ///< input FPA coordinate 177 const psFPA *fpa) ///< FPA description 178 ; 179 180 /** Convert tangent plane coords to (RA,Dec) */ 181 psSphere * 182 psCoordTPtoSky(psSphere *out, ///< Coordinates to return, or NULL 183 const psPlane *in, ///< input TP coordinate 184 const psGrommit *grommit) ///< Grommit for fast conversion 185 ; 186 187 /** Convert Cell coords to FPA coordinates */ 188 psPlane * 189 psCoordCellToFPA(psPlane *out, ///< Coordinates to return, or NULL 190 const psPlane *in, ///< Input cell coordinates 191 const psCell *cell) ///< Cell description 192 ; 193 194 /** Convert cell and cell coordinate to (RA,Dec) */ 195 psSphere * 196 psCoordCellToSky(psSphere *out, ///< Coordinates to return, or NULL 197 const psPlane *in, ///< cell coordinates to transform 198 const psCell *cell) ///< Cell to get coordinates for 199 ; 200 201 /** Convert cell and cell coordinate to (RA,Dec) */ 202 psSphere * 203 psCoordCellToSkyQD(psSphere *out, ///< Coordinates to return, or NULL 204 const psPlane *in, ///< cell coordinates to transform 205 const psCell *cell) ///< Cell to get coordinates for 206 ; 207 208 209 /************ conversions low -> high ****************/ 210 /** Convert (RA,Dec) to tangent plane coords */ 211 psPlane * 212 psCoordSkyToTP(psPlane *out, ///< Coordinates to return, or NULL 213 const psSphere *in, ///< input Sky coordinate 214 const psGrommit *grommit) ///< Grommit for fast conversion 215 ; 216 217 /** Convert tangent plane coords to focal plane coordinates */ 218 psPlane * 219 psCoordTPtoFPA(psPlane *out, ///< Coordinates to return, or NULL 220 const psPlane *in, ///< input TP coordinate 221 const psFPA *fpa) ///< FPA description 222 ; 223 224 /** converts the specified FPA coord to the coord on the given Chip */ 225 psPlane * 226 psCoordFPAtoChip (psPlane *out, ///< Coordinates to return, or NULL 227 const psPlane *in, ///< input FPA coordinate 228 const psChip *chip) ///< Chip of interest 229 ; 230 231 /** converts the specified Chip coord to the coord on the given Cell */ 232 psPlane * 233 psCoordChiptoCell (psPlane *out, ///< Coordinates to return, or NULL 234 const psPlane *in, ///< input Chip coordinate 235 const psCell *cell) ///< Cell of interest 236 ; 157 237 158 238 /** Convert (RA,Dec) to cell and cell coordinates */ 159 psPlaneCoord * 160 psCoordSkyToCell(psPlaneCoord *out, ///< Coordinates to return, or NULL 161 psCell *cell, ///< Cell to return 162 const psSphereCoord *in, ///< Input coordinates 163 const psFPA *fpa ///< FPA description 164 ); 165 166 /** Convert cell and cell coordinate to (RA,Dec) */ 167 psSphereCoord * 168 psCoordCellToSky(psSphereCoord *out, ///< Coordinates to return, or NULL 169 const psPlaneCoord *coord, ///< cell coordinates to transform 170 const psCell *cell ///< Cell to get coordinates for 171 ); 239 psPlane * 240 psCoordSkyToCell(psPlane *out, ///< Coordinates to return 241 const psSphere *in, ///< Input coordinates 242 const psCell *cell) ///< Cell of interest 243 ; 172 244 173 245 /** Quick and dirty cell to (RA,Dec) --- employs cellToSky transformation */ 174 psSphereCoord * 175 psCoordCellToSkyQuick(psSphereCoord *out, ///< Coordinates to return, or NULL 176 const psPlaneCoord *coord, ///< cell coordinates to transform 177 const psCell *cell ///< Cell description 178 ); 179 180 /** Convert (RA,Dec) to tangent plane coords */ 181 psPlaneCoord * 182 psCoordSkyToTP(psPlaneCoord *out, ///< Coordinates to return, or NULL 183 const psSphereCoord *coord, ///< input Sky coordinate 184 const psGrommit *grommit ///< Grommit for fast conversion 185 ); 186 187 /** Convert tangent plane coords to focal plane coordinates */ 188 psPlaneCoord * 189 psCoordTPtoFPA(psPlaneCoord *out, ///< Coordinates to return, or NULL 190 const psPlaneCoord *coord, ///< input TP coordinate 191 const psFPA *fpa ///< FPA description 192 ); 193 194 /** converts the specified FPA coord to the coord on the given Chip */ 195 psPlaneCoord * 196 psCoordFPAtoChip (psPlaneCoord *out, ///< Coordinates to return, or NULL 197 const psPlaneCoord *coord, ///< input FPA coordinate 198 const psChip *chip ///< Chip of interest 199 ); 200 201 /** converts the specified Chip coord to the coord on the given Cell */ 202 psPlaneCoord * 203 psCoordChiptoCell (psPlaneCoord *out, ///< Coordinates to return, or NULL 204 const psPlaneCoord *coord, ///< input Chip coordinate 205 const psCell *cell ///< Cell of interest 206 ); 207 208 /** converts the specified Cell coord to the coord on the parent Chip */ 209 psPlaneCoord * 210 psCoordCelltoChip (psPlaneCoord *out, ///< Coordinates to return, or NULL 211 const psPlaneCoord *coord, ///< input Cell coordinate 212 const psCell *cell ///< Cell description 213 ); 214 215 /** converts the specified Chip coord to the coord on the parent FPA */ 216 psPlaneCoord * 217 psCoordChiptoFPA (psPlaneCoord *out, ///< Coordinates to return, or NULL 218 const psPlaneCoord *coord, ///< input Chip coordinate 219 const psChip *chip ///< Chip description 220 ); 221 222 /** Convert focal plane coords to tangent plane coordinates */ 223 psPlaneCoord * 224 psCoordFPAToTP(psPlaneCoord *out, ///< Coordinates to return, or NULL 225 const psPlaneCoord *coord, ///< input FPA coordinate 226 const psFPA *fpa ///< FPA description 227 ); 228 229 /** Convert tangent plane coords to (RA,Dec) */ 230 psSphereCoord * 231 psCoordTPtoSky(psSphereCoord *out, ///< Coordinates to return, or NULL 232 const psPlaneCoord *coord, ///< input TP coordinate 233 const psGrommit *grommit ///< Grommit for fast conversion 234 ); 235 236 /** Convert Cell coords to FPA coordinates */ 237 psPlaneCoord * 238 psCoordCellToFPA(psPlaneCoord *out, ///< Coordinates to return, or NULL 239 const psPlaneCoord *coord, ///< Input cell coordinates 240 const psCell *cell ///< Cell description 241 ); 246 psSphere * 247 psCoordSkyToCellQD(psPlane *out, ///< Coordinates to return 248 const psSphere *in, ///< Input coordinates 249 const psCell *cell) ///< Cell of interest 250 ; 251 252 /**** other utilities ****/ 242 253 243 254 /** Get the airmass for a given position and sidereal time */ 244 255 float 245 psGetAirmass(const psSphere Coord *coord,///< Position on the sky256 psGetAirmass(const psSphere *coord, ///< Position on the sky 246 257 double siderealTime, ///< Sidereal time 247 float height ///< Height above sea level248 );258 float height) ///< Height above sea level 259 ; 249 260 250 261 /** Get the parallactic angle for a given position and sidereal time */ 251 262 float 252 psGetParallactic(const psSphere Coord*coord, ///< Position on the sky253 double siderealTime ///< Sidereal time254 );263 psGetParallactic(const psSphere *coord, ///< Position on the sky 264 double siderealTime) ///< Sidereal time 265 ; 255 266 256 267 /** Estimate atmospheric refraction, along the parallactic */ … … 259 270 psPhotSystem colorPlus, ///< Colour reference 260 271 psPhotSystem colorMinus, ///< Colour reference 261 const psExposure *exp ///< Telescope pointing information, for airmass, temp and pressure262 );272 const psExposure *exp) ///< Telescope pointing information, for airmass, temp and pressure 273 ; 263 274 264 275 /** Calculate the parallax factor */ 265 psSphere Coord*266 psGetParallaxFactor(const psExposure *exp ///< Exposure details267 );276 psSphere * 277 psGetParallaxFactor(const psExposure *exp) ///< Exposure details 278 ; 268 279 269 280 /*** Constructors / Destructors ******************************************************/ … … 281 292 float pressure, ///< Pressure 282 293 float humidity, ///< Relative humidity 283 float exptime ///< Exposure time284 );294 float exptime) ///< Exposure time 295 ; 285 296 286 297 /** Destructor */ 287 298 void 288 psExposureFree(psExposure *restrict myExp ///< Object to destroy289 );299 psExposureFree(psExposure *restrict myExp) ///< Object to destroy 300 ; 290 301 291 302 /** Constructor */ 292 303 psGrommit * 293 psGrommitAlloc(const psExposure *exp ///< Relevant exposure294 );304 psGrommitAlloc(const psExposure *exp) ///< Relevant exposure 305 ; 295 306 296 307 /** Destructor */ 297 308 void 298 psGrommitFree(psGrommit *grommit ///< Grommit to destroy299 );309 psGrommitFree(psGrommit *grommit) ///< Grommit to destroy 310 ; 300 311 301 312 /* \} */ // End of AstroGroup Functions … … 304 315 305 316 /* 306 example images:307 308 GPC: 1 Chip per file, 1 Cell per extension309 Megacam: 1 FPA per file, 1 Chip per extension, 2 Cell per extension (DSEC)310 CFH12K (MEF): 1 FPA per file, 1 Chip per extension, 1 Cell per extension311 CFHT-IR: 1 FPA per file, 1 Chip per extension, 4 Cell per extension (NAXIS = 3)312 WIRCAM: 1 FPA per file, 1 Chip per extension, 1 Cell per extension (?)317 example images: 318 319 GPC: 1 Chip per file, 1 Cell per extension 320 Megacam: 1 FPA per file, 1 Chip per extension, 2 Cell per extension (DSEC) 321 CFH12K (MEF): 1 FPA per file, 1 Chip per extension, 1 Cell per extension 322 CFHT-IR: 1 FPA per file, 1 Chip per extension, 4 Cell per extension (NAXIS = 3) 323 WIRCAM: 1 FPA per file, 1 Chip per extension, 1 Cell per extension (?) 313 324 314 325 -
trunk/archive/pslib/include/psBitset.h
r604 r753 19 19 20 20 /** Constructor */ 21 psBitset *psBitsetAlloc(int n ///< Number of bits required22 );21 psBitset *psBitsetAlloc(int n) ///< Number of bits required 22 ; 23 23 24 24 /** Destructor */ 25 void psBitsetFree(psBitset *restrict myBits ///< bitset to destroy26 );25 void psBitsetFree(psBitset *restrict myBits) ///< bitset to destroy 26 ; 27 27 28 28 /************************************************************************************************************/ … … 31 31 psBitset * 32 32 psBitsetSet(psBitset *restrict myBits, ///< Input bitset 33 int bit ///< Bit to set34 );33 int bit) ///< Bit to set 34 ; 35 35 36 36 /** Check a bitset. Returns true or false */ 37 37 int 38 38 psBitsetTest(const psBitset *restrict checkBits, ///< bitset to check 39 int bit ///< Bit to check40 );39 int bit) ///< Bit to check 40 ; 41 41 42 42 /** apply the given operator to two bitsets */ … … 45 45 const psBitset *restrict inBits1, ///< Input bitset 1 46 46 char *operator, ///< bitset operator (AND, OR, XOR) 47 const psBitset *restrict inBits2 ///< Input bitset 248 );47 const psBitset *restrict inBits2) ///< Input bitset 2 48 ; 49 49 50 50 /** Apply unary NOT to a bitset */ 51 51 psBitset * 52 52 psBitsetNot(psBitset *out, ///< Output bitset, or NULL 53 psBitset *in ///< Input bitset to be NOT-ed54 );53 psBitset *in) ///< Input bitset to be NOT-ed 54 ; 55 55 56 56 /* \} */ // End of MathGroup Functions -
trunk/archive/pslib/include/psDateTime.h
r396 r753 1 1 #if !defined(PS_DATE_TIME_H) 2 2 #define PS_DATE_TIME_H 3 4 #include "taia.h" 3 5 4 6 /** \file psDateTime.h … … 19 21 definition. */ 20 22 typedef struct { 21 long numSeconds; ///< Number of seconds from some defined epoch 22 double fracSeconds; ///< Fraction of seconds 23 struct taia t; 23 24 } psTime; 24 25 … … 52 53 /** Convert psTime to JD */ 53 54 double 54 psTimeToJD (psTime time) ///< Input psTime time55 psTimeToJD (psTime time) ///< Input psTime time 55 56 ; 56 57 … … 61 62 62 63 /** Convert psTime to broken-down time (struct tm) */ 63 struct tm * 64 psTimeToTm (psTime time) ///< Input psTime time 64 struct tm * 65 psTimeToTm (psTime time) ///< Input psTime time 66 ; 67 68 /** Convert psTime to lunation number */ 69 float 70 psTimeToLunation (psTime time) ///< Input psTime time 65 71 ; 66 72 … … 86 92 ; 87 93 88 /** Convert timeval to psTime (struct timeval)*/94 /** Convert timeval (struct timeval) to psTime */ 89 95 psTime * 90 96 psTimevalToTime (struct timeval *input) ///< Input timeval time 91 97 ; 92 98 93 /** Convert broken- to psTime down time (struct tm)*/99 /** Convert broken-down time (struct tm) to psTime */ 94 100 psTime * 95 psTMtoTime (struct tm *input) ///< Input tm time 101 psTMToTime (struct tm *input) ///< Input tm time 102 ; 103 104 /** Convert lunation number to psTime */ 105 psTime * 106 psLunationToTime (float lunation) ///< Input lunation 96 107 ; 97 108 -
trunk/archive/pslib/include/psDlist.h
r706 r753 86 86 87 87 /** Convert doubly-linked list to a vector of (void *) */ 88 psVector *psDlistTo Array(psDlist *dlist) ///< List to convert88 psVector *psDlistToVector(psDlist *dlist) ///< List to convert 89 89 ; 90 90 91 91 /** Convert array to a doubly-linked list */ 92 psDlist *psArrayToDlist(psVector * arr) ///< vecotor of (void *) to convert92 psDlist *psArrayToDlist(psVector *vector) ///< vector of (void *) to convert 93 93 ; 94 94 -
trunk/archive/pslib/include/psError.h
r611 r753 12 12 13 13 typedef struct { 14 psErrorCode code; // An error code15 const char *descrip; // the associated description14 psErrorCode code; ///< An error code 15 const char *descrip; ///< the associated description 16 16 } psErrorDescription; 17 17 18 18 typedef struct { 19 char *name; // category of code that caused the error20 psErrorCode code; // class of error (equivalent to errno)21 char *msg; // the message associated with the error19 char *name; ///< category of code that caused the error 20 psErrorCode code; ///< class of error (equivalent to errno) 21 char *msg; ///< the message associated with the error 22 22 } psErr; 23 24 typedef enum {25 PS_OLD_ERROR = 0, ///< This is an old error, and should append to the error stack26 PS_NEW_ERROR = 1, ///< This is a new error and should clear the error stack27 } psErrorStatus;28 23 29 24 /// Prints an error message and doesn't abort; returns code 30 25 int psError(const char *name, ///< Category of code that caused the error 31 26 psErrorCode code, ///< class of error (equivalent to errno) 32 psErrorStatus status,///< is this a new error?27 int new, ///< is this a new error? 33 28 const char *fmt, ///< Format 34 ... ///< Extra arguments to use format35 );29 ...) ///< Extra arguments to use format 30 ; 36 31 37 32 void p_psErrorRegister(const psErrorDescription *errors, ///< register a set of errors 38 int nerror); ///< number of errors 33 int nerror) ///< number of errors 34 ; 39 35 40 const psErr *psErrorGet(int which); //return specified error (or an "error" with code PS_ERR_NONE)41 const psErr *psError Last(void); // return last error (or an "error" with code PS_ERR_NONE)36 ///< return specified error (or an "error" with code PS_ERR_NONE) 37 const psErr *psErrorGet(int which); 42 38 43 void psErrorClear(void); ///< Clear the error stack 39 ///< return last error (or an "error" with code PS_ERR_NONE) 40 const psErr *psErrorLast(void); 44 41 45 const char *psErrorCodeString(psErrorCode code); ///< return the string associated with the error code 46 void psErrorStackPrint(FILE *fd, const char *fmt, ...); ///< print the errorstack to this file descriptor 47 void psErrorVStackPrint(FILE *fd, //< write to this file descriptor 48 const char *fmt,//< format for any header information; may be NULL 49 va_list ap); //< arguments for format 42 ///< Clear the error stack 43 void psErrorClear(void); 44 45 ///< return the string associated with the error code 46 const char *psErrorCodeString(psErrorCode code); 47 48 ///< print the errorstack to this file descriptor 49 void psErrorStackPrint(FILE *fd, ///< write to this file descriptor 50 const char *fmt, ///< format for any header information; may be NULL 51 ...) ///< arguments for format 52 ; 53 54 ///< print the errorstack to this file descriptor (stdargs version) 55 void psErrorStackPrintV(FILE *fd, ///< write to this file descriptor 56 const char *fmt,///< format for any header information; may be NULL 57 va_list ap) ///< arguments for format 58 ; 59 50 60 51 61 #endif -
trunk/archive/pslib/include/psFFT.h
r704 r753 2 2 #define PS_FFT_H 3 3 4 #include <fftw3.h> 4 /* #include <fftw3.h> */ 5 5 6 6 /** \file psFFT.h … … 13 13 * \{ 14 14 */ 15 16 /**** Vector FFT & Complex functions ****/ 17 18 /** FFT a vector. in: psF32 or psC32, out: psC32 */ 19 psVector * 20 psVectorFFT(const psVector *vector, ///< Vector to transform 21 int dir) ///< FFT direction (1: forward, -1: reverse) 22 ; 23 24 /** Calculate power spectrum of a vector of floating-point numbers */ 25 psVector * 26 psVectorPowerSpectrum(const psVector *vector) ///< Vector to obtain power spectrum of 27 ; 28 29 /** Get the real part of a vector */ 30 psVector * 31 psVectorReal(psVector *out, ///< Vector for output (or NULL) 32 const psVector *in) ///< Vector to get the real part of 33 ; 34 35 /** Get the imaginary part of a vector */ 36 psVector * 37 psVectorImaginary(psVector *out, ///< Vector for output (or NULL) 38 const psVector *in) ///< Vector to get the imaginary part of 39 ; 40 41 /** Construct a complex vector from real & imaginary parts */ 42 psVector * 43 psVectorComplex(psVector *out, ///< Vector for output (or NULL) 44 const psVector *real, ///< real part of vector 45 const psVector *imag) ///< imaginary part of vector 46 ; 47 48 /** Get the complex conjugate of an vector of complex floating-point numbers */ 49 psVector * 50 psVectorConjugate(psVector *out, ///< Vector for output (or NULL) 51 const psVector *in) ///< Vector to get the complex conjugate of 52 ; 15 53 16 54 /**** Image FFT & Complex functions ****/ … … 52 90 ; 53 91 54 /**** Vector FFT & Complex functions ****/55 56 /** FFT a vector. in: psF32 or psC32, out: psC32 */57 psVector *58 psVectorFFT(const psVector *vector) ///< Vector to transform59 ;60 61 /** Calculate power spectrum of a vector of floating-point numbers */62 psVector *63 psVectorPowerSpectrum(const psVector *vector) ///< Vector to obtain power spectrum of64 ;65 66 /** Get the real part of a vector */67 psVector *68 psVectorReal(psVector *out, ///< Vector for output (or NULL)69 const psVector *in) ///< Vector to get the real part of70 ;71 72 /** Get the imaginary part of a vector */73 psVector *74 psVectorImaginary(psVector *out, ///< Vector for output (or NULL)75 const psVector *in) ///< Vector to get the imaginary part of76 ;77 78 /** Construct a complex vector from real & imaginary parts */79 psVector *80 psVectorComplex(psVector *out, ///< Vector for output (or NULL)81 const psVector *real, ///< real part of vector82 const psVector *imag) ///< imaginary part of vector83 ;84 85 /** Get the complex conjugate of an vector of complex floating-point numbers */86 psVector *87 psVectorConjugate(psVector *out, ///< Vector for output (or NULL)88 const psVector *in) ///< Vector to get the complex conjugate of89 ;90 92 91 93 /* \} */ // End of MathGroup Functions -
trunk/archive/pslib/include/psFunctions.h
r618 r753 14 14 psGaussian(float x, ///< Value at which to evaluate 15 15 float mean, ///< Mean for the Gaussian 16 float stddev ///< Standard deviation for the Gaussian 17 ); 16 float stddev, ///< Standard deviation for the Gaussian 17 int normal) ///< normalized Gaussian? 18 ; 19 20 psVector * 21 psGaussianDev(float mean, ///< Mean for the Gaussian 22 float stddev, ///< Standard deviation for the Gaussian 23 int Npts) ///< Number of points generated 24 ; 18 25 19 26 /************************************************************************************************************/ 20 27 21 /** One-dimensional polynomial */28 /** one-dimensional polynomial */ 22 29 typedef struct { 23 30 int n; ///< Number of terms … … 86 93 /** Evaluate 1D polynomial */ 87 94 float 88 ps EvalPolynomial1D(float x, ///< Value at which to evaluate95 psPolynomial1DEval(float x, ///< Value at which to evaluate 89 96 const psPolynomial1D *restrict myPoly ///< Coefficients for the polynomial 90 97 ); … … 92 99 /** Evaluate 2D polynomial */ 93 100 float 94 ps EvalPolynomial2D(float x, ///< Value x at which to evaluate101 psPolynomial2DEval(float x, ///< Value x at which to evaluate 95 102 float y, ///< Value y at which to evaluate 96 103 const psPolynomial2D *restrict myPoly ///< Coefficients for the polynomial … … 99 106 /** Evaluate 3D polynomial */ 100 107 float 101 ps EvalPolynomial3D(float x, ///< Value x at which to evaluate108 psPolynomial3DEval(float x, ///< Value x at which to evaluate 102 109 float y, ///< Value y at which to evaluate 103 110 float z, ///< Value z at which to evaluate … … 107 114 /** Evaluate 4D polynomial */ 108 115 float 109 ps EvalPolynomial4D(float w, ///< Value w at which to evaluate116 psPolynomial4DEval(float w, ///< Value w at which to evaluate 110 117 float x, ///< Value x at which to evaluate 111 118 float y, ///< Value y at which to evaluate … … 187 194 /** Evaluate 1D polynomial (double precision) */ 188 195 double 189 ps EvalDPolynomial1D(double x, ///< Value at which to evaluate196 psDPolynomial1DEval(double x, ///< Value at which to evaluate 190 197 const psDPolynomial1D *restrict myPoly ///< Coefficients for the polynomial 191 198 ); … … 193 200 /** Evaluate 2D polynomial (double precision) */ 194 201 double 195 ps EvalDPolynomial2D(double x, ///< Value x at which to evaluate202 psDPolynomial2DEval(double x, ///< Value x at which to evaluate 196 203 double y, ///< Value y at which to evaluate 197 204 const psDPolynomial2D *restrict myPoly ///< Coefficients for the polynomial … … 200 207 /** Evaluate 3D polynomial (double precision) */ 201 208 double 202 ps EvalDPolynomial3D(double x, ///< Value x at which to evaluate209 psDPolynomial3DEval(double x, ///< Value x at which to evaluate 203 210 double y, ///< Value y at which to evaluate 204 211 double z, ///< Value z at which to evaluate … … 208 215 /** Evaluate 4D polynomial (double precision) */ 209 216 double 210 ps EvalDPolynomial4D(double w, ///< Value w at which to evaluate217 psDPolynomial4DEval(double w, ///< Value w at which to evaluate 211 218 double x, ///< Value x at which to evaluate 212 219 double y, ///< Value y at which to evaluate -
trunk/archive/pslib/include/psImage.h
r680 r753 13 13 const int x0, y0; ///< data region relative to parent 14 14 union { 15 psF32 **rows; ///< Pointers to floating-point data (default) 16 psS8 **rows_S8; ///< Pointers to char data 17 psS16 **rows_S16; ///< Pointers to short-integer data 18 psS32 **rows_S32; ///< Pointers to integer data 19 psS64 **rows_S64; ///< Pointers to long-integer data 20 psU8 **rows_U8; ///< Pointers to unsigned-char data 21 psU16 **rows_U16; ///< Pointers to unsigned-short-integer data 22 psU32 **rows_U32; ///< Pointers to unsigned-integer data 23 psU64 **rows_U64; ///< Pointers to unsigned-long-integer data 24 psF32 **rows_F32; ///< Pointers to floating-point data 25 psF64 **rows_F64; ///< Pointers to double-precision data 26 psC32 **rows_C32; ///< Pointers to complex floating-point data 27 } rows; 15 psS8 **S8; ///< Pointers to char data 16 psS16 **S16; ///< Pointers to short-integer data 17 psS32 **S32; ///< Pointers to integer data 18 psS64 **S64; ///< Pointers to long-integer data 19 psU8 **U8; ///< Pointers to unsigned-char data 20 psU16 **U16; ///< Pointers to unsigned-short-integer data 21 psU32 **U32; ///< Pointers to unsigned-integer data 22 psU64 **U64; ///< Pointers to unsigned-long-integer data 23 psF32 **F32; ///< Pointers to floating-point data 24 psF64 **F64; ///< Pointers to double-precision data 25 psC32 **C32; ///< Pointers to complex floating-point data 26 } data; 28 27 const struct psImage *parent; ///< parent, if a subimage 29 28 int Nchildren; ///< number of subimages … … 215 214 ; 216 215 217 /// Read only header from image file.218 psMetadata *219 psImageReadHeader(psMetadata *output, ///< read data to this structure220 const char *extname, ///< MEF extension name ("PHU" for primary header)221 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)222 const char *filename) ///< file to read from223 ;224 225 /// Read only header from image file descriptor.226 psMetadata *227 psImageFReadHeader(psMetadata *output, ///< read data to this structure228 const char *extname, ///< MEF extension name ("PHU" for primary header)229 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)230 FILE *f) ///< file descriptor to read from231 ;232 233 216 /*** basic pixel manipulations ***/ 234 217 /// Clip image values outside of range to given values. Return number of clipped pixels. … … 260 243 # endif 261 244 /* image overlay operations 262 PS_OVERLAY_EQUALS = '=',263 PS_OVERLAY_ADD = '+',264 PS_OVERLAY_SUBTRACT = '-',265 PS_OVERLAY_MULTIPLY = '*',266 PS_OVERLAY_DIVIDE = '/',245 PS_OVERLAY_EQUALS = '=', 246 PS_OVERLAY_ADD = '+', 247 PS_OVERLAY_SUBTRACT = '-', 248 PS_OVERLAY_MULTIPLY = '*', 249 PS_OVERLAY_DIVIDE = '/', 267 250 */ -
trunk/archive/pslib/include/psLib.h
r704 r753 49 49 50 50 /** @ingroup AstroGroup */ 51 # include <psDateTime.h> 51 52 # include <psPosition.h> 52 # include <psDateTime.h>53 53 # include <psMetadata.h> 54 54 # include <psImage.h> -
trunk/archive/pslib/include/psLogMsg.h
r602 r753 30 30 31 31 /// Logs a message from varargs 32 void p _psLogVMsg(const char *name, ///< name of the log source33 int myLevel, ///< severity level of this log message34 const char *fmt, ///< printf-style format command35 va_list ap) ///< varargs argument list32 void psLogMsgV(const char *name, ///< name of the log source 33 int myLevel, ///< severity level of this log message 34 const char *fmt, ///< printf-style format command 35 va_list ap) ///< varargs argument list 36 36 ; 37 37 -
trunk/archive/pslib/include/psMath.h
r380 r753 11 11 psType type; ///< data type information 12 12 union { 13 int i;///< integer value entry14 float f; ///< float value entry15 double d; ///< double value entry16 complex float c;///< complex value entry17 } val;13 psS32 S32; ///< integer value entry 14 psF32 F32; ///< float value entry 15 psF64 F64; ///< double value entry 16 psC32 C32; ///< complex value entry 17 } data; 18 18 } p_psScalar; 19 19 … … 28 28 void *in1, ///< first input 29 29 char *op, ///< operator 30 void *in2 ///< second input31 );30 void *in2) ///< second input 31 ; 32 32 33 33 /** Perform a unary operation on two data items (psImage, psVector, psScalar). */ … … 35 35 psUnaryOp (void *out, ///< destination (may be NULL) 36 36 void *in, ///< input 37 char *op ///< operator38 );37 char *op) ///< operator 38 ; 39 39 40 40 /** create a psType-ed structure from a constant double value. */ … … 45 45 p_psScalar * 46 46 psScalarType (char *mode, ///< type description 47 ... ///< value (or values) of specified types48 );47 ...) ///< value (or values) of specified types 48 ; 49 49 50 50 /* \} */ // End of MathGroup Functions -
trunk/archive/pslib/include/psMatrix.h
r610 r753 19 19 psMatrixInvert(psImage *out, ///< Matrix to return, or NULL 20 20 const psImage *myMatrix, ///< Matrix to be inverted 21 float *restrict determinant ///< Determinant to return, or NULL22 );21 float *restrict determinant) ///< Determinant to return, or NULL 22 ; 23 23 24 24 /** Matrix determinant */ 25 25 float 26 psMatrixDeterminant(const psImage *restrict myMatrix ///< Matrix to get determinant for27 );26 psMatrixDeterminant(const psImage *restrict myMatrix) ///< Matrix to get determinant for 27 ; 28 28 29 29 /** Matrix operation: addition, subtraction, multiplication */ 30 30 psImage * 31 psMatrixOp(psImage *out, ///< Matrix to return, or NULL 32 const psImage *matrix1, ///< Matrix 1 33 const char *op, ///< Operation to perform: "+", "-", "*" 34 const psImage *matrix2 ///< Matrix 2 35 ); 31 psMatrixMultiply(psImage *out, ///< Matrix to return, or NULL 32 const psImage *in1, ///< Matrix 1 33 const psImage *in2) ///< Matrix 2 34 ; 36 35 37 36 /** Transpose Matrix */ 38 37 psImage * 39 38 psMatrixTranspose(psImage *out, ///< Matrix to return, or NULL 40 const psImage * myMatrix///< Matrix to transpose41 );39 const psImage *in) ///< Matrix to transpose 40 ; 42 41 43 42 /** LU Decomposition of a matrix */ 44 43 psImage * 45 44 psMatrixLUD(psImage *out, ///< Matrix to return, or NULL 46 psImage * myMatrix///< Matrix to decompose47 );45 psImage *in) ///< Matrix to decompose 46 ; 48 47 49 48 /** LU Solution. Solves for and returns x in the equation Ax = b */ 50 49 psVector * 51 50 psMatrixLUSolve(psVector *out, ///< Vector to return, or NULL 52 const psImage * luMatrix,///< LU-decomposed matrix53 const psVector * rhsVector///< right-hand-side of the equation54 ); 51 const psImage *LU, ///< LU-decomposed matrix 52 const psVector *RHS) ///< right-hand-side of the equation 53 ; 55 54 56 55 /** Eigenvectors of a matrix */ 57 56 psVector * 58 psMatrixEigenvectors(psImage *myMatrix ///< Matrix to get eigenvectors for59 );57 psMatrixEigenvectors(psImage *myMatrix) ///< Matrix to get eigenvectors for 58 ; 60 59 61 60 /***********************************************************************************************************/ … … 66 65 psVector * 67 66 psMatrixToVector(psVector *out, ///< Vector to return, or NULL 68 psImage * myMatrix///< Matrix to convert69 );67 psImage *in) ///< Matrix to convert 68 ; 70 69 71 70 /** Convert vector to matrix. */ 72 71 psImage * 73 72 psVectorToMatrix(psImage *out, ///< Matrix to return, or NULL 74 psVector * myVector///< Vector to convert75 );73 psVector *in) ///< Vector to convert 74 ; 76 75 77 76 /* \} */ // End of MathGroup Functions -
trunk/archive/pslib/include/psMemory.h
r396 r753 26 26 27 27 /// prototype of a basic callback used by memory functions 28 typedef long (*psMemAllocateC B)(const psMemBlock *ptr);28 typedef long (*psMemAllocateCallback)(const psMemBlock *ptr); 29 29 30 30 /// prototype of memory free callback used by memory functions 31 typedef long (*psMemFreeC B)(const psMemBlock *ptr);31 typedef long (*psMemFreeCallback)(const psMemBlock *ptr); 32 32 33 33 /// prototype of a callback used in error conditions 34 typedef void (*psMemProblemC B)(const psMemBlock *ptr, const char *file, int lineno);34 typedef void (*psMemProblemCallback)(const psMemBlock *ptr, const char *file, int lineno); 35 35 36 36 /// prototype of a callback used when memory runs out 37 typedef void *(*psMemExhaustedC B)(size_t size);37 typedef void *(*psMemExhaustedCallback)(size_t size); 38 38 39 39 /** Functions **************************************************************/ … … 84 84 85 85 /// Set callback for problems 86 psMemProblemC B psMemProblemCBSet(psMemProblemCBfunc) ///< Function to run86 psMemProblemCallback psMemProblemCallbackSet(psMemProblemCallback func) ///< Function to run 87 87 ; 88 88 89 89 /// Set callback for out-of-memory 90 psMemExhaustedC B psMemExhaustedCBSet(psMemExhaustedCBfunc) ///< Function to run90 psMemExhaustedCallback psMemExhaustedCallbackSet(psMemExhaustedCallback func) ///< Function to run 91 91 ; 92 92 93 93 /// Set call back for when a particular memory block is allocated 94 psMemAllocateC B psMemAllocateCBSet(psMemAllocateCBfunc) ///< Function to run94 psMemAllocateCallback psMemAllocateCallbackSet(psMemAllocateCallback func) ///< Function to run 95 95 ; 96 96 97 97 /// Set call back for when a particular memory block is freed 98 psMemFreeC B psMemFreeCBSet(psMemFreeCBfunc) ///< Function to run98 psMemFreeCallback psMemFreeCallbackSet(psMemFreeCallback func) ///< Function to run 99 99 ; 100 100 -
trunk/archive/pslib/include/psMetadata.h
r619 r753 10 10 typedef enum { ///< type of val is: 11 11 PS_META_ITEM_SET = 0, ///< NULL; metadata is in psMetadataType.items 12 PS_META_FLOAT, ///< float (.f) 13 PS_META_INT, ///< int (.i) 12 PS_META_S32, ///< int (.i) 13 PS_META_F32, ///< float (.f) 14 PS_META_F64, ///< float (.f) 14 15 PS_META_STR, ///< string (.v) 15 16 PS_META_IMG, ///< image (.v) … … 34 35 psMetadataType type; ///< type of this item 35 36 psMetadataFlags flags; ///< flags associated with this item 36 constunion {37 double d; ///< doublevalue38 float f; ///< floating value39 int i; ///< integervalue40 void * v; ///< other type41 } val; ///< value of metadata37 union { 38 psS32 S32; ///< integer value 39 psF32 F32; ///< floating value 40 psF64 F64; ///< double value 41 void *V; ///< other type 42 } data; ///< value of metadata 42 43 char *comment; ///< optional comment ("", not NULL) 43 44 psDlist *restrict items; ///< list of psMetadataItems with the same name … … 56 57 57 58 /** Constructor */ 58 psMetadataItem *psMetadataItemAlloc(int typeFlags, ///< type of this piece of metadata + flags 59 const void *val, ///< value of new item N.b. a pointer even if the item 60 ///< is of type e.g. int 59 psMetadataItem *psMetadataItemAlloc(const char *name, ///< name of new item of metadata (sprintf format) 60 int format, ///< type of this piece of metadata + flags 61 61 const char *comment, ///< comment associated with item 62 const char *name, ///< name of new item of metadata (may be in sprintf 63 ///< format) 64 ... ///< possible arguments for name format 65 ); 66 psMetadataItem *psVMetadataItemAlloc( 67 int typeFlags, // type of this piece of metadata + flags 68 const void *data, // value of new item 69 const char *comment, // comment associated with item; may be NULL 70 const char *name, // name of new item of metadata (may be an sprintf format) 71 va_list ap // possible arguments for name format 72 ); 62 ...) ///< arguments for name and data 63 ; 64 65 psMetadataItem *psMetadataItemAllocV(const char *name, ///< name of new item of metadata (sprintf format) 66 int format, ///< type of this piece of metadata + flags 67 const char *comment, ///< comment associated with item 68 va_list ap) ///< arguments for name and data 69 ; 73 70 74 71 /** Destructor */ 75 void psMetadataItemFree(psMetadataItem *ms ///< piece of metadata to destroy 76 ); 72 void psMetadataItemFree(psMetadataItem *ms) ///< piece of metadata to destroy 73 ; 74 77 75 /** Constructor */ 78 psMetadata *psMetadataAlloc(void); ///< make a new set of metadata 76 psMetadata *psMetadataAlloc(void) ///< make a new set of metadata 77 ; 79 78 80 79 /** Destructor */ 81 void psMetadataFree(psMetadata *md ///< destroy a set of metadata82 );80 void psMetadataFree(psMetadata *md) ///< destroy a set of metadata 81 ; 83 82 84 83 /**** Utilities **********************************************************************/ … … 86 85 /// Add item to the end of the metadata 87 86 psMetadataItem *psMetadataAppendItem(psMetadata *restrict md, ///< metadata to add to 88 psMetadataItem *restrict item ///< Metatdata item to add89 );87 psMetadataItem *restrict item) ///< Metatdata item to add 88 ; 90 89 91 90 /// Add item to the end of the metadata. Combines psMetadataItemAlloc and psMetadataAppendItem 92 91 psMetadataItem *psMetadataAppend(psMetadata *restrict md, ///< Metadata to add to 93 int typeFlags, ///< type of this piece of metadata + flags 94 const void *val, ///< value of new item N.b. a pointer even if the item 95 ///< is of type e.g. int 92 const char *name, ///< name of new item of metadata (sprintf format) 93 int format, ///< type of this piece of metadata + flags 96 94 const char *comment, ///< comment associated with item 97 const char *name, ///< name of new item of metadata (may be in sprintf 98 ///< format) 99 ... ///< possible arguments for name format 100 ); 95 ...) ///< possible arguments for name format 96 ; 101 97 102 98 /// delete item from the metadata … … 125 121 const char *prefix ///< print this at the beginning of each line 126 122 ); 123 124 /// Read only header from image file. 125 psMetadata * 126 psMetadataReadHeader(psMetadata *out, ///< read data to this structure 127 const char *ext, ///< MEF extension name ("PHU" for primary header) 128 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1) 129 const char *file) ///< file to read from 130 ; 131 132 /// Read only header from image file descriptor. 133 psMetadata * 134 psMetadataFReadHeader(psMetadata *out, ///< read data to this structure 135 const char *ext, ///< MEF extension name ("PHU" for primary header) 136 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1) 137 FILE *f) ///< file descriptor to read from 138 ; 139 127 140 /* \} */ // End of AstroGroup Functions 128 141 #endif -
trunk/archive/pslib/include/psMinimize.h
r671 r753 15 15 psVector * 16 16 psMinimize(psVector *restrict initialGuess, ///< Initial guess and answer 17 float (*myFunction)(const psVector *restrict ), ///< Function to minimize18 float (*myFuncDeriv)(const psVector *restrict ), ///< Derivatives of function, or NULL17 float (*myFunction)(const psVector *restrict, const psVector *restrict), ///< Function to minimize 18 float (*myFuncDeriv)(const psVector *restrict, const psVector *restrict), ///< Derivatives of function, or NULL 19 19 const psVector *restrict paramMask) ///< 1 = fit for parameter, 0 = hold parameter constant 20 20 ; … … 24 24 psVector * 25 25 psMinimizeChi2(psVector *restrict initialGuess, ///< Initial guess and answer 26 float (*evalModel)(const psVector *restrict, 27 const psVector *restrict), ///< Model to fit; (domain and params) 26 float (*evalModel)(const psVector *restrict, const psVector *restrict), ///< Model to fit; (domain and params) 28 27 const psVector *restrict domain, ///< The domain values for the corresponding measurements 29 28 const psVector *restrict data, ///< Data to fit 30 29 const psVector *restrict errors, ///< Errors in the data 31 const psVector *restrict paramMask) ///< 1 = fit for parameter, 0 = hold parameter constant 30 const psVector *restrict paramMask, ///< 1 = fit for parameter, 0 = hold parameter constant 31 float ChiSq) ///< calculated chisq of fit 32 32 ; 33 33 … … 35 35 psPolynomial1D * 36 36 psVectorFitPolynomial(psPolynomial1D myPoly, ///< Polynomial to fit 37 const psVector *restrict x, ///< Ordinates (or NULL to just use the indices)38 const psVector *restrict y, ///< Coordinates39 const psVector *restrict yErr) ///< Errors in coordinates, or NULL37 const psVector *restrict x, ///< Ordinates (or NULL to just use the indices) 38 const psVector *restrict y, ///< Coordinates 39 const psVector *restrict yErr) ///< Errors in coordinates, or NULL 40 40 ; 41 41 -
trunk/archive/pslib/include/psPosition.h
r710 r753 8 8 9 9 /** Structures *********************/ 10 11 /** projection types */ 12 typedef enum { ///< type of val is: 13 PS_PROJ_TAN, ///< Tangent projection 14 PS_PROJ_SIN, ///< Sine projection 15 PS_PROJ_AIT, ///< Aitoff projection 16 PS_PROJ_PAR, ///< Par projection 17 PS_PROJ_GLS, ///< GLS projection 18 PS_PROJ_NTYPE ///< Number of types; must be last 19 } psProjectionType; 10 20 11 21 /** A point in 2-D space, with errors. */ … … 15 25 double xErr; ///< Error in x position 16 26 double yErr; ///< Error in y position 17 } psPlane Coord;27 } psPlane; 18 28 19 29 /** A point on the surface of a sphere, with errors */ … … 23 33 double rErr; ///< Error in RA 24 34 double dErr; ///< Error in Dec 25 } psSphere Coord;35 } psSphere; 26 36 27 37 /** A polynomial transformation between coordinate frames. This may be a linear relationship, or may … … 31 41 psDPolynomial2D *x; 32 42 psDPolynomial2D *y; 33 } psPlane CoordXform;43 } psPlaneTransform; 34 44 35 45 /** The optical distortion terms. The lowest two terms are the x and y axis of the target system. The higher … … 39 49 psDPolynomial4D *x; 40 50 psDPolynomial4D *y; 41 } psPlaneDistortion; 51 } psPlaneDistort; 52 53 /** General spherical transformation */ 54 typedef struct { 55 double sinNPlon; ///< sin of North Pole longitude 56 double cosNPlon; ///< cos of North Pole longitude 57 double sinNPlat; ///< sin of North Pole lattitude 58 double cosNPlat; ///< cos of North Pole lattitude 59 double sinZP; ///< sin of First PT of Ares lon 60 double cosZP; ///< cos of First PT of Ares lon 61 } psSphereTransform; 62 63 /** Spherical <-> Linear projections */ 64 typedef struct { 65 double R, D; ///< coordinates of projection center 66 double Xs, Ys; ///< plate-scale in X and Y directions 67 psProjectionType type; ///< projection type 68 } psProjection; 42 69 43 70 /** Functions **************************************************************/ … … 47 74 48 75 /** apply the coordinate transformation to the given coordinate */ 49 psPlane Coord *psPlaneCoordXformApply (psPlaneCoord*out, ///< Output coordinates, or NULL50 const psPlaneCoordXform *frame, ///< coordinate transformation51 const psPlaneCoord *coords///< input coordiate52 );76 psPlane *psPlaneTransformApply (psPlane *out, ///< Output coordinates, or NULL 77 const psPlaneTransform *frame, ///< coordinate transformation 78 const psPlane *coords) ///< input coordiate 79 ; 53 80 54 81 /** apply the optical distortion to the given coordinate, magnitude, color */ 55 psPlaneCoord *psPlaneDistortionApply (psPlaneCoord *out, ///< Output coordinates, or NULL 56 const psPlaneDistortion *pattern, ///< optical distortion pattern 57 const psPlaneCoord *coords, ///< input coordinate 58 float mag, ///< magnitude of object 59 float color ///< color of object 60 ); 82 psPlane *psPlaneDistortApply (psPlane *out, ///< Output coordinates, or NULL 83 const psPlaneDistort *pattern, ///< optical distortion pattern 84 const psPlane *coords, ///< input coordinate 85 float mag, ///< magnitude of object 86 float color) ///< color of object 87 ; 88 89 /* Celestial coordinate conversions */ 90 91 /** Constructor */ 92 psSphereTransform * 93 psSphereTransformAlloc(double pole1, ///< First location of pole 94 double pole2, ///< Second location of pole 95 double rotation) ///< Rotation between systems 96 ; 97 98 /** Destructor */ 99 void psSphereTransformFree(psSphereTransform *trans) ///< Transform to destroy 100 ; 101 102 /** Apply general spherical transformation */ 103 psSphere * 104 psSphereTransformApply(const psSphere *coord, ///< Coordinates to convert 105 const psSphereTransform *sys) ///< System to use to convert 106 ; 107 108 /** Return transformation structure to convert ICRS to Ecliptic */ 109 psSphereTransform *psSphereTransformItoE(void); 110 111 /** Return transformation structure to convert Ecliptic to ICRS */ 112 psSphereTransform *psSphereTransformEtoI(void); 113 114 /** Return transformation structure to convert ICRS to Galactic */ 115 psSphereTransform *psSphereTransformItoG(void); 116 117 /** Return transformation structure to convert Galactic to ICRS */ 118 psSphereTransform *psSphereTransformGtoI(void); 119 120 /***********************************************************************************************************/ 121 122 123 /** Project spherical system onto a plane */ 124 psPlane * 125 psCoordProject(const psSphere *coord, ///< Spherical coordinates to project 126 const psProjection *projection) ///< Projection to use 127 ; 128 129 /** Deproject plane onto spherical system */ 130 psSphere * 131 psCoordDeproject(const psPlane *coord, ///< Plane coordinates to deproject 132 const psProjection *projection) ///< Projection to use 133 ; 61 134 62 135 /** Get offset (RA,Dec) on the sky between two positions position1 and position2 may not be identical */ 63 psSphereCoord * 64 psSphereCoordGetOffset(const psSphereCoord *restrict position1, ///< Position 1 65 const psSphereCoord *restrict position2, ///< Position 2 66 const char *type ///< Type of offset: Linear, Spherical/Arcsec, 67 ///< Spherical/Degreees etc 68 ); 136 psSphere * 137 psSphereGetOffset(const psSphere *restrict position1, ///< Position 1 138 const psSphere *restrict position2, ///< Position 2 139 const char *type) ///< Type of offset: Spherical/Arcsec, Spherical/Degreees etc 140 ; 69 141 70 142 /** Apply an offset to a position */ 71 psSphereCoord * 72 psSphereCoordApplyOffset(const psSphereCoord *restrict position, ///< Position 73 const psSphereCoord *restrict offset, ///< Offset 74 const char *type ///< Type of offset: Linear, Spherical/Arcsec, 75 ///< Spherical/Degreees etc 76 ); 143 psSphere * 144 psSphereApplyOffset(const psSphere *restrict position, ///< Position 145 const psSphere *restrict offset, ///< Offset 146 const char *type) ///< Type of offset: Spherical/Arcsec, Spherical/Degreees etc 147 ; 77 148 78 149 /* Positions of well-known objects */ 79 150 80 151 /** Get Sun Position */ 81 psSphereCoord * 82 psGetSunPos(float mjd ///< MJD to get position for 83 ); 84 85 /** Get Moon position */ 86 psSphereCoord * 87 psGetMoonPos(float mjd, ///< MJD to get position for 88 double latitude, ///< Latitude for apparent position 89 double longitude ///< Longitude for apparent position 90 ); 152 psSphere * 153 psSunGetPos(psTime time) ///< MJD to get position for 154 ; 155 156 /** Get Sun Rise time */ 157 psSphere * 158 psSunGetRise(psTime *twi15, ///< corresponding 15 deg twilight 159 psTime *twi18, ///< corresponding 18 deg twilight 160 psTime time) ///< get rise closest to this time 161 ; 162 163 /** Get Sun Set time */ 164 psSphere * 165 psSunGetSet(psTime *twi15, ///< corresponding 15 deg twilight 166 psTime *twi18, ///< corresponding 18 deg twilight 167 psTime time) ///< get set closest to this time 168 ; 169 170 /** Get Length of closest night */ 171 float 172 psNightLength(psTime time) ///< MJD to get position for 173 ; 174 175 /** Get Moon Position */ 176 psSphere * 177 psMoonGetPos(psTime time) ///< MJD to get position for 178 ; 179 180 /** Get Moon Rise time */ 181 psSphere * 182 psMoonGetRise(psTime time) ///< get rise closest to this time 183 ; 184 185 /** Get Moon Set time */ 186 psSphere * 187 psMoonGetSet(psTime time) ///< get set closest to this time 188 ; 91 189 92 190 /** Get Moon phase */ 93 191 float 94 ps GetMoonPhase(float mjd///< MJD to get phase for95 );192 psMoonGetPhase(psTime time) ///< MJD to get phase for 193 ; 96 194 97 195 /** Get Planet positions */ 98 psSphere Coord*99 ps GetSolarSystemPos(const char *solarSystemObject, ///< Named S.S. object100 float mjd///< MJD to get position for101 );196 psSphere * 197 psPlanetGetPos(const char *solarSystemObject, ///< Named S.S. object 198 psTime time) ///< MJD to get position for 199 ; 102 200 103 201 /***********************************************************************************************************/ 104 202 105 /* Celestial coordinate conversions */106 107 /** General spherical transformation */108 typedef struct {109 double sin1, sin2, sin3, cos1, cos2, cos3; ///< Sines and cosines for transformation110 } psSphereCoordTransformation;111 112 /** Constructor */113 psSphereCoordTransformation *114 psSphereCoordTransformationAlloc(double pole1, ///< First location of pole115 double pole2, ///< Second location of pole116 double rotation ///< Rotation between systems117 );118 119 /** Destructor */120 void psSphereCoordTranformationFree(psSphereCoordTransformation *trans ///< Transformation to destroy121 );122 123 /** Apply general spherical transformation */124 psSphereCoord *125 psSphereCoordTransform(const psSphereCoord *coord, ///< Coordinates to convert126 const psSphereCoordTransformation *sys ///< System to use to convert127 );128 129 /** Return transformation structure to convert ICRS to Ecliptic */130 psSphereCoordTransformation *psSphereCoordTransformationItoE(void);131 132 /** Return transformation structure to convert Ecliptic to ICRS */133 psSphereCoordTransformation *psSphereCoordTransformationEtoI(void);134 135 /** Return transformation structure to convert ICRS to Galactic */136 psSphereCoordTransformation *psSphereCoordTransformationItoG(void);137 138 /** Return transformation structure to convert Galactic to ICRS */139 psSphereCoordTransformation *psSphereCoordTransformationGtoI(void);140 141 /***********************************************************************************************************/142 143 144 /** Project spherical system onto a plane */145 psPlaneCoord *146 psCoordProject(const psSphereCoord *coord, ///< Spherical coordinates to project147 const char *projection ///< Projection to use148 );149 150 /** Deproject plane onto spherical system */151 psSphereCoord *152 psCoordDeproject(const psPlaneCoord *coord, ///< Plane coordinates to deproject153 const char *projection ///< Projection to use154 );155 156 203 /* \} */ // End of AstroGroup Functions 157 204 -
trunk/archive/pslib/include/psStats.h
r671 r753 12 12 PS_STAT_SAMPLE_MEDIAN = 0x000002, 13 13 PS_STAT_SAMPLE_STDEV = 0x000004, 14 PS_STAT_SAMPLE_UQ = 0x000008, 15 PS_STAT_SAMPLE_LQ = 0x000010, 16 PS_STAT_ROBUST_MEAN = 0x000020, 17 PS_STAT_ROBUST_MEAN_NVALUES = 0x000040, 18 PS_STAT_ROBUST_MEDIAN = 0x000080, 19 PS_STAT_ROBUST_MEDIAN_NVALUES = 0x000100, 20 PS_STAT_ROBUST_MODE = 0x000200, 21 PS_STAT_ROBUST_MODE_NVALUES = 0x000400, 22 PS_STAT_ROBUST_STDEV = 0x000800, 23 PS_STAT_ROBUST_UQ = 0x001000, 24 PS_STAT_ROBUST_LQ = 0x002000, 25 PS_STAT_CLIPPED_MEAN = 0x004000, 26 PS_STAT_CLIPPED_MEAN_NVALUES = 0x008000, 27 PS_STAT_CLIPPED_MEAN_NSIGMA = 0x010000, 28 PS_STAT_CLIPPED_STDEV = 0x020000, 29 PS_STAT_MAX = 0x040000, 30 PS_STAT_MIN = 0x080000, 31 PS_STAT_NVALUES = 0x100000 14 PS_STAT_SAMPLE_QUARTILE = 0x000008, 15 PS_STAT_ROBUST_MEAN = 0x000010, 16 PS_STAT_ROBUST_MEDIAN = 0x000020, 17 PS_STAT_ROBUST_MODE = 0x000040, 18 PS_STAT_ROBUST_STDEV = 0x000080, 19 PS_STAT_ROBUST_QUARTILE = 0x000100, 20 PS_STAT_CLIPPED_MEAN = 0x000200, 21 PS_STAT_CLIPPED_STDEV = 0x000400, 22 PS_STAT_MAX = 0x000800, 23 PS_STAT_MIN = 0x001000, 24 PS_STAT_USE_RANGE = 0x002000, 25 PS_STAT_USE_BINSIZE = 0x004000, 26 PS_STAT_ROBUST_FOR_SAMPLE = 0x008000 32 27 } psStatsOptions; 33 28 34 29 /** generic statistics structure */ 35 30 typedef struct { 36 double sampleMean; ///< formal mean of sample37 double sampleMedian; ///< formal median of sample38 double sampleStdev; ///< standard deviation of sample39 double sampleUQ; ///< upper quartile of sample40 double sampleLQ; ///< lower quartile of sample41 double robustMean; ///< robust mean of data42 int robustMeanNvalues; ///< number of measurements used for robust mean43 double robustMedian; ///< robust median of data44 int robustMedianNvalues; ///< number of measurements used for robust median45 double robust Mode; ///< Robust modeof data46 int robustModeNvalues; ///< Number of measurements used for robust mode47 double robust Stdev; ///< robust standard deviation of data48 double robustUQ; ///< robust upper quartile49 double robustLQ; ///< robust lower quartile50 double clippedMean; ///< Nsigma clipped mean51 int clippedMeanNvalues; ///< number of data points used for clipped mean52 double clippedStdev; ///< standard deviation after clipping53 double clipSigma; ///< Nsigma used for clipping; user input54 int clipIter; ///< Number of clipping iterations; user input55 double min; ///< minimum data value in data56 double max; ///< maximum data value in data57 int nValues; ///< number of data values in data58 psStatsOptions options; ///< bitmask of calculated values31 double sampleMean; ///< formal mean of sample 32 double sampleMedian; ///< formal median of sample 33 double sampleStdev; ///< standard deviation of sample 34 double sampleUQ; ///< upper quartile of sample 35 double sampleLQ; ///< lower quartile of sample 36 double sampleLimit; ///< Number of datapoints to 37 double robustMean; ///< robust mean of data 38 double robustMedian; ///< robust median of data 39 double robustMode; ///< Robust mode of data 40 double robustStdev; ///< robust standard deviation of data 41 double robustUQ; ///< robust upper quartile 42 double robustLQ; ///< robust lower quartile 43 int robustN50; ///< Number of points UQ-LQ 44 int robustNfit; ///< Number of points in Gauss. fit 45 double clippedMean; ///< Nsigma clipped mean 46 double clippedStdev; ///< standard deviation after clipping 47 int clippedNvalues; ///< number of data points used for clipped mean 48 double clipSigma; ///< Nsigma used for clipping; user input 49 int clipIter; ///< Number of clipping iterations; user input 50 double min; ///< minimum data value in data; input range 51 double max; ///< maximum data value in data; input range 52 double binsize; ///< binsize for robust fit (input/output) 53 psStatsOptions options; ///< bitmask of calculated values 59 54 } psStats; 60 55 … … 85 80 const psVector *restrict bounds; ///< Bounds for the bins 86 81 psVector *nums; ///< Number in each of the bins 87 const float minVal, maxVal; ///< Minimum and maximum values88 82 int minNum, maxNum; ///< Number below the minimum and above the maximum 89 83 int uniform; ///< Is it a uniform distribution? … … 99 93 /** Generic constructor \ingroup MathGroup */ 100 94 psHistogram * 101 psHistogramAllocGeneric(const psVector *restrict bounds, ///< Bounds for the bins 102 float minVal, ///< Minimum value 103 float maxVal) ///< Maximum value 95 psHistogramAllocGeneric(const psVector *restrict bounds) ///< Bounds for the bins 104 96 ; 105 97 … … 112 104 /** Calculate a histogram \ingroup MathGroup **/ 113 105 psHistogram * 114 ps VectorHistogram(psHistogram *restrict myHist, ///< Histogram data106 psHistogramVector(psHistogram *restrict myHist, ///< Histogram data 115 107 const psVector *restrict myArray) ///< Array to analyse 116 108 ; -
trunk/archive/pslib/include/psVector.h
r704 r753 11 11 psType type; ///< vector data type and dimension 12 12 const int n; ///< size of vector 13 const int nalloc; ///< data region relative to parent13 const int nalloc; ///< allocated data block 14 14 union { 15 psF32 *arr; ///< Pointers to floating-point data (default) 16 psS8 *arr_S8; ///< Pointers to short-integer data 17 psS16 *arr_S16; ///< Pointers to short-integer data 18 psS32 *arr_S32; ///< Pointers to integer data 19 psS64 *arr_S64; ///< Pointers to long-integer data 20 psU8 *arr_U18; ///< Pointers to unsigned-short-integer data 21 psU16 *arr_U16; ///< Pointers to unsigned-short-integer data 22 psU32 *arr_U32; ///< Pointers to unsigned-integer data 23 psU64 *arr_U64; ///< Pointers to unsigned-long-integer data 24 psF32 *arr_F32; ///< Pointers to floating-point data 25 psF64 *arr_F64; ///< Pointers to double-precision data 26 psF32 *arr_C32; ///< Pointers to complex floating-point data 27 void **arr_v; 28 } arr; 15 psS8 *S8; ///< Pointers to short-integer data 16 psS16 *S16; ///< Pointers to short-integer data 17 psS32 *S32; ///< Pointers to integer data 18 psS64 *S64; ///< Pointers to long-integer data 19 psU8 *U18; ///< Pointers to unsigned-short-integer data 20 psU16 *U16; ///< Pointers to unsigned-short-integer data 21 psU32 *U32; ///< Pointers to unsigned-integer data 22 psU64 *U64; ///< Pointers to unsigned-long-integer data 23 psF32 *F32; ///< Pointers to floating-point data 24 psF64 *F64; ///< Pointers to double-precision data 25 psF32 *C32; ///< Pointers to complex floating-point data 26 void **V; 27 } data; 29 28 } psVector; 30 29 -
trunk/archive/pslib/src/Metadata/metadata.c
r707 r753 47 47 */ 48 48 psMetadataItem *psMetadataItemAlloc( 49 int typeFlags, // type of this piece of metadata + flags50 const void *data, // value of new item49 const char *name, // name of new item of metadata (may be an sprintf format) 50 int format, // type of this piece of metadata + flags 51 51 const char *comment, // comment associated with item; may be NULL 52 ...) // data + possible arguments for name format 53 { 54 va_list ap; 55 va_start(ap, comment); 56 57 psMetadataItem *mi = psMetadataItemAllocV(name, format, comment, ap); 58 59 va_end(ap); 60 61 return mi; 62 } 63 64 psMetadataItem *psMetadataItemAllocV( 52 65 const char *name, // name of new item of metadata (may be an sprintf format) 53 ... // possible arguments for name format 54 ) 55 { 56 va_list ap; 57 va_start(ap, name); 58 59 psMetadataItem *mi = psVMetadataItemAlloc(typeFlags, data, comment, name, ap); 60 61 va_end(ap); 62 63 return mi; 64 } 65 66 psMetadataItem *psVMetadataItemAlloc( 67 int typeFlags, // type of this piece of metadata + flags 68 const void *data, // value of new item 66 int format, // type of this piece of metadata + flags 69 67 const char *comment, // comment associated with item; may be NULL 70 const char *name, // name of new item of metadata (may be an sprintf format) 71 va_list ap // possible arguments for name format 72 ) 73 { 74 const psMetadataType type = typeFlags & PS_META_TYPE_MASK; // the type part of typeFlags 75 psMetadataFlags flags = typeFlags & ~PS_META_TYPE_MASK; // the flags part of typeFlags 68 va_list ap) // possible arguments for name format 69 { 70 const psMetadataType type = format & PS_META_TYPE_MASK; // the type part of format 71 psMetadataFlags flags = format & ~PS_META_TYPE_MASK; // the flags part of format 76 72 static int id = 0; // unique ID for an item of metadata 77 73 psMetadataItem *ms = psAlloc(sizeof(psMetadataItem)); … … 94 90 ms->items = NULL; 95 91 96 assert (name != NULL);97 if (strchr(name, '%') != NULL) {98 static char tmp[201]; // should be enough; we won't overflow even if it isn't99 100 if(vsnprintf(tmp, sizeof(tmp), name, ap) > sizeof(tmp) - 1) {101 psTrace("metadata.name", 1, "Keyword \"%s\" was truncated to \"%s\" upon expansion\n", name, tmp);102 }103 104 name = tmp;105 }106 ms->name = psStringCopy(name);107 108 ms->comment = psStringCopy(comment == NULL ? "" : comment);109 110 92 assert (type >= 0 && type < PS_META_NTYPE); 111 93 switch (type) { 112 94 case PS_META_ITEM_SET: 113 *(void **)&ms->val.v= NULL;95 ms->data.V = NULL; 114 96 ms->items = psDlistAlloc(NULL); 115 97 break; 116 98 117 case PS_META_FLOAT: 118 *(float *)&ms->val.f = *(float *)data; 119 break; 120 121 case PS_META_INT: 122 *(int *)&ms->val.i = *(int *)data; 99 case PS_META_F32: // psF32 promoted to psF64 through ... 100 case PS_META_F64: 101 ms->data.F64 = va_arg (ap, psF64); 102 break; 103 104 case PS_META_S32: 105 ms->data.S32 = va_arg (ap, psS32); 123 106 break; 124 107 125 108 case PS_META_STR: 126 *(void **)&ms->val.v = psStringCopy(data);109 ms->data.V = psStringCopy(va_arg(ap, char *)); 127 110 break; 128 111 … … 132 115 case PS_META_ASTROM: 133 116 case PS_META_UNKNOWN: 134 *(void **)&ms->val.v = (void *)data;117 ms->data.V = va_arg(ap, void *); 135 118 break; 136 119 … … 139 122 break; // NOTREACHED 140 123 } 124 125 assert (name != NULL); 126 if (strchr(name, '%') != NULL) { 127 static char tmp[201]; // should be enough; we won't overflow even if it isn't 128 129 if(vsnprintf(tmp, sizeof(tmp), name, ap) > sizeof(tmp) - 1) { 130 psTrace("metadata.name", 1, "Keyword \"%s\" was truncated to \"%s\" upon expansion\n", name, tmp); 131 } 132 133 name = tmp; 134 } 135 ms->name = psStringCopy(name); 136 137 ms->comment = psStringCopy(comment == NULL ? "" : comment); 141 138 142 139 return ms; … … 159 156 break; 160 157 161 case PS_META_FLOAT: 162 case PS_META_INT: 158 case PS_META_F32: 159 case PS_META_F64: 160 case PS_META_S32: 163 161 break; // nothing to do 164 162 165 163 case PS_META_STR: 166 psFree(ms-> val.v);164 psFree(ms->data.V); 167 165 break; 168 166 … … 198 196 psMetadataItem *head = meta; 199 197 if (head == NULL) { // this is the first item of this name 200 head = psMetadataAppend(ms, PS_META_ITEM_SET, NULL, NULL, item->name);198 head = psMetadataAppend(ms, item->name, PS_META_ITEM_SET, NULL); 201 199 } 202 200 … … 224 222 return item; 225 223 } else if (meta != NULL) { 226 psError(__func__, PS_ERR_UNKNOWN, PS_NEW_ERROR,224 psError(__func__, PS_ERR_UNKNOWN, 1, 227 225 "Key \"%s\" is already present in the metaDataSet 0x%x", item->name, ms); 228 226 psMetadataItemFree(item); … … 242 240 */ 243 241 psMetadataItem *psMetadataAppend(psMetadata *restrict md, ///< Metadata to add to 244 int typeFlags, ///< type of this piece of metadata + flags 245 const void *val, ///< value of new item N.b. a pointer even if the item 246 ///< is of type e.g. int 247 const char *comment, ///< comment associated with item 248 const char *name, ///< name of new item of metadata (may be in sprintf 249 ///< format) 250 ... ///< possible arguments for name format 251 ) 242 const char *name, ///< name of new item of metadata 243 int format, ///< type of this piece of metadata + flags 244 const char *comment, ///< comment associated with item 245 ...) ///< possible arguments for name format 252 246 { 253 247 va_list ap; 254 va_start(ap, name);255 256 psMetadataItem *mi = ps VMetadataItemAlloc(typeFlags, val, comment, name, ap);248 va_start(ap, comment); 249 250 psMetadataItem *mi = psMetadataItemAllocV(name, format, comment, ap); 257 251 258 252 va_end(ap); … … 363 357 break; 364 358 365 case PS_META_FLOAT: 366 fprintf(fd, "%g\n", ms->val.f); 367 break; 368 369 case PS_META_INT: 370 fprintf(fd, "%d\n", ms->val.i); 359 case PS_META_F64: 360 case PS_META_F32: 361 fprintf(fd, "%g\n", ms->data.F32); 362 break; 363 364 case PS_META_S32: 365 fprintf(fd, "%d\n", ms->data.S32); 371 366 break; 372 367 373 368 case PS_META_STR: 374 fprintf(fd, "%s\n", (char *)ms-> val.v);369 fprintf(fd, "%s\n", (char *)ms->data.V); 375 370 break; 376 371 -
trunk/archive/pslib/src/Utils/Makefile
r707 r753 2 2 CFLAGS = -Wall -g -I$(PSLIB_DIR)/include -I$(FFTW_DIR)/include 3 3 DYLIB = dylib 4 DYLIB_LDFLAGS = "-undefined suppress -flat_namespace -dynamiclib";4 DYLIB_LDFLAGS = -undefined suppress -flat_namespace -dynamiclib -shared 5 5 6 6 PSLIB_DIR = ../.. -
trunk/archive/pslib/src/Utils/dlist.c
r707 r753 317 317 psDlistElem *ptr = dlist->head; 318 318 for (int i = 0, n = dlist->n; i < n; i++) { 319 arr->arr.arr_v[i] = ptr->data; 320 319 arr->data.V[i] = ptr->data; 321 320 ptr->data = NULL; 322 321 ptr = ptr->next; … … 339 338 for (int i = 0, n = arr->n; i < n; i++) { 340 339 psDlistAppend(list, 341 psMemDecrRefCounter(arr-> arr.arr_v[i])); // it\'s already Incr342 arr-> arr.arr_v[i] = NULL;340 psMemDecrRefCounter(arr->data.V[i])); // it\'s already Incr 341 arr->data.V[i] = NULL; 343 342 } 344 343 -
trunk/archive/pslib/src/Utils/error.c
r707 r753 76 76 int psError(const char *name, // category of code that caused the error 77 77 psErrorCode code, // code of error (equivalent to errno) 78 psErrorStatus status,// is this a new error?78 int new, // is this a new error? 79 79 const char *fmt, ...) // format and possible extra arguments 80 80 { 81 if (code == PS_ERR_NONE || status == PS_NEW_ERROR) { // free old error stack81 if (code == PS_ERR_NONE || new) { // free old error stack 82 82 errStack *eptr = errorStack; 83 83 … … 99 99 100 100 va_start(ap, fmt); 101 p _psLogVMsg(name, PS_LOG_ERROR, fmt, ap);101 psLogMsgV(name, PS_LOG_ERROR, fmt, ap); 102 102 va_end(ap); 103 103 } … … 210 210 } 211 211 212 psError VStackPrint(fd, fmt, ap);212 psErrorStackPrintV(fd, fmt, ap); 213 213 214 214 if (fmt != NULL) { … … 217 217 } 218 218 219 void psError VStackPrint(FILE *fd, // write to this file descriptor219 void psErrorStackPrintV(FILE *fd, // write to this file descriptor 220 220 const char *fmt,// format for any header information; may be NULL 221 221 va_list ap) // arguments for format -
trunk/archive/pslib/src/Utils/logmsg.c
r707 r753 110 110 #endif 111 111 112 void p _psLogVMsg(const char *name, int level, const char *fmt, va_list ap)112 void psLogMsgV(const char *name, int level, const char *fmt, va_list ap) 113 113 { 114 114 static int first = 1; … … 224 224 va_start(ap, fmt); 225 225 226 p _psLogVMsg(name, level, fmt, ap);226 psLogVMsg(name, level, fmt, ap); 227 227 va_end(ap); 228 228 } -
trunk/archive/pslib/src/Utils/memory.c
r687 r753 48 48 * First the I-can't-get-the-memory callback 49 49 */ 50 static void *memExhaustedC B0(size_t size)50 static void *memExhaustedCallback0(size_t size) 51 51 { 52 52 return NULL; 53 53 } 54 static psMemExhaustedC B memExhaustedCB = memExhaustedCB0;55 56 psMemExhaustedC B psMemExhaustedCBSet(psMemExhaustedCBfunc)57 { 58 psMemExhaustedC B old = memExhaustedCB;59 60 memExhaustedC B = (func != NULL) ? func : memExhaustedCB0;54 static psMemExhaustedCallback memExhaustedCallback = memExhaustedCallback0; 55 56 psMemExhaustedCallback psMemExhaustedCallbackSet(psMemExhaustedCallback func) 57 { 58 psMemExhaustedCallback old = memExhaustedCallback; 59 60 memExhaustedCallback = (func != NULL) ? func : memExhaustedCallback0; 61 61 62 62 return old; … … 65 65 * then the I-have-detected-a-problem callback 66 66 */ 67 static void memProblemC B0(const psMemBlock *ptr,67 static void memProblemCallback0(const psMemBlock *ptr, 68 68 const char *file, int lineno) 69 69 { … … 76 76 fprintf(stderr, "\n"); 77 77 } else if (ptr->refCounter <= 0) { 78 psError(__func__, PS_ERR_BADFREE, PS_NEW_ERROR,78 psError(__func__, PS_ERR_BADFREE, 1, 79 79 "Block %ld allocated at %s:%d freed more than once at %s:%d\n", 80 80 ptr->id, ptr->file, ptr->lineno, file, lineno); 81 81 } else if (ptr->refCounter > 1) { 82 psError(__func__, PS_ERR_BADFREE, PS_NEW_ERROR,82 psError(__func__, PS_ERR_BADFREE, 1, 83 83 "Block %ld allocated at %s:%d freed while still referenced at %s:%d\n", 84 84 ptr->id, ptr->file, ptr->lineno, file, lineno); … … 89 89 } 90 90 } 91 static psMemProblemC B memProblemCB = memProblemCB0;92 93 psMemProblemC B psMemProblemCBSet(psMemProblemCBfunc)94 { 95 psMemProblemC B old = memProblemCB;96 97 memProblemC B = (func != NULL) ? func : memProblemCB0;91 static psMemProblemCallback memProblemCallback = memProblemCallback0; 92 93 psMemProblemCallback psMemProblemCallbackSet(psMemProblemCallback func) 94 { 95 psMemProblemCallback old = memProblemCallback; 96 97 memProblemCallback = (func != NULL) ? func : memProblemCallback0; 98 98 99 99 return old; … … 129 129 * isn't resignalled) 130 130 */ 131 static long memAllocateC B0(const psMemBlock *ptr)131 static long memAllocateCallback0(const psMemBlock *ptr) 132 132 { 133 133 static int incr = 0; // "p_psMemAllocateID += incr" … … 138 138 } 139 139 140 static long memFreeC B0(const psMemBlock *ptr)140 static long memFreeCallback0(const psMemBlock *ptr) 141 141 { 142 142 static int incr = 0; // "p_psMemFreeID += incr" … … 150 150 * The default callbacks, and the routines to change them 151 151 */ 152 static psMemAllocateC B memAllocateCB = memAllocateCB0;153 static psMemFreeC B memFreeCB = memFreeCB0;154 155 psMemAllocateC B psMemAllocateCBSet(psMemAllocateCBfunc)156 { 157 psMemAllocateC B old = memAllocateCB;158 159 memAllocateC B = (func != NULL) ? func : memAllocateCB0;160 161 return old; 162 } 163 164 psMemFreeC B psMemFreeCBSet(psMemFreeCBfunc)165 { 166 psMemFreeC B old = memFreeCB;167 168 memFreeC B = (func != NULL) ? func : memFreeCB0;152 static psMemAllocateCallback memAllocateCallback = memAllocateCallback0; 153 static psMemFreeCallback memFreeCallback = memFreeCallback0; 154 155 psMemAllocateCallback psMemAllocateCallbackSet(psMemAllocateCallback func) 156 { 157 psMemAllocateCallback old = memAllocateCallback; 158 159 memAllocateCallback = (func != NULL) ? func : memAllocateCallback0; 160 161 return old; 162 } 163 164 psMemFreeCallback psMemFreeCallbackSet(psMemFreeCallback func) 165 { 166 psMemFreeCallback old = memFreeCallback; 167 168 memFreeCallback = (func != NULL) ? func : memFreeCallback0; 169 169 170 170 return old; … … 194 194 if (m == NULL) { 195 195 if (!quiet) { 196 psError(__func__, PS_ERR_MEMORY_CORRUPTION, PS_NEW_ERROR,196 psError(__func__, PS_ERR_MEMORY_CORRUPTION, 1, 197 197 "psMemCheckCorruption: NULL memory block\n"); 198 198 } … … 202 202 if (!ALIGNED(m)) { 203 203 if (!quiet) { 204 psError(__func__, PS_ERR_MEMORY_CORRUPTION, PS_NEW_ERROR,204 psError(__func__, PS_ERR_MEMORY_CORRUPTION, 1, 205 205 "psMemCheckCorruption: non-aligned memory block\n"); 206 206 } … … 210 210 if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) { 211 211 if (!quiet) { 212 psError(__func__, PS_ERR_MEMORY_CORRUPTION, PS_NEW_ERROR,212 psError(__func__, PS_ERR_MEMORY_CORRUPTION, 1, 213 213 "psMemCheckCorruption: memory block %ld is corrupted\n", m->id); 214 214 } … … 232 232 nbad++; 233 233 234 memProblemC B(memBlocks[i], "(psMemCheckCorruption)", 0);234 memProblemCallback(memBlocks[i], "(psMemCheckCorruption)", 0); 235 235 236 236 if (abort_on_error) { … … 251 251 252 252 if (ptr == NULL) { 253 ptr = memExhaustedC B(size);253 ptr = memExhaustedCallback(size); 254 254 if (ptr == NULL) { 255 255 psAbort(__func__, "Failed to allocate %ld bytes at %s:%d", … … 270 270 271 271 if (ptr->id == p_psMemAllocateID && p_psMemAllocateID > 0) { 272 p_psMemAllocateID += memAllocateC B(ptr);272 p_psMemAllocateID += memAllocateCallback(ptr); 273 273 } 274 274 /* … … 310 310 */ 311 311 if (ptr->id == p_psMemFreeID && p_psMemFreeID > 0) { 312 p_psMemFreeID += memFreeC B(ptr);312 p_psMemFreeID += memFreeCallback(ptr); 313 313 } 314 314 315 315 if (bad_memblock(ptr, 0)) { 316 memProblemC B(ptr, file, lineno); // we may not own this block; don't free it316 memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it 317 317 } else { 318 318 if (ptr->refCounter != 1) { 319 memProblemC B(ptr, file, lineno);319 memProblemCallback(ptr, file, lineno); 320 320 } 321 321 ptr->refCounter--; … … 396 396 397 397 if (bad_memblock(ptr, 0)) { 398 memProblemC B(ptr, "(psMemGetRefCounter)", -1);398 memProblemCallback(ptr, "(psMemGetRefCounter)", -1); 399 399 } 400 400 … … 411 411 412 412 if (bad_memblock(ptr, 0)) { 413 memProblemC B(ptr, "(psMemIncrRefCounter)", -1);413 memProblemCallback(ptr, "(psMemIncrRefCounter)", -1); 414 414 } 415 415 … … 428 428 429 429 if (bad_memblock(ptr, 0)) { 430 memProblemC B(ptr, "(psMemDecrRefCounter)", -1);430 memProblemCallback(ptr, "(psMemDecrRefCounter)", -1); 431 431 } 432 432 -
trunk/archive/pslib/src/Utils/misc.c
r707 r753 29 29 30 30 va_start(ap, fmt); 31 p _psLogVMsg(name, PS_LOG_ABORT, fmt, ap);31 psLogMsgV(name, PS_LOG_ABORT, fmt, ap); 32 32 va_end(ap); 33 33 -
trunk/archive/pslib/src/Utils/vector.c
r709 r753 16 16 17 17 *(int *)&vec->n = *(int *)&vec->nalloc = nalloc; 18 vec-> arr.arr_v= psAlloc(nalloc*sizeof(void **));18 vec->data.V = psAlloc(nalloc*sizeof(void **)); 19 19 20 20 return vec; … … 34 34 35 35 if (elemFree != NULL && vec->nalloc > 0) { 36 assert (vec-> arr.arr!= NULL); /* choose any member of the union */36 assert (vec->data.V != NULL); /* choose any member of the union */ 37 37 const int n = vec->nalloc; 38 38 for (int i = 0; i < n; i++) { 39 elemFree(vec-> arr.arr_v[i]);39 elemFree(vec->data.V[i]); 40 40 } 41 41 } 42 42 43 psFree(vec-> arr.arr_v);43 psFree(vec->data.V); 44 44 psFree(vec); 45 45 }
Note:
See TracChangeset
for help on using the changeset viewer.
