IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 24, 2006, 1:58:13 PM (20 years ago)
Author:
Paul Price
Message:

Changed definition of psArrayAlloc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroChooseRefstars.c

    r9627 r9732  
    1111    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, "PSASTRO");
    1212    if (!recipe) {
    13         psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n");
    14         return false;
     13        psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n");
     14        return false;
    1515    }
    1616
     
    1818    pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
    1919    if (!input) {
    20         psError(PSASTRO_ERR_CONFIG, true, "Can't find input data!\n");
    21         return false;
     20        psError(PSASTRO_ERR_CONFIG, true, "Can't find input data!\n");
     21        return false;
    2222    }
    2323
    24     float fieldExtra = psMetadataLookupS32 (&status, recipe, "PSASTRO.FIELD.EXTRA"); 
     24    float fieldExtra = psMetadataLookupS32 (&status, recipe, "PSASTRO.FIELD.EXTRA");
    2525    if (!status) fieldExtra = 0.0;
    2626
     
    3232        psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    3333        if (!chip->process || !chip->file_exists) { continue; }
    34        
    35         while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
     34
     35        while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
    3636            psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    3737            if (!cell->process || !cell->file_exists) { continue; }
    3838
    39             // process each of the readouts
    40             // XXX there can only be one readout per chip in astrometry, right?
    41             while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
    42                 if (! readout->data_exists) { continue; }
     39            // process each of the readouts
     40            // XXX there can only be one readout per chip in astrometry, right?
     41            while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
     42                if (! readout->data_exists) { continue; }
    4343
    44                 // read WCS data from the corresponding header
    45                 pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
     44                // read WCS data from the corresponding header
     45                pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
    4646
    47                 int Nx = psMetadataLookupS32 (&status, hdu->header, "NAXIS1");
    48                 int Ny = psMetadataLookupS32 (&status, hdu->header, "NAXIS2");
     47                int Nx = psMetadataLookupS32 (&status, hdu->header, "NAXIS1");
     48                int Ny = psMetadataLookupS32 (&status, hdu->header, "NAXIS2");
    4949
    50                 float minX = -fieldExtra*Nx;
    51                 float maxX = (1+fieldExtra)*Nx;
    52                 float minY = -fieldExtra*Ny;
    53                 float maxY = (1+fieldExtra)*Ny;
     50                float minX = -fieldExtra*Nx;
     51                float maxX = (1+fieldExtra)*Nx;
     52                float minY = -fieldExtra*Ny;
     53                float maxY = (1+fieldExtra)*Ny;
    5454
    55                 // the refstars is a subset within range of this chip
    56                 psArray *refstars = psArrayAlloc (100);
     55                // the refstars is a subset within range of this chip
     56                psArray *refstars = psArrayAllocEmpty (100);
    5757
    58                 // select the reference objects within range of this readout
    59                 // project the reference objects to this chip
    60                 for (int i = 0; i < refs->n; i++) {
    61                     pmAstromObj *ref = pmAstromObjCopy(refs->data[i]);
    62        
    63                     // XXX why is this still a private function?
    64                     p_psProject (ref->TP, ref->sky, fpa->projection);
    65                     psPlaneDistortApply (ref->FP, fpa->fromTangentPlane, ref->TP, 0.0, 0.0);
    66                     psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP);
     58                // select the reference objects within range of this readout
     59                // project the reference objects to this chip
     60                for (int i = 0; i < refs->n; i++) {
     61                    pmAstromObj *ref = pmAstromObjCopy(refs->data[i]);
    6762
    68                     // limit the X,Y range of the refs to the selected chip
    69                     if (ref->chip->x < minX) goto skip;
    70                     if (ref->chip->x > maxX) goto skip;
    71                     if (ref->chip->y < minY) goto skip;
    72                     if (ref->chip->y > maxY) goto skip;
     63                    // XXX why is this still a private function?
     64                    p_psProject (ref->TP, ref->sky, fpa->projection);
     65                    psPlaneDistortApply (ref->FP, fpa->fromTangentPlane, ref->TP, 0.0, 0.0);
     66                    psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP);
    7367
    74                     psArrayAdd (refstars, 100, ref);
    75                 skip:
    76                     psFree (ref);
    77                 }
    78                 psTrace ("psastro", 4, "Added %ld refstars\n", refstars->n);
     68                    // limit the X,Y range of the refs to the selected chip
     69                    if (ref->chip->x < minX) goto skip;
     70                    if (ref->chip->x > maxX) goto skip;
     71                    if (ref->chip->y < minY) goto skip;
     72                    if (ref->chip->y > maxY) goto skip;
    7973
    80                 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", refstars);
    81                 psFree (refstars);
     74                    psArrayAdd (refstars, 100, ref);
     75                skip:
     76                    psFree (ref);
     77                }
     78                psTrace ("psastro", 4, "Added %ld refstars\n", refstars->n);
    8279
    83                 psastroRefstarSubset (readout);
    84             }
    85         }
     80                psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", refstars);
     81                psFree (refstars);
     82
     83                psastroRefstarSubset (readout);
     84            }
     85        }
    8686    }
    8787
Note: See TracChangeset for help on using the changeset viewer.