IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2012, 5:24:19 PM (14 years ago)
Author:
mhuber
Message:

merging latest r34040 trunk changes to branch

Location:
branches/meh_branches/ppstack_test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/meh_branches/ppstack_test

  • branches/meh_branches/ppstack_test/Ohana/src/opihi/dvo/mextract.c

    r30612 r34041  
    2525  selection = NULL;
    2626
     27  // fprintf (stderr, "start...");
    2728  if ((N = get_argument (argc, argv, "-h"))) goto help;
    2829  if ((N = get_argument (argc, argv, "--help"))) goto help;
     
    3435  }
    3536
     37  int PARALLEL = FALSE;
     38  if ((N = get_argument (argc, argv, "-parallel"))) {
     39    remove_argument (N, &argc, argv);
     40    PARALLEL = TRUE;
     41  }
     42
     43  // this is used to NOT save the results in the results file
     44  // use this option when mextract is used in a script which does its
     45  // own job of packaging the results
     46  int SKIP_RESULTS = FALSE;
     47  if ((N = get_argument (argc, argv, "-skip-results"))) {
     48    remove_argument (N, &argc, argv);
     49    SKIP_RESULTS = TRUE;
     50  }
     51
     52  // init here so free in 'escape' block does not crash
    3653  dvo_catalog_init (&catalog, TRUE);
    3754
     
    4057  Nsecfilt = GetPhotcodeNsecfilt ();
    4158 
     59  // parse skyregion options.  NOTE: this is stripped off in parallel operation and always
     60  // defined for the client via the -skyregion option.  The dvo_client parses this
     61  // argument in the main program, before it is passed to the command (like mextract)
     62  if ((selection = SetRegionSelection (&argc, argv)) == NULL) {
     63    print_error();
     64    goto escape;
     65  }
     66
    4267  // init locally static variables (time refs)
    4368  dbExtractMeasuresInit();
    4469
    45   // parse skyregion options
    46   if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape;
    47 
    48   // command-line is of the form: avextract field,field, field [where (field op value)...]
     70  // command-line is of the form: mextract field,field, field [where (field op value)...]
    4971
    5072  // parse the fields to be extracted and returned
     
    84106  if ((skylist = SelectRegions (selection)) == NULL) goto escape;
    85107
     108  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
     109  if (PARALLEL && !HOST_ID) {
     110    int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);
     111
     112    dbFreeFields (fields, Nfields);
     113    dbFreeStack (stack, Nstack);
     114    free (stack);
     115    FreeSkyRegionSelection (selection);
     116    dvo_catalog_free (&catalog);
     117
     118    return status;
     119  }
     120
    86121  // load image data if needed (for fields listed below)
    87122  loadImages = FALSE;
    88123  mosaicMode = FALSE;
    89124  for (i = 0; !loadImages && (i < Nfields); i++) {
    90     if (fields[i].ID == MEAS_XCCD) loadImages = TRUE;   // Are these still needed? Xccd and Yccd are in measurement
    91     if (fields[i].ID == MEAS_YCCD) loadImages = TRUE;   // and dbExtractMeasures doesn't look at the image for these
    92     if (fields[i].ID == MEAS_XMOSAIC) loadImages = mosaicMode = TRUE;
    93     if (fields[i].ID == MEAS_YMOSAIC) loadImages = mosaicMode = TRUE;
     125    if (!MEASURE_HAS_XCCD) {
     126      // I'm keeping this code because it gives a way of handling dvo dbs that don't have
     127      // measure.xccd if we need it
     128      if (fields[i].ID == MEAS_XCCD) loadImages = TRUE;
     129      if (fields[i].ID == MEAS_YCCD) loadImages = TRUE;
     130    }
     131    if (fields[i].ID == MEAS_XMOSAIC)   loadImages = mosaicMode = TRUE;
     132    if (fields[i].ID == MEAS_YMOSAIC)   loadImages = mosaicMode = TRUE;
    94133    if (fields[i].ID == MEAS_EXTERN_ID) loadImages = mosaicMode = TRUE;
     134    if (fields[i].ID == MEAS_FLAT)      loadImages = mosaicMode = TRUE;
    95135  }
    96136  if (loadImages && !SetImageSelection (mosaicMode, selection)) goto escape;
     
    115155  interrupt = FALSE;
    116156
     157  // fprintf (stderr, "done setup...");
     158
    117159  for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
     160
     161    // does this host ID match the desired location for the table?
     162    if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue;
     163
    118164    /* lock, load, unlock catalog */
    119     catalog.filename = skylist[0].filename[i];
     165    char hostfile[1024];
     166    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name);
     167    catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i];
    120168    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    121169    catalog.Nsecfilt = Nsecfilt;
     
    126174    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
    127175      gprint (GP_ERR, "ERROR: failure to open catalog file %s\n", catalog.filename);
    128       exit (2);
     176      return FALSE;
    129177    }
    130178    dvo_catalog_unlock (&catalog);
     
    132180    /* XXX need to call dvo_catalog_chipcoords here passing the loaded images */
    133181
     182    // fprintf (stderr, "done read...");
     183
    134184    for (j = 0; (j < catalog.Naverage) && !interrupt; j++) {
    135185      m = catalog.average[j].measureOffset;
    136       dbExtractMeasuresInitAve (); // reset counters for saved fields
     186      if (m > catalog.Nmeasure) {
     187        gprint (GP_ERR, "ERROR: inconsistent average->measure offset.  Unsorted database?\n");
     188        goto escape;
     189      }
     190
     191      dbExtractMeasuresInitAve (); // reset counters for saved fields (costs very little)
    137192
    138193      for (k = 0; (k < catalog.average[j].Nmeasure); k++, m++) {
     194        if (catalog.measure[m].averef != j) {
     195          gprint (GP_ERR, "ERROR: inconsistent measure->average link.  Unsorted database?\n");
     196          goto escape;
     197        }
    139198
    140199        // extract the relevant values for this measurement
    141         dbExtractMeasuresInitMeas (); // reset counters for saved fields
     200        dbExtractMeasuresInitMeas (); // reset counters for saved fields  (costs very little
    142201        for (n = 0; n < Nfields; n++) {
    143202          values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
     
    173232  interrupt = FALSE;
    174233
     234  // fprintf (stderr, "done load...");
     235
    175236  for (n = 0; n < Nreturn; n++) {
    176     ResetVector (vec[n], fields[n].type, MAX(1,Npts));
     237    ResetVector (vec[n], fields[n].type, Npts);
     238  }
     239
     240  // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)
     241  if (RESULT_FILE && !SKIP_RESULTS) {
     242    int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, NULL);
     243    if (!status) goto escape;
    177244  }
    178245
     
    185252  SkyListFree (skylist);
    186253  FreeSkyRegionSelection (selection);
     254
     255  // fprintf (stderr, "done extr...\n");
    187256  return (TRUE);
    188257
     
    307376    gprint (GP_ERR, "  imageID : ID of source image (32 bit)\n");
    308377    gprint (GP_ERR, "  externID : externID of source image (32 bit)\n");
     378
     379    gprint (GP_ERR, "  Mcal_offset : difference wrt nominal zero point (clouds are positive)\n");
     380    gprint (GP_ERR, "  flat : flat-field correction (measure.Mcal - image.Mcal)\n");
    309381    return (FALSE);
    310382  }
Note: See TracChangeset for help on using the changeset viewer.