- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psModules
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psModules merged eligible /branches/eam_branches/stackphot.20100406/psModules 27623-27653 /branches/pap_delete/psModules 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/psModules/src/imcombine/pmSubtractionIO.c
r23378 r27840 3 3 #include <string.h> 4 4 5 #include "pmErrorCodes.h" 5 6 #include "pmHDU.h" 6 7 #include "pmHDUUtils.h" … … 66 67 } 67 68 if (regions->n == 0) { 68 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "No subtraction regions found.");69 // We wrote everything we could find 69 70 psFree(regions); 70 return false;71 return true; 71 72 } 72 73 … … 80 81 while ((item = psMetadataGetAndIncrement(iter))) { 81 82 assert(item->type == PS_DATA_UNKNOWN); 82 // Set the normalisation dimensions, since these will be otherwise unavailable when reading the83 // images by scans.84 83 pmSubtractionKernels *kernel = item->data.V; // Kernel used in subtraction 85 kernel->numCols = ro->image->numCols;86 kernel->numRows = ro->image->numRows;87 88 84 kernels = psArrayAdd(kernels, ARRAY_BUFFER, kernel); 89 85 } … … 92 88 93 89 if (regions->n != kernels->n) { 94 psError(P S_ERR_BAD_PARAMETER_SIZE, true, "Number of regions (%ld) and kernels (%ld) don't match.\n",90 psError(PM_ERR_PROG, true, "Number of regions (%ld) and kernels (%ld) don't match.\n", 95 91 regions->n, kernels->n); 96 92 psFree(regions); … … 103 99 psArray *rows = psArrayAlloc(num); // Array of FITS table rows 104 100 for (int i = 0; i < num; i++) { 105 psMetadata *row = psMetadataAlloc(); // Row of interest 106 rows->data[i] = psMemIncrRefCounter(row); 101 psMetadata *row = rows->data[i] = psMetadataAlloc(); // Row of interest 107 102 108 103 psRegion *region = regions->data[i]; // Region of interest … … 126 121 kernel->bgOrder); 127 122 psMetadataAddS32(row, PS_LIST_TAIL, NAME_MODE, 0, "Matching mode (enum)", kernel->mode); 128 psMetadataAddS32(row, PS_LIST_TAIL, NAME_COLS, 0, "Number of columns", kernel->numCols);129 psMetadataAddS32(row, PS_LIST_TAIL, NAME_ROWS, 0, "Number of rows", kernel->numRows);130 123 if (kernel->mode == PM_SUBTRACTION_MODE_1 || kernel->mode == PM_SUBTRACTION_MODE_2) { 131 124 psMetadataAddVector(row, PS_LIST_TAIL, NAME_SOL1, 0, "Solution vector 1", kernel->solution1); … … 172 165 173 166 if (!psFitsWriteTable(fits, header, rows, EXTNAME_KERNEL)) { 174 psError( PS_ERR_IO, false, "Unable to write subtraction kernel to FITS table.");167 psError(psErrorCodeLast(), false, "Unable to write subtraction kernel to FITS table."); 175 168 psFree(header); 176 169 psFree(rows); … … 182 175 183 176 if (image && !psFitsWriteImage(fits, header, image, 0, EXTNAME_IMAGE)) { 184 psError( PS_ERR_IO, false, "Unable to write subtraction kernel image.");177 psError(psErrorCodeLast(), false, "Unable to write subtraction kernel image."); 185 178 psFree(header); 186 179 psFree(rows); … … 208 201 thisView->readout = i; 209 202 if (!pmReadoutWriteSubtractionKernels(readout, file->fits)) { 210 psError( PS_ERR_IO, false, "Failed to write %dth readout", i);203 psError(psErrorCodeLast(), false, "Failed to write %dth readout", i); 211 204 psFree(thisView); 212 205 return false; … … 231 224 thisView->cell = i; 232 225 if (!pmCellWriteSubtractionKernels(cell, thisView, file, config)) { 233 psError( PS_ERR_IO, false, "Failed to write %dth cell", i);226 psError(psErrorCodeLast(), false, "Failed to write %dth cell", i); 234 227 psFree(thisView); 235 228 return false; … … 254 247 thisView->chip = i; 255 248 if (!pmChipWriteSubtractionKernels(chip, thisView, file, config)) { 256 psError( PS_ERR_IO, false, "Failed to write %dth chip", i);249 psError(psErrorCodeLast(), false, "Failed to write %dth chip", i); 257 250 psFree(thisView); 258 251 return false; … … 272 265 273 266 if (!psFitsMoveExtName(fits, EXTNAME_KERNEL)) { 274 psError( PS_ERR_IO, false, "Unable to move to subtraction kernel table.");267 psError(psErrorCodeLast(), false, "Unable to move to subtraction kernel table."); 275 268 return false; 276 269 } … … 278 271 psArray *table = psFitsReadTable(fits); // Table of interest 279 272 if (!table) { 280 psError( PS_ERR_IO, false, "Unable to read FITS table");273 psError(psErrorCodeLast(), false, "Unable to read FITS table"); 281 274 return false; 282 275 } … … 289 282 TARGET = psMetadataLookup##SUFFIX(&mdok, row, NAME); \ 290 283 if (!mdok) { \ 291 psError(P S_ERR_UNKNOWN, false, "Unable to find column %s in subtraction kernel table.", NAME); \284 psError(PM_ERR_PROG, false, "Unable to find column %s in subtraction kernel table.", NAME); \ 292 285 psFree(table); \ 293 286 return false; \ … … 318 311 319 312 TABLE_LOOKUP(int, S32, bg, NAME_BG); 320 TABLE_LOOKUP(int, S32, numCols, NAME_COLS);321 TABLE_LOOKUP(int, S32, numRows, NAME_ROWS);322 313 323 314 TABLE_LOOKUP(float, F32, mean, NAME_MEAN); … … 325 316 TABLE_LOOKUP(int, S32, numStamps, NAME_NUMSTAMPS); 326 317 327 pmSubtractionKernels *kernels = pmSubtractionKernelsFromDescription(description, bg, mode); 328 kernels->numCols = numCols; 329 kernels->numRows = numRows; 318 pmSubtractionKernels *kernels = pmSubtractionKernelsFromDescription(description, bg, *region, mode); 330 319 kernels->mean = mean; 331 320 kernels->rms = rms; … … 336 325 kernels->solution1 = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, row, NAME_SOL1)); 337 326 if (!mdok) { 338 psError(P S_ERR_UNKNOWN, false, "Unable to find column %s in subtraction kernel table.",327 psError(PM_ERR_PROG, false, "Unable to find column %s in subtraction kernel table.", 339 328 NAME_SOL1); 340 329 psFree(kernels); … … 346 335 kernels->solution1 = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, row, NAME_SOL1)); 347 336 if (!mdok) { 348 psError(P S_ERR_UNKNOWN, false, "Unable to find column %s in subtraction kernel table.",337 psError(PM_ERR_PROG, false, "Unable to find column %s in subtraction kernel table.", 349 338 NAME_SOL1); 350 339 psFree(kernels); … … 354 343 kernels->solution2 = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, row, NAME_SOL2)); 355 344 if (!mdok) { 356 psError(P S_ERR_UNKNOWN, false, "Unable to find column %s in subtraction kernel table.",345 psError(PM_ERR_PROG, false, "Unable to find column %s in subtraction kernel table.", 357 346 NAME_SOL2); 358 347 psFree(kernels); … … 390 379 pmReadout *readout = cell->readouts->data[i]; 391 380 thisView->readout = i; 392 pmReadoutReadSubtractionKernels(readout, file->fits); 381 if (!pmReadoutReadSubtractionKernels(readout, file->fits)) { 382 psError(psErrorCodeLast(), false, "Unable to read subtraction kernels from cell"); 383 psFree(thisView); 384 return false; 385 } 393 386 if (!readout->data_exists) { 394 387 continue; … … 421 414 pmCell *cell = chip->cells->data[i]; 422 415 thisView->cell = i; 423 pmCellReadSubtractionKernels(cell, thisView, file, config); 424 if (!cell->data_exists) { 416 if (!pmCellReadSubtractionKernels(cell, thisView, file, config)) { 417 psError(psErrorCodeLast(), false, "Unable to read subtraction kernels from cell"); 418 psFree(thisView); 419 return false; 420 } 421 if (!cell->data_exists) { 425 422 continue; 426 423 } … … 430 427 431 428 if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, true, NULL)) { 432 psError( PS_ERR_IO, false, "Failed to read concepts for chip.\n");429 psError(psErrorCodeLast(), false, "Failed to read concepts for chip.\n"); 433 430 return false; 434 431 } … … 451 448 pmChip *chip = fpa->chips->data[i]; 452 449 thisView->chip = i; 453 pmChipReadSubtractionKernels(chip, thisView, file, config); 450 if (!pmChipReadSubtractionKernels(chip, thisView, file, config)) { 451 psError(psErrorCodeLast(), false, "Unable to read subtraction kernels from chip"); 452 psFree(thisView); 453 return false; 454 } 454 455 } 455 456 psFree(thisView); 456 457 457 458 if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, true, NULL)) { 458 psError( PS_ERR_IO, false, "Failed to read concepts for fpa.\n");459 psError(psErrorCodeLast(), false, "Failed to read concepts for fpa.\n"); 459 460 return false; 460 461 } … … 475 476 if (view->chip == -1) { 476 477 if (!pmFPAWriteSubtractionKernels(fpa, view, file, config)) { 477 psError( PS_ERR_IO, false, "Failed to write subtraction kernels from fpa");478 psError(psErrorCodeLast(), false, "Failed to write subtraction kernels from fpa"); 478 479 psFree(fpa); 479 480 return false; … … 484 485 485 486 if (view->chip >= fpa->chips->n) { 486 psError(P S_ERR_UNKNOWN, false, "Writing chip == %d (>= chips->n == %ld)", view->chip, fpa->chips->n);487 psError(PM_ERR_PROG, true, "Writing chip == %d (>= chips->n == %ld)", view->chip, fpa->chips->n); 487 488 psFree(fpa); 488 489 return false; … … 492 493 if (view->cell == -1) { 493 494 if (!pmChipWriteSubtractionKernels(chip, view, file, config)) { 494 psError( PS_ERR_IO, false, "Failed to write objects from chip");495 psError(psErrorCodeLast(), false, "Failed to write objects from chip"); 495 496 psFree(fpa); 496 497 return false; … … 501 502 502 503 if (view->cell >= chip->cells->n) { 503 psError(P S_ERR_UNKNOWN, false, "Writing cell == %d (>= cells->n == %ld)",504 psError(PM_ERR_PROG, true, "Writing cell == %d (>= cells->n == %ld)", 504 505 view->cell, chip->cells->n); 505 506 psFree(fpa); … … 510 511 if (view->readout == -1) { 511 512 if (!pmCellWriteSubtractionKernels(cell, view, file, config)) { 512 psError( PS_ERR_IO, false, "Failed to write objects from cell");513 psError(psErrorCodeLast(), false, "Failed to write objects from cell"); 513 514 psFree(fpa); 514 515 return false; … … 519 520 520 521 if (view->readout >= cell->readouts->n) { 521 psError(P S_ERR_UNKNOWN, false, "Writing readout == %d (>= readouts->n == %ld)",522 psError(PM_ERR_PROG, true, "Writing readout == %d (>= readouts->n == %ld)", 522 523 view->readout, cell->readouts->n); 523 524 psFree(fpa); … … 527 528 528 529 if (!pmReadoutWriteSubtractionKernels(readout, file->fits)) { 529 psError( PS_ERR_IO, false, "Failed to write objects from readout %d", view->readout);530 psError(psErrorCodeLast(), false, "Failed to write objects from readout %d", view->readout); 530 531 psFree(fpa); 531 532 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
