Changeset 14328
- Timestamp:
- Jul 19, 2007, 3:02:55 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppSub/src/ppSubReadout.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSubReadout.c
r14316 r14328 11 11 12 12 #define TESTING 13 #define WCS_TOLERANCE 0.001 // Tolerance for WCS 13 14 14 15 bool ppSubReadout(pmConfig *config, const pmFPAview *view) … … 121 122 } 122 123 } 124 psFree(stamps); 125 stamps = NULL; 126 127 #ifdef TESTING 128 { 129 // Generate image with convolution kernels 130 int fullSize = 2 * size + 1 + 1; // Full size of kernel 131 psImage *convKernels = psImageAlloc(5 * fullSize - 1, 5 * fullSize - 1, PS_TYPE_F32); 132 psImageInit(convKernels, NAN); 133 for (int j = -2; j <= 2; j++) { 134 for (int i = -2; i <= 2; i++) { 135 psImage *kernel = pmSubtractionKernelImage(solution, kernels, (float)i / 2.0, 136 (float)j / 2.0); // Image of the kernel 137 if (!kernel) { 138 psError(PS_ERR_UNKNOWN, false, "Unable to generate kernel image."); 139 psFree(convKernels); 140 goto ERROR; 141 } 142 143 if (psImageOverlaySection(convKernels, kernel, (i + 2) * fullSize, 144 (j + 2) * fullSize, "=") == 0) { 145 psError(PS_ERR_UNKNOWN, false, "Unable to overlay kernel image."); 146 psFree(kernel); 147 psFree(convKernels); 148 goto ERROR; 149 } 150 psFree(kernel); 151 } 152 } 153 154 // XXX What do we do with this image? 155 156 psFits *kernelFile = psFitsOpen("kernel.fits", "w"); 157 (void)psFitsWriteImage(kernelFile, NULL, convKernels, 0, NULL); 158 psFitsClose(kernelFile); 159 160 psFree(convKernels); 161 } 162 163 { 164 // Generate images of the kernel components 165 psMetadata *header = psMetadataAlloc(); // Header 166 for (int i = 0; i < solution->n; i++) { 167 psString name = NULL; // Header keyword 168 psStringAppend(&name, "SOLN%04d", i); 169 psMetadataAddF64(header, PS_LIST_TAIL, name, 0, NULL, solution->data.F64[i]); 170 psFree(name); 171 } 172 psArray *kernelImages = pmSubtractionKernelSolutions(solution, kernels, 0.0, 0.0); 173 psFits *kernelFile = psFitsOpen("kernels.fits", "w"); 174 (void)psFitsWriteImageCube(kernelFile, header, kernelImages, NULL); 175 psFitsClose(kernelFile); 176 psFree(kernelImages); 177 psFree(header); 178 } 179 #endif 123 180 124 181 psImage *convImage = NULL, *convWeight = NULL, *convMask = NULL; // Convolved images … … 130 187 psFree(subMask); 131 188 subMask = NULL; 189 190 psFree(kernels); 191 psFree(solution); 132 192 133 193 // Do the subtraction … … 165 225 } 166 226 167 #ifdef TESTING168 // Generate image with convolution kernels169 int fullSize = 2 * size + 1 + 1; // Full size of kernel170 psImage *convKernels = psImageAlloc(5 * fullSize - 1, 5 * fullSize - 1, PS_TYPE_F32);171 psImageInit(convKernels, NAN);172 for (int j = -2; j <= 2; j++) {173 for (int i = -2; i <= 2; i++) {174 psImage *kernel = pmSubtractionKernelImage(solution, kernels, (float)i / 2.0,175 (float)j / 2.0); // Image of the kernel176 if (!kernel) {177 psError(PS_ERR_UNKNOWN, false, "Unable to generate kernel image.");178 psFree(convKernels);179 goto ERROR;180 }181 if (psImageOverlaySection(convKernels, kernel, (i + 2) * fullSize,182 (j + 2) * fullSize, "=") == 0) {183 psError(PS_ERR_UNKNOWN, false, "Unable to overlay kernel image.");184 psFree(kernel);185 psFree(convKernels);186 goto ERROR;187 }188 }189 }190 191 // XXX What do we do with this image?192 193 psFits *kernelFile = psFitsOpen("kernel.fits", "w");194 (void)psFitsWriteImage(kernelFile, NULL, convKernels, 0, NULL);195 psFitsClose(kernelFile);196 197 psFree(convKernels);198 #endif199 200 psFree(kernels);201 psFree(stamps);202 psFree(solution);203 204 227 if (psMetadataLookupBool(NULL, config->arguments, "PHOTOMETRY")) { 205 228 pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT"); … … 210 233 pmFPAfileActivate(config->files, false, "PSPHOT.INPUT"); 211 234 } 235 236 // Copy astrometry over 237 pmFPA *refFPA = refRO->parent->parent->parent; // Reference FPA 238 pmHDU *refHDU = refFPA->hdu; // Reference HDU 239 pmFPA *outFPA = outCell->parent->parent; // Output FPA 240 pmHDU *outHDU = outFPA->hdu; // Output HDU 241 if (!outHDU || !refHDU) { 242 psWarning("Unable to find HDU at FPA level to copy astrometry."); 243 } else { 244 if (!pmAstromReadWCS(outFPA, outCell->parent, refHDU->header, 1.0)) { 245 psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry from reference FPA."); 246 psFree(outRO); 247 return false; 248 } 249 if (!outHDU->header) { 250 outHDU->header = psMetadataAlloc(); 251 } 252 if (!pmAstromWriteWCS(outHDU->header, outFPA, outCell->parent, WCS_TOLERANCE)) { 253 psError(PS_ERR_UNKNOWN, false, "Unable to write WCS astrometry to output FPA."); 254 psFree(outRO); 255 return false; 256 } 257 } 258 259 psFree(outRO); 212 260 213 261 return true; … … 218 266 psFree(stamps); 219 267 psFree(solution); 268 psFree(outRO); 220 269 return false; 221 270 }
Note:
See TracChangeset
for help on using the changeset viewer.
