IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 15, 2006, 8:30:16 AM (21 years ago)
Author:
eugene
Message:

API cleanup, removed old test files, some re-organization, changed FLT/GAL to EXT

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotTest.c

    r5980 r5993  
    11# include "psphot.h"
    2 bool apResidSetPower (float value);
    32
    43void psExit (int status, char *process, char *format, ...) {
     
    1615int main (int argc, char **argv) {
    1716
    18     // read in a file consisting of:
    19     // x y radius fitmag apmag dmag
     17    psMetadata *row;
     18    psArray *table;
    2019
    21     double fit;
    22     double ap;
     20    psMetadataItem *mdi;
     21    psRegion region = {0,0,0,0};        // a region representing the entire array
    2322
    2423    psphotTestArguments (&argc, argv);
    2524
    26     FILE *f = fopen (argv[1], "r");
    27     if (f == NULL) psExit (2, "test", "no file\n");
     25    psFits *file = psFitsOpen (argv[1], "r");
     26    psMetadata *header = psFitsReadHeader (NULL, file);
     27    psImage *image = psFitsReadImage (NULL, file, region, 0);
     28    psFitsClose (file);
    2829
    29     float power = atof (argv[2]);
    30     apResidSetPower (power);
     30    psMetadataConfigWrite (header, argv[2]);
    3131
    32     psVector *x     = psVectorAlloc (100, PS_TYPE_F64);
    33     psVector *y     = psVectorAlloc (100, PS_TYPE_F64);
    34     psVector *rad   = psVectorAlloc (100, PS_TYPE_F64);
    35     psVector *rflux = psVectorAlloc (100, PS_TYPE_F64);
    36     psVector *apres = psVectorAlloc (100, PS_TYPE_F64);
    37     psVector *dmag  = psVectorAlloc (100, PS_TYPE_F64);
     32    // attempt to write image with NAXIS = 0
     33    mdi = psMetadataLookup (header, "NAXIS");
     34    mdi->data.S32 = 0;
     35    mdi->type = PS_DATA_S32;
     36   
     37    // create a test image
     38    // psImage *tmpimage = psImageAlloc (10, 10, PS_DATA_F32);
    3839
    39     int Npt = 0;
    40     while (fscanf (f, "%lf %lf %lf %lf %lf %lf",
    41                    &x->data.F64[Npt],
    42                    &y->data.F64[Npt],
    43                    &rad->data.F64[Npt],
    44                    &fit, &ap,
    45                    &dmag->data.F64[Npt]) != EOF) {
     40    // create a test table
     41    table = psArrayAlloc (10);
     42    table->n = 0;
    4643
    47         if (fabs(ap-fit) > 0.1) continue;
    48         if (fit > -10) continue;
     44    for (int i = 0; i < 10; i++) {
     45        row = psMetadataAlloc ();
     46        psMetadataAdd (row, PS_LIST_TAIL, "ROW",   PS_DATA_S32,    "", i);
     47        psMetadataAdd (row, PS_LIST_TAIL, "FROW",  PS_TYPE_F32,    "", 0.1*i);
     48        psMetadataAdd (row, PS_LIST_TAIL, "DUMMY", PS_DATA_STRING, "", "test line");
     49   
     50        table->data[i] = row;
     51    }
     52    table->n = 10;
     53   
     54    psMetadata *theader = psMetadataAlloc ();
     55    psMetadataAdd (theader, PS_LIST_HEAD, "EXTNAME", PS_DATA_STRING, "extension name", "SMPFILE");
    4956
    50         apres->data.F64[Npt] = ap-fit;
    51         rflux->data.F64[Npt] = pow(10.0, 0.4*fit);
     57    psFits *fits = psFitsOpen (argv[3], "w");
     58    // psFitsWriteImage (fits, header, tmpimage, 0);
     59    psFitsWriteHeader (header, fits);
     60    psFitsWriteTable (fits, theader, table);
     61    psFitsClose (fits);
    5262
    53         psVectorExtend (x,     100, 1);
    54         psVectorExtend (y,     100, 1);
    55         psVectorExtend (rad,   100, 1);
    56         psVectorExtend (rflux, 100, 1);
    57         psVectorExtend (apres, 100, 1);
    58         psVectorExtend (dmag,  100, 1);
    59         Npt ++;
    60     }
    61     x->n = y->n = rad->n = rflux->n = apres->n = dmag->n = Npt;
    62 
    63     psphotApResidPolyFit (x, y, rad, rflux, apres, dmag);
    64 
     63    psFree (header);
     64    psFree (image);
    6565    exit (0);
    6666}
Note: See TracChangeset for help on using the changeset viewer.