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/mmatch.c

    r34749 r35263  
    11# include "dvoshell.h"
     2int field_needs_images (dbField *field);
    23
    34/* This function uses the 'find_match' algorithm to select the objects of interest.
     
    4849  }
    4950
     51  // load info about the images from a reduced-size file
     52  char *imageMetadataFile = FALSE;
     53  if ((N = get_argument (argc, argv, "-image-metadata"))) {
     54    remove_argument (N, &argc, argv);
     55    imageMetadataFile = strcreate (argv[N]);
     56    remove_argument (N, &argc, argv);
     57  }
     58
    5059  int PARALLEL = FALSE;
    5160  if ((N = get_argument (argc, argv, "-parallel"))) {
     
    7281
    7382  // init locally static variables (time refs)
    74   dbExtractMeasuresInit();
     83  // HOST_ID tells library if operation is on remote client or not
     84  dbExtractMeasuresInit(HOST_ID);
     85
     86  // parse the fields to be extracted and returned
     87  int first = 3;
     88  if (CoordsFile) {
     89    first = 1;
     90  }
     91  fields = dbCmdlineFields (argc-first, &argv[first], DVO_TABLE_MEASURE, &last, &Nfields);
     92  if (fields == NULL) goto help;
     93  if ((Nfields == 0) || (last != argc - first)) {
     94    dbFreeFields (fields, Nfields);
     95    dvo_catalog_free (&catalog);
     96    goto help;
     97  }
     98
     99  // load image data if needed (for fields listed below)
     100  int loadImages = FALSE;
     101  for (i = 0; !loadImages && (i < Nfields); i++) {
     102    loadImages = field_needs_images (&fields[i]);
     103  }
    75104
    76105  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
     
    122151      targc += 2;
    123152    }     
     153
     154    if (loadImages) {
     155      Image *image;
     156      off_t Nimage;
     157      if ((image = LoadImagesDVO (&Nimage)) == NULL) goto escape;
     158
     159      char *filename = abspath("image.metadata.fits", DVO_MAX_PATH);
     160      ImageMetadataSave (filename, image, Nimage);
     161
     162      REALLOCATE (targv, char *, targc + 2);
     163      targv[targc+0] = strcreate ("-image-metadata");
     164      targv[targc+1] = strcreate (filename);
     165      targc += 2;
     166    }
    124167
    125168    // call the remote client
     
    153196  remove_argument (1, &argc, argv);
    154197
    155   // parse the fields to be extracted and returned
    156   fields = dbCmdlineFields (argc, argv, DVO_TABLE_MEASURE, &last, &Nfields);
    157   if (fields == NULL) goto help;
    158   if ((Nfields == 0) || (last != argc)) {
    159     dbFreeFields (fields, Nfields);
    160     dvo_catalog_free (&catalog);
    161     goto help;
    162   }
    163 
    164   // load image data if needed (for fields listed below)
    165   int loadImages = FALSE;
    166   int mosaicMode = FALSE;
    167   for (i = 0; !loadImages && (i < Nfields); i++) {
    168     if (!MEASURE_HAS_XCCD) {
    169       // I'm keeping this code because it gives a way of handling dvo dbs that don't have
    170       // measure.xccd if we need it
    171       if (fields[i].ID == MEAS_XCCD) loadImages = TRUE;
    172       if (fields[i].ID == MEAS_YCCD) loadImages = TRUE;
    173     }
    174     if (fields[i].ID == MEAS_XMOSAIC)       loadImages = mosaicMode = TRUE;
    175     if (fields[i].ID == MEAS_YMOSAIC)       loadImages = mosaicMode = TRUE;
    176     if (fields[i].ID == MEAS_EXTERN_ID)     loadImages = mosaicMode = TRUE;
    177     if (fields[i].ID == MEAS_FLAT)          loadImages = mosaicMode = TRUE;
    178     if (fields[i].ID == MEAS_CENTER_OFFSET) loadImages = mosaicMode = TRUE;
    179   }
    180 
    181198  // use the whole sky (since we select random points around the sky)
    182199  SkyRegionSelection selection;
    183200  selection.useDisplay = FALSE;
    184201  selection.useSkyregion = FALSE;
    185   if (loadImages && !SetImageSelection (mosaicMode, &selection)) goto escape;
     202
     203  if (loadImages) {
     204    if (HOST_ID) {
     205      if (!SetImageMetadataSelection (imageMetadataFile)) goto escape;
     206    } else {
     207      if (!SetImageSelection (TRUE, &selection)) goto escape;
     208    }
     209  }
    186210
    187211  /* load regions which contain all supplied RA,DEC coordinates */
     
    318342  if (invec) FreeVectorArray (invec, Ninvec);
    319343  dbFreeFields (fields, Nfields);
     344  FreeImageSelection ();
     345  FreeImageMetadataSelection ();
    320346  SkyListFree (skylist);
    321347  return (TRUE);
     
    326352  if (invec) FreeVectorArray (invec, Ninvec);
    327353  dbFreeFields (fields, Nfields);
     354  FreeImageSelection ();
     355  FreeImageMetadataSelection ();
    328356  SkyListFree (skylist);
    329357  return (FALSE);
Note: See TracChangeset for help on using the changeset viewer.