IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 30, 2017, 2:34:03 PM (9 years ago)
Author:
watersc1
Message:

Semi-clean version of the glint and ghost code, but with those turned off in the config. Still finalizing the magnitude limits.

Location:
branches/czw_branch/20170908/psastro/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20170908/psastro/src/psastro.h

    r39926 r40199  
    6060psastroGhost     *psastroGhostAlloc (void);
    6161bool              psastroLoadGhosts (pmConfig *config);
     62bool              psastroLoadGhostsHSC (pmConfig *config);
    6263
    6364bool              psastroDataSave (pmConfig *config, psMetadata *stats);
  • branches/czw_branch/20170908/psastro/src/psastroLoadGhosts.c

    r40181 r40199  
    6161    psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions");
    6262
     63    if (1) {
     64      psWarning("Doing the hard coded switch to HSC ghosts still.");
     65      return (psastroLoadGhostsHSC(config));
     66    }
     67
    6368    // select the current recipe
    6469    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);
     
    7176    if (!REFSTAR_MASK_GHOST) return true;
    7277
     78   
    7379    char *ghostFile = psMetadataLookupStr (&status, recipe, "GHOST_MODEL");
    7480    if (!strcasecmp(ghostFile, "NONE")) return true;
     
    264270bool psastroLoadGhostsHSC (pmConfig *config) {
    265271  bool status;
    266     pmChip *chip = NULL;
    267     pmCell *cell = NULL;
    268     pmReadout *readout = NULL;
    269     //    float zeropt, exptime, MAX_MAG;
    270     float MAX_MAG;
    271     psMetadata *ghostModel = NULL;
    272     psVector *C_terms;
    273     psVector *R_terms;
    274     float glintPixelScale;
     272  pmChip *chip = NULL;
     273  pmCell *cell = NULL;
     274  pmReadout *readout = NULL;
     275  float zeropt, exptime, MAX_MAG;
     276  psMetadata *ghostModel = NULL;
     277  psVector *C_terms;
     278  psVector *R_terms;
     279  float glintPixelScale;
     280 
     281  psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions");
     282 
     283  // select the current recipe
     284  psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);
     285  if (!recipe) {
     286    psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe");
     287    return false;
     288  }
     289 
     290  bool REFSTAR_MASK_GHOST = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_GHOST");
     291  if (!REFSTAR_MASK_GHOST) return true;
     292 
     293  // Load model from file
     294  char *ghostFile = psMetadataLookupStr (&status, recipe, "GHOST_MODEL");
     295  if (!strcasecmp(ghostFile, "NONE")) return true;
     296  psLogMsg("psastro", PS_LOG_INFO, "ghost file %s",ghostFile);
     297  if (!pmConfigFileRead (&ghostModel, ghostFile, "GHOST MODEL")) {
     298    psError(PSASTRO_ERR_CONFIG, true, "Trouble loading ghost model");
     299    return false;
     300  }
     301 
     302  // Allocate FPA and refstars
     303  pmFPAview *view = pmFPAviewAlloc (0);
     304  // select the input astrometry data (also carries the refstars)
     305  pmFPAfile *astrom = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
     306  if (!astrom) {
     307    psError(PSASTRO_ERR_CONFIG, true, "Can't find input data");
     308    goto escape;
     309  }
     310  pmFPA *fpa = astrom->fpa;
     311 
     312  char *filter = psMetadataLookupStr (&status, fpa->concepts, "FPA.FILTERID");
     313  psMetadataItem *item = psMetadataLookup(ghostModel, "GHOST.MODEL.HSC");
     314  if (!item) {
     315    psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC data missing");
     316    return false;
     317  }
     318  if (item->type != PS_DATA_METADATA_MULTI) {
     319    psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC not multi");
     320    return false;
     321  }
     322 
     323  psListIterator *iter = psListIteratorAlloc(item->data.list,PS_LIST_HEAD, false);
     324  psMetadataItem *refItem = NULL;
     325  while ((refItem = psListGetAndIncrement(iter))) {
     326    if (refItem->type != PS_DATA_METADATA) {
     327      psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC entry not metadata");
     328      return false;
     329    }
     330    char *refFilter = psMetadataLookupStr (&status, refItem->data.md, "FILTER");
     331    if (!status) {
     332      // psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER");
     333      continue;
     334    }
     335    if (strcmp(refFilter, filter)) continue;
    275336   
    276     psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions");
    277 
    278     // select the current recipe
    279     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);
    280     if (!recipe) {
    281         psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe");
    282         return false;
    283     }
    284 
    285     bool REFSTAR_MASK_GHOST = psMetadataLookupBool (&status, recipe, "REFSTAR_MASK_GHOST");
    286     if (!REFSTAR_MASK_GHOST) return true;
    287 
    288     // Load model from file
    289     char *ghostFile = psMetadataLookupStr (&status, recipe, "GHOST_MODEL");
    290     if (!strcasecmp(ghostFile, "NONE")) return true;
    291 
    292     if (!pmConfigFileRead (&ghostModel, ghostFile, "GHOST MODEL")) {
    293         psError(PSASTRO_ERR_CONFIG, true, "Trouble loading ghost model");
    294         return false;
    295     }
    296 
    297     // Allocate FPA and refstars
    298     pmFPAview *view = pmFPAviewAlloc (0);
    299     // select the input astrometry data (also carries the refstars)
    300     pmFPAfile *astrom = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
    301     if (!astrom) {
    302         psError(PSASTRO_ERR_CONFIG, true, "Can't find input data");
    303         goto escape;
    304     }
    305     pmFPA *fpa = astrom->fpa;
    306 
    307     char *filter = psMetadataLookupStr (&status, fpa->concepts, "FPA.FILTERID");
    308     psMetadataItem *item = psMetadataLookup(ghostModel, "GHOST.MODEL.HSC");
    309     if (!item) {
    310       psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC data missing");
    311       return false;
    312     }
    313     if (item->type != PS_DATA_METADATA_MULTI) {
    314       psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC not multi");
    315       return false;
    316     }
    317     psListIterator *iter = psListIteratorAlloc(item->data.list,PS_LIST_HEAD, false);
    318     psMetadataItem *refItem = NULL;
    319     while ((refItem = psListGetAndIncrement(iter))) {
    320       if (refItem->type != PS_DATA_METADATA) {
    321         psLogMsg ("psastro", PS_LOG_INFO, "GHOST.MODEL.HSC entry not metadata");
    322         return false;
     337    C_terms = psMetadataLookupPtr(&status, refItem->data.md, "C_TERMS");
     338    R_terms = psMetadataLookupPtr(&status, refItem->data.md, "R_TERMS");
     339    glintPixelScale = psMetadataLookupF32(&status, refItem->data.md, "SCALE");
     340  }
     341 
     342  // really error-out here?  or just skip?
     343  if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa, recipe)) {
     344    psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");
     345    goto escape;
     346  }
     347 
     348  // recipe values are given in instrumental magnitudes
     349  // use the zero point and exposure time to convert to apparent mags: M_ap = M_inst + C_0 + 2.5*log(exptime)
     350  float MagOffset = zeropt + 2.5*log10(exptime);
     351  MAX_MAG += MagOffset;
     352 
     353  // this loop selects the matched stars for all chips
     354  while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) {
     355    psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     356    if (!chip->process || !chip->file_exists) { continue; }
     357    if (!chip->fromFPA) { continue; }
     358   
     359    while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
     360      psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     361      if (!cell->process || !cell->file_exists) { continue; }
     362     
     363      // process each of the readouts
     364      while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
     365        if (! readout->data_exists) { continue; }
     366       
     367        // select the raw objects for this readout (loaded in psastroChooseRefstars.c)
     368        // XXX : note that we place limits on the refstar sample in psastroChooseRefstars.c:
     369        // 1) on chip and 2) < PSASTRO.MAX.NREF. magnitude limits and clump exclusion are only
     370        psArray *refstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.REFSTARS");
     371        if (refstars == NULL) { continue; }
     372       
     373        // identify the bright stars of interest
     374        for (int i = 0; i < refstars->n; i++) {
     375          pmAstromObj *ref = refstars->data[i];
     376          if (ref->Mag > MAX_MAG) continue;
     377         
     378          psastroGhost *ghost = psastroGhostAlloc ();
     379         
     380          double R_TPA  = sqrt(pow(ref->TP->y,2) + pow(ref->TP->x,2));
     381          double theta0 = atan2(ref->TP->y,ref->TP->x);
     382          double star_radius_deg = R_TPA * glintPixelScale;
     383         
     384          //      psTrace("psastro.ghost",5,
     385          psLogMsg("psastro",PS_LOG_INFO,
     386                  "Begin ghost %d/%ld: MAX_MAG: %g; ref_mag: %g @ (%.10g,%.10g) TPA: (%f %f) R: %f %f %f",
     387                  i,refstars->n,MAX_MAG,ref->Mag,ref->sky->r * 180 / M_PI,ref->sky->d * 180.0 / M_PI,ref->TP->x,ref->TP->y,
     388                  R_TPA,star_radius_deg,theta0);
     389         
     390          if (star_radius_deg > 0.5) { continue; }
     391         
     392          // Calculate expected position.
     393          double C = C_terms->data.F32[0] + C_terms->data.F32[1] * star_radius_deg + C_terms->data.F32[2] * pow(star_radius_deg,2) +
     394            C_terms->data.F32[3] * pow(star_radius_deg,3) + C_terms->data.F32[4] * pow(star_radius_deg,4) +
     395            C_terms->data.F32[5] * pow(star_radius_deg,5) + C_terms->data.F32[6] * pow(star_radius_deg,6) +
     396            C_terms->data.F32[7] * pow(star_radius_deg,7);
     397          double R = R_terms->data.F32[0] + R_terms->data.F32[1] * star_radius_deg + R_terms->data.F32[2] * pow(star_radius_deg,2) +
     398            R_terms->data.F32[3] * pow(star_radius_deg,3) + R_terms->data.F32[4] * pow(star_radius_deg,4) +
     399            R_terms->data.F32[5] * pow(star_radius_deg,5) + R_terms->data.F32[6] * pow(star_radius_deg,6) +
     400            R_terms->data.F32[7] * pow(star_radius_deg,7);
     401          R = R / 0.015;
     402         
     403          psPlane *fp = psPlaneAlloc();
     404          psPlane *tp = psPlaneAlloc();
     405         
     406          tp->x = 13.5 * (C * cos(theta0) / 0.015 + 12.78);
     407          tp->y = 13.5 * (C * sin(theta0) / 0.015 + 57.74);
     408          psPlaneTransformApply(fp,fpa->fromTPA, tp);
     409         
     410          ghost->srcFP->x = ref->FP->x;
     411          ghost->srcFP->y = ref->FP->y;
     412          ghost->FP->x    = fp->x;
     413          ghost->FP->y    = fp->y;
     414         
     415          ghost->inner.major = 0.0;
     416          ghost->inner.minor = 0.0;
     417          ghost->outer.major = R;
     418          ghost->outer.minor = R;
     419         
     420          pmChip *ghostChip = psastroFindChip (&ghost->chip->x, &ghost->chip->y, fpa, ghost->FP->x, ghost->FP->y);
     421         
     422          if (ghostChip) {
     423            psLogMsg("psastro",PS_LOG_INFO,
     424                     //     psTrace("psastro.ghost",5,
     425                    "   in ghost: %d/%ld: ref: (%f,%f) or (%s) ghost: (%f,%f) or (%f,%f,%s) %f inner: (%f,%f,%f) outer: (%f,%f,%f)",
     426                    i,refstars->n,
     427                    ref->FP->x,ref->FP->y,
     428                    psMetadataLookupStr(NULL,chip->concepts,"CHIP.NAME"),
     429                    ghost->FP->x,ghost->FP->y,
     430                    ghost->chip->x,ghost->chip->y,psMetadataLookupStr(NULL,ghostChip->concepts,"CHIP.NAME"),
     431                    C,
     432                    ghost->inner.major,ghost->inner.minor,ghost->inner.theta,
     433                    ghost->outer.major,ghost->outer.minor,ghost->outer.theta);
     434          }
     435          else {
     436            psTrace("psastro.ghost",5,"   in ghost: %d/%ld: ref: (%f,%f) ghost: (%f,%f) or (%f,%f,%s) inner: (%f,%f,%f) outer: (%f,%f,%f)",
     437                    i,refstars->n,
     438                    ref->FP->x,ref->FP->y,
     439                    ghost->FP->x,ghost->FP->y,
     440                    ghost->chip->x,ghost->chip->y,"NONE",
     441                    ghost->inner.major,ghost->inner.minor,ghost->inner.theta,
     442                    ghost->outer.major,ghost->outer.minor,ghost->outer.theta);
     443          }                   
     444         
     445         
     446         
     447          if (!ghostChip) goto skip;
     448          if (!ghostChip->cells) goto skip;
     449          if (!ghostChip->cells->n) goto skip;
     450         
     451         
     452          pmCell *ghostCell = ghostChip->cells->data[0];
     453          if (!ghostCell) goto skip;
     454          if (!ghostCell->readouts) goto skip;
     455          if (!ghostCell->readouts->n) goto skip;
     456          pmReadout *ghostReadout = ghostCell->readouts->data[0];
     457          if (!ghostReadout) goto skip;
     458         
     459          psArray *ghosts = psMetadataLookupPtr (&status, ghostReadout->analysis, "PSASTRO.GHOSTS");
     460          if (ghosts == NULL) {
     461            ghosts = psArrayAllocEmpty (100);
     462            if (!psMetadataAdd (ghostReadout->analysis, PS_LIST_TAIL, "PSASTRO.GHOSTS", PS_DATA_ARRAY, "astrometry matches", ghosts)) {
     463              psError(PSASTRO_ERR_CONFIG, false, "failure to add ghosts to readout");
     464              goto escape;
     465            }
     466            psFree (ghosts);
     467          }
     468         
     469          psArrayAdd (ghosts, 100, ghost);
     470         
     471        skip:
     472         
     473          psFree (ghost);
     474        }
    323475      }
    324       char *refFilter = psMetadataLookupStr (&status, refItem->data.md, "FILTER");
    325       if (!status) {
    326         // psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER");
    327         continue;
    328       }
    329       if (strcmp(refFilter, filter)) continue;
    330 
    331       C_terms = psMetadataLookupPtr(&status, refItem->data.md, "C_TERMS");
    332       R_terms = psMetadataLookupPtr(&status, refItem->data.md, "R_TERMS");
    333       MAX_MAG = psMetadataLookupF32(&status, refItem->data.md, "LIMIT");
    334       glintPixelScale = psMetadataLookupF32(&status, refItem->data.md, "SCALE");
    335     }
    336 
    337     // really error-out here?  or just skip?
    338     //    if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa, recipe)) {
    339     //        psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");
    340     //  goto escape;
    341     //    }
    342    
    343     // recipe values are given in instrumental magnitudes
    344     // use the zero point and exposure time to convert to apparent mags: M_ap = M_inst + C_0 + 2.5*log(exptime)
    345     //    float MagOffset = zeropt + 2.5*log10(exptime);
    346     //    MAX_MAG += MagOffset;
    347 
    348     // this loop selects the matched stars for all chips
    349     while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) {
    350         psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    351         if (!chip->process || !chip->file_exists) { continue; }
    352         if (!chip->fromFPA) { continue; }
    353 
    354         while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
    355             psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    356             if (!cell->process || !cell->file_exists) { continue; }
    357 
    358             // process each of the readouts
    359             while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
    360                 if (! readout->data_exists) { continue; }
    361 
    362                 // select the raw objects for this readout (loaded in psastroChooseRefstars.c)
    363                 // XXX : note that we place limits on the refstar sample in psastroChooseRefstars.c:
    364                 // 1) on chip and 2) < PSASTRO.MAX.NREF. magnitude limits and clump exclusion are only
    365                 psArray *refstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.REFSTARS");
    366                 if (refstars == NULL) { continue; }
    367 
    368                 // identify the bright stars of interest
    369                 for (int i = 0; i < refstars->n; i++) {
    370                     pmAstromObj *ref = refstars->data[i];
    371                     psTrace("psastro.ghost",5,"Begin ghost %d/%ld: MAX_MAG: %g; ref_mag: %g @ (%.10g,%.10g) TPA: (%f %f)",
    372                             i,refstars->n,MAX_MAG,ref->Mag,ref->sky->r * 180 / M_PI,ref->sky->d * 180.0 / M_PI,ref->TP->x,ref->TP->y);
    373                     if (ref->Mag > MAX_MAG) continue;
    374                    
    375                     psastroGhost *ghost = psastroGhostAlloc ();
    376 
    377                     double R_TPA  = sqrt(pow(ref->TP->y,2) + pow(ref->TP->x,2));
    378                     double theta0 = atan2(ref->TP->y,ref->TP->x);
    379                     double star_radius_deg = R_TPA * glintPixelScale;
    380                     if (star_radius_deg > 0.5) { continue; }
    381 
    382                     // Calculate expected position.
    383                     double C = C_terms->data.F32[0] + C_terms->data.F32[1] * star_radius_deg + C_terms->data.F32[2] * pow(star_radius_deg,2) +
    384                       C_terms->data.F32[3] * pow(star_radius_deg,3) + C_terms->data.F32[4] * pow(star_radius_deg,4) +
    385                       C_terms->data.F32[5] * pow(star_radius_deg,5) + C_terms->data.F32[6] * pow(star_radius_deg,6) +
    386                       C_terms->data.F32[7] * pow(star_radius_deg,7);
    387                     double R = R_terms->data.F32[0] + R_terms->data.F32[1] * star_radius_deg + R_terms->data.F32[2] * pow(star_radius_deg,2) +
    388                       R_terms->data.F32[3] * pow(star_radius_deg,3) + R_terms->data.F32[4] * pow(star_radius_deg,4) +
    389                       R_terms->data.F32[5] * pow(star_radius_deg,5) + R_terms->data.F32[6] * pow(star_radius_deg,6) +
    390                       R_terms->data.F32[7] * pow(star_radius_deg,7);
    391                     R = 13.5 * (R / 0.015); // Convert to TPA units.
    392 
    393                     psPlane *fp = psPlaneAlloc();
    394                     psPlane *tp = psPlaneAlloc();
    395 
    396                     tp->x = 13.5 * (C * cos(theta0) / 0.015 + 12.78);
    397                     tp->y = 13.5 * (C * sin(theta0) / 0.015 + 57.74);
    398                     psPlaneTransformApply(fp,fpa->fromTPA, tp);
    399                    
    400                     ghost->srcFP->x = ref->FP->x;
    401                     ghost->srcFP->y = ref->FP->y;
    402                     ghost->FP->x    = fp->x;
    403                     ghost->FP->y    = fp->y;
    404 
    405                     ghost->inner.major = 0.0;
    406                     ghost->inner.minor = 0.0;
    407                     ghost->outer.major = R;
    408                     ghost->outer.minor = R;
    409                    
    410                     pmChip *ghostChip = psastroFindChip (&ghost->chip->x, &ghost->chip->y, fpa, ghost->FP->x, ghost->FP->y);
    411                    
    412 
    413                    
    414                     if (ghostChip) {
    415                       psTrace("psastro.ghost",5,"   in ghost: %d/%ld: ref: (%f,%f) or (%s) ghost: (%f,%f) or (%f,%f,%s) %f inner: (%f,%f,%f) outer: (%f,%f,%f)",
    416                               i,refstars->n,
    417                               ref->FP->x,ref->FP->y,
    418                               psMetadataLookupStr(NULL,chip->concepts,"CHIP.NAME"),
    419                               ghost->FP->x,ghost->FP->y,
    420                               ghost->chip->x,ghost->chip->y,psMetadataLookupStr(NULL,ghostChip->concepts,"CHIP.NAME"),
    421                               C,
    422                               ghost->inner.major,ghost->inner.minor,ghost->inner.theta,
    423                               ghost->outer.major,ghost->outer.minor,ghost->outer.theta);
    424 /*                    psWarning("   GHOST_DATA: %d/%ld: ref: (%f,%f) or (%f,%f,%s) ghost: (%f,%f) or (%f,%f,%s) %f inner: (%f,%f,%f) outer: (%f,%f,%f)", */
    425 /*                            i,refstars->n, */
    426 /*                            ref->FP->x,ref->FP->y, */
    427 /*                            ref_chip_x,ref_chip_y,psMetadataLookupStr(NULL,chip->concepts,"CHIP.NAME"), */
    428 /*                            ghost->FP->x,ghost->FP->y, */
    429 /*                            ghost->chip->x,ghost->chip->y,psMetadataLookupStr(NULL,ghostChip->concepts,"CHIP.NAME"), */
    430 /*                            rSrc, */
    431 /*                            ghost->inner.major,ghost->inner.minor,ghost->inner.theta, */
    432 /*                            ghost->outer.major,ghost->outer.minor,ghost->outer.theta); */
    433                     }
    434                     else {
    435                       psTrace("psastro.ghost",5,"   in ghost: %d/%ld: ref: (%f,%f) ghost: (%f,%f) or (%f,%f,%s) inner: (%f,%f,%f) outer: (%f,%f,%f)",
    436                               i,refstars->n,
    437                               ref->FP->x,ref->FP->y,
    438                               ghost->FP->x,ghost->FP->y,
    439                               ghost->chip->x,ghost->chip->y,"NONE",
    440                               ghost->inner.major,ghost->inner.minor,ghost->inner.theta,
    441                               ghost->outer.major,ghost->outer.minor,ghost->outer.theta);
    442                     }                 
    443                      
    444 
    445                            
    446                     if (!ghostChip) goto skip;
    447                     if (!ghostChip->cells) goto skip;
    448                     if (!ghostChip->cells->n) goto skip;
    449 
    450                    
    451                     pmCell *ghostCell = ghostChip->cells->data[0];
    452                     if (!ghostCell) goto skip;
    453                     if (!ghostCell->readouts) goto skip;
    454                     if (!ghostCell->readouts->n) goto skip;
    455                     pmReadout *ghostReadout = ghostCell->readouts->data[0];
    456                     if (!ghostReadout) goto skip;
    457 
    458                     psArray *ghosts = psMetadataLookupPtr (&status, ghostReadout->analysis, "PSASTRO.GHOSTS");
    459                     if (ghosts == NULL) {
    460                         ghosts = psArrayAllocEmpty (100);
    461                         if (!psMetadataAdd (ghostReadout->analysis, PS_LIST_TAIL, "PSASTRO.GHOSTS", PS_DATA_ARRAY, "astrometry matches", ghosts)) {
    462                           psError(PSASTRO_ERR_CONFIG, false, "failure to add ghosts to readout");
    463                           goto escape;
    464                         }
    465                         psFree (ghosts);
    466                     }
    467 
    468                     psArrayAdd (ghosts, 100, ghost);
    469 
    470                 skip:
    471                    
    472                     psFree (ghost);
    473                 }
    474             }
    475         }
    476     }
    477 
    478     psastroExtractFreeChipBounds();
    479 
    480     psFree (C_terms);
    481     psFree (R_terms);
    482     psFree (ghostModel);
    483     psFree (view);
    484     return true;
    485 
    486 escape:
    487     psFree (C_terms);
    488     psFree (R_terms);
    489     psFree (ghostModel);
    490     psFree (view);
    491     return false;
     476    }
     477  }
     478 
     479  psastroExtractFreeChipBounds();
     480 
     481  psFree (C_terms);
     482  psFree (R_terms);
     483  //    psFree (ghostModel);
     484  psFree (view);
     485  return true;
     486 
     487 escape:
     488  psFree (C_terms);
     489  psFree (R_terms);
     490  //    psFree (ghostModel);
     491  psFree (view);
     492  return false;
    492493}
Note: See TracChangeset for help on using the changeset viewer.