IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39643


Ignore:
Timestamp:
Jul 31, 2016, 12:04:20 PM (10 years ago)
Author:
eugene
Message:

fix double-free of images table when all images are used; for full overlap, require images to be completely contained by extracted region

Location:
trunk/Ohana/src/relphot
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot/include/relphot.h

    r39642 r39643  
    618618
    619619void relphot_free (SkyTable *sky, SkyList *skylist);
    620 void freeImages (int freeImageData);
     620void freeImages (char *dbImagePtr);
    621621void relphot_client_free (SkyTable *sky, SkyList *skylist);
    622622void BrightCatalogFree (BrightCatalog *bcatalog);
  • trunk/Ohana/src/relphot/src/ImageOps.c

    r39642 r39643  
    269269}
    270270
    271 void freeImages (int freeImageData) {
    272 
    273   if (freeImageData) FREE (image);
     271void freeImages (char *dbImagePtr) {
     272
    274273  FREE (LineNumber);
    275274
     
    280279  FREE (projectID);
    281280  FREE (skycellID);
     281
     282  // we call gfits_db_free as well as this function.  sometimes those point at the same
     283  // memory location, in which case we should only do the free once.
     284  if ((void *) dbImagePtr != (void *) image) free (image);
    282285
    283286  free_astrom_table();
     
    662665    // only freeze the gpc1 chips
    663666    if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue;
     667    if (image[i].photcode == 0) continue; // skip the PHU images
    664668
    665669    // UBERCAL image: if this is an ubercal image, set minUbercalDist to 0:
     
    674678    off_t Nref = 0;  // total number of reference stars on the image
    675679    int Nbright = 0; // number of stars to measure the bright-end scatter
     680
     681    if (N_onImage[i] == 0) {
     682      fprintf (stderr, "image missing detections? %s %d "OFF_T_FMT"\n", image[i].name, image[i].nstar, N_onImage[i]);
     683      continue;
     684    }
    676685
    677686    for (j = 0; j < N_onImage[i]; j++) {
  • trunk/Ohana/src/relphot/src/relphot_client.c

    r39481 r39643  
    8383      FlatCorrectionTable *flatcorr = NULL;
    8484      reload_catalogs (skylist, flatcorr, HOST_ID, HOSTDIR);
    85       freeImages (TRUE);
     85      freeImages ((char *)image);
    8686      free (image);
    8787      client_logger_message ("updated catalogs\n");
  • trunk/Ohana/src/relphot/src/relphot_images.c

    r39642 r39643  
    263263  }
    264264  dvo_image_unlock (&db);
     265
     266  freeImages (db.ftable.buffer);
    265267  gfits_db_free (&db);
    266   freeImages (TRUE);
    267268
    268269  return TRUE;
  • trunk/Ohana/src/relphot/src/relphot_objects.c

    r39642 r39643  
    182182  }
    183183
     184  freeImages(db.ftable.buffer);
    184185  gfits_db_free (&db);
    185   freeImages(TRUE);
    186186
    187187  return (TRUE);
  • trunk/Ohana/src/relphot/src/relphot_parallel_images.c

    r39481 r39643  
    170170  freeMosaicBins (Ncatalog, TRUE);
    171171  freeGridBins (Ncatalog);
    172   freeImages(TRUE);
     172  freeImages((char *)image);
    173173
    174174  SkyListFree(skylist);
  • trunk/Ohana/src/relphot/src/relphot_parallel_regions.c

    r39481 r39643  
    8888  MARKTIME ("finished relphot -parallel-regions: %f sec total\n", dtime);
    8989
     90  freeImages(db.ftable.buffer);
    9091  gfits_db_free (&db);
    91   freeImages(FALSE);
    9292
    9393  SkyListFree(skylist);
  • trunk/Ohana/src/relphot/src/select_images.c

    r39609 r39643  
    4646  double DmaxSkyRegion = region[0].Dmax;
    4747
    48   double dD = 5.0;
     48  double dD = CALIBRATE_STACKS_AND_WARPS ? 0.5 : 5.0;
    4949  double dR = dD / cos(RAD_DEG*DminSkyRegion);
    5050  RminSkyRegion -= dR;
     
    8080    }
    8181  }
    82 
    83 # if (0)
    84   // XXX quick test of the dec bands:
    85   FILE *fout = fopen ("dec.bands.dat", "w");
    86   for (i = 0; i < NDecBands; i++) {
    87     fprintf (fout, "%d %f : %f - %f\n", (int) i, dDecBand * i - 90.0, RminBand[i], RmaxBand[i]);
    88   }
    89   fclose (fout);
    90 # endif
    9182
    9283  SkyRegionCoords *skycoords = NULL;
     
    168159    }
    169160
    170     // fprintf (ftest, "%f %f : %f %f : %d %d\n", RminImage, RmaxImage, DminImage, DmaxImage, timage[i].tzero, timage[i].photcode);
    171 
    172161    // check that this image is even in range of the searched region
    173     if (DminImage > DmaxSkyRegion) continue;
    174     if (DmaxImage < DminSkyRegion) continue;
    175    
    176     // the sky region RA is defined to be 0 - 360.0
    177     if (RminImage > RmaxSkyRegion) continue;
    178     if (RmaxImage < RminSkyRegion) continue;
    179 
     162    if (USE_FULL_OVERLAP) {
     163      // for full overlap, the image must be completely inside the region of interest
     164      if (DmaxImage > DmaxSkyRegion) continue;
     165      if (DminImage < DminSkyRegion) continue;
     166     
     167      // the sky region RA is defined to be 0 - 360.0
     168      if (RmaxImage > RmaxSkyRegion) continue;
     169      if (RminImage < RminSkyRegion) continue;
     170    } else {
     171      if (DminImage > DmaxSkyRegion) continue;
     172      if (DmaxImage < DminSkyRegion) continue;
     173     
     174      // the sky region RA is defined to be 0 - 360.0
     175      if (RminImage > RmaxSkyRegion) continue;
     176      if (RmaxImage < RminSkyRegion) continue;
     177    }
     178     
    180179    // the above checks are only valid for the outermost region.  however, at a given
    181180    // declination, the range of RA is limited by the actual catalog boundaries
     
    204203      }
    205204    }
     205
     206    // fprintf (ftest, "%f %f : %f %f : %d %d\n", RminImage, RmaxImage, DminImage, DmaxImage, timage[i].tzero, timage[i].photcode);
    206207
    207208    // image overlaps region, keep it
Note: See TracChangeset for help on using the changeset viewer.