IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 7, 2013, 9:51:07 AM (13 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20130306: addstar now can block against duplicate image IDs; mextract, mmatch now use a subset of image metadata instead of the whole table

Location:
trunk/Ohana
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/opihi

  • trunk/Ohana/src/opihi/dvo/mextract.c

    r34749 r35263  
    11# include "dvoshell.h"
     2
     3int field_needs_images (dbField *field) {
     4  // the image subset table requires imageID for all fields
     5
     6    if (!MEASURE_HAS_XCCD) {
     7      // I'm keeping this code because it gives a way of handling dvo dbs that don't have
     8      // measure.xccd if we need it
     9      if (field->ID == MEAS_XCCD) return TRUE; // full astrometry per chip (120 bytes!)
     10      if (field->ID == MEAS_YCCD) return TRUE; // full astrometry per chip (120 bytes!)
     11    }
     12    if (field->ID == MEAS_XMOSAIC)        return TRUE; // crval1,2 only
     13    if (field->ID == MEAS_YMOSAIC)        return TRUE; // crval1,2 only
     14    if (field->ID == MEAS_EXTERN_ID)      return TRUE; // externID
     15    if (field->ID == MEAS_FLAT)           return TRUE; // Mcal
     16    if (field->ID == MEAS_CENTER_OFFSET)  return TRUE; // 0.5*NX, 0.5*NY
     17    if (field->ID == MEAS_EXPNAME_AS_INT) return TRUE; // expname (or as int)
     18    if (field->ID == MEAS_AIRMASS)        return TRUE; // airmass
     19    return FALSE;
     20}
    221
    322int mextract (int argc, char **argv) {
     
    524  off_t i, j, k, m; // used for counter averages and measures
    625  int n, N, Npts, NPTS, last, next, state, Nfields, Nreturn, Ncstack, Nstack;
    7   int Nsecfilt, VERBOSE, loadImages, mosaicMode;
     26  int Nsecfilt, VERBOSE, loadImages;
    827  char **cstack, name[1024];
    928  dbValue *values;
     
    3352    remove_argument (N, &argc, argv);
    3453    VERBOSE = TRUE;
     54  }
     55
     56  char *imageMetadataFile = FALSE;
     57  if ((N = get_argument (argc, argv, "-image-metadata"))) {
     58    remove_argument (N, &argc, argv);
     59    imageMetadataFile = strcreate (argv[N]);
     60    remove_argument (N, &argc, argv);
    3561  }
    3662
     
    6692
    6793  // init locally static variables (time refs)
    68   dbExtractMeasuresInit();
     94  // HOST_ID tells library if operation is on remote client or not
     95  dbExtractMeasuresInit(HOST_ID);
    6996
    7097  // command-line is of the form: mextract field,field, field [where (field op value)...]
     
    106133  if ((skylist = SelectRegions (selection)) == NULL) goto escape;
    107134
     135  // load image data if needed (for fields listed below)
     136  loadImages = FALSE;
     137  for (i = 0; !loadImages && (i < Nfields); i++) {
     138    loadImages = field_needs_images (&fields[i]);
     139  }
     140   
    108141  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
    109142  if (PARALLEL && !HOST_ID) {
    110     int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, 0, VERBOSE);
     143
     144    // Image Metadata for remote queries:
     145    // 1) figure out if we need any image metadata
     146    // 2) load the images and generate a subset table with just the fields of interest
     147    // 3) add the input subset filename to the dvo_client command
     148
     149    // allocate the temp array and copy all but (RA) (DEC)
     150    int targc = 0;
     151    char **targv = NULL;
     152    ALLOCATE (targv, char *, argc);
     153    for (i = 0; i < argc; i++) {
     154      targv[targc] = strcreate (argv[i]);
     155      targc ++;
     156    }
     157
     158    if (loadImages) {
     159      Image *image;
     160      off_t Nimage;
     161      if ((image = LoadImagesDVO (&Nimage)) == NULL) goto escape;
     162
     163      char *filename = abspath("image.metadata.fits", DVO_MAX_PATH);
     164      ImageMetadataSave (filename, image, Nimage);
     165
     166      REALLOCATE (targv, char *, targc + 2);
     167      targv[targc+0] = strcreate ("-image-metadata");
     168      targv[targc+1] = strcreate (filename);
     169      targc += 2;
     170    }
     171
     172    // call the remote client
     173    int status = HostTableParallelOps (targc, targv, RESULT_FILE, TRUE, 0, VERBOSE);
    111174
    112175    dbFreeFields (fields, Nfields);
     
    116179    dvo_catalog_free (&catalog);
    117180
     181    // free up targv
     182    for (i = 0; i < targc; i++) {
     183      free (targv[i]);
     184    }
     185    free (targv);
     186
    118187    return status;
    119188  }
    120189
    121   // load image data if needed (for fields listed below)
    122   loadImages = FALSE;
    123   mosaicMode = FALSE;
    124   for (i = 0; !loadImages && (i < Nfields); i++) {
    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;
    133     if (fields[i].ID == MEAS_EXTERN_ID)     loadImages = mosaicMode = TRUE;
    134     if (fields[i].ID == MEAS_FLAT)          loadImages = mosaicMode = TRUE;
    135     if (fields[i].ID == MEAS_CENTER_OFFSET) loadImages = mosaicMode = TRUE;
    136   }
    137   if (loadImages && !SetImageSelection (mosaicMode, selection)) goto escape;
     190  if (loadImages) {
     191    if (HOST_ID) {
     192      if (!SetImageMetadataSelection (imageMetadataFile)) goto escape;
     193    } else {
     194      if (!SetImageSelection (TRUE, selection)) goto escape;
     195    }
     196  }
    138197
    139198  /* create storage vector */
     
    251310  free (stack);
    252311  FreeImageSelection ();
     312  FreeImageMetadataSelection ();
    253313  SkyListFree (skylist);
    254314  FreeSkyRegionSelection (selection);
     
    264324  free (stack);
    265325  FreeImageSelection ();
     326  FreeImageMetadataSelection ();
    266327  SkyListFree (skylist);
    267328  FreeSkyRegionSelection (selection);
Note: See TracChangeset for help on using the changeset viewer.