Changeset 33662 for trunk/Ohana/src/opihi/dvo/mextract.c
- Timestamp:
- Apr 1, 2012, 3:24:39 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/mextract.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/mextract.c
r30612 r33662 25 25 selection = NULL; 26 26 27 // fprintf (stderr, "start..."); 27 28 if ((N = get_argument (argc, argv, "-h"))) goto help; 28 29 if ((N = get_argument (argc, argv, "--help"))) goto help; … … 34 35 } 35 36 37 int PARALLEL = FALSE; 38 if ((N = get_argument (argc, argv, "-parallel"))) { 39 remove_argument (N, &argc, argv); 40 PARALLEL = TRUE; 41 } 42 43 // this is used to NOT save the results in the results file 44 // use this option when mextract is used in a script which does its 45 // own job of packaging the results 46 int SKIP_RESULTS = FALSE; 47 if ((N = get_argument (argc, argv, "-skip-results"))) { 48 remove_argument (N, &argc, argv); 49 SKIP_RESULTS = TRUE; 50 } 51 52 // init here so free in 'escape' block does not crash 36 53 dvo_catalog_init (&catalog, TRUE); 37 54 … … 40 57 Nsecfilt = GetPhotcodeNsecfilt (); 41 58 59 // parse skyregion options. NOTE: this is stripped off in parallel operation and always 60 // defined for the client via the -skyregion option. The dvo_client parses this 61 // argument in the main program, before it is passed to the command (like mextract) 62 if ((selection = SetRegionSelection (&argc, argv)) == NULL) { 63 print_error(); 64 goto escape; 65 } 66 42 67 // init locally static variables (time refs) 43 68 dbExtractMeasuresInit(); 44 69 45 // parse skyregion options 46 if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape; 47 48 // command-line is of the form: avextract field,field, field [where (field op value)...] 70 // command-line is of the form: mextract field,field, field [where (field op value)...] 49 71 50 72 // parse the fields to be extracted and returned … … 84 106 if ((skylist = SelectRegions (selection)) == NULL) goto escape; 85 107 108 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 109 if (PARALLEL && !HOST_ID) { 110 int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE); 111 112 dbFreeFields (fields, Nfields); 113 dbFreeStack (stack, Nstack); 114 free (stack); 115 FreeSkyRegionSelection (selection); 116 dvo_catalog_free (&catalog); 117 118 return status; 119 } 120 86 121 // load image data if needed (for fields listed below) 87 122 loadImages = FALSE; 88 123 mosaicMode = FALSE; 89 124 for (i = 0; !loadImages && (i < Nfields); i++) { 90 if (fields[i].ID == MEAS_XCCD) loadImages = TRUE; // Are these still needed? Xccd and Yccd are in measurement 91 if (fields[i].ID == MEAS_YCCD) loadImages = TRUE; // and dbExtractMeasures doesn't look at the image for these 92 if (fields[i].ID == MEAS_XMOSAIC) loadImages = mosaicMode = TRUE; 93 if (fields[i].ID == MEAS_YMOSAIC) loadImages = mosaicMode = TRUE; 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; 94 133 if (fields[i].ID == MEAS_EXTERN_ID) loadImages = mosaicMode = TRUE; 134 if (fields[i].ID == MEAS_FLAT) loadImages = mosaicMode = TRUE; 95 135 } 96 136 if (loadImages && !SetImageSelection (mosaicMode, selection)) goto escape; … … 115 155 interrupt = FALSE; 116 156 157 // fprintf (stderr, "done setup..."); 158 117 159 for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) { 160 161 // does this host ID match the desired location for the table? 162 if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 163 118 164 /* lock, load, unlock catalog */ 119 catalog.filename = skylist[0].filename[i]; 165 char hostfile[1024]; 166 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 167 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 120 168 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; 121 169 catalog.Nsecfilt = Nsecfilt; … … 126 174 if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) { 127 175 gprint (GP_ERR, "ERROR: failure to open catalog file %s\n", catalog.filename); 128 exit (2);176 return FALSE; 129 177 } 130 178 dvo_catalog_unlock (&catalog); … … 132 180 /* XXX need to call dvo_catalog_chipcoords here passing the loaded images */ 133 181 182 // fprintf (stderr, "done read..."); 183 134 184 for (j = 0; (j < catalog.Naverage) && !interrupt; j++) { 135 185 m = catalog.average[j].measureOffset; 136 dbExtractMeasuresInitAve (); // reset counters for saved fields 186 if (m > catalog.Nmeasure) { 187 gprint (GP_ERR, "ERROR: inconsistent average->measure offset. Unsorted database?\n"); 188 goto escape; 189 } 190 191 dbExtractMeasuresInitAve (); // reset counters for saved fields (costs very little 137 192 138 193 for (k = 0; (k < catalog.average[j].Nmeasure); k++, m++) { 194 if (catalog.measure[m].averef != j) { 195 gprint (GP_ERR, "ERROR: inconsistent measure->average link. Unsorted database?\n"); 196 goto escape; 197 } 139 198 140 199 // extract the relevant values for this measurement 141 dbExtractMeasuresInitMeas (); // reset counters for saved fields 200 dbExtractMeasuresInitMeas (); // reset counters for saved fields (costs very little 142 201 for (n = 0; n < Nfields; n++) { 143 202 values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]); … … 173 232 interrupt = FALSE; 174 233 234 // fprintf (stderr, "done load..."); 235 175 236 for (n = 0; n < Nreturn; n++) { 176 ResetVector (vec[n], fields[n].type, MAX(1,Npts)); 237 ResetVector (vec[n], fields[n].type, Npts); 238 } 239 240 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 241 if (RESULT_FILE && !SKIP_RESULTS) { 242 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, NULL); 243 if (!status) goto escape; 177 244 } 178 245 … … 185 252 SkyListFree (skylist); 186 253 FreeSkyRegionSelection (selection); 254 255 // fprintf (stderr, "done extr...\n"); 187 256 return (TRUE); 188 257 … … 307 376 gprint (GP_ERR, " imageID : ID of source image (32 bit)\n"); 308 377 gprint (GP_ERR, " externID : externID of source image (32 bit)\n"); 378 379 gprint (GP_ERR, " Mcal_offset : difference wrt nominal zero point (clouds are positive)\n"); 380 gprint (GP_ERR, " flat : flat-field correction (measure.Mcal - image.Mcal)\n"); 309 381 return (FALSE); 310 382 }
Note:
See TracChangeset
for help on using the changeset viewer.
