- Timestamp:
- Apr 3, 2021, 2:31:34 PM (5 years ago)
- Location:
- trunk/pswarp/src
- Files:
-
- 3 edited
-
pswarpDefineBackground.c (modified) (1 diff)
-
pswarpLoopSkycell.c (modified) (26 diffs)
-
pswarpMapGrid.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpDefineBackground.c
r35563 r41538 145 145 } 146 146 } 147 148 147 149 148 view->chip = view->cell = view->readout = -1; 150 149 pmFPAAddSourceFromView(output->fpa, view, output->format); 151 150 152 153 151 psFree (view); 154 152 return true; -
trunk/pswarp/src/pswarpLoopSkycell.c
r35563 r41538 1 1 /** @file pswarpLoop.c 2 2 * 3 * ** this function is not used... ** 3 4 * @brief mail processing loop for pswarp 4 5 * @ingroup pswarp … … 63 64 64 65 // select the output readout 65 pmFPAview *view = pmFPAviewAlloc(0);66 view ->chip = 0;67 view ->cell = 0;68 view ->readout = 0;69 pmReadout *output = pmFPAfileThisReadout(config->files, view , "PSWARP.OUTPUT");66 pmFPAview *viewT0 = pmFPAviewAlloc(0); 67 viewT0->chip = 0; 68 viewT0->cell = 0; 69 viewT0->readout = 0; 70 pmReadout *output = pmFPAfileThisReadout(config->files, viewT0, "PSWARP.OUTPUT"); 70 71 if (!output) { 71 72 psError(PSWARP_ERR_CONFIG, true, "Can't find output data!\n"); 73 psFree (viewT0); 72 74 return false; 73 75 } 74 psFree (view); 75 76 psFree (viewT0); 76 77 77 78 // Turn all skycell files on to generate them, and then turn them off for the loop over the input images … … 97 98 98 99 pmChip *chip; 99 pmFPAview *view = pmFPAviewAlloc(0);100 if (!pmFPAfileIOChecks(config, view , PM_FPA_BEFORE)) {100 pmFPAview *viewT1 = pmFPAviewAlloc(0); 101 if (!pmFPAfileIOChecks(config, viewT1, PM_FPA_BEFORE)) { 101 102 psError(psErrorCodeLast(), false, "Unable to read files."); 102 goto DONE; 103 } 104 while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) { 105 psTrace ("pswarp", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 103 psFree(viewT1); 104 goto DONE; 105 } 106 while ((chip = pmFPAviewNextChip (viewT1, input->fpa, 1)) != NULL) { 107 psTrace ("pswarp", 4, "Chip %d: %x %x\n", viewT1->chip, chip->file_exists, chip->process); 106 108 if (!chip->process || !chip->file_exists) { continue; } 107 if (!pmFPAfileIOChecks(config, view , PM_FPA_BEFORE)) {109 if (!pmFPAfileIOChecks(config, viewT1, PM_FPA_BEFORE)) { 108 110 psError(psErrorCodeLast(), false, "Unable to read files."); 111 psFree(viewT1); 109 112 goto DONE; 110 113 } 111 114 pmCell *cell; 112 while ((cell = pmFPAviewNextCell (view , input->fpa, 1)) != NULL) {113 psTrace ("pswarp", 4, "Cell %d: %x %x\n", view ->cell, cell->file_exists, cell->process);115 while ((cell = pmFPAviewNextCell (viewT1, input->fpa, 1)) != NULL) { 116 psTrace ("pswarp", 4, "Cell %d: %x %x\n", viewT1->cell, cell->file_exists, cell->process); 114 117 if (!cell->process || !cell->file_exists) { continue; } 115 if (!pmFPAfileIOChecks (config, view , PM_FPA_BEFORE) ||116 !pmFPAfileIOChecks (config, view , PM_FPA_AFTER)) {118 if (!pmFPAfileIOChecks (config, viewT1, PM_FPA_BEFORE) || 119 !pmFPAfileIOChecks (config, viewT1, PM_FPA_AFTER)) { 117 120 psError(psErrorCodeLast(), false, "Unable to read files."); 121 psFree(viewT1); 118 122 goto DONE; 119 123 } 120 124 } 121 if (!pmFPAfileIOChecks (config, view , PM_FPA_AFTER)) {125 if (!pmFPAfileIOChecks (config, viewT1, PM_FPA_AFTER)) { 122 126 psError(psErrorCodeLast(), false, "Unable to write files."); 123 goto DONE; 124 } 125 } 126 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 127 psFree(viewT1); 128 goto DONE; 129 } 130 } 131 if (!pmFPAfileIOChecks (config, viewT1, PM_FPA_AFTER)) { 127 132 psError(psErrorCodeLast(), false, "Unable to write files."); 128 goto DONE; 129 } 130 psFree(view); 133 psFree(viewT1); 134 goto DONE; 135 } 136 psFree(viewT1); 131 137 132 138 pswarpFileActivation(config, detectorFiles, true); … … 139 145 // Don't care about the skycell anymore --- we've read it, and that's all we need to do. 140 146 pmFPAfileActivate(config->files, false, "PSWARP.SKYCELL"); 141 view= pmFPAviewAlloc(0);147 pmFPAview *viewT2 = pmFPAviewAlloc(0); 142 148 143 149 // find the FPA phu 144 150 bool bilevelAstrometry = false; 145 pmHDU *phu = pmFPAviewThisPHU(view , astrom->fpa);151 pmHDU *phu = pmFPAviewThisPHU(viewT2, astrom->fpa); 146 152 if (phu) { 147 153 char *ctype = psMetadataLookupStr(NULL, phu->header, "CTYPE1"); … … 153 159 if (!pmAstromReadBilevelMosaic(input->fpa, phu->header)) { 154 160 psError(psErrorCodeLast(), false, "Unable to read bilevel mosaic astrometry for input FPA."); 155 psFree(view );161 psFree(viewT2); 156 162 goto DONE; 157 163 } … … 161 167 162 168 // files associated with the science image 163 if (!pmFPAfileIOChecks (config, view , PM_FPA_BEFORE)) {169 if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_BEFORE)) { 164 170 psError(psErrorCodeLast(), false, "Unable to read files."); 171 psFree(viewT2); 165 172 goto DONE; 166 173 } … … 168 175 // *** main transformation block 169 176 pmChip *chip; 170 while ((chip = pmFPAviewNextChip (view , input->fpa, 1)) != NULL) {171 psTrace ("pswarp", 4, "Chip %d: %x %x\n", view ->chip, chip->file_exists, chip->process);177 while ((chip = pmFPAviewNextChip (viewT2, input->fpa, 1)) != NULL) { 178 psTrace ("pswarp", 4, "Chip %d: %x %x\n", viewT2->chip, chip->file_exists, chip->process); 172 179 if (!chip->process || !chip->file_exists) { continue; } 173 if (!pmFPAfileIOChecks (config, view , PM_FPA_BEFORE)) {180 if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_BEFORE)) { 174 181 psError(psErrorCodeLast(), false, "Unable to read files."); 182 psFree(viewT2); 175 183 goto DONE; 176 184 } 177 185 178 186 // read WCS data from the corresponding header 179 pmHDU *hdu = pmFPAviewThisHDU (view , astrom->fpa);187 pmHDU *hdu = pmFPAviewThisHDU (viewT2, astrom->fpa); 180 188 181 189 … … 183 191 if (!pmAstromReadBilevelChip (chip, hdu->header)) { 184 192 psError(psErrorCodeLast(), false, "Unable to read bilevel chip astrometry for input FPA."); 185 psFree(view );193 psFree(viewT2); 186 194 goto DONE; 187 195 } … … 190 198 if (!pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0)) { 191 199 psError(psErrorCodeLast(), false, "Unable to read WCS astrometry for input FPA."); 192 psFree(view );200 psFree(viewT2); 193 201 goto DONE; 194 202 } … … 196 204 197 205 pmCell *cell; 198 while ((cell = pmFPAviewNextCell (view , input->fpa, 1)) != NULL) {199 psTrace ("pswarp", 4, "Cell %d: %x %x\n", view ->cell, cell->file_exists, cell->process);206 while ((cell = pmFPAviewNextCell (viewT2, input->fpa, 1)) != NULL) { 207 psTrace ("pswarp", 4, "Cell %d: %x %x\n", viewT2->cell, cell->file_exists, cell->process); 200 208 if (!cell->process || !cell->file_exists) { continue; } 201 209 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 202 210 psError(psErrorCodeLast(), false, "Unable to read files."); 211 psFree(viewT2); 203 212 goto DONE; 204 213 } … … 211 220 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 212 221 psError(psErrorCodeLast(), false, "Unable to read files."); 222 psFree(viewT2); 213 223 goto DONE; 214 224 } … … 229 239 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 230 240 psError(psErrorCodeLast(), false, "Unable to write files."); 241 psFree(viewT2); 231 242 goto DONE; 232 243 } … … 234 245 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 235 246 psError(psErrorCodeLast(), false, "Unable to write files."); 247 psFree(viewT2); 236 248 goto DONE; 237 249 } … … 239 251 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 240 252 psError(psErrorCodeLast(), false, "Unable to write files."); 253 psFree(viewT2); 241 254 goto DONE; 242 255 } … … 251 264 psphotFilesActivate(config, false); 252 265 psFree(cells); 253 psFree(view );266 psFree(viewT2); 254 267 goto DONE; 255 268 } … … 262 275 psError(psErrorCodeLast(), false, "Unable to calculate pixel regions."); 263 276 psFree(cells); 264 psFree(view );277 psFree(viewT2); 265 278 goto DONE; 266 279 } … … 270 283 psError(psErrorCodeLast(), false, "Unable to calculate mask stats."); 271 284 psFree(cells); 272 psFree(view );285 psFree(viewT2); 273 286 goto DONE; 274 287 } … … 299 312 psError(psErrorCodeLast(), false, "Unable to average cell concepts."); 300 313 psFree(cells); 301 psFree(view );314 psFree(viewT2); 302 315 goto DONE; 303 316 } … … 309 322 if (!psMetadataCopy(outFPA->concepts, input->fpa->concepts)) { 310 323 psError(psErrorCodeLast(), false, "Unable to copy FPA concepts from input to output."); 311 psFree(view );324 psFree(viewT2); 312 325 goto DONE; 313 326 } … … 330 343 if (!skyHDU) { 331 344 psError(PSWARP_ERR_DATA, false, "Unable to find skycell HDU."); 332 psFree(view );345 psFree(viewT2); 333 346 goto DONE; 334 347 } … … 340 353 if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) { 341 354 psError(psErrorCodeLast(), false, "Unable to generate WCS header."); 342 goto DONE; 343 } 344 345 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 355 psFree(viewT2); 356 goto DONE; 357 } 358 359 if (!pmFPAfileIOChecks(config, viewT2, PM_FPA_AFTER)) { 346 360 psError(psErrorCodeLast(), false, "Unable to write files."); 361 psFree(viewT2); 347 362 goto DONE; 348 363 } … … 360 375 if (!pswarpIOChecksBefore(config)) { 361 376 psError(psErrorCodeLast(), false, "Unable to read files."); 377 psFree(viewT2); 362 378 goto DONE; 363 379 } … … 367 383 pmFPACopy(photFile->fpa, outFPA); 368 384 369 pmFPAview *view = pmFPAviewAlloc(0); ///< View into skycell370 view ->chip = view->cell = view->readout = 0;385 pmFPAview *viewT3 = pmFPAviewAlloc(0); ///< View into skycell 386 viewT3->chip = viewT3->cell = viewT3->readout = 0; 371 387 372 388 // grab the sources of interest from the storage location (pmFPAfile PSPHOT.INPUT.CMF) … … 374 390 if (!sources) { 375 391 psError(psErrorCodeLast(), false, "No sources supplied to measure PSF"); 392 psFree(viewT2); 376 393 goto DONE; 377 394 } … … 432 449 const char *cellName = psMetadataLookupStr(NULL, output->parent->concepts, "CELL.NAME"); 433 450 psString headerName = NULL; ///< Header name for MD5 434 psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, view ->readout);451 psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, viewT2->readout); 435 452 psVector *md5 = psImageMD5(output->image); ///< md5 hash 436 453 psString md5string = psMD5toString(md5); ///< String … … 440 457 psFree(md5string); 441 458 psFree(headerName); 442 psFree(view );459 psFree(viewT2); 443 460 444 461 DONE: -
trunk/pswarp/src/pswarpMapGrid.c
r31878 r41538 13 13 # include "pswarp.h" 14 14 15 FILE *fout = NULL; 16 15 17 /** 16 18 * pswarpMapGridFromImage builds a set (a grid) of locally-linear maps which convert the source … … 46 48 } 47 49 50 if (0) { 51 // test the transformation sky<->chip for chip in smf: 52 if (fout == NULL) { fout = fopen ("map.grid.txt", "w"); } 53 54 pmCell *cell = dest->parent; 55 pmChip *chip = cell->parent; 56 pmFPA *fpa = chip->parent; 57 58 int NxChip = dest->image->numCols; 59 int NyChip = dest->image->numRows; 60 61 // XXX save these as static for speed? 62 psPlane *CH0 = psPlaneAlloc(); 63 psPlane *CH1 = psPlaneAlloc(); 64 65 psPlane *FP0 = psPlaneAlloc(); 66 psPlane *TP0 = psPlaneAlloc(); 67 68 psPlane *FP1 = psPlaneAlloc(); 69 psPlane *TP1 = psPlaneAlloc(); 70 71 psSphere *sky = psSphereAlloc(); 72 73 // measure the map for the center of each superpixel 74 for (i = 0; i < NxChip; i += 100) { 75 for (j = 0; j < NyChip; j += 100) { 76 77 CH0->x = i; 78 CH0->y = j; 79 psPlaneTransformApply(FP0, chip->toFPA, CH0); 80 psPlaneTransformApply (TP0, fpa->toTPA, FP0); 81 psDeproject (sky, TP0, fpa->toSky); 82 psProject (TP1, sky, fpa->toSky); 83 psPlaneTransformApply (FP1, fpa->fromTPA, TP1); 84 psPlaneTransformApply (CH1, chip->fromFPA, FP1); 85 86 fprintf (fout, "%f %f > %f %f > %f %f > %f %f | ", CH0->x, CH0->y, FP0->x, FP0->y, TP0->x, TP0->y, sky->r*180/M_PI, sky->d*180/M_PI); 87 fprintf (fout, "%f %f < %f %f < %f %f \n", TP1->x, TP1->y, FP1->x, FP1->y, CH1->x, CH1->y); 88 89 } 90 } 91 fclose (fout); 92 93 psFree (CH0); 94 psFree (FP0); 95 psFree (TP0); 96 97 psFree (CH1); 98 psFree (FP1); 99 psFree (TP1); 100 101 psFree (sky); 102 } 103 48 104 grid->nXpix = nXpix; 49 105 grid->nYpix = nYpix; … … 164 220 165 221 // XXX need to include readout->cell->chip offsets 222 // XXX note that 'dest' is the SMF and 'src' is the skycell CMF 223 // this is the lower accuracy direction... 166 224 167 225 /** V(0,0) position */ … … 205 263 map->xo = ix; 206 264 map->yo = iy; 207 265 208 266 psFree (offset); 209 267 psFree (FP);
Note:
See TracChangeset
for help on using the changeset viewer.
