IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 753


Ignore:
Timestamp:
May 20, 2004, 6:12:37 PM (22 years ago)
Author:
eugene
Message:

substantial API changes based on change to PSLib SDRS

Location:
trunk/archive/pslib
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/include/psAstrom.h

    r704 r753  
    7979
    8080    psMetadata *md;                     ///< FPA-level metadata
    81     psPlaneDistortion *TPtoFP;          ///< Transformation term from
    82     psPlaneDistortion *FPtoTP;          ///< Transformation term from
     81    psPlaneDistort *TPtoFP;             ///< Transformation term from
     82    psPlaneDistort *FPtoTP;             ///< Transformation term from
    8383    psFixedPattern *pattern;            ///< Fixed pattern residual offsets
    8484    const psExposure *exp;              ///< information about this exposure
     
    9696
    9797    psMetadata *md;                     ///< Chip-level metadata
    98     psPlaneCoordXform *chipToFPA;       ///< Transformations from chip coordinates to FPA coordinates
    99     psPlaneCoordXform *FPAtoChip;       ///< Transformations from FPA coordinates to chip
     98    psPlaneTransform *chipToFPA;        ///< Transformations from chip coordinates to FPA coordinates
     99    psPlaneTransform *FPAtoChip;        ///< Transformations from FPA coordinates to chip
    100100
    101101    struct psFPA *parentFPA;            ///< FPA which contains this chip
     
    110110    psMetadata *md;                     ///< Cell-level metadata
    111111
    112     psPlaneCoordXform *cellToChip;      ///< Transformations from cell coordinates to chip coordinates
    113     psPlaneCoordXform *cellToFPA;       ///< Transformations from cell coordinates to FPA coordinates
    114     psPlaneCoordXform *cellToSky;       ///< Quick and Dirty transformations from cell coordinates to sky
     112    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
    115115
    116116    struct psChip  *parentChip;         ///< chip which contains this cell
     
    134134/*** Calculating and applying astrometric solutions ***/
    135135
     136/** Return the cell in FPA which contains the given FPA coordinates */
     137psCell *
     138psCellInFPA(psCell *out,                ///< Cell to return, or NULL
     139            const psPlane *coord,       ///< Coordinate in FPA
     140            const psFPA *fpa)           ///< FPA description
     141;
     142
     143
    136144/** returns Chip in FPA which contains the given FPA coordinate */
    137145psChip *
    138146psChipInFPA (psChip *out,               ///< Chip to return, or NULL
    139              const psPlaneCoord *coord, ///< coordinate in FPA
    140              const psFPA *fpa           ///< FPA description
    141              );
     147             const psPlane *coord,      ///< coordinate in FPA
     148             const psFPA *fpa)          ///< FPA description
     149;
    142150
    143151/** returns Cell in Chip which contains the given chip coordinate */
    144152psCell *
    145153psCellInChip(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 */
     160psPlane *
     161psCoordCelltoChip (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 */
     167psPlane *
     168psCoordChiptoFPA (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 */
     174psPlane *
     175psCoordFPAToTP(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) */
     181psSphere *
     182psCoordTPtoSky(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 */
     188psPlane *
     189psCoordCellToFPA(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) */
     195psSphere *
     196psCoordCellToSky(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) */
     202psSphere *
     203psCoordCellToSkyQD(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 */
     211psPlane *
     212psCoordSkyToTP(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 */
     218psPlane *
     219psCoordTPtoFPA(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 */
     225psPlane *
     226psCoordFPAtoChip (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 */
     232psPlane *
     233psCoordChiptoCell (psPlane *out,        ///< Coordinates to return, or NULL
     234                   const psPlane *in,   ///< input Chip coordinate
     235                   const psCell *cell)  ///< Cell of interest
     236;
    157237
    158238/** 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                  );
     239psPlane *
     240psCoordSkyToCell(psPlane *out,          ///< Coordinates to return
     241                 const psSphere *in,    ///< Input coordinates
     242                 const psCell *cell)    ///< Cell of interest
     243;
    172244
    173245/** 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                  );
     246psSphere *
     247psCoordSkyToCellQD(psPlane *out,        ///< Coordinates to return
     248                   const psSphere *in,  ///< Input coordinates
     249                   const psCell *cell)  ///< Cell of interest
     250;
     251
     252/**** other utilities ****/
    242253
    243254/** Get the airmass for a given position and sidereal time */
    244255float
    245 psGetAirmass(const psSphereCoord *coord, ///< Position on the sky
     256psGetAirmass(const psSphere *coord,     ///< Position on the sky
    246257             double siderealTime,       ///< Sidereal time
    247              float height               ///< Height above sea level
    248              );
     258             float height)              ///< Height above sea level
     259;
    249260
    250261/** Get the parallactic angle for a given position and sidereal time */
    251262float
    252 psGetParallactic(const psSphereCoord *coord, ///< Position on the sky
    253                  double siderealTime    ///< Sidereal time
    254                  );
     263psGetParallactic(const psSphere *coord, ///< Position on the sky
     264                 double siderealTime)   ///< Sidereal time
     265;
    255266
    256267/** Estimate atmospheric refraction, along the parallactic */
     
    259270                psPhotSystem colorPlus, ///< Colour reference
    260271                psPhotSystem colorMinus, ///< Colour reference
    261                 const psExposure *exp   ///< Telescope pointing information, for airmass, temp and pressure
    262                 );
     272                const psExposure *exp)  ///< Telescope pointing information, for airmass, temp and pressure
     273;
    263274
    264275/** Calculate the parallax factor */
    265 psSphereCoord *
    266 psGetParallaxFactor(const psExposure *exp ///< Exposure details
    267     );
     276psSphere *
     277psGetParallaxFactor(const psExposure *exp) ///< Exposure details
     278;
    268279
    269280/*** Constructors / Destructors ******************************************************/
     
    281292                float pressure,         ///< Pressure
    282293                float humidity,         ///< Relative humidity
    283                 float exptime           ///< Exposure time
    284                 );
     294                float exptime)          ///< Exposure time
     295;
    285296
    286297/** Destructor */
    287298void
    288 psExposureFree(psExposure *restrict myExp ///< Object to destroy
    289                );
     299psExposureFree(psExposure *restrict myExp) ///< Object to destroy
     300;
    290301
    291302/** Constructor */
    292303psGrommit *
    293 psGrommitAlloc(const psExposure *exp    ///< Relevant exposure
    294     );
     304psGrommitAlloc(const psExposure *exp)   ///< Relevant exposure
     305;
    295306
    296307/** Destructor */
    297308void
    298 psGrommitFree(psGrommit *grommit        ///< Grommit to destroy
    299     );
     309psGrommitFree(psGrommit *grommit)       ///< Grommit to destroy
     310;
    300311
    301312/* \} */ // End of AstroGroup Functions
     
    304315
    305316/*
    306    example images:
    307 
    308    GPC:          1 Chip per file, 1 Cell per extension
    309    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 extension
    311    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 (?)
    313324   
    314325
  • trunk/archive/pslib/include/psBitset.h

    r604 r753  
    1919
    2020/** Constructor */
    21 psBitset *psBitsetAlloc(int n           ///< Number of bits required
    22     );
     21psBitset *psBitsetAlloc(int n)          ///< Number of bits required
     22;
    2323
    2424/** Destructor */
    25 void psBitsetFree(psBitset *restrict myBits ///< bitset to destroy
    26     );
     25void psBitsetFree(psBitset *restrict myBits) ///< bitset to destroy
     26;
    2727
    2828/************************************************************************************************************/
     
    3131psBitset *
    3232psBitsetSet(psBitset *restrict myBits,  ///< Input bitset
    33              int bit                    ///< Bit to set
    34     );
     33             int bit)                   ///< Bit to set
     34;
    3535
    3636/** Check a bitset.  Returns true or false */
    3737int
    3838psBitsetTest(const psBitset *restrict checkBits, ///< bitset to check
    39               int bit                   ///< Bit to check
    40     );
     39              int bit)                  ///< Bit to check
     40;
    4141
    4242/** apply the given operator to two bitsets */
     
    4545            const psBitset *restrict inBits1, ///< Input bitset 1
    4646            char *operator,             ///< bitset operator (AND, OR, XOR)
    47             const psBitset *restrict inBits2 ///< Input bitset 2
    48     );
     47            const psBitset *restrict inBits2) ///< Input bitset 2
     48;
    4949
    5050/** Apply unary NOT to a bitset */
    5151psBitset *
    5252psBitsetNot(psBitset *out,              ///< Output bitset, or NULL
    53             psBitset *in                ///< Input bitset to be NOT-ed
    54     );
     53            psBitset *in)               ///< Input bitset to be NOT-ed
     54;
    5555
    5656/* \} */ // End of MathGroup Functions
  • trunk/archive/pslib/include/psDateTime.h

    r396 r753  
    11#if !defined(PS_DATE_TIME_H)
    22#define PS_DATE_TIME_H
     3
     4#include "taia.h"
    35
    46/** \file psDateTime.h
     
    1921    definition. */
    2022typedef struct {
    21     long numSeconds;                    ///< Number of seconds from some defined epoch
    22     double fracSeconds;                 ///< Fraction of seconds
     23  struct taia t;
    2324} psTime;
    2425
     
    5253/** Convert psTime to JD */
    5354double
    54 psTimeToJD (psTime time)                        ///< Input psTime time
     55psTimeToJD (psTime time)                ///< Input psTime time
    5556;
    5657
     
    6162
    6263/** Convert psTime to broken-down time (struct tm) */
    63 struct tm *
    64 psTimeToTm (psTime time)                        ///< Input psTime time
     64struct tm *                             
     65psTimeToTm (psTime time)                ///< Input psTime time
     66;
     67
     68/** Convert psTime to lunation number */
     69float
     70psTimeToLunation (psTime time)          ///< Input psTime time
    6571;
    6672
     
    8692;
    8793
    88 /** Convert timeval to psTime (struct timeval) */
     94/** Convert timeval (struct timeval) to psTime */
    8995psTime *
    9096psTimevalToTime (struct timeval *input) ///< Input timeval time
    9197;
    9298
    93 /** Convert broken-to psTime down time (struct tm) */
     99/** Convert broken-down time (struct tm) to psTime */
    94100psTime *
    95 psTMtoTime (struct tm *input)           ///< Input tm time
     101psTMToTime (struct tm *input)           ///< Input tm time
     102;
     103
     104/** Convert lunation number to psTime */
     105psTime *
     106psLunationToTime (float lunation)       ///< Input lunation
    96107;
    97108
  • trunk/archive/pslib/include/psDlist.h

    r706 r753  
    8686
    8787/** Convert doubly-linked list to a vector of (void *) */
    88 psVector *psDlistToArray(psDlist *dlist) ///< List to convert
     88psVector *psDlistToVector(psDlist *dlist) ///< List to convert
    8989;
    9090
    9191/** Convert array to a doubly-linked list */
    92 psDlist *psArrayToDlist(psVector *arr) ///< vecotor of (void *) to convert
     92psDlist *psArrayToDlist(psVector *vector) ///< vector of (void *) to convert
    9393;
    9494
  • trunk/archive/pslib/include/psError.h

    r611 r753  
    1212
    1313typedef struct {
    14     psErrorCode code;                   // An error code
    15     const char *descrip;                // the associated description
     14    psErrorCode code;                   ///< An error code
     15    const char *descrip;                ///< the associated description
    1616} psErrorDescription;
    1717
    1818typedef struct {
    19     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
     19    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
    2222} psErr;
    23 
    24 typedef enum {
    25     PS_OLD_ERROR = 0,                   ///< This is an old error, and should append to the error stack
    26     PS_NEW_ERROR = 1,                   ///< This is a new error and should clear the error stack
    27 } psErrorStatus;
    2823
    2924/// Prints an error message and doesn't abort; returns code
    3025int psError(const char *name,           ///< Category of code that caused the error
    3126            psErrorCode code,           ///< class of error (equivalent to errno)
    32             psErrorStatus status,       ///< is this a new error?
     27            int new,                    ///< is this a new error?
    3328            const char *fmt,            ///< Format
    34             ...                         ///< Extra arguments to use format
    35     );
     29            ...)                        ///< Extra arguments to use format
     30;
    3631
    3732void p_psErrorRegister(const psErrorDescription *errors, ///< register a set of errors
    38                        int nerror);                    ///< number of errors
     33                       int nerror)      ///< number of errors
     34;
    3935
    40 const psErr *psErrorGet(int which);     // return specified error (or an "error" with code PS_ERR_NONE)
    41 const psErr *psErrorLast(void);         // return last error (or an "error" with code PS_ERR_NONE)
     36///< return specified error (or an "error" with code PS_ERR_NONE)
     37const psErr *psErrorGet(int which);     
    4238
    43 void psErrorClear(void);                ///< Clear the error stack
     39///< return last error (or an "error" with code PS_ERR_NONE)
     40const psErr *psErrorLast(void);         
    4441
    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
     43void psErrorClear(void);               
     44
     45///< return the string associated with the error code
     46const char *psErrorCodeString(psErrorCode code);       
     47
     48///< print the errorstack to this file descriptor
     49void 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)
     55void 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
    5060
    5161#endif
  • trunk/archive/pslib/include/psFFT.h

    r704 r753  
    22#define PS_FFT_H
    33
    4 #include <fftw3.h>
     4/* #include <fftw3.h> */
    55
    66/** \file psFFT.h
     
    1313 *  \{
    1414 */
     15
     16/**** Vector FFT & Complex functions ****/
     17
     18/** FFT a vector. in: psF32 or psC32, out: psC32 */
     19psVector *
     20psVectorFFT(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 */
     25psVector *
     26psVectorPowerSpectrum(const psVector *vector) ///< Vector to obtain power spectrum of
     27;
     28
     29/** Get the real part of a vector */
     30psVector *
     31psVectorReal(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 */
     36psVector *
     37psVectorImaginary(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 */
     42psVector *
     43psVectorComplex(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 */
     49psVector *
     50psVectorConjugate(psVector *out,        ///< Vector for output (or NULL)
     51                  const psVector *in)   ///< Vector to get the complex conjugate of
     52;
    1553
    1654/**** Image FFT & Complex functions ****/
     
    5290;
    5391
    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 transform
    59 ;
    60 
    61 /** Calculate power spectrum of a vector of floating-point numbers */
    62 psVector *
    63 psVectorPowerSpectrum(const psVector *vector) ///< Vector to obtain power spectrum of
    64 ;
    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 of
    70 ;
    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 of
    76 ;
    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 vector
    82                const psVector *imag)    ///< imaginary part of vector
    83 ;
    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 of
    89 ;
    9092
    9193/* \} */ // End of MathGroup Functions
  • trunk/archive/pslib/include/psFunctions.h

    r618 r753  
    1414psGaussian(float x,                     ///< Value at which to evaluate
    1515           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
     20psVector *
     21psGaussianDev(float mean,               ///< Mean for the Gaussian
     22              float stddev,             ///< Standard deviation for the Gaussian
     23              int Npts)                 ///< Number of points generated
     24;
    1825
    1926/************************************************************************************************************/
    2027
    21 /** One-dimensional polynomial */
     28/** one-dimensional polynomial */
    2229typedef struct {
    2330    int n;                              ///< Number of terms
     
    8693/** Evaluate 1D polynomial */
    8794float
    88 psEvalPolynomial1D(float x,             ///< Value at which to evaluate
     95psPolynomial1DEval(float x,             ///< Value at which to evaluate
    8996                   const psPolynomial1D *restrict myPoly ///< Coefficients for the polynomial
    9097                   );
     
    9299/** Evaluate 2D polynomial */
    93100float
    94 psEvalPolynomial2D(float x,             ///< Value x at which to evaluate
     101psPolynomial2DEval(float x,             ///< Value x at which to evaluate
    95102                   float y,             ///< Value y at which to evaluate
    96103                   const psPolynomial2D *restrict myPoly ///< Coefficients for the polynomial
     
    99106/** Evaluate 3D polynomial */
    100107float
    101 psEvalPolynomial3D(float x,             ///< Value x at which to evaluate
     108psPolynomial3DEval(float x,             ///< Value x at which to evaluate
    102109                   float y,             ///< Value y at which to evaluate
    103110                   float z,             ///< Value z at which to evaluate
     
    107114/** Evaluate 4D polynomial */
    108115float
    109 psEvalPolynomial4D(float w,             ///< Value w at which to evaluate
     116psPolynomial4DEval(float w,             ///< Value w at which to evaluate
    110117                   float x,             ///< Value x at which to evaluate
    111118                   float y,             ///< Value y at which to evaluate
     
    187194/** Evaluate 1D polynomial (double precision) */
    188195double
    189 psEvalDPolynomial1D(double x,           ///< Value at which to evaluate
     196psDPolynomial1DEval(double x,           ///< Value at which to evaluate
    190197                    const psDPolynomial1D *restrict myPoly ///< Coefficients for the polynomial
    191198                    );
     
    193200/** Evaluate 2D polynomial (double precision) */
    194201double
    195 psEvalDPolynomial2D(double x,           ///< Value x at which to evaluate
     202psDPolynomial2DEval(double x,           ///< Value x at which to evaluate
    196203                    double y,           ///< Value y at which to evaluate
    197204                    const psDPolynomial2D *restrict myPoly ///< Coefficients for the polynomial
     
    200207/** Evaluate 3D polynomial (double precision) */
    201208double
    202 psEvalDPolynomial3D(double x,           ///< Value x at which to evaluate
     209psDPolynomial3DEval(double x,           ///< Value x at which to evaluate
    203210                    double y,           ///< Value y at which to evaluate
    204211                    double z,           ///< Value z at which to evaluate
     
    208215/** Evaluate 4D polynomial (double precision) */
    209216double
    210 psEvalDPolynomial4D(double w,           ///< Value w at which to evaluate
     217psDPolynomial4DEval(double w,           ///< Value w at which to evaluate
    211218                    double x,           ///< Value x at which to evaluate
    212219                    double y,           ///< Value y at which to evaluate
  • trunk/archive/pslib/include/psImage.h

    r680 r753  
    1313    const int x0, y0;                   ///< data region relative to parent
    1414    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;
    2827    const struct psImage *parent;       ///< parent, if a subimage
    2928    int Nchildren;                      ///< number of subimages
     
    215214;
    216215
    217 /// Read only header from image file.
    218 psMetadata *
    219 psImageReadHeader(psMetadata *output,   ///< read data to this structure
    220                   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 from
    223 ;
    224 
    225 /// Read only header from image file descriptor.
    226 psMetadata *
    227 psImageFReadHeader(psMetadata *output,  ///< read data to this structure
    228                    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 from
    231 ;
    232 
    233216/*** basic pixel manipulations ***/
    234217/// Clip image values outside of range to given values.  Return number of clipped pixels.
     
    260243# endif
    261244/* 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   = '/',
    267250*/
  • trunk/archive/pslib/include/psLib.h

    r704 r753  
    4949
    5050/** @ingroup AstroGroup */
     51# include <psDateTime.h>
    5152# include <psPosition.h>
    52 # include <psDateTime.h>
    5353# include <psMetadata.h>
    5454# include <psImage.h>
  • trunk/archive/pslib/include/psLogMsg.h

    r602 r753  
    3030
    3131/// Logs a message from varargs
    32 void p_psLogVMsg(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
     32void 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
    3636;
    3737
  • trunk/archive/pslib/include/psMath.h

    r380 r753  
    1111    psType type;                        ///< data type information
    1212    union {                           
    13         int i;                          ///< integer value entry
    14         float f;                        ///< float value entry
    15         double d;                       ///< double value entry
    16         complex float c;                ///< complex value entry
    17     } 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;
    1818} p_psScalar;
    1919
     
    2828            void *in1,                  ///< first input
    2929            char *op,                   ///< operator
    30             void *in2                   ///< second input
    31     );
     30            void *in2)                  ///< second input
     31;
    3232
    3333/** Perform a unary operation on two data items (psImage, psVector, psScalar). */
     
    3535psUnaryOp (void *out,                   ///< destination (may be NULL)
    3636           void *in,                    ///< input
    37            char *op                     ///< operator
    38     );
     37           char *op)                    ///< operator
     38;
    3939
    4040/** create a psType-ed structure from a constant double value. */
     
    4545p_psScalar *
    4646psScalarType (char *mode,               ///< type description
    47               ...                       ///< value (or values) of specified types
    48     );
     47              ...)                      ///< value (or values) of specified types
     48;
    4949
    5050/* \} */ // End of MathGroup Functions
  • trunk/archive/pslib/include/psMatrix.h

    r610 r753  
    1919psMatrixInvert(psImage *out,            ///< Matrix to return, or NULL
    2020               const psImage *myMatrix, ///< Matrix to be inverted
    21                float *restrict determinant ///< Determinant to return, or NULL
    22     );
     21               float *restrict determinant) ///< Determinant to return, or NULL
     22;
    2323
    2424/** Matrix determinant */
    2525float
    26 psMatrixDeterminant(const psImage *restrict myMatrix ///< Matrix to get determinant for
    27                     );
     26psMatrixDeterminant(const psImage *restrict myMatrix) ///< Matrix to get determinant for
     27;
    2828
    2929/** Matrix operation: addition, subtraction, multiplication */
    3030psImage *
    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     );
     31psMatrixMultiply(psImage *out,          ///< Matrix to return, or NULL
     32                 const psImage *in1,    ///< Matrix 1
     33                 const psImage *in2)    ///< Matrix 2
     34;
    3635
    3736/** Transpose Matrix */
    3837psImage *
    3938psMatrixTranspose(psImage *out,         ///< Matrix to return, or NULL
    40                   const psImage *myMatrix ///< Matrix to transpose
    41                   );
     39                  const psImage *in)    ///< Matrix to transpose
     40;
    4241
    4342/** LU Decomposition of a matrix */
    4443psImage *
    4544psMatrixLUD(psImage *out,               ///< Matrix to return, or NULL
    46             psImage *myMatrix           ///< Matrix to decompose
    47             );
     45            psImage *in)                ///< Matrix to decompose
     46;
    4847
    4948/** LU Solution.  Solves for and returns x in the equation Ax = b */
    5049psVector *
    5150psMatrixLUSolve(psVector *out,          ///< Vector to return, or NULL
    52                 const psImage *luMatrix, ///< LU-decomposed matrix
    53                 const psVector *rhsVector ///< right-hand-side of the equation
    54                 );
     51                const psImage *LU,      ///< LU-decomposed matrix
     52                const psVector *RHS)    ///< right-hand-side of the equation
     53;
    5554
    5655/** Eigenvectors of a matrix */
    5756psVector *
    58 psMatrixEigenvectors(psImage *myMatrix  ///< Matrix to get eigenvectors for
    59     );
     57psMatrixEigenvectors(psImage *myMatrix) ///< Matrix to get eigenvectors for
     58;
    6059
    6160/***********************************************************************************************************/
     
    6665psVector *
    6766psMatrixToVector(psVector *out,         ///< Vector to return, or NULL
    68                  psImage *myMatrix      ///< Matrix to convert
    69     );
     67                 psImage *in)           ///< Matrix to convert
     68;
    7069
    7170/** Convert vector to matrix. */
    7271psImage *
    7372psVectorToMatrix(psImage *out,          ///< Matrix to return, or NULL
    74                  psVector *myVector     ///< Vector to convert
    75     );
     73                 psVector *in)          ///< Vector to convert
     74;
    7675
    7776/* \} */ // End of MathGroup Functions
  • trunk/archive/pslib/include/psMemory.h

    r396 r753  
    2626
    2727/// prototype of a basic callback used by memory functions
    28 typedef long (*psMemAllocateCB)(const psMemBlock *ptr);
     28typedef long (*psMemAllocateCallback)(const psMemBlock *ptr);
    2929
    3030/// prototype of memory free callback used by memory functions
    31 typedef long (*psMemFreeCB)(const psMemBlock *ptr);
     31typedef long (*psMemFreeCallback)(const psMemBlock *ptr);
    3232
    3333/// prototype of a callback used in error conditions
    34 typedef void (*psMemProblemCB)(const psMemBlock *ptr, const char *file, int lineno);
     34typedef void (*psMemProblemCallback)(const psMemBlock *ptr, const char *file, int lineno);
    3535
    3636/// prototype of a callback used when memory runs out
    37 typedef void *(*psMemExhaustedCB)(size_t size);
     37typedef void *(*psMemExhaustedCallback)(size_t size);
    3838
    3939/** Functions **************************************************************/
     
    8484
    8585/// Set callback for problems
    86 psMemProblemCB psMemProblemCBSet(psMemProblemCB func) ///< Function to run
     86psMemProblemCallback psMemProblemCallbackSet(psMemProblemCallback func) ///< Function to run
    8787;
    8888
    8989/// Set callback for out-of-memory
    90 psMemExhaustedCB psMemExhaustedCBSet(psMemExhaustedCB func) ///< Function to run
     90psMemExhaustedCallback psMemExhaustedCallbackSet(psMemExhaustedCallback func) ///< Function to run
    9191;
    9292
    9393/// Set call back for when a particular memory block is allocated
    94 psMemAllocateCB psMemAllocateCBSet(psMemAllocateCB func) ///< Function to run
     94psMemAllocateCallback psMemAllocateCallbackSet(psMemAllocateCallback func) ///< Function to run
    9595;
    9696
    9797/// Set call back for when a particular memory block is freed
    98 psMemFreeCB psMemFreeCBSet(psMemFreeCB func) ///< Function to run
     98psMemFreeCallback psMemFreeCallbackSet(psMemFreeCallback func) ///< Function to run
    9999;
    100100
  • trunk/archive/pslib/include/psMetadata.h

    r619 r753  
    1010typedef enum {                          ///< type of val is:
    1111    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)
    1415    PS_META_STR,                        ///< string (.v)
    1516    PS_META_IMG,                        ///< image (.v)
     
    3435    psMetadataType type;                ///< type of this item
    3536    psMetadataFlags flags;              ///< flags associated with this item
    36     const union {
    37         double d;                       ///< double value
    38         float f;                        ///< floating value
    39         int i;                          ///< integer value
    40         void *v;                        ///< other type
    41     } val;                              ///< value of metadata
     37    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
    4243    char *comment;                      ///< optional comment ("", not NULL)
    4344    psDlist *restrict items;            ///< list of psMetadataItems with the same name
     
    5657
    5758/** 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
     59psMetadataItem *psMetadataItemAlloc(const char *name, ///< name of new item of metadata (sprintf format)
     60                                    int format, ///< type of this piece of metadata + flags
    6161                                    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
     65psMetadataItem *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;
    7370
    7471/** Destructor */
    75 void psMetadataItemFree(psMetadataItem *ms ///< piece of metadata to destroy
    76     );
     72void psMetadataItemFree(psMetadataItem *ms) ///< piece of metadata to destroy
     73;
     74
    7775/** Constructor */
    78 psMetadata *psMetadataAlloc(void);   ///< make a new set of metadata
     76psMetadata *psMetadataAlloc(void)   ///< make a new set of metadata
     77;
    7978
    8079/** Destructor */
    81 void psMetadataFree(psMetadata *md ///< destroy a set of metadata
    82     );
     80void psMetadataFree(psMetadata *md) ///< destroy a set of metadata
     81;
    8382
    8483/**** Utilities **********************************************************************/
     
    8685/// Add item to the end of the metadata
    8786psMetadataItem *psMetadataAppendItem(psMetadata *restrict md, ///< metadata to add to
    88                                      psMetadataItem *restrict item ///< Metatdata item to add
    89     );
     87                                     psMetadataItem *restrict item) ///< Metatdata item to add
     88;
    9089
    9190/// Add item to the end of the metadata.  Combines psMetadataItemAlloc and psMetadataAppendItem
    9291psMetadataItem *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
    9694                                 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;
    10197
    10298/// delete item from the metadata
     
    125121                         const char *prefix        ///< print this at the beginning of each line
    126122    );
     123
     124/// Read only header from image file.
     125psMetadata *
     126psMetadataReadHeader(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.
     133psMetadata *
     134psMetadataFReadHeader(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
    127140/* \} */ // End of AstroGroup Functions
    128141#endif
  • trunk/archive/pslib/include/psMinimize.h

    r671 r753  
    1515psVector *
    1616psMinimize(psVector *restrict initialGuess, ///< Initial guess and answer
    17            float (*myFunction)(const psVector *restrict), ///< Function to minimize
    18            float (*myFuncDeriv)(const psVector *restrict), ///< Derivatives of function, or NULL
     17           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
    1919           const psVector *restrict paramMask) ///< 1 = fit for parameter, 0 = hold parameter constant
    2020;
     
    2424psVector *
    2525psMinimizeChi2(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)
    2827               const psVector *restrict domain, ///< The domain values for the corresponding measurements
    2928               const psVector *restrict data, ///< Data to fit
    3029               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
    3232;
    3333
     
    3535psPolynomial1D *
    3636psVectorFitPolynomial(psPolynomial1D myPoly, ///< Polynomial to fit
    37                      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
     37                      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
    4040;
    4141
  • trunk/archive/pslib/include/psPosition.h

    r710 r753  
    88
    99/** Structures *********************/
     10
     11/** projection types */
     12typedef 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;
    1020
    1121/** A point in 2-D space, with errors. */
     
    1525    double xErr;                        ///< Error in x position
    1626    double yErr;                        ///< Error in y position
    17 } psPlaneCoord;
     27} psPlane;
    1828
    1929/** A point on the surface of a sphere, with errors */
     
    2333    double rErr;                        ///< Error in RA
    2434    double dErr;                        ///< Error in Dec
    25 } psSphereCoord;
     35} psSphere;
    2636
    2737/** A polynomial transformation between coordinate frames.  This may be a linear relationship, or may
     
    3141    psDPolynomial2D *x;
    3242    psDPolynomial2D *y;
    33 } psPlaneCoordXform;
     43} psPlaneTransform;
    3444
    3545/** The optical distortion terms.  The lowest two terms are the x and y axis of the target system.  The higher
     
    3949    psDPolynomial4D *x;
    4050    psDPolynomial4D *y;
    41 } psPlaneDistortion;
     51} psPlaneDistort;
     52
     53/** General spherical transformation */
     54typedef 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 */
     64typedef 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;
    4269
    4370/** Functions **************************************************************/
     
    4774
    4875/** apply the coordinate transformation to the given coordinate */
    49 psPlaneCoord *psPlaneCoordXformApply (psPlaneCoord *out, ///< Output coordinates, or NULL
    50                                       const psPlaneCoordXform *frame, ///< coordinate transformation
    51                                       const psPlaneCoord *coords ///< input coordiate
    52     );
     76psPlane *psPlaneTransformApply (psPlane *out, ///< Output coordinates, or NULL
     77                                const psPlaneTransform *frame, ///< coordinate transformation
     78                                const psPlane *coords) ///< input coordiate
     79;
    5380
    5481/** 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     );
     82psPlane *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 */
     92psSphereTransform *
     93psSphereTransformAlloc(double pole1, ///< First location of pole
     94                       double pole2, ///< Second location of pole
     95                       double rotation) ///< Rotation between systems
     96;
     97
     98/** Destructor */
     99void psSphereTransformFree(psSphereTransform *trans) ///< Transform to destroy
     100;
     101
     102/** Apply general spherical transformation */
     103psSphere *
     104psSphereTransformApply(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 */
     109psSphereTransform *psSphereTransformItoE(void);
     110
     111/** Return transformation structure to convert Ecliptic to ICRS */
     112psSphereTransform *psSphereTransformEtoI(void);
     113
     114/** Return transformation structure to convert ICRS to Galactic */
     115psSphereTransform *psSphereTransformItoG(void);
     116
     117/** Return transformation structure to convert Galactic to ICRS */
     118psSphereTransform *psSphereTransformGtoI(void);
     119
     120/***********************************************************************************************************/
     121
     122
     123/** Project spherical system onto a plane */
     124psPlane *
     125psCoordProject(const psSphere *coord, ///< Spherical coordinates to project
     126               const psProjection *projection)  ///< Projection to use
     127;
     128
     129/** Deproject plane onto spherical system */
     130psSphere *
     131psCoordDeproject(const psPlane *coord, ///< Plane coordinates to deproject
     132                 const psProjection *projection)        ///< Projection to use
     133;
    61134
    62135/** 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     );
     136psSphere *
     137psSphereGetOffset(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;
    69141
    70142/** 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     );
     143psSphere *
     144psSphereApplyOffset(const psSphere *restrict position, ///< Position
     145                    const psSphere *restrict offset, ///< Offset
     146                    const char *type)   ///< Type of offset: Spherical/Arcsec, Spherical/Degreees etc
     147;
    77148
    78149/* Positions of well-known objects */
    79150
    80151/** 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     );
     152psSphere *
     153psSunGetPos(psTime time)                ///< MJD to get position for
     154;
     155
     156/** Get Sun Rise time */
     157psSphere *
     158psSunGetRise(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 */
     164psSphere *
     165psSunGetSet(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 */
     171float
     172psNightLength(psTime time)              ///< MJD to get position for
     173;
     174
     175/** Get Moon Position */
     176psSphere *
     177psMoonGetPos(psTime time)               ///< MJD to get position for
     178;
     179
     180/** Get Moon Rise time */
     181psSphere *
     182psMoonGetRise(psTime time)              ///< get rise closest to this time
     183;
     184
     185/** Get Moon Set time */
     186psSphere *
     187psMoonGetSet(psTime time)               ///< get set closest to this time
     188;
    91189
    92190/** Get Moon phase */
    93191float
    94 psGetMoonPhase(float mjd                ///< MJD to get phase for
    95     );
     192psMoonGetPhase(psTime time)             ///< MJD to get phase for
     193;
    96194
    97195/** Get Planet positions */
    98 psSphereCoord *
    99 psGetSolarSystemPos(const char *solarSystemObject, ///< Named S.S. object
    100                     float mjd           ///< MJD to get position for
    101     );
     196psSphere *
     197psPlanetGetPos(const char *solarSystemObject, ///< Named S.S. object
     198               psTime time)             ///< MJD to get position for
     199;
    102200
    103201/***********************************************************************************************************/
    104202
    105 /* Celestial coordinate conversions */
    106 
    107 /** General spherical transformation */
    108 typedef struct {
    109     double sin1, sin2, sin3, cos1, cos2, cos3; ///< Sines and cosines for transformation
    110 } psSphereCoordTransformation;
    111 
    112 /** Constructor */
    113 psSphereCoordTransformation *
    114 psSphereCoordTransformationAlloc(double pole1, ///< First location of pole
    115                                  double pole2, ///< Second location of pole
    116                                  double rotation ///< Rotation between systems
    117     );
    118 
    119 /** Destructor */
    120 void psSphereCoordTranformationFree(psSphereCoordTransformation *trans ///< Transformation to destroy
    121     );
    122 
    123 /** Apply general spherical transformation */
    124 psSphereCoord *
    125 psSphereCoordTransform(const psSphereCoord *coord, ///< Coordinates to convert
    126                        const psSphereCoordTransformation *sys ///< System to use to convert
    127     );
    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 project
    147                const char *projection   ///< Projection to use
    148     );
    149 
    150 /** Deproject plane onto spherical system */
    151 psSphereCoord *
    152 psCoordDeproject(const psPlaneCoord *coord, ///< Plane coordinates to deproject
    153                  const char *projection ///< Projection to use
    154     );
    155 
    156203/* \} */ // End of AstroGroup Functions
    157204
  • trunk/archive/pslib/include/psStats.h

    r671 r753  
    1212    PS_STAT_SAMPLE_MEDIAN         = 0x000002,
    1313    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
    3227} psStatsOptions;                         
    3328
    3429/** generic statistics structure */
    3530typedef struct {
    36     double sampleMean;                  ///< formal mean of sample
    37     double sampleMedian;                ///< formal median of sample
    38     double sampleStdev;                 ///< standard deviation of sample
    39     double sampleUQ;                    ///< upper quartile of sample
    40     double sampleLQ;                    ///< lower quartile of sample
    41     double robustMean;                  ///< robust mean of data
    42     int    robustMeanNvalues;           ///< number of measurements used for robust mean
    43     double robustMedian;                ///< robust median of data
    44     int    robustMedianNvalues;         ///< number of measurements used for robust median
    45     double robustMode;                  ///< Robust mode of data
    46     int    robustModeNvalues;           ///< Number of measurements used for robust mode
    47     double robustStdev;                 ///< robust standard deviation of data
    48     double robustUQ;                    ///< robust upper quartile
    49     double robustLQ;                    ///< robust lower quartile
    50     double clippedMean;                 ///< Nsigma clipped mean
    51     int    clippedMeanNvalues;          ///< number of data points used for clipped mean
    52     double clippedStdev;                ///< standard deviation after clipping
    53     double clipSigma;                   ///< Nsigma used for clipping; user input
    54     int    clipIter;                    ///< Number of clipping iterations; user input
    55     double min;                         ///< minimum data value in data
    56     double max;                         ///< maximum data value in data
    57     int    nValues;                     ///< number of data values in data
    58     psStatsOptions options;             ///< bitmask of calculated values
     31    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
    5954} psStats;
    6055
     
    8580    const psVector *restrict bounds;    ///< Bounds for the bins
    8681    psVector *nums;                     ///< Number in each of the bins
    87     const float minVal, maxVal;         ///< Minimum and maximum values
    8882    int minNum, maxNum;                 ///< Number below the minimum and above the maximum
    8983    int uniform;                        ///< Is it a uniform distribution?
     
    9993/** Generic constructor \ingroup MathGroup */
    10094psHistogram *
    101 psHistogramAllocGeneric(const psVector *restrict bounds, ///< Bounds for the bins
    102                         float minVal,   ///< Minimum value
    103                         float maxVal)   ///< Maximum value
     95psHistogramAllocGeneric(const psVector *restrict bounds) ///< Bounds for the bins
    10496;
    10597
     
    112104/** Calculate a histogram \ingroup MathGroup **/
    113105psHistogram *
    114 psVectorHistogram(psHistogram *restrict myHist, ///< Histogram data
     106psHistogramVector(psHistogram *restrict myHist, ///< Histogram data
    115107                  const psVector *restrict myArray) ///< Array to analyse
    116108;
  • trunk/archive/pslib/include/psVector.h

    r704 r753  
    1111    psType type;                        ///< vector data type and dimension
    1212    const int n;                        ///< size of vector
    13     const int nalloc;                   ///< data region relative to parent
     13    const int nalloc;                   ///< allocated data block
    1414    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;
    2928} psVector;
    3029
  • trunk/archive/pslib/src/Metadata/metadata.c

    r707 r753  
    4747 */
    4848psMetadataItem *psMetadataItemAlloc(
    49     int typeFlags,                      // type of this piece of metadata + flags
    50     const void *data,                   // value of new item
     49    const char *name,                   // name of new item of metadata (may be an sprintf format)
     50    int format,                         // type of this piece of metadata + flags
    5151    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
     64psMetadataItem *psMetadataItemAllocV(
    5265    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
    6967    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
    7672    static int id = 0;                  // unique ID for an item of metadata
    7773    psMetadataItem *ms = psAlloc(sizeof(psMetadataItem));
     
    9490    ms->items = NULL;
    9591
    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't
    99 
    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 
    11092    assert (type >= 0 && type < PS_META_NTYPE);
    11193    switch (type) {
    11294      case PS_META_ITEM_SET:
    113         *(void **)&ms->val.v = NULL;
     95        ms->data.V = NULL;
    11496        ms->items = psDlistAlloc(NULL);
    11597        break;
    11698
    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);
    123106        break;
    124107       
    125108      case PS_META_STR:
    126         *(void **)&ms->val.v = psStringCopy(data);
     109        ms->data.V = psStringCopy(va_arg(ap, char *));
    127110        break;
    128111       
     
    132115      case PS_META_ASTROM:
    133116      case PS_META_UNKNOWN:
    134         *(void **)&ms->val.v = (void *)data;
     117        ms->data.V = va_arg(ap, void *);
    135118        break;
    136119
     
    139122        break;                          // NOTREACHED
    140123    }
     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);
    141138
    142139    return ms;
     
    159156        break;
    160157       
    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:
    163161        break;                          // nothing to do
    164162       
    165163      case PS_META_STR:
    166         psFree(ms->val.v);
     164        psFree(ms->data.V);
    167165        break;
    168166       
     
    198196        psMetadataItem *head = meta;
    199197        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);
    201199        }           
    202200
     
    224222        return item;
    225223    } else if (meta != NULL) {
    226         psError(__func__, PS_ERR_UNKNOWN, PS_NEW_ERROR,
     224        psError(__func__, PS_ERR_UNKNOWN, 1,
    227225                "Key \"%s\" is already present in the metaDataSet 0x%x", item->name, ms);
    228226        psMetadataItemFree(item);
     
    242240 */
    243241psMetadataItem *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
    252246{
    253247    va_list ap;
    254     va_start(ap, name);
    255 
    256     psMetadataItem *mi = psVMetadataItemAlloc(typeFlags, val, comment, name, ap);
     248    va_start(ap, comment);
     249
     250    psMetadataItem *mi = psMetadataItemAllocV(name, format, comment, ap);
    257251
    258252    va_end(ap);
     
    363357        break;
    364358       
    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);
    371366        break;
    372367       
    373368      case PS_META_STR:
    374         fprintf(fd, "%s\n", (char *)ms->val.v);
     369        fprintf(fd, "%s\n", (char *)ms->data.V);
    375370        break;
    376371       
  • trunk/archive/pslib/src/Utils/Makefile

    r707 r753  
    22CFLAGS = -Wall -g -I$(PSLIB_DIR)/include -I$(FFTW_DIR)/include
    33DYLIB = dylib
    4 DYLIB_LDFLAGS = "-undefined suppress -flat_namespace -dynamiclib";
     4DYLIB_LDFLAGS = -undefined suppress -flat_namespace -dynamiclib -shared
    55
    66PSLIB_DIR = ../..
  • trunk/archive/pslib/src/Utils/dlist.c

    r707 r753  
    317317    psDlistElem *ptr = dlist->head;
    318318    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;
    321320        ptr->data = NULL;
    322321        ptr = ptr->next;
     
    339338    for (int i = 0, n = arr->n; i < n; i++) {
    340339        psDlistAppend(list,
    341                       psMemDecrRefCounter(arr->arr.arr_v[i])); // it\'s already Incr
    342         arr->arr.arr_v[i] = NULL;
     340                      psMemDecrRefCounter(arr->data.V[i])); // it\'s already Incr
     341        arr->data.V[i] = NULL;
    343342    }
    344343
  • trunk/archive/pslib/src/Utils/error.c

    r707 r753  
    7676int psError(const char *name,           // category of code that caused the error
    7777            psErrorCode code,           // code of error (equivalent to errno)
    78             psErrorStatus status,       // is this a new error?
     78            int new,                    // is this a new error?
    7979            const char *fmt, ...)       // format and possible extra arguments
    8080{
    81     if (code == PS_ERR_NONE || status == PS_NEW_ERROR) { // free old error stack
     81    if (code == PS_ERR_NONE || new) { // free old error stack
    8282        errStack *eptr = errorStack;
    8383
     
    9999       
    100100        va_start(ap, fmt);
    101         p_psLogVMsg(name, PS_LOG_ERROR, fmt, ap);
     101        psLogMsgV(name, PS_LOG_ERROR, fmt, ap);
    102102        va_end(ap);
    103103    }
     
    210210    }
    211211
    212     psErrorVStackPrint(fd, fmt, ap);
     212    psErrorStackPrintV(fd, fmt, ap);
    213213
    214214    if (fmt != NULL) {
     
    217217}
    218218
    219 void psErrorVStackPrint(FILE *fd,       // write to this file descriptor
     219void psErrorStackPrintV(FILE *fd,       // write to this file descriptor
    220220                        const char *fmt,// format for any header information; may be NULL
    221221                        va_list ap)     // arguments for format
  • trunk/archive/pslib/src/Utils/logmsg.c

    r707 r753  
    110110#endif
    111111
    112 void p_psLogVMsg(const char *name, int level, const char *fmt, va_list ap)
     112void psLogMsgV(const char *name, int level, const char *fmt, va_list ap)
    113113{
    114114    static int first = 1;
     
    224224    va_start(ap, fmt);
    225225
    226     p_psLogVMsg(name, level, fmt, ap);
     226    psLogVMsg(name, level, fmt, ap);
    227227    va_end(ap);
    228228}
  • trunk/archive/pslib/src/Utils/memory.c

    r687 r753  
    4848 * First the I-can't-get-the-memory callback
    4949 */
    50 static void *memExhaustedCB0(size_t size)
     50static void *memExhaustedCallback0(size_t size)
    5151{
    5252    return NULL;
    5353}
    54 static psMemExhaustedCB memExhaustedCB = memExhaustedCB0;
    55 
    56 psMemExhaustedCB psMemExhaustedCBSet(psMemExhaustedCB func)
    57 {
    58     psMemExhaustedCB old = memExhaustedCB;
    59 
    60     memExhaustedCB = (func != NULL) ? func : memExhaustedCB0;
     54static psMemExhaustedCallback memExhaustedCallback = memExhaustedCallback0;
     55
     56psMemExhaustedCallback psMemExhaustedCallbackSet(psMemExhaustedCallback func)
     57{
     58    psMemExhaustedCallback old = memExhaustedCallback;
     59
     60    memExhaustedCallback = (func != NULL) ? func : memExhaustedCallback0;
    6161
    6262    return old;
     
    6565 * then the I-have-detected-a-problem callback
    6666 */
    67 static void memProblemCB0(const psMemBlock *ptr,
     67static void memProblemCallback0(const psMemBlock *ptr,
    6868                          const char *file, int lineno)
    6969{
     
    7676        fprintf(stderr, "\n");
    7777    } else if (ptr->refCounter <= 0) {
    78         psError(__func__, PS_ERR_BADFREE, PS_NEW_ERROR,
     78        psError(__func__, PS_ERR_BADFREE, 1,
    7979                "Block %ld allocated at %s:%d freed more than once at %s:%d\n",
    8080                ptr->id, ptr->file, ptr->lineno, file, lineno);
    8181    } else if (ptr->refCounter > 1) {
    82         psError(__func__,  PS_ERR_BADFREE, PS_NEW_ERROR,
     82        psError(__func__,  PS_ERR_BADFREE, 1,
    8383                "Block %ld allocated at %s:%d freed while still referenced at %s:%d\n",
    8484                ptr->id, ptr->file, ptr->lineno, file, lineno);
     
    8989    }
    9090}
    91 static psMemProblemCB memProblemCB = memProblemCB0;
    92 
    93 psMemProblemCB psMemProblemCBSet(psMemProblemCB func)
    94 {
    95     psMemProblemCB old = memProblemCB;
    96 
    97     memProblemCB = (func != NULL) ? func : memProblemCB0;
     91static psMemProblemCallback memProblemCallback = memProblemCallback0;
     92
     93psMemProblemCallback psMemProblemCallbackSet(psMemProblemCallback func)
     94{
     95    psMemProblemCallback old = memProblemCallback;
     96
     97    memProblemCallback = (func != NULL) ? func : memProblemCallback0;
    9898
    9999    return old;
     
    129129 * isn't resignalled)
    130130 */
    131 static long memAllocateCB0(const psMemBlock *ptr)
     131static long memAllocateCallback0(const psMemBlock *ptr)
    132132{
    133133    static int incr = 0;                // "p_psMemAllocateID += incr"
     
    138138}
    139139
    140 static long memFreeCB0(const psMemBlock *ptr)
     140static long memFreeCallback0(const psMemBlock *ptr)
    141141{
    142142    static int incr = 0;                // "p_psMemFreeID += incr"
     
    150150 * The default callbacks, and the routines to change them
    151151 */
    152 static psMemAllocateCB memAllocateCB = memAllocateCB0;
    153 static psMemFreeCB memFreeCB = memFreeCB0;
    154 
    155 psMemAllocateCB psMemAllocateCBSet(psMemAllocateCB func)
    156 {
    157     psMemAllocateCB old = memAllocateCB;
    158 
    159     memAllocateCB = (func != NULL) ? func : memAllocateCB0;
    160 
    161     return old;
    162 }
    163 
    164 psMemFreeCB psMemFreeCBSet(psMemFreeCB func)
    165 {
    166     psMemFreeCB old = memFreeCB;
    167 
    168     memFreeCB = (func != NULL) ? func : memFreeCB0;
     152static psMemAllocateCallback memAllocateCallback = memAllocateCallback0;
     153static psMemFreeCallback memFreeCallback = memFreeCallback0;
     154
     155psMemAllocateCallback psMemAllocateCallbackSet(psMemAllocateCallback func)
     156{
     157    psMemAllocateCallback old = memAllocateCallback;
     158
     159    memAllocateCallback = (func != NULL) ? func : memAllocateCallback0;
     160
     161    return old;
     162}
     163
     164psMemFreeCallback psMemFreeCallbackSet(psMemFreeCallback func)
     165{
     166    psMemFreeCallback old = memFreeCallback;
     167
     168    memFreeCallback = (func != NULL) ? func : memFreeCallback0;
    169169
    170170    return old;
     
    194194    if (m == NULL) {
    195195        if (!quiet) {
    196             psError(__func__,  PS_ERR_MEMORY_CORRUPTION, PS_NEW_ERROR,
     196            psError(__func__,  PS_ERR_MEMORY_CORRUPTION, 1,
    197197                    "psMemCheckCorruption: NULL memory block\n");
    198198        }
     
    202202    if (!ALIGNED(m)) {
    203203        if (!quiet) {
    204             psError(__func__,  PS_ERR_MEMORY_CORRUPTION, PS_NEW_ERROR,
     204            psError(__func__,  PS_ERR_MEMORY_CORRUPTION, 1,
    205205                    "psMemCheckCorruption: non-aligned memory block\n");
    206206        }
     
    210210    if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
    211211        if (!quiet) {
    212             psError(__func__, PS_ERR_MEMORY_CORRUPTION, PS_NEW_ERROR,
     212            psError(__func__, PS_ERR_MEMORY_CORRUPTION, 1,
    213213                    "psMemCheckCorruption: memory block %ld is corrupted\n", m->id);
    214214        }
     
    232232                nbad++;
    233233
    234                 memProblemCB(memBlocks[i], "(psMemCheckCorruption)", 0);
     234                memProblemCallback(memBlocks[i], "(psMemCheckCorruption)", 0);
    235235               
    236236                if (abort_on_error) {
     
    251251
    252252    if (ptr == NULL) {
    253         ptr = memExhaustedCB(size);
     253        ptr = memExhaustedCallback(size);
    254254        if (ptr == NULL) {
    255255            psAbort(__func__, "Failed to allocate %ld bytes at %s:%d",
     
    270270   
    271271    if (ptr->id == p_psMemAllocateID && p_psMemAllocateID > 0) {
    272         p_psMemAllocateID += memAllocateCB(ptr);       
     272        p_psMemAllocateID += memAllocateCallback(ptr); 
    273273    }
    274274    /*
     
    310310     */
    311311    if (ptr->id == p_psMemFreeID && p_psMemFreeID > 0) {
    312         p_psMemFreeID += memFreeCB(ptr);       
     312        p_psMemFreeID += memFreeCallback(ptr); 
    313313    }
    314314
    315315    if (bad_memblock(ptr, 0)) {
    316         memProblemCB(ptr, file, lineno); // we may not own this block; don't free it
     316        memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it
    317317    } else {
    318318        if (ptr->refCounter != 1) {
    319             memProblemCB(ptr, file, lineno);
     319            memProblemCallback(ptr, file, lineno);
    320320        }
    321321        ptr->refCounter--;
     
    396396
    397397    if (bad_memblock(ptr, 0)) {
    398         memProblemCB(ptr, "(psMemGetRefCounter)", -1);
     398        memProblemCallback(ptr, "(psMemGetRefCounter)", -1);
    399399    }
    400400
     
    411411
    412412    if (bad_memblock(ptr, 0)) {
    413         memProblemCB(ptr, "(psMemIncrRefCounter)", -1);
     413        memProblemCallback(ptr, "(psMemIncrRefCounter)", -1);
    414414    }
    415415
     
    428428
    429429    if (bad_memblock(ptr, 0)) {
    430         memProblemCB(ptr, "(psMemDecrRefCounter)", -1);
     430        memProblemCallback(ptr, "(psMemDecrRefCounter)", -1);
    431431    }
    432432
  • trunk/archive/pslib/src/Utils/misc.c

    r707 r753  
    2929
    3030    va_start(ap, fmt);
    31     p_psLogVMsg(name, PS_LOG_ABORT, fmt, ap);
     31    psLogMsgV(name, PS_LOG_ABORT, fmt, ap);
    3232    va_end(ap);
    3333   
  • trunk/archive/pslib/src/Utils/vector.c

    r709 r753  
    1616
    1717   *(int *)&vec->n = *(int *)&vec->nalloc = nalloc;
    18    vec->arr.arr_v = psAlloc(nalloc*sizeof(void **));
     18   vec->data.V = psAlloc(nalloc*sizeof(void **));
    1919
    2020   return vec;
     
    3434
    3535   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 */
    3737      const int n = vec->nalloc;
    3838      for (int i = 0; i < n; i++) {
    39          elemFree(vec->arr.arr_v[i]);
     39         elemFree(vec->data.V[i]);
    4040      }
    4141   }
    4242
    43    psFree(vec->arr.arr_v);
     43   psFree(vec->data.V);
    4444   psFree(vec);
    4545}
Note: See TracChangeset for help on using the changeset viewer.