IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 13, 2006, 8:24:10 PM (21 years ago)
Author:
eugene
Message:

substantial work on the aperture residuals

File:
1 edited

Legend:

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

    r5837 r5980  
    11# include "psphot.h"
     2bool apResidSetPower (float value);
     3
     4void psExit (int status, char *process, char *format, ...) {
     5
     6    va_list ap;
     7
     8    va_start (ap, format);
     9    fprintf (stderr, "exiting %s\n", process);
     10    vfprintf (stderr, format, ap);
     11    va_end (ap);
     12
     13    exit (status);
     14}
    215
    316int main (int argc, char **argv) {
    417
    5     char line[80];
    6     psImage *image;
     18    // read in a file consisting of:
     19    // x y radius fitmag apmag dmag
    720
    8     image = psImageAlloc (512, 512, PS_DATA_F32);
    9     for (int j = 0; j < 512; j++) {
    10         for (int i = 0; i < 512; i++) {
    11             image->data.F32[j][i] = i;
    12         }
     21    double fit;
     22    double ap;
     23
     24    psphotTestArguments (&argc, argv);
     25
     26    FILE *f = fopen (argv[1], "r");
     27    if (f == NULL) psExit (2, "test", "no file\n");
     28
     29    float power = atof (argv[2]);
     30    apResidSetPower (power);
     31
     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);
     38
     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) {
     46
     47        if (fabs(ap-fit) > 0.1) continue;
     48        if (fit > -10) continue;
     49
     50        apres->data.F64[Npt] = ap-fit;
     51        rflux->data.F64[Npt] = pow(10.0, 0.4*fit);
     52
     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 ++;
    1360    }
     61    x->n = y->n = rad->n = rflux->n = apres->n = dmag->n = Npt;
    1462
    15     psMetadata *row = NULL;
    16 
    17     psArray *table = psArrayAlloc (100);
    18     table->n = 0;
    19    
    20     for (int i = 0; i < 100; i++) {
    21         row = psMetadataAlloc ();
    22         sprintf (line, "line %03d", i);
    23         psMetadataAdd (row, PS_LIST_HEAD, "FLOAT_DATA", PS_DATA_F32,    "", 0.2*i);
    24         psMetadataAdd (row, PS_LIST_HEAD, "INT_DATA",   PS_DATA_S32,    "", i);
    25         psMetadataAdd (row, PS_LIST_HEAD, "CHAR_DATA",  PS_DATA_STRING, "", line);
    26         psArrayAdd (table, 100, row);
    27         // psFree (row);
    28     }
    29 
    30     psFits *fits = psFitsOpen ("test.fits", "w");
    31     psFitsWriteImage (fits, NULL, image, 0);
    32     psFitsWriteTable (fits, NULL, table);
    33     psFitsClose (fits);
     63    psphotApResidPolyFit (x, y, rad, rflux, apres, dmag);
    3464
    3565    exit (0);
Note: See TracChangeset for help on using the changeset viewer.