Changeset 26597
- Timestamp:
- Jan 14, 2010, 10:50:00 AM (16 years ago)
- Location:
- branches/eam_branches/20091201/ppSub/src
- Files:
-
- 5 edited
-
ppSub.h (modified) (1 diff)
-
ppSubCamera.c (modified) (1 diff)
-
ppSubFiles.c (modified) (1 diff)
-
ppSubLoop.c (modified) (2 diffs)
-
ppSubReadoutJpeg.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/ppSub/src/ppSub.h
r26432 r26597 152 152 ); 153 153 154 /// Generate JPEG images 155 bool ppSubResidualSampleJpeg(pmConfig *config); 156 154 157 /// Generate inverse subtraction 155 158 bool ppSubReadoutInverse(pmConfig *config // Configuration -
branches/eam_branches/20091201/ppSub/src/ppSubCamera.c
r26543 r26597 297 297 jpeg2->save = true; 298 298 299 // Output residual JPEG 300 pmFPAfile *jpeg3 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.RESID.JPEG"); 301 if (!jpeg3) { 302 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.RESID.JPEG")); 303 return false; 304 } 305 if (jpeg3->type != PM_FPA_FILE_JPEG) { 306 psError(PS_ERR_IO, true, "PPSUB.OUTPUT.RESID.JPEG is not of type JPEG"); 307 return false; 308 } 309 jpeg3->save = true; 310 299 311 // Output subtraction kernel 300 312 pmFPAfile *kernel = defineCalcFile(config, output, "PPSUB.OUTPUT.KERNELS", PM_FPA_FILE_SUBKERNEL); -
branches/eam_branches/20091201/ppSub/src/ppSubFiles.c
r23740 r26597 23 23 // Subtraction files 24 24 static const char *subFiles[] = { "PPSUB.OUTPUT", "PPSUB.OUTPUT.MASK", "PPSUB.OUTPUT.VARIANCE", 25 "PPSUB.OUTPUT.JPEG1", "PPSUB.OUTPUT.JPEG2", 25 "PPSUB.OUTPUT.JPEG1", "PPSUB.OUTPUT.JPEG2", "PPSUB.OUTPUT.RESID.JPEG", 26 26 NULL }; 27 27 -
branches/eam_branches/20091201/ppSub/src/ppSubLoop.c
r26431 r26597 54 54 // Can't do anything at all 55 55 return true; 56 } 57 // generate the residual stamp grid for visualization 58 if (!ppSubResidualSampleJpeg(config)) { 59 psError(PS_ERR_UNKNOWN, false, "Unable to update."); 60 return false; 56 61 } 57 62 … … 130 135 } 131 136 137 // generate the binned image used to write the jpeg 132 138 if (!ppSubReadoutJpeg(config)) { 133 139 psError(PS_ERR_UNKNOWN, false, "Unable to update."); -
branches/eam_branches/20091201/ppSub/src/ppSubReadoutJpeg.c
r23740 r26597 49 49 return true; 50 50 } 51 52 bool ppSubResidualSampleJpeg(pmConfig *config) { 53 54 pmFPAview *view = ppSubViewReadout(); // View to readout 55 56 // we save sample difference stamps on the convolved image readout->analysis metadata 57 pmReadout *inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input convolved 58 59 psArray *samples = psArrayAllocEmpty(16); // Array of sample stamp images 60 61 // we may have multiple entries with the same name; pull them off into a separate array: 62 psString regex = NULL; // Regular expression 63 psStringAppend(®ex, "^%s$", "SUBTRACTION.SAMPLE.STAMP.SET"); 64 psMetadataIterator *iter = psMetadataIteratorAlloc(inConv->analysis, PS_LIST_HEAD, regex); // Iterator 65 psFree(regex); 66 67 psMetadataItem *item = NULL;// Item from iteration 68 while ((item = psMetadataGetAndIncrement(iter))) { 69 assert(item->type == PS_DATA_ARRAY); 70 psArray *sampleStamps = item->data.V; 71 samples = psArrayAdd(samples, 16, sampleStamps); 72 } 73 psFree(iter); 74 psAssert (samples, "no sample stamps?"); 75 psAssert (samples->n, "no sample stamps?"); 76 77 // get the kernel sizes 78 psArray *kernels = samples->data[0]; 79 psAssert (kernels, "no valid kernel?"); 80 psAssert (kernels->n, "no valid kernel?"); 81 82 psImage *kernel = kernels->data[0]; 83 psAssert (kernel, "missing valid kernel?"); 84 85 int DX = kernel->numCols; 86 int DY = kernel->numRows; 87 88 // each array contains up to 9 sample stamps. generate an image mosaicking these together in 3x3 blocks. 89 int innerBorder = 1; 90 int outerBorder = 2; 91 int NXblock = sqrt(samples->n); 92 int NYblock = samples->n / NXblock; 93 if (samples->n % NXblock) NYblock ++; 94 95 int NXpix = NXblock * (3 * (DX + innerBorder) + outerBorder); 96 int NYpix = NYblock * (3 * (DY + innerBorder) + outerBorder); 97 98 // output cell 99 pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.RESID.JPEG"); 100 pmReadout *readout = pmReadoutAlloc(cell); 101 readout->image = psImageAlloc(NXpix, NYpix, PS_TYPE_F32); 102 103 cell->data_exists = true; 104 cell->parent->data_exists = true; 105 106 psImageInit (readout->image, 0.0); 107 108 for (int i = 0; i < samples->n; i++) { 109 110 int xBlock = i % NXblock; 111 int yBlock = i / NYblock; 112 113 psArray *kernels = samples->data[i]; 114 115 for (int j = 0; j < kernels->n; j++) { 116 117 psImage *kernel = kernels->data[j]; 118 119 int xSub = j % 3; 120 int ySub = j / 3; 121 122 int xPix = xBlock * (3 * (DX + innerBorder) + outerBorder) + xSub * (DX + innerBorder); 123 int yPix = yBlock * (3 * (DX + innerBorder) + outerBorder) + ySub * (DY + innerBorder); 124 125 for (int y = 0; y < kernel->numRows; y++) { 126 for (int x = 0; x < kernel->numCols; x++) { 127 readout->image->data.F32[y + yPix][x + xPix] = kernel->data.F32[y][x]; 128 } 129 } 130 } 131 } 132 133 { 134 psFits *fits = psFitsOpen ("resid.stamps.fits", "w"); 135 psFitsWriteImage (fits, NULL, readout->image, 0, NULL); 136 psFitsClose (fits); 137 } 138 139 return true; 140 }
Note:
See TracChangeset
for help on using the changeset viewer.
