IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35250


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

Location:
branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo
Files:
3 edited

Legend:

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

    r35249 r35250  
    147147    // 3) add the input subset filename to the dvo_client command
    148148
     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
    149158    if (loadImages) {
    150159      Image *image;
     
    154163      char *filename = abspath("image.metadata.fits", DVO_MAX_PATH);
    155164      ImageMetadataSave (filename, image, Nimage);
    156       argc += 2;
    157       argv[argc-2] = strcreate ("-image-metadata");
    158       argv[argc-1] = strcreate (filename);
    159     }
    160 
    161     int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, 0, VERBOSE);
     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);
    162174
    163175    dbFreeFields (fields, Nfields);
     
    167179    dvo_catalog_free (&catalog);
    168180
    169     if (loadImages) {
    170       free (argv[argc-1]);
    171       free (argv[argc-2]);
    172     }
     181    // free up targv
     182    for (i = 0; i < targc; i++) {
     183      free (targv[i]);
     184    }
     185    free (targv);
    173186
    174187    return status;
  • 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);
  • branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/test/mmatch.sh

    r34464 r35250  
    1010  $Ro = 2.59
    1111  $Do = 1.23
    12   catdir /data/pikake.0/eugene/src/ipp-dev/Ohana/src/dvomerge/test/catdir.merge
     12  catdir catdir.merge
    1313  $Gname = g
    1414  $Rname = r
     
    2121  subset r_ave = $Rname  if (ra > $Ro - 0.1) && (ra > $Ro + 0.1) && (dec > $Do - 0.1) && (dec < $Do + 0.1)
    2222  vectors
    23   mmatch -v -parallel R D 1.0 RA DEC MAG PHOTCODE -index index
     23
     24  # mmatch -v -parallel R D 1.0 RA DEC MAG PHOTCODE -index index
     25  mmatch -v -parallel R D 1.0 RA DEC MAG PHOTCODE externID mean_airmass -index index
    2426
    2527  reindex g_ave_match = g_ave using index
Note: See TracChangeset for help on using the changeset viewer.