IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35231


Ignore:
Timestamp:
Mar 5, 2013, 12:48:55 PM (13 years ago)
Author:
eugene
Message:

delete the images and PHUs identified; add -update, -image-details and -image-only options

Location:
branches/eam_branches/ipp-20130207/Ohana/src/delstar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130207/Ohana/src/delstar/include/delstar.h

    r35229 r35231  
    3838int    VERBOSE;
    3939int    VERBOSE2;
     40int    UPDATE;
     41int    IMAGE_DETAILS;
     42int    IMAGE_ONLY;
    4043int    ORPHAN;
    4144int    MISSED;
  • branches/eam_branches/ipp-20130207/Ohana/src/delstar/src/args.c

    r35229 r35231  
    99  fprintf (stderr, "  delstar -orphan (region)\n");
    1010  fprintf (stderr, "  delstar -missed (region)\n\n");
     11  fprintf (stderr, "  delstar -photcodes (list) : delete by photcode\n\n");
     12  fprintf (stderr, "  delstar -dup-images : delete duplicate images (by externID)\n\n");
    1113  fprintf (stderr, "  optional flags:\n");
    1214  fprintf (stderr, "  -v               : verbose mode\n");
    1315  fprintf (stderr, "  -photcode (code) : restrict by photcode\n");
     16  fprintf (stderr, "  -update : apply changes (-dup-images only)\n");
     17  fprintf (stderr, "  -image-details : list info about the deleted images (-dup-images only)\n");
     18  fprintf (stderr, "  -image-only : only examine the image table (changes are NOT saved; -dup-images only)\n");
     19  fprintf (stderr, "  -region Rmin Rmax Dmin Dmax : apply changes to this part of the sky\n");
     20 
    1421  fprintf (stderr, "\n");
    1522  exit (2);
     
    4855    VERBOSE = TRUE;
    4956    VERBOSE2 = TRUE;
     57    remove_argument (N, &argc, argv);
     58  }
     59
     60  UPDATE = FALSE;
     61  if ((N = get_argument (argc, argv, "-update"))) {
     62    UPDATE = TRUE;
     63    remove_argument (N, &argc, argv);
     64  }
     65
     66  IMAGE_DETAILS = FALSE;
     67  if ((N = get_argument (argc, argv, "-image-details"))) {
     68    IMAGE_DETAILS = TRUE;
     69    remove_argument (N, &argc, argv);
     70  }
     71
     72  // we should never delete the images before the measures (or we won't know what to delete)
     73  // -image-only is for testing
     74  IMAGE_ONLY = FALSE;
     75  if ((N = get_argument (argc, argv, "-image-only"))) {
     76    IMAGE_ONLY = TRUE;
     77    UPDATE = FALSE;
    5078    remove_argument (N, &argc, argv);
    5179  }
     
    256284  }
    257285
     286  UPDATE = FALSE;
     287  if ((N = get_argument (argc, argv, "-update"))) {
     288    UPDATE = TRUE;
     289    remove_argument (N, &argc, argv);
     290  }
     291
     292  IMAGE_DETAILS = FALSE;
     293  if ((N = get_argument (argc, argv, "-image-details"))) {
     294    IMAGE_DETAILS = TRUE;
     295    remove_argument (N, &argc, argv);
     296  }
     297
     298  IMAGE_ONLY = FALSE;
     299  if ((N = get_argument (argc, argv, "-image-only"))) {
     300    IMAGE_ONLY = TRUE;
     301    UPDATE = FALSE;
     302    remove_argument (N, &argc, argv);
     303  }
     304
    258305  /* specify portion of the sky */
    259306  UserPatch.Rmin = 0;
  • branches/eam_branches/ipp-20130207/Ohana/src/delstar/src/delete_duplicate_images.c

    r35229 r35231  
    88int delete_duplicate_images (int hostID, char *hostpath, FITS_DB *db) {
    99
    10   off_t Nimage;
    11   Image *image;
     10  off_t i, Nimage;
     11  Image *image, *outimage;
    1212
    1313  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     
    1919  IndexArray *imageID = find_duplicates (image, Nimage);
    2020
    21   delete_duplicate_image_measures (hostID, hostpath, imageID);
     21  if (!IMAGE_ONLY) {
     22    delete_duplicate_image_measures (hostID, hostpath, imageID);
     23  }
     24
     25  if (!UPDATE) return TRUE;
     26
     27  /* delete the identified images */
     28  off_t Noutimage = 0;
     29  ALLOCATE (outimage, Image, Nimage);
     30  for (i = 0; i < Nimage; i++) {
     31    if (image[i].imageID == 0) continue;
     32    off_t Ni = image[i].imageID - imageID->minID;
     33    myAssert (Ni >= 0, "oops");
     34    myAssert (Ni < imageID->range, "oops");
     35 
     36    // imageID->value[Ni] is TRUE if we want to delete the image
     37    if (imageID->value[Ni]) continue;
     38    outimage[Noutimage] = image[i];
     39    Noutimage ++;
     40  }
     41  free (image);
     42 
     43  fprintf (stderr, "removing "OFF_T_FMT" images (leaving "OFF_T_FMT" of "OFF_T_FMT")\n",  Nimage - Noutimage, Noutimage, Nimage);
     44  // gfits_table_set_Image (&db[0].ftable, outimage, Noutimage);
     45
     46  gfits_modify (&db[0].theader, "NAXIS2", OFF_T_FMT, 1,  Noutimage);
     47  gfits_modify (&db[0].header, "NIMAGES", OFF_T_FMT, 1,  Noutimage);
     48  db[0].theader.Naxis[1] = Noutimage;
     49  db[0].ftable.buffer = (char *) outimage;
     50
     51  if (!dvo_image_save (db, VERBOSE)) return FALSE;
     52  if (!dvo_image_unlock (db)) return FALSE;
    2253
    2354  return TRUE;
     
    77108
    78109    delete_duplicate_image_measures_catalog (&catalog, imageID);
    79     dvo_catalog_save_complete (&catalog, VERBOSE2);
     110
     111    if (UPDATE) {
     112      dvo_catalog_save_complete (&catalog, VERBOSE2);
     113    }
     114
    80115    dvo_catalog_unlock (&catalog);
    81116    dvo_catalog_free (&catalog);
     
    342377  if (VERBOSE) fprintf (stderr, "ending with Nave, Nmeas: "OFF_T_FMT" "OFF_T_FMT"\n",  catalog[0].Naverage,  catalog[0].Nmeasure);
    343378
     379  off_t NdelAves = Naverage - catalog[0].Naverage;
     380  off_t NdelMeas = Nmeasure - catalog[0].Nmeasure;
     381  if (NdelAves || NdelMeas) {
     382    fprintf (stderr, "deleting "OFF_T_FMT" measures and "OFF_T_FMT" averages : %s\n",  NdelMeas, NdelAves, catalog[0].filename);
     383  }
     384
    344385  FREE (measureDrop);
    345386  FREE (measureSeqRaw);
     
    406447    imageID->value[Ni] = TRUE;
    407448    Ndelete[Nx] ++;
     449
    408450    // mark the parentID for deletion as well..
    409   }
    410 
    411   for (i = 0; i < Nimage; i++) {
     451    // XXX this is probably bad : it assumes all chips
     452    // should be deleted for a given exposure
     453    off_t parentID = image[i].parentID;
     454    if (parentID) {
     455      off_t Np = parentID - imageID->minID;
     456      myAssert (Np >= 0, "oops");
     457      myAssert (Np < imageID->range, "oops");
     458      imageID->value[Np] = TRUE;
     459    }
     460  }
     461
     462  for (i = 0; IMAGE_DETAILS && (i < Nimage); i++) {
    412463    off_t Ni = image[i].imageID - imageID->minID;
    413464    if (!imageID->value[Ni]) continue;
    414     fprintf (stderr, "delete image (i) " OFF_T_FMT ", extID = %d\n", i, image[i].externID);
     465    fprintf (stderr, "delete image (i) " OFF_T_FMT ", extID = %d : %s\n", i, image[i].externID, image[i].name);
    415466  }
    416467
Note: See TracChangeset for help on using the changeset viewer.