IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 6, 2013, 4:50:14 PM (13 years ago)
Author:
eugene
Message:

get mextract and mmatch to work with a subset metadata file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/mmatch.c

    r35249 r35250  
    4949  }
    5050
     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
    5159  int PARALLEL = FALSE;
    5260  if ((N = get_argument (argc, argv, "-parallel"))) {
     
    7583  // HOST_ID tells library if operation is on remote client or not
    7684  dbExtractMeasuresInit(HOST_ID);
     85
     86  // parse the fields to be extracted and returned
     87  int first = 4;
     88  if (CoordsFile) {
     89    first = 2;
     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  }
    77104
    78105  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
     
    124151      targc += 2;
    125152    }     
     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    }
    126167
    127168    // call the remote client
     
    155196  remove_argument (1, &argc, argv);
    156197
    157   // parse the fields to be extracted and returned
    158   fields = dbCmdlineFields (argc, argv, DVO_TABLE_MEASURE, &last, &Nfields);
    159   if (fields == NULL) goto help;
    160   if ((Nfields == 0) || (last != argc)) {
    161     dbFreeFields (fields, Nfields);
    162     dvo_catalog_free (&catalog);
    163     goto help;
    164   }
    165 
    166   // load image data if needed (for fields listed below)
    167   int loadImages = FALSE;
    168   for (i = 0; !loadImages && (i < Nfields); i++) {
    169     loadImages = field_needs_images (&fields[i]);
    170   }
    171 
    172198  // use the whole sky (since we select random points around the sky)
    173199  SkyRegionSelection selection;
    174200  selection.useDisplay = FALSE;
    175201  selection.useSkyregion = FALSE;
    176   if (loadImages && !SetImageSelection (TRUE, &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  }
    177210
    178211  /* load regions which contain all supplied RA,DEC coordinates */
     
    309342  if (invec) FreeVectorArray (invec, Ninvec);
    310343  dbFreeFields (fields, Nfields);
     344  FreeImageSelection ();
     345  FreeImageMetadataSelection ();
    311346  SkyListFree (skylist);
    312347  return (TRUE);
     
    317352  if (invec) FreeVectorArray (invec, Ninvec);
    318353  dbFreeFields (fields, Nfields);
     354  FreeImageSelection ();
     355  FreeImageMetadataSelection ();
    319356  SkyListFree (skylist);
    320357  return (FALSE);
Note: See TracChangeset for help on using the changeset viewer.