Changeset 18884
- Timestamp:
- Aug 4, 2008, 11:12:16 AM (18 years ago)
- Location:
- trunk/pswarp/src
- Files:
-
- 2 edited
-
pswarpTransformReadout.c (modified) (8 diffs)
-
pswarpTransformReadout_Threaded.c (modified) (4 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 -
trunk/pswarp/src/pswarpTransformReadout_Threaded.c
r18839 r18884 23 23 24 24 // output mask bits 25 psMaskType maskIn = psMetadataLookupU8(&mdok, recipe, "MASK.INPUT"); 26 psMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config); 27 psMaskType maskBad = pmConfigMaskGet("BAD.WARP", config); 25 psMaskType maskIn = psMetadataLookupU8(&mdok, recipe, "MASK.INPUT"); 26 psMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config); 27 psMaskType maskBad = pmConfigMaskGet("BAD.WARP", config); 28 28 psAssert (mdok, "MASK.INPUT was not defined"); 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 // find the output pixel range … … 58 58 59 59 // Interpolation options 60 psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(interpolationMode, inImage, 60 psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(interpolationMode, inImage, 61 61 inVar, inMask, maskIn, NAN, NAN, 62 62 maskBad, maskPoor, poorFrac); 63 63 64 64 if (inVar && !output->weight) { 65 output->weight = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_F32);66 psImageInit(output->weight, NAN);65 output->weight = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_F32); 66 psImageInit(output->weight, NAN); 67 67 } 68 68 if ((inMask || maskPoor || maskBad) && !output->mask) { 69 output->mask = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_MASK);70 psImageInit(output->mask, maskBad);69 output->mask = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_MASK); 70 psImageInit(output->mask, maskBad); 71 71 } 72 72 … … 76 76 // create jobs and supply them to the threads 77 77 for (gridY = 0; gridY < nGridX; gridY++) { 78 for (gridX = 0; gridX < nGridY; gridX++) {79 80 pswarpTransformTileArgs *args = pswarpTransformTileArgsAlloc();81 82 // these items are just views to the data; they are not freed with args83 args->input = input;84 args->output = output;85 args->grid = grid;86 args->interp = interp;87 args->region = region;88 89 args->gridX = gridX;90 args->gridY = gridY;91 args->goodPixels = 0;92 93 # if (THREADED) 94 // allocate a job95 psThreadJob *job = psThreadJobAlloc ("PSWARP_TRANSFORM_TILE", 0);96 97 // construct the arguments for this job98 // job is pswarpTransformTile (gridX, gridY);99 psArrayAdd (job->args, 1, args);100 psThreadJobAddPending (job);78 for (gridX = 0; gridX < nGridY; gridX++) { 79 80 pswarpTransformTileArgs *args = pswarpTransformTileArgsAlloc(); 81 82 // these items are just views to the data; they are not freed with args 83 args->input = input; 84 args->output = output; 85 args->grid = grid; 86 args->interp = interp; 87 args->region = region; 88 89 args->gridX = gridX; 90 args->gridY = gridY; 91 args->goodPixels = 0; 92 93 # if (THREADED) 94 // allocate a job 95 psThreadJob *job = psThreadJobAlloc ("PSWARP_TRANSFORM_TILE", 0); 96 97 // construct the arguments for this job 98 // job is pswarpTransformTile (gridX, gridY); 99 psArrayAdd (job->args, 1, args); 100 psThreadJobAddPending (job); 101 101 # else 102 pswarpTransformTile (args);103 goodPixels += args->goodPixels;102 pswarpTransformTile (args); 103 goodPixels += args->goodPixels; 104 104 # endif 105 psFree (args);106 }107 } 108 109 # if (THREADED) 105 psFree (args); 106 } 107 } 108 109 # if (THREADED) 110 110 // wait here for the threaded jobs to finish 111 111 if (!psThreadPoolWait ()) { 112 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 113 return false; 114 } 115 fprintf (stderr, "success for threaded jobs\n"); 112 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 113 return false; 114 } 116 115 117 116 // each job records its own goodPixel values; sum them here … … 119 118 psThreadJob *job = NULL; 120 119 while ((job = psThreadJobGetDone()) != NULL) { 121 pswarpTransformTileArgs *args = job->args->data[0];122 goodPixels += args->goodPixels;123 psFree (job);120 pswarpTransformTileArgs *args = job->args->data[0]; 121 goodPixels += args->goodPixels; 122 psFree (job); 124 123 } 125 124 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
