Changeset 35263 for trunk/Ohana/src/opihi/dvo/mextract.c
- Timestamp:
- Mar 7, 2013, 9:51:07 AM (13 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20130306/Ohana (added) merged: 35244-35246,35248-35259,35261-35262
- Property svn:mergeinfo changed
-
trunk/Ohana/src/opihi
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20130306/Ohana/src/opihi (added) merged: 35244,35246,35249-35250,35258
- Property svn:mergeinfo changed
-
trunk/Ohana/src/opihi/dvo/mextract.c
r34749 r35263 1 1 # include "dvoshell.h" 2 3 int 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 } 2 21 3 22 int mextract (int argc, char **argv) { … … 5 24 off_t i, j, k, m; // used for counter averages and measures 6 25 int n, N, Npts, NPTS, last, next, state, Nfields, Nreturn, Ncstack, Nstack; 7 int Nsecfilt, VERBOSE, loadImages , mosaicMode;26 int Nsecfilt, VERBOSE, loadImages; 8 27 char **cstack, name[1024]; 9 28 dbValue *values; … … 33 52 remove_argument (N, &argc, argv); 34 53 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); 35 61 } 36 62 … … 66 92 67 93 // 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); 69 96 70 97 // command-line is of the form: mextract field,field, field [where (field op value)...] … … 106 133 if ((skylist = SelectRegions (selection)) == NULL) goto escape; 107 134 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 108 141 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 109 142 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); 111 174 112 175 dbFreeFields (fields, Nfields); … … 116 179 dvo_catalog_free (&catalog); 117 180 181 // free up targv 182 for (i = 0; i < targc; i++) { 183 free (targv[i]); 184 } 185 free (targv); 186 118 187 return status; 119 188 } 120 189 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 } 138 197 139 198 /* create storage vector */ … … 251 310 free (stack); 252 311 FreeImageSelection (); 312 FreeImageMetadataSelection (); 253 313 SkyListFree (skylist); 254 314 FreeSkyRegionSelection (selection); … … 264 324 free (stack); 265 325 FreeImageSelection (); 326 FreeImageMetadataSelection (); 266 327 SkyListFree (skylist); 267 328 FreeSkyRegionSelection (selection);
Note:
See TracChangeset
for help on using the changeset viewer.
