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:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/opihi

  • trunk/Ohana/src/opihi/cmd.astro

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/Ohana/src/opihi/cmd.data

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/Ohana/src/opihi/dvo/dvo_client.c

    r33963 r35263  
    3939    remove_argument (N, argc, argv);
    4040  }
     41  if (!HOST_ID) {
     42    fprintf (stderr, "ERROR: dvo_client requires a -hostID value\n");
     43    exit (3);
     44  }
    4145
    4246  HOSTDIR = NULL;
     
    4549    HOSTDIR = strcreate (argv[N]);;
    4650    remove_argument (N, argc, argv);
     51  }
     52  if (!HOSTDIR) {
     53    fprintf (stderr, "ERROR: dvo_client requires a -hostdir value\n");
     54    exit (3);
    4755  }
    4856
  • 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);
  • 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);
  • trunk/Ohana/src/opihi/dvo/mmextract.c

    r30612 r35263  
    11# include "dvoshell.h"
     2int field_needs_images (dbField *field);
    23
    34int mmextract (int argc, char **argv) {
     
    78  int Nfields, Nreturn, Nreturn_base, Ncstack1, Ncstack2, Nstack1, Nstack2;
    89  int Nwhere, Iwhere, Nmatch, Imatch, NTABLE, Nt1, Nt2, n1, n2;
    9   int Nsecfilt, VERBOSE, loadImages, mosaicMode;
     10  int Nsecfilt, VERBOSE, loadImages;
    1011  char **cstack1, **cstack2, name1[1024], name2[1024];
    1112  dbValue *values, **table1, **table2;
     
    4546 
    4647  // init locally static variables (time refs)
    47   dbExtractMeasuresInit();
     48  dbExtractMeasuresInit(HOST_ID);
    4849
    4950  // parse skyregion options
     
    137138  // load image data if needed (for fields listed below)
    138139  loadImages = FALSE;
    139   mosaicMode = FALSE;
    140140  for (i = 0; !loadImages && (i < Nfields); i++) {
    141     if (fields[i].ID == MEAS_XCCD) loadImages = TRUE;
    142     if (fields[i].ID == MEAS_YCCD) loadImages = TRUE;
    143     if (fields[i].ID == MEAS_XMOSAIC) loadImages = mosaicMode = TRUE;
    144     if (fields[i].ID == MEAS_YMOSAIC) loadImages = mosaicMode = TRUE;
    145   }
    146   if (loadImages && !SetImageSelection (mosaicMode, selection)) goto escape;
     141    loadImages = field_needs_images (&fields[i]);
     142  }
     143  if (loadImages && !SetImageSelection (TRUE, selection)) goto escape;
    147144
    148145  /* create storage vector */
  • trunk/Ohana/src/opihi/dvo/test/mmatch.sh

    r34464 r35263  
    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.