IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38669


Ignore:
Timestamp:
Aug 9, 2015, 6:45:41 AM (11 years ago)
Author:
eugene
Message:

add a -skip-compressed option (somewhat hackish)

Location:
branches/eam_branches/ipp-20150625/Ohana/src/photdbc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150625/Ohana/src/photdbc/include/dvocompress.h

    r38657 r38669  
    1616char  *UPDATE_CATFORMAT;  /* internal, elixir, loneos, panstarrs */
    1717char  *UPDATE_CATCOMPRESS;  /* ?? */
     18int    SKIP_COMPRESSED;
    1819
    1920SkyRegion REGION;
  • branches/eam_branches/ipp-20150625/Ohana/src/photdbc/src/args_dvocompress.c

    r38657 r38669  
    3030    UPDATE_CATCOMPRESS = strcreate (argv[N]);
    3131    remove_argument (N, argc, argv);
     32  }
     33
     34  SKIP_COMPRESSED = FALSE;
     35  if ((N = get_argument (*argc, argv, "-skip-compressed"))) {
     36    remove_argument (N, argc, argv);
     37    SKIP_COMPRESSED = TRUE;
    3238  }
    3339
     
    149155    UPDATE_CATCOMPRESS = strcreate (argv[N]);
    150156    remove_argument (N, argc, argv);
     157  }
     158
     159  SKIP_COMPRESSED = FALSE;
     160  if ((N = get_argument (*argc, argv, "-skip-compressed"))) {
     161    remove_argument (N, argc, argv);
     162    SKIP_COMPRESSED = TRUE;
    151163  }
    152164
  • branches/eam_branches/ipp-20150625/Ohana/src/photdbc/src/dvocompress_catalogs.c

    r38657 r38669  
    3535      DVO_LOAD_GALPHOT;
    3636
     37    // XXX this is fairly ad-hoc : I'd like to be able to check that the operation below
     38    // is a NOOP, but I don't want to put in all the full logic at the moment.  instead,
     39    // since I know I just want to compress previously uncompressed catalogs, I'm just
     40    // going to get the cpt header and check for ZTABLE.  Too bad my APIs force me to read
     41    // the header in full here and then again in dvo_catalog_open.
     42
     43    if (SKIP_COMPRESSED) {
     44      FILE *f = fopen (catalog.filename, "r");
     45      if (!f) { fprintf (stderr, "cannot open %s, skipping\n", catalog.filename); continue; }
     46
     47      Header header;
     48      if (!gfits_fread_Xheader (f, &header, 0)) {
     49        fprintf (stderr, "cannot read header for %s, skipping\n", catalog.filename);
     50        fclose (f);
     51        continue;
     52      }
     53
     54      int isZtable;
     55      int ztableStatus = gfits_scan_alt (&header, "ZTABLE", "%t", 1, &isZtable);
     56
     57      fclose (f);
     58      gfits_free_header (&header);
     59
     60      if (ztableStatus && isZtable) {
     61        fprintf (stderr, "%s is compressed, skipping\n", catalog.filename);
     62        continue;
     63      }
     64    }
     65
     66    // XXX for a test, do nothing
     67    fprintf (stderr, "%s is not compressed, compressing\n", catalog.filename);
     68
     69    // ohana_memcheck_func (TRUE);
     70
    3771    // an error exit status here is a significant error
    3872    if (!dvo_catalog_open (&catalog, skylist[0].regions[i], (VERBOSE > 1), "w")) {
     
    4074      exit (2);
    4175    }
     76
     77    // ohana_memcheck_func (TRUE);
    4278
    4379    // skip empty input catalogs
     
    5793    }
    5894
     95    // ohana_memcheck_func (TRUE);
     96
    5997    if (!dvo_catalog_backup (&catalog, TRUE)) {
    6098      fprintf (stderr, "ERROR: failed to make backup for catalog %s\n", catalog.filename);
     
    62100    }
    63101
     102    // ohana_memcheck_func (TRUE);
     103
    64104    SetProtect (TRUE);
    65105    if (!dvo_catalog_save (&catalog, (VERBOSE > 1))) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); }
    66106    if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); }
    67107    SetProtect (FALSE);
     108
     109    // ohana_memcheck_func (TRUE);
    68110
    69111    if (!dvo_catalog_unlink_backup (&catalog, TRUE)) {
     
    110152    if (UPDATE_CATCOMPRESS) { strextend (&command, "-set-compress %s", UPDATE_CATCOMPRESS); }
    111153    if (UPDATE_CATFORMAT)   { strextend (&command, "-set-format %s", UPDATE_CATFORMAT); }
     154    if (SKIP_COMPRESSED)    { strextend (&command, "-skip-compressed"); }
    112155
    113156    fprintf (stderr, "command: %s\n", command);
Note: See TracChangeset for help on using the changeset viewer.