Changeset 18884 for trunk/pswarp/src/pswarpTransformReadout.c
- Timestamp:
- Aug 4, 2008, 11:12:16 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/pswarp/src/pswarpTransformReadout.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpTransformReadout.c
r18839 r18884 20 20 21 21 // output mask bits 22 psMaskType maskIn = psMetadataLookupU8(&mdok, recipe, "MASK.INPUT"); 23 psMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config); 24 psMaskType maskBad = pmConfigMaskGet("BAD.WARP", config); 22 psMaskType maskIn = psMetadataLookupU8(&mdok, recipe, "MASK.INPUT"); 23 psMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config); 24 psMaskType maskBad = pmConfigMaskGet("BAD.WARP", config); 25 25 psAssert (mdok, "MASK.INPUT was not defined"); 26 26 … … 29 29 30 30 // Flux fraction for "poor" 31 float poorFrac = psMetadataLookupF32(NULL, config->arguments, "POOR.FRAC"); 31 float poorFrac = psMetadataLookupF32(NULL, config->arguments, "POOR.FRAC"); 32 32 33 33 // pswarpMapGridFromImage builds a set of locally-linear maps which convert the … … 43 43 44 44 if (input->weight && !output->weight) { 45 output->weight = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_F32);46 psImageInit(output->weight, NAN);45 output->weight = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_F32); 46 psImageInit(output->weight, NAN); 47 47 } 48 48 if ((input->mask || maskPoor || maskBad) && !output->mask) { 49 output->mask = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_MASK);50 psImageInit(output->mask, maskBad);49 output->mask = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_MASK); 50 psImageInit(output->mask, maskBad); 51 51 } 52 52 … … 56 56 // create jobs and supply them to the threads 57 57 for (int gridY = 0; gridY < grid->nYpts; gridY++) { 58 for (int gridX = 0; gridX < grid->nXpts; gridX++) {58 for (int gridX = 0; gridX < grid->nXpts; gridX++) { 59 59 60 pswarpTransformTileArgs *args = pswarpTransformTileArgsAlloc();60 pswarpTransformTileArgs *args = pswarpTransformTileArgsAlloc(); 61 61 62 // these items are just views to the data; they are not freed with args63 args->input = input;64 args->output = output;65 args->grid = grid;66 args->interp = interp;67 args->region = region;62 // these items are just views to the data; they are not freed with args 63 args->input = input; 64 args->output = output; 65 args->grid = grid; 66 args->interp = interp; 67 args->region = region; 68 68 69 args->gridX = gridX;70 args->gridY = gridY;71 args->goodPixels = 0;69 args->gridX = gridX; 70 args->gridY = gridY; 71 args->goodPixels = 0; 72 72 73 // allocate a job74 psThreadJob *job = psThreadJobAlloc ("PSWARP_TRANSFORM_TILE");73 // allocate a job 74 psThreadJob *job = psThreadJobAlloc ("PSWARP_TRANSFORM_TILE"); 75 75 76 // construct the arguments for this job77 // job is pswarpTransformTile (gridX, gridY);78 psArrayAdd (job->args, 1, args);79 // fprintf (stderr, "adding job %d,%d, Nargs: %ld\n", gridX, gridY, job->args->n);76 // construct the arguments for this job 77 // job is pswarpTransformTile (gridX, gridY); 78 psArrayAdd (job->args, 1, args); 79 // fprintf (stderr, "adding job %d,%d, Nargs: %ld\n", gridX, gridY, job->args->n); 80 80 81 // call: pswarpTransformTile (args);82 if (!psThreadJobAddPending (job)) {83 psError(PS_ERR_UNKNOWN, false, "Unable to warp image.");84 return false;85 }86 psFree (args);87 }81 // call: pswarpTransformTile (args); 82 if (!psThreadJobAddPending (job)) { 83 psError(PS_ERR_UNKNOWN, false, "Unable to warp image."); 84 return false; 85 } 86 psFree (args); 87 } 88 88 } 89 89 … … 91 91 // wait here for the threaded jobs to finish 92 92 if (!psThreadPoolWait ()) { 93 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");94 return false;93 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 94 return false; 95 95 } 96 fprintf (stderr, "success for threaded jobs\n");97 96 98 97 // each job records its own goodPixel values; sum them here … … 100 99 psThreadJob *job = NULL; 101 100 while ((job = psThreadJobGetDone()) != NULL) { 102 if (job->args->n < 1) {103 fprintf (stderr, "error with job\n");104 } else {105 pswarpTransformTileArgs *args = job->args->data[0];106 // fprintf (stderr, "finished job %d,%d, Nargs: %ld\n", args->gridX, args->gridY, job->args->n);107 goodPixels += args->goodPixels;108 }109 psFree (job);101 if (job->args->n < 1) { 102 fprintf (stderr, "error with job\n"); 103 } else { 104 pswarpTransformTileArgs *args = job->args->data[0]; 105 // fprintf (stderr, "finished job %d,%d, Nargs: %ld\n", args->gridX, args->gridY, job->args->n); 106 goodPixels += args->goodPixels; 107 } 108 psFree (job); 110 109 } 111 110 psFree(interp); … … 115 114 // Store the variance factor and number of good pixels 116 115 if (goodPixels > 0) { 117 // Variance factor: large factor --> small scale118 float varFactor = psImageInterpolateVarianceFactor(input->image->numCols / 2.0 + input->image->col0, input->image->numRows / 2.0 + input->image->row0, interp); 116 // Variance factor: large factor --> small scale 117 float varFactor = psImageInterpolateVarianceFactor(input->image->numCols / 2.0 + input->image->col0, input->image->numRows / 2.0 + input->image->row0, interp); 119 118 psMetadataItem *vfItem = psMetadataLookup(output->analysis, PSWARP_ANALYSIS_VARFACTOR); 120 119 if (vfItem) { … … 135 134 136 135 if (goodPixels > 0) { 137 if (!pswarpTransformSources (output, input, config)) {138 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");139 return false;140 }136 if (!pswarpTransformSources (output, input, config)) { 137 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 138 return false; 139 } 141 140 } 142 141
Note:
See TracChangeset
for help on using the changeset viewer.
