Changeset 7311
- Timestamp:
- Jun 2, 2006, 3:02:08 PM (20 years ago)
- Location:
- trunk/psModules/src
- Files:
-
- 28 edited
-
camera/pmFPAConstruct.c (modified) (9 diffs)
-
camera/pmFPARead.c (modified) (3 diffs)
-
camera/pmFPA_JPEG.c (modified) (2 diffs)
-
camera/pmFPAfile.c (modified) (55 diffs)
-
camera/pmReadout.c (modified) (1 diff)
-
concepts/pmConcepts.c (modified) (1 diff)
-
concepts/pmConcepts.h (modified) (1 diff)
-
concepts/pmConceptsRead.c (modified) (11 diffs)
-
concepts/pmConceptsStandard.c (modified) (20 diffs)
-
config/pmConfig.c (modified) (13 diffs)
-
config/pmConfig.h (modified) (2 diffs)
-
objects/pmPSF.c (modified) (3 diffs)
-
objects/pmPSF.h (modified) (3 diffs)
-
objects/pmPSF_IO.c (modified) (2 diffs)
-
objects/pmPSFtry.c (modified) (2 diffs)
-
objects/pmPSFtry.h (modified) (3 diffs)
-
objects/pmPeaks.c (modified) (4 diffs)
-
objects/pmPeaks.h (modified) (3 diffs)
-
objects/pmSource.c (modified) (5 diffs)
-
objects/pmSource.h (modified) (3 diffs)
-
objects/pmSourceFitModel.c (modified) (2 diffs)
-
objects/pmSourceIO.c (modified) (9 diffs)
-
objects/pmSourceIO_CMP.c (modified) (2 diffs)
-
pslib/psAdditionals.c (modified) (1 diff)
-
pslib/psImageUnbin.c (modified) (2 diffs)
-
pslib/psImageUnbin.h (modified) (1 diff)
-
pslib/psMetadataItemParse.c (modified) (1 diff)
-
pslib/psMetadataItemParse.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAConstruct.c
r7278 r7311 26 26 bool status = true; // Result of MD lookup 27 27 psMetadata *cells = psMetadataLookupMD(&status, format, "CELLS"); // The CELLS 28 if (! status) {29 psError(PS_ERR_IO, false, "Unable to determine CELLS of camera.\n");28 if (!status || !cells) { 29 psError(PS_ERR_IO, true, "Unable to determine CELLS of camera.\n"); 30 30 return NULL; 31 31 } … … 114 114 } 115 115 psMetadataItem *resultItem = psMetadataLookup(header, keyword); 116 if (! resultItem) {117 psError(PS_ERR_IO, false, "Unable to find %s in primary header to identify %s.\n", keyword, name);116 if (!resultItem) { 117 psError(PS_ERR_IO, true, "Unable to find %s in primary header to identify %s.\n", keyword, name); 118 118 return NULL; 119 119 } … … 138 138 fpa->hdu = psMemIncrRefCounter(hdu); 139 139 if (hdu->header) { 140 pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL); 140 if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL)) { 141 psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for FPA"); 142 return false; 143 } 141 144 } 142 145 pmFPASetFileStatus(fpa, true); … … 256 259 257 260 if (hdu && level == PM_FPA_LEVEL_FPA) { 258 addHDUtoFPA(fpa, hdu); 261 if (!addHDUtoFPA(fpa, hdu)) { 262 psError(PS_ERR_UNKNOWN, false, "Adding HDU to FPA (%s)", contents); 263 return -1; 264 } 259 265 } 260 266 … … 333 339 } 334 340 newCell->config = psMemIncrRefCounter(cellData); 335 pmConceptsReadCell(newCell, PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS, false, NULL); 341 if (!pmConceptsReadCell(newCell, PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS, false, NULL)) { 342 psError(PS_ERR_IO, false, "Reading concepts for cell %d", numCells); 343 return -1; 344 } 336 345 numCells++; 337 346 } … … 388 397 bool mdok = true; // Status from MD lookups 389 398 psMetadata *components = psMetadataLookupMD(&mdok, camera, "FPA"); // FPA components 399 if (!mdok || !components) { 400 psError(PS_ERR_IO, true, "Failed to lookup \"FPA\""); 401 psFree(fpa); 402 return NULL; 403 } 390 404 psMetadataIterator *componentsIter = psMetadataIteratorAlloc(components, PS_LIST_HEAD, NULL); 391 405 psMetadataItem *componentsItem = NULL; // Item from components … … 500 514 hdu->format = psMemIncrRefCounter(format); 501 515 const char *content = contentsItem->data.V; // The content data 502 processContents(fpa, chip, cell, hdu, level, content, format); 516 if (processContents(fpa, chip, cell, hdu, level, content, format) < 0) { 517 psError(PS_ERR_IO, false, "Error setting contents for %s", contentsItem->name); 518 psFree(hdu); 519 psFree(contentsIter); 520 521 return false; 522 } 503 523 psFree(hdu); 504 524 } … … 568 588 if (!mdok || !contents || strlen(contents) == 0) { 569 589 psError(PS_ERR_IO, true, "Unable to find CONTENTS in the camera format configuration.\n"); 590 psFree(phdu); 570 591 psFree(view); 571 592 return NULL; 572 593 } 573 594 574 processContents(fpa, NULL, NULL, phdu, PM_FPA_LEVEL_FPA, contents, format); 595 if (processContents(fpa, NULL, NULL, phdu, PM_FPA_LEVEL_FPA, contents, format) < 0) { 596 psError(PS_ERR_IO, false, "Error setting CONTENTS"); 597 psFree(phdu); 598 psFree(view); 599 600 return NULL; 601 } 602 575 603 psFree(phdu); 576 604 return view; … … 581 609 psMetadata *contents = psMetadataLookupMD(&mdok, format, "CONTENTS"); // The contents of the FITS file 582 610 if (!mdok || !contents) { 583 psError(PS_ERR_IO, false, "Unable to find CONTENTS in the camera format configuration.\n"); 611 if (mdok && !contents) { 612 psError(PS_ERR_IO, true, "CONTENTS metadata is NULL in the camera format configuration."); 613 } else { 614 if(psMetadataLookup(format, "CONTENTS") != NULL) { 615 psError(PS_ERR_IO, true, "CONTENTS is of wrong type in camera format configuration"); 616 } else { 617 psError(PS_ERR_IO, true, "Unable to find CONTENTS in the camera format configuration."); 618 } 619 } 620 584 621 psFree(view); 585 622 return NULL; -
trunk/psModules/src/camera/pmFPARead.c
r7278 r7311 35 35 if (psRegionIsBad(*trimsec)) { 36 36 psString regionString = psRegionToString(*trimsec); 37 psError(PS_ERR_ IO, true, "Invalid trim section: %s\n", regionString);37 psError(PS_ERR_UNKNOWN, true, "Invalid trim section: %s\n", regionString); 38 38 psFree(regionString); 39 39 psFree(readout); … … 319 319 } 320 320 if (!hdu->images && !pmHDURead(hdu, fits)) { 321 psError(PS_ERR_IO, false, "Unable to read HDU for cell.\n"); 322 return false; 323 } 324 325 pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, false, NULL); 321 psError(PS_ERR_UNKNOWN, false, "Unable to read HDU for cell.\n"); 322 return false; 323 } 324 325 if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, false, NULL)) { 326 psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell"); 327 return false; 328 } 326 329 327 330 // Having read the cell, we now have to cut it up … … 397 400 pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL); 398 401 } else { 399 ps LogMsg(__func__, PS_LOG_WARN, "Unable to read any chips in FPA.\n");402 psError(PS_ERR_UNKNOWN, false, "Unable to read any chips in FPA"); 400 403 } 401 404 -
trunk/psModules/src/camera/pmFPA_JPEG.c
r7278 r7311 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-06-0 2 00:55:22$7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-06-03 01:02:08 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 141 141 142 142 // XXX we need to decide where the scale will come from in the long term 143 psImageClippedStatsInit (10000); 143 unsigned long seed = 0; 144 psImageClippedStatsInit (10000, seed); 144 145 145 146 psStats *stats = psImageClippedStats (readout->image, NULL, 0, 0.25, 0.75); -
trunk/psModules/src/camera/pmFPAfile.c
r7307 r7311 21 21 #include "pmPSF_IO.h" 22 22 #include "pmFPA_JPEG.h" 23 #define WERROR 0 // if true, warnings in this file are treated as errors 23 24 24 25 static void pmFPAfileFree(pmFPAfile *file) … … 84 85 return file; 85 86 } 87 88 static const char *depthEnumToName(pmFPAdepth depth) 89 { 90 const char *val = NULL; 91 92 switch (depth) { 93 case PM_FPA_DEPTH_NONE: 94 val = "NONE"; 95 break; 96 case PM_FPA_DEPTH_FPA: 97 val = "FPA"; 98 break; 99 case PM_FPA_DEPTH_CHIP: 100 val = "CHIP"; 101 break; 102 case PM_FPA_DEPTH_CELL: 103 val = "CELL"; 104 break; 105 case PM_FPA_DEPTH_READOUT: 106 val = "READOUT"; 107 break; 108 default: 109 psAbort(PS_FILE_LINE, "You can't get here; depth = %d", depth); 110 } 111 112 return val; 113 } 114 115 static pmFPAdepth depthNameToEnum(const char *name) 116 { 117 pmFPAdepth val; 118 119 if (name == NULL) { 120 val = PM_FPA_DEPTH_NONE; 121 } else if (!strcasecmp(name, "FPA")) { 122 val = PM_FPA_DEPTH_FPA; 123 } else if (!strcasecmp(name, "CHIP")) { 124 val = PM_FPA_DEPTH_CHIP; 125 } else if (!strcasecmp(name, "CELL")) { 126 val = PM_FPA_DEPTH_CELL; 127 } else if (!strcasecmp(name, "READOUT")) { 128 val = PM_FPA_DEPTH_READOUT; 129 } else { 130 val = PM_FPA_DEPTH_NONE; 131 } 132 133 return val; 134 } 135 86 136 87 137 pmFPAfile *pmFPAfileDefine(psMetadata *files, psMetadata *camera, pmFPA *fpa, char *name) … … 94 144 95 145 bool status; 96 char *depth;97 146 char *type; 98 147 … … 100 149 psMetadata *filerules = psMetadataLookupPtr (&status, camera, "FILERULES"); 101 150 if (filerules == NULL) { 102 psError StackPrint(stderr, "Can't find FILERULES in the CAMERA configuration!\n");151 psError(PS_ERR_IO, true, "Can't find FILERULES in the CAMERA configuration!"); 103 152 return NULL; 104 153 } … … 107 156 // check for alias name (type == STR, name is aliased name) 108 157 char *realname = psMetadataLookupStr (&status, filerules, name); 109 if ( realname == NULL)158 if (!realname || strlen(realname) == 0) { 110 159 realname = name; 160 } 111 161 112 162 psMetadata *data = psMetadataLookupPtr (&status, filerules, realname); 113 163 if (data == NULL) { 114 psError StackPrint(stderr, "Can't find file concept %s!\n", name);164 psError(PS_ERR_IO, true, "Can't find file concept %s!", name); 115 165 return NULL; 116 166 } … … 126 176 file->extxtra = psMemIncrRefCounter(psMetadataLookupStr (&status, data, "EXTNAME.XTRA")); 127 177 128 file->fileDepth = PM_FPA_DEPTH_NONE; 129 depth = psMetadataLookupStr (&status, data, "FILE.DEPTH"); 130 if (depth != NULL) { 131 if (!strcasecmp (depth, "FPA")) { 132 file->fileDepth = PM_FPA_DEPTH_FPA; 133 } 134 if (!strcasecmp (depth, "CHIP")) { 135 file->fileDepth = PM_FPA_DEPTH_CHIP; 136 } 137 if (!strcasecmp (depth, "CELL")) { 138 file->fileDepth = PM_FPA_DEPTH_CELL; 139 } 140 if (!strcasecmp (depth, "READOUT")) { 141 file->fileDepth = PM_FPA_DEPTH_READOUT; 142 } 143 } 178 file->fileDepth = depthNameToEnum(psMetadataLookupStr(&status, data, "FILE.DEPTH")); 144 179 if (file->fileDepth == PM_FPA_DEPTH_NONE) { 145 180 psLogMsg (__func__, 3, "warning: FILE.DEPTH is not set for %s\n", name); 146 181 } 147 182 148 file->dataDepth = PM_FPA_DEPTH_NONE; 149 depth = psMetadataLookupStr (&status, data, "DATA.DEPTH"); 150 if (depth != NULL) { 151 if (!strcasecmp (depth, "FPA")) { 152 file->dataDepth = PM_FPA_DEPTH_FPA; 153 } 154 if (!strcasecmp (depth, "CHIP")) { 155 file->dataDepth = PM_FPA_DEPTH_CHIP; 156 } 157 if (!strcasecmp (depth, "CELL")) { 158 file->dataDepth = PM_FPA_DEPTH_CELL; 159 } 160 if (!strcasecmp (depth, "READOUT")) { 161 file->dataDepth = PM_FPA_DEPTH_READOUT; 162 } 163 } 183 file->dataDepth = depthNameToEnum(psMetadataLookupStr (&status, data, "DATA.DEPTH")); 164 184 if (file->dataDepth == PM_FPA_DEPTH_NONE) { 165 185 psLogMsg (__func__, 3, "warning: DATA.DEPTH is not set for %s\n", name); … … 240 260 pmFPAfile *file = pmFPAfileDefine (files, format, fpa, name); 241 261 psFree (fpa); 262 if (!file) { 263 psErrorStackPrint(stderr, "file %s not defined\n", name); 264 return NULL; 265 } 242 266 return file; 243 267 } … … 257 281 258 282 if (file->state & PM_FPA_STATE_INACTIVE) { 283 psError(PS_ERR_IO, true, "Atempted to read an inactive file"); 259 284 return false; 260 285 } … … 265 290 266 291 if (file->mode == PM_FPA_MODE_NONE) { 292 psError(PS_ERR_IO, true, "File is mode PM_FPA_MODE_NONE"); 267 293 return false; 268 294 } 269 295 if (file->mode == PM_FPA_MODE_INTERNAL) { 296 psError(PS_ERR_IO, true, "File is mode PM_FPA_MODE_INTERNAL"); 270 297 return false; 271 298 } … … 279 306 // determine the file name 280 307 file->filename = pmFPAfileNameFromRule (file->filerule, file, view); 281 if (file->filename == NULL) 282 return false; 308 if (file->filename == NULL) { 309 psError(PS_ERR_IO, true, "Filename is NULL"); 310 return false; 311 } 283 312 284 313 // indirect filenames … … 288 317 file->filename = psMetadataLookupStr (&status, file->names, extra); 289 318 psFree (extra); 290 if (file->filename == NULL) 319 if (file->filename == NULL) { 291 320 psAbort ("pmFPAfile", "no file specified"); 321 } 292 322 // psMetadataLookupStr just returns a view, file->filename must be protected 293 323 psMemIncrRefCounter (file->filename); … … 298 328 // file->filename = pmDetrendSelect (extra); 299 329 psFree (extra); 300 if (file->filename == NULL) 330 if (file->filename == NULL) { 301 331 psAbort ("pmFPAfile", "no file specified"); 332 } 302 333 psMemIncrRefCounter (file->filename); 303 334 } … … 309 340 psTrace ("pmFPAfile", 5, "opening %s (type: %d)\n", file->filename, file->type); 310 341 file->fits = psFitsOpen (file->filename, mode); 311 if (file->fits == NULL) 312 psAbort (__func__, "error opening file %s\n", file->filename); 342 if (file->fits == NULL) { 343 psError(PS_ERR_IO, false, "error opening file %s\n", file->filename); 344 return false; 345 } 313 346 file->state = PM_FPA_STATE_OPEN; 314 347 break; … … 325 358 326 359 default: 327 fprintf (stderr, "warning:type mismatch for %s : %d\n", file->filename, file->type);360 psError(PS_ERR_IO, true, "type mismatch for %s : %d\n", file->filename, file->type); 328 361 return false; 329 362 } … … 336 369 PS_ASSERT_PTR_NON_NULL(view, false); 337 370 338 if (file->state & PM_FPA_STATE_INACTIVE) 339 return false; 340 341 if (file->mode != PM_FPA_MODE_READ) 342 return false; 371 if (file->state & PM_FPA_STATE_INACTIVE) { 372 psError(PS_ERR_IO, true, "Atempted to read an inactive file"); 373 return false; 374 } 375 376 if (file->mode != PM_FPA_MODE_READ) { 377 psError(PS_ERR_IO, true, "File isn't mode PM_FPA_MODE_READ"); 378 return false; 379 } 343 380 344 381 // get the current depth … … 347 384 // do we need to open this file? 348 385 if (depth == file->fileDepth) { 349 pmFPAfileOpen (file, view); 386 if (!pmFPAfileOpen (file, view)) { 387 psError(PS_ERR_IO, false, "Opening file"); 388 return false; 389 } 350 390 } 351 391 352 392 // do we need to read this file? 353 if (depth != file->dataDepth) 354 return false; 393 if (depth != file->dataDepth) { 394 #if WERROR 395 psError(PS_ERR_IO, true, "Desired depth %s doesn't match dataDepth %s", 396 depthEnumToName(depth), depthEnumToName(file->dataDepth)); 397 return false; 398 #else 399 400 return true; 401 #endif 402 403 } 355 404 356 405 switch (file->type) { … … 359 408 psTrace ("pmFPAfile", 5, "reading %s (type: %d)\n", file->filename, file->type); 360 409 } else { 361 psTrace ("pmFPAfile", 5, "skipping %s (type: %d)\n", file->filename, file->type); 410 psError(PS_ERR_UNKNOWN, false, "skipping %s (type: %d)\n", file->filename, file->type); 411 return false; 362 412 } 363 413 break; … … 381 431 382 432 default: 383 fprintf (stderr, "warning: type mismatch\n");433 psError(PS_ERR_IO, true, "warning: type mismatch; saw type %d", file->type); 384 434 return false; 385 435 } … … 393 443 394 444 if (file->state & PM_FPA_STATE_INACTIVE) { 445 psError(PS_ERR_IO, true, "Atempted to write an inactive file"); 395 446 return false; 396 447 } 397 448 398 449 if (file->mode != PM_FPA_MODE_WRITE) { 450 psError(PS_ERR_IO, true, "File isn't mode PM_FPA_MODE_WRITE"); 399 451 return false; 400 452 } … … 404 456 405 457 // do we need to write this file? 406 if (depth != file->dataDepth) 407 return false; 458 if (depth != file->dataDepth) { 459 #if WERROR 460 psError(PS_ERR_IO, true, "Desired depth %s doesn't match dataDepth %s", 461 depthEnumToName(depth), depthEnumToName(file->dataDepth)); 462 return false; 463 #else 464 465 return true; 466 #endif 467 468 } 408 469 409 470 // do we need to open this file? 410 471 if (depth >= file->fileDepth) { 411 pmFPAfileOpen (file, view); 472 if (!pmFPAfileOpen (file, view)) { 473 psError(PS_ERR_IO, false, "failed to open %s", file->filename); 474 return false; 475 } 412 476 } 413 477 … … 423 487 case PM_FPA_FILE_CMP: 424 488 case PM_FPA_FILE_CMF: 425 pmFPAviewWriteObjects (view, file); 426 psTrace ("pmFPAfile", 5, "wrote object %s (fpa: %p)\n", file->filename, file->fpa); 489 psTrace ("pmFPAfile", 5, "writing object %s (fpa: %p)\n", file->filename, file->fpa); 490 if (!pmFPAviewWriteObjects (view, file)) { 491 psError(PS_ERR_IO, false, "Failed to write object %s", file->filename); 492 return false; 493 } 494 427 495 break; 428 496 … … 451 519 452 520 if (file->state & PM_FPA_STATE_INACTIVE) { 453 return false; 454 } 455 if (file->mode != PM_FPA_MODE_WRITE) 456 return false; 521 psError(PS_ERR_IO, true, "Atempted to create an inactive file"); 522 return false; 523 } 524 if (file->mode != PM_FPA_MODE_WRITE) { 525 psError(PS_ERR_IO, true, "File isn't mode PM_FPA_MODE_WRITE"); 526 return false; 527 } 457 528 458 529 // get the current depth 459 530 pmFPAdepth depth = pmFPAviewDepth (view); 460 531 532 // XXX is this a sufficient check to avoid creating elements? 533 if (file->src == NULL) { 534 #if WERROR 535 psError(PS_ERR_IO, true, "file->src is NULL"); 536 return false; 537 #else 538 539 return true; 540 #endif 541 542 } 543 461 544 // do we need to write this file? 462 if (depth != file->dataDepth) 463 return false; 464 465 // XXX is this a sufficient check to avoid creating elements? 466 if (file->src == NULL) 467 return false; 545 if (depth != file->dataDepth) { 546 psError(PS_ERR_IO, true, "Desired depth %s doesn't match dataDepth %s", 547 depthEnumToName(depth), depthEnumToName(file->dataDepth)); 548 return false; 549 } 468 550 469 551 switch (file->type) { … … 484 566 485 567 default: 486 fprintf (stderr, "warning: type mismatch\n");568 psError(PS_ERR_IO, true, "Unsupported type: %d", file->type); 487 569 return false; 488 570 } … … 496 578 497 579 if (file->state & PM_FPA_STATE_INACTIVE) { 580 psError(PS_ERR_IO, true, "Atempted to close an inactive file"); 498 581 return false; 499 582 } … … 505 588 pmFPAdepth depth = pmFPAviewDepth (view); 506 589 if (file->fileDepth != depth) { 507 return false; 590 #if WERROR 591 psError(PS_ERR_IO, true, "Desired depth %s doesn't match fileDepth %s", 592 depthEnumToName(depth), depthEnumToName(file->fileDepth)); 593 return false; 594 #else 595 596 return true; 597 #endif 598 508 599 } 509 600 … … 531 622 532 623 default: 533 fprintf (stderr, "warning: type mismatch\n");624 psError(PS_ERR_IO, true, "type mismatch: %d", file->type); 534 625 return false; 535 626 } … … 560 651 bool status = false; 561 652 pmFPAfile *file = psMetadataLookupPtr (&status, files, name); 653 if (!status) { 654 psError(PS_ERR_IO, true, "Failed to look up file %s", name); 655 return false; 656 } 562 657 if (!file) { 658 psError(PS_ERR_IO, true, "file %s is NULL", name); 563 659 return false; 564 660 } … … 583 679 pmFPAfile *file = item->data.V; 584 680 585 if (place == PM_FPA_BEFORE) { 586 pmFPAfileRead (file, view); 587 pmFPAfileCreate (file, view); 588 } else { 589 pmFPAfileWrite (file, view); 590 pmFPAfileClose (file, view); 681 switch (place) { 682 case PM_FPA_BEFORE: 683 if (file->mode == PM_FPA_MODE_READ && !pmFPAfileRead (file, view)) { 684 psError(PS_ERR_IO, false, "failed in FPA_BEFORE block for %s", file->name); 685 psFree(iter); 686 return false; 687 } 688 if (file->mode == PM_FPA_MODE_WRITE && !pmFPAfileCreate(file, view)) { 689 psError(PS_ERR_IO, false, "failed in FPA_BEFORE block for %s", file->name); 690 psFree(iter); 691 return false; 692 } 693 break; 694 case PM_FPA_AFTER: 695 if (file->mode == PM_FPA_MODE_WRITE && !pmFPAfileWrite (file, view)) { 696 psError(PS_ERR_IO, false, "failed in FPA_AFTER block for %s", file->name); 697 psFree(iter); 698 return false; 699 } 700 if (!pmFPAfileClose(file, view)) { 701 psError(PS_ERR_IO, false, "failed in FPA_AFTER block for %s", file->name); 702 psFree(iter); 703 return false; 704 } 705 break; 706 default: 707 psAbort(PS_FILE_LINE, "You can't get here"); 591 708 } 592 709 } 593 710 psFree (iter); 711 594 712 return true; 595 713 } … … 627 745 628 746 pmFPAfile *file = psMetadataLookupPtr (&status, files, name); 629 if (file == NULL) 630 return false; 631 632 if (file->mode != PM_FPA_MODE_INTERNAL) 633 return false; 747 if (file == NULL) { 748 psError(PS_ERR_IO, true, "Failed to lookup %s", name); 749 return false; 750 } 751 752 if (file->mode != PM_FPA_MODE_INTERNAL) { 753 psError(PS_ERR_IO, true, "File %s has mode %d != PM_FPA_MODE_INTERNAL", name, file->mode); 754 return false; 755 } 634 756 635 757 psMetadataRemoveKey (files, name); … … 648 770 649 771 pmFPAfile *file = psMetadataLookupPtr (&status, files, name); 650 if (file == NULL) 651 return NULL; 772 if (file == NULL) { 773 return NULL; 774 } 652 775 653 776 // internal files have the readout as a separate element: … … 677 800 678 801 if (view->chip >= fpa->chips->n) { 802 psError(PS_ERR_IO, true, "Requested chip == %d >= fpa->chips->n == %d", view->chip, fpa->chips->n); 679 803 return false; 680 804 } … … 687 811 688 812 if (view->cell >= chip->cells->n) { 813 psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %d", view->cell, chip->cells->n); 689 814 return false; 690 815 } … … 695 820 return status; 696 821 } 822 psError(PS_ERR_UNKNOWN, true, "Returning false"); 697 823 return false; 698 824 699 825 // XXX pmReadoutRead, pmReadoutReadSegement disabled for now 700 # if (0) 701 702 if (view->readout >= cell->readouts->n) { 703 return false; 704 } 826 #if 0 827 828 if (view->readout >= cell->readouts->n) { 829 psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouts->n == %d", 830 view->readout, cell->readouts->n); 831 return false; 832 } 705 833 pmReadout *readout = cell->readouts->data[view->readout]; 706 834 … … 711 839 } 712 840 return true; 713 # endif841 #endif 714 842 } 715 843 … … 731 859 732 860 if (view->chip >= fpa->chips->n) { 861 psError(PS_ERR_IO, true, "Requested chip == %d >= fpa->chips->n == %d", view->chip, fpa->chips->n); 733 862 return false; 734 863 } … … 757 886 758 887 if (view->cell >= chip->cells->n) { 888 psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %d", view->cell, chip->cells->n); 759 889 return false; 760 890 } … … 762 892 763 893 if (view->readout == -1) { 764 pmCellWrite (cell, fits, NULL, true);765 return true;766 }894 return pmCellWrite (cell, fits, NULL, true); 895 } 896 psError(PS_ERR_UNKNOWN, true, "Returning false"); 767 897 return false; 768 898 769 899 // XXX disable readout write for now 770 # if (0) 771 772 if (view->readout >= cell->readouts->n) { 773 return false; 774 } 900 #if 0 901 902 if (view->readout >= cell->readouts->n) { 903 psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouts->n == %d", 904 view->readout, cell->readouts->n); 905 return false; 906 } 775 907 pmReadout *readout = cell->readouts->data[view->readout]; 776 908 … … 781 913 } 782 914 return true; 783 # endif915 #endif 784 916 } 785 917 … … 808 940 psArray *infiles = psMetadataLookupPtr(&status, config->arguments, argname); 809 941 if (!status) { 942 psError(PS_ERR_IO, false, "Failed to read %s from metadata\n", argname); 810 943 return NULL; 811 944 } 812 945 if (infiles->n < 1) { 946 psError(PS_ERR_IO, false, "Found n == %d files in %s from metadata\n", infiles->n, argname); 813 947 return NULL; 814 948 } … … 819 953 phu = psFitsReadHeader (NULL, fits); 820 954 format = pmConfigCameraFormatFromHeader (config, phu); 821 psFitsClose (fits); 955 psFitsClose (fits); // don't close phu; we'll use it below 956 if (!format) { 957 psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", infiles->data[0]); 958 psFree(phu); 959 return NULL; 960 } 822 961 823 962 // build the template fpa, set up the basic view 824 963 fpa = pmFPAConstruct (config->camera); 964 if (!fpa) { 965 psError(PS_ERR_IO, false, "Failed to construct FPA from %s", infiles->data[0]); 966 return NULL; 967 } 825 968 826 969 // load the given filerule (from config->camera) and associate it with the fpa … … 828 971 file = pmFPAfileDefine (config->files, config->camera, fpa, filename); 829 972 if (!file) { 830 psErrorStackPrint(stderr, "file %s not defined\n", filename); 973 psError(PS_ERR_IO, false, "file %s not defined", filename); 974 psFree(phu); 831 975 psFree (fpa); 832 976 psFree (format); … … 854 998 // set the view to the corresponding entry for this phu 855 999 pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format); 1000 if (!view) { 1001 psError(PS_ERR_IO, false, "Failed to set view from file %s", infiles->data[i]); 1002 psFree(phu); 1003 psFree (fpa); 1004 psFree (format); 1005 return NULL; 1006 } 856 1007 857 1008 // XXX is this the correct psMD to save the filename? … … 871 1022 872 1023 // XXX this this function through, then finish 873 # if 01024 #if 0 874 1025 // look for the given name on the argument list. 875 1026 // returns the file (a view to the one saved on config->files) … … 925 1076 file = pmFPAfileDefine (config->files, config->camera, fpa, filename); 926 1077 if (!file) { 927 psError StackPrint(stderr, "file %s not defined\n", filename);1078 psError(PS_ERR_IO, false, "file %s not defined", filename); 928 1079 psFree (fpa); 929 1080 psFree (format); … … 966 1117 return file; 967 1118 } 968 # endif1119 #endif 969 1120 970 1121 // create a new output pmFPAfile based on an existing FPA … … 979 1130 pmFPA *fpa = pmFPAConstruct (config->camera); 980 1131 pmFPAfile *file = pmFPAfileDefine (config->files, config->camera, fpa, filename); 1132 if (!file) { 1133 psErrorStackPrint(stderr, "file %s not defined\n", filename); 1134 return NULL; 1135 } 981 1136 file->src = src; // inherit output elements from this source pmFPA 982 1137 file->xBin = xBin; … … 1014 1169 file = pmFPAfileDefine (config->files, config->camera, NULL, filename); 1015 1170 if (!file) { 1016 psError StackPrint(stderr, "file %s not defined\n", filename);1171 psError(PS_ERR_IO, false, "file %s not defined\n", filename); 1017 1172 return NULL; 1018 1173 } … … 1120 1275 newName = psStringCopy (rule); 1121 1276 1277 if (strstr (newName, "{OUTPUT}") != NULL) { 1278 char *name = psMetadataLookupStr (NULL, file->names, "OUTPUT"); 1279 if (name != NULL) { 1280 newName = psStringSubstitute (newName, name, "{OUTPUT}"); 1281 } 1282 } 1122 1283 if (strstr (newName, "{CHIP.NAME}") != NULL) { 1123 1284 pmChip *chip = pmFPAviewThisChip (view, file->fpa); … … 1144 1305 } 1145 1306 } 1146 if (strstr (newName, "{OUTPUT}") != NULL) {1147 char *name = psMetadataLookupStr (NULL, file->names, "OUTPUT");1148 if (name != NULL) {1149 newName = psStringSubstitute (newName, name, "{OUTPUT}");1150 }1151 }1152 1307 return newName; 1153 1308 } … … 1167 1322 } 1168 1323 if (view->chip >= in->chips->n) { 1324 psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %d", view->chip, in->chips->n); 1169 1325 return false; 1170 1326 } … … 1177 1333 } 1178 1334 if (view->cell >= inChip->cells->n) { 1335 psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %d", 1336 view->cell, inChip->cells->n); 1179 1337 return false; 1180 1338 } … … 1186 1344 return true; 1187 1345 } 1346 psError(PS_ERR_UNKNOWN, true, "Returning false"); 1188 1347 return false; 1189 1348 … … 1203 1362 if (view->chip == -1) { 1204 1363 pmFPAAddSourceFromView (out, view, format); 1205 pmFPACopyStructure (out, in, xBin, yBin); 1206 return true; 1364 return pmFPACopyStructure (out, in, xBin, yBin); 1207 1365 } 1208 1366 if (view->chip >= in->chips->n) { 1367 psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %d", view->chip, in->chips->n); 1209 1368 return false; 1210 1369 } … … 1214 1373 if (view->cell == -1) { 1215 1374 pmFPAAddSourceFromView (out, view, format); 1216 pmChipCopyStructure (outChip, inChip, xBin, yBin); 1217 return true; 1375 return pmChipCopyStructure (outChip, inChip, xBin, yBin); 1218 1376 } 1219 1377 if (view->cell >= inChip->cells->n) { 1378 psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %d", 1379 view->cell, inChip->cells->n); 1220 1380 return false; 1221 1381 } … … 1225 1385 if (view->readout == -1) { 1226 1386 pmFPAAddSourceFromView (out, view, format); 1227 pmCellCopyStructure (outCell, inCell, xBin, yBin);1228 return true;1229 }1387 return pmCellCopyStructure (outCell, inCell, xBin, yBin); 1388 } 1389 psError(PS_ERR_UNKNOWN, true, "Returning false"); 1230 1390 return false; 1231 1391 -
trunk/psModules/src/camera/pmReadout.c
r7017 r7311 76 76 readout->mask = psMemIncrRefCounter(psImageSubset(masks->data[i], *trimsec)); 77 77 } 78 if (readout->weight == NULL || readout->mask == NULL) { 79 psError(PS_ERR_UNKNOWN, false, "Trimming readout %d", i); 80 return false; 81 } 78 82 79 83 // Set up the mask -
trunk/psModules/src/concepts/pmConcepts.c
r7310 r7311 131 131 } 132 132 133 bool success = true; // Success in reading concepts? 133 134 if (source & PM_CONCEPT_SOURCE_CAMERA && !(*read & PM_CONCEPT_SOURCE_CAMERA)) { 134 pmConceptsReadFromCamera(*specs, cell, target); 135 *read |= PM_CONCEPT_SOURCE_CAMERA; 135 if (pmConceptsReadFromCamera(*specs, cell, target)) { 136 *read |= PM_CONCEPT_SOURCE_CAMERA; 137 } else { 138 psError(PS_ERR_UNKNOWN, false, "Error reading concepts from camera configuration.\n"); 139 success = false; 140 } 136 141 } 137 142 138 143 if (source & PM_CONCEPT_SOURCE_DEFAULTS && !(*read & PM_CONCEPT_SOURCE_DEFAULTS)) { 139 pmConceptsReadFromDefaults(*specs, fpa, chip, cell, target); 140 *read |= PM_CONCEPT_SOURCE_DEFAULTS; 144 if (pmConceptsReadFromDefaults(*specs, fpa, chip, cell, target)) { 145 *read |= PM_CONCEPT_SOURCE_DEFAULTS; 146 } else { 147 psError(PS_ERR_UNKNOWN, false, "Error reading concepts from defaults.\n"); 148 success = false; 149 } 141 150 } 142 151 143 152 if (source & PM_CONCEPT_SOURCE_HEADER && !(*read & PM_CONCEPT_SOURCE_HEADER)) { 144 pmConceptsReadFromHeader(*specs, fpa, chip, cell, target); 145 *read |= PM_CONCEPT_SOURCE_HEADER; 146 } 147 153 if (pmConceptsReadFromHeader(*specs, fpa, chip, cell, target)) { 154 *read |= PM_CONCEPT_SOURCE_HEADER; 155 } else { 156 psError(PS_ERR_UNKNOWN, false, "Error reading concepts from header.\n"); 157 success = false; 158 } 159 } 160 161 #ifndef OMIT_PSDB 148 162 if (source & PM_CONCEPT_SOURCE_DATABASE && !(*read & PM_CONCEPT_SOURCE_DATABASE)) { 149 pmConceptsReadFromDatabase(*specs, fpa, chip, cell, db, target); 150 *read |= PM_CONCEPT_SOURCE_DATABASE; 151 } 152 153 return true; 163 if (pmConceptsReadFromDatabase(*specs, fpa, chip, cell, db, target)) { 164 *read |= PM_CONCEPT_SOURCE_DATABASE; 165 } else { 166 psError(PS_ERR_UNKNOWN, false, "Error reading concepts from database.\n"); 167 success = false; 168 } 169 } 170 #endif 171 172 return success; 154 173 } 155 174 -
trunk/psModules/src/concepts/pmConcepts.h
r7017 r7311 6 6 7 7 // Function to call to parse a concept once it has been read 8 typedef psMetadataItem* (*pmConceptParseFunc)( psMetadataItem *concept, psMetadataItem *pattern, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip,pmCell *cell);8 typedef psMetadataItem* (*pmConceptParseFunc)(const psMetadataItem *concept, const psMetadataItem *pattern, const psMetadata *cameraFormat, const pmFPA *fpa, const pmChip *chip, const pmCell *cell); 9 9 // Function to call to format a concept for writing 10 typedef psMetadataItem* (*pmConceptFormatFunc)( psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip,pmCell *cell);10 typedef psMetadataItem* (*pmConceptFormatFunc)(const psMetadataItem *concept, const psMetadata *cameraFormat, const pmFPA *fpa, const pmChip *chip, const pmCell *cell); 11 11 12 12 // A "concept" specification -
trunk/psModules/src/concepts/pmConceptsRead.c
r7280 r7311 71 71 parsed = parsePlain(concept, spec->blank); 72 72 } 73 if (!parsed) 74 return false; 73 if (!parsed) { 74 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s\n", spec->blank->name); 75 return false; 76 } 75 77 76 78 // Plug the parsed concept into a new psMetadataItem, so each "concept" has its own version that can … … 117 119 118 120 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level 119 if (! hdu) {121 if (!hdu) { 120 122 return false; 121 123 } … … 124 126 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 125 127 psMetadataItem *specItem = NULL; // Item from the specs metadata 128 bool status = true; // Status of reading concepts 126 129 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 127 130 pmConceptSpec *spec = specItem->data.V; // The specification 128 131 psString name = specItem->name; // The concept name 129 132 psMetadataItem *conceptItem = psMetadataLookup(cellConfig, name); // The concept, or NULL 130 psMetadataItem *value = NULL; // The value of the concept131 133 if (conceptItem) { 132 134 if (conceptItem->type == PS_DATA_STRING) { … … 138 140 psFree(nameSource); 139 141 if (mdok && strlen(source) > 0 && strcasecmp(source, "VALUE") == 0) { 140 value = conceptItem; 141 conceptParse(spec, value, cameraFormat, target, NULL, NULL, cell); 142 if (!conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell)) { 143 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from camera " 144 "configuration\n", name); 145 status = false; 146 } 142 147 } else if (source && (strlen(source) == 0 || strcasecmp(source, "HEADER") != 0)) { 143 148 // We leave "HEADER" to pmConceptsReadFromHeader … … 148 153 } else { 149 154 // Another type --- should be OK 150 conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell); 155 if (!conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell)) { 156 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from camera " 157 "configuration. It has a weird %s.SOURCE: %s\n", name, name); 158 status = false; 159 } 151 160 } 152 161 } 153 162 } 154 163 psFree(specsIter); 155 return true;164 return status; 156 165 } 157 166 … … 179 188 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 180 189 psMetadataItem *specItem = NULL; // Item from the specs metadata 190 bool status = true; // Status of reading concepts 181 191 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 182 192 pmConceptSpec *spec = specItem->data.V; // The specification 183 193 psString name = specItem->name; // The concept name 184 194 psMetadataItem *conceptItem = psMetadataLookup(defaults, name); // The concept, or NULL 185 conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell); 195 if (conceptItem && !conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell)) { 196 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from DEFAULTS.\n", name); 197 status = false; 198 } 186 199 } 187 200 psFree(specsIter); 188 return true;201 return status; 189 202 } 190 203 … … 213 226 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 214 227 psMetadataItem *specItem = NULL; // Item from the specs metadata 228 bool status = true; // Status of reading concepts 215 229 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 216 230 pmConceptSpec *spec = specItem->data.V; // The specification … … 257 271 258 272 // This will also clean up the name 259 conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell); 273 if (headerItem && !conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell)) { 274 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from header.\n", name); 275 status = false; 276 } 260 277 } 261 278 psFree(specsIter); 262 return true;279 return status; 263 280 } 264 281 … … 294 311 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 295 312 psMetadataItem *specItem = NULL; // Item from the specs metadata 313 bool status = true; // Status of reading concepts 296 314 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 297 315 pmConceptSpec *spec = specItem->data.V; // The specification … … 374 392 375 393 // Now we have the result 376 conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell); 394 if (!conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell)) { 395 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from database.\n", 396 name); 397 status = false; 398 } 377 399 378 400 } … … 385 407 psFree(specsIter); 386 408 387 return true;409 return status; 388 410 #endif 389 411 } -
trunk/psModules/src/concepts/pmConceptsStandard.c
r7281 r7311 69 69 sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3) 70 70 { 71 psError(PS_ERR_ IO, true, "Cannot interpret FPA.RA: %s\n", concept->data.V);71 psError(PS_ERR_UNKNOWN, true, "Cannot interpret FPA.RA: %s\n", concept->data.V); 72 72 break; 73 73 } … … 80 80 break; 81 81 default: 82 psError(PS_ERR_ IO, true, "%s concept is of an unexpected type: %x\n", pattern->name, concept->type);82 psError(PS_ERR_UNKNOWN, true, "%s concept is of an unexpected type: %x\n", pattern->name, concept->type); 83 83 return NULL; 84 84 } … … 171 171 assert(pattern); 172 172 173 psRegion *trimsec = ps Alloc(sizeof(psRegion)); // Make space for a psRegion (usually passed by value)173 psRegion *trimsec = psRegionAlloc(0, 0, 0, 0); 174 174 175 175 if (concept->type != PS_DATA_STRING) { 176 psError(PS_ERR_IO, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type); 177 *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0); 176 psError(PS_ERR_UNKNOWN, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type); 178 177 } else { 179 178 *trimsec = psRegionFromString(concept->data.V); … … 231 230 } 232 231 default: 233 psError(PS_ERR_ IO, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming "232 psError(PS_ERR_UNKNOWN, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming " 234 233 "blank.\n"); 235 234 } … … 259 258 (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 && 260 259 sscanf(binString, "%*d,%d", &binning) != 1)) { 261 psError(PS_ERR_ IO, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);260 psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString); 262 261 } 263 262 } … … 269 268 TYPE_CASE(binning, concept, S32); 270 269 default: 271 psError(PS_ERR_ IO, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,270 psError(PS_ERR_UNKNOWN, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name, 272 271 concept->type); 273 272 } … … 290 289 psString sys = concept->data.V; // The time system string 291 290 if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) { 292 psError(PS_ERR_ IO, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");291 psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n"); 293 292 } else if (strcasecmp(sys, "TAI") == 0) { 294 293 timeSys = PS_TIME_TAI; … … 300 299 timeSys = PS_TIME_TT; 301 300 } else { 302 psError(PS_ERR_ IO, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");301 psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n"); 303 302 } 304 303 … … 334 333 // Get format 335 334 psMetadata *formats = psMetadataLookupMD(&mdok, cameraFormat, "FORMATS"); 336 if (!mdok || !formats) 335 if (!mdok || !formats) { 336 psError(PS_ERR_UNKNOWN, false, "Unable to find FORMATS in camera configuration.\n"); 337 337 return NULL; 338 } 338 339 339 340 psString timeFormat = psMetadataLookupStr(&mdok, formats, "CELL.TIME"); 340 if (!mdok || !timeFormat || !strlen(timeFormat)) 341 if (!mdok || !timeFormat || !strlen(timeFormat)) { 342 psError(PS_ERR_UNKNOWN, false, "Unable to find CELL.TIME in FORMATS.\n"); 341 343 return NULL; 344 } 342 345 343 346 // Parse the time format … … 385 388 psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time 386 389 if (dateItem->type != PS_DATA_STRING) { 387 psError(PS_ERR_ IO, true, "Date is not of type STR.\n");390 psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n"); 388 391 return NULL; 389 392 } … … 392 395 if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 && 393 396 sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) { 394 psError(PS_ERR_ IO, true, "Unable to read date: %s\n", dateString);397 psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString); 395 398 return NULL; 396 399 } … … 408 411 year = temp; 409 412 } 410 if (pre2000Time || year < 2000) { 411 year += 2000; 412 } 413 if (year < 100) { 414 if (pre2000Time) { 415 year += 1900; 416 } else { 417 year += 2000; 418 } 419 } 420 sprintf(dateString,"%04d-%02d-%02d", year, month, day); 421 413 422 psString timeString = NULL; // The string with the time 414 423 if (timeItem->type == PS_DATA_STRING) { … … 427 436 TYPE_CASE(seconds, timeItem, F64); 428 437 default: 429 psError(PS_ERR_ IO, true, "Time is not of an expected type: %x\n", timeItem->type);438 psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type); 430 439 return NULL; 431 440 } … … 440 449 psStringAppend(&dateTimeString, "%sT%s", dateString, timeString); 441 450 time = psTimeFromISO(dateTimeString, timeSys); 451 psFree(dateTimeString); 442 452 break; 443 453 } … … 463 473 time = psTimeFromMJD(timeValue); 464 474 } else { 465 psError(PS_ERR_IO, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", timeValue); 475 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", 476 timeValue); 466 477 time = psTimeFromJD(timeValue); 467 478 } … … 475 486 time = psTimeFromMJD(timeValue); 476 487 } else { 477 psError(PS_ERR_IO, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", timeValue); 488 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", 489 timeValue); 478 490 time = psTimeFromJD(timeValue); 479 491 } … … 481 493 } 482 494 default: 483 psError(PS_ERR_ IO, true, "Unable to parse CELL.TIME.\n");495 psError(PS_ERR_UNKNOWN, true, "Unable to parse CELL.TIME.\n"); 484 496 return NULL; 485 497 } … … 526 538 TYPE_CASE(offset, concept, S32); 527 539 default: 528 psError(PS_ERR_ IO, true, "Concept %s is not of integer type, as expected.\n", pattern->name);540 psError(PS_ERR_UNKNOWN, true, "Concept %s is not of integer type, as expected.\n", pattern->name); 529 541 return NULL; 530 542 } … … 724 736 // XXX: Couldn't be bothered doing these right now 725 737 if (pre2000Time) { 726 psError(PS_ERR_ IO, true, "Don't you realise it's the twenty-first century?\n");738 psError(PS_ERR_UNKNOWN, true, "Don't you realise it's the twenty-first century?\n"); 727 739 return NULL; 728 740 } 729 741 if (backwardsTime) { 730 psError(PS_ERR_ IO, true, "You want it BACKWARDS? Not right now, thanks.\n");742 psError(PS_ERR_UNKNOWN, true, "You want it BACKWARDS? Not right now, thanks.\n"); 731 743 return NULL; 732 744 } 733 745 if (usaTime) { 734 psError(PS_ERR_ IO, true, "USA? No OK --- yet.\n");746 psError(PS_ERR_UNKNOWN, true, "USA? No OK.\n"); 735 747 return NULL; 736 748 } … … 778 790 779 791 if (concept->type != PS_TYPE_S32) { 780 psError(PS_ERR_ IO, true, "Concept %s is not of type S32, as expected.\n", concept->name);792 psError(PS_ERR_UNKNOWN, true, "Concept %s is not of type S32, as expected.\n", concept->name); 781 793 return NULL; 782 794 } -
trunk/psModules/src/config/pmConfig.c
r7278 r7311 3 3 * @author PAP, IfA 4 4 * 5 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-06-0 2 00:55:22$5 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-06-03 01:02:08 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 12 12 #include <string.h> 13 13 #include <unistd.h> 14 #include <libgen.h> 14 15 #include <assert.h> 15 16 #include <sys/types.h> … … 52 53 } 53 54 55 void pmConfigSet(const char *path) 56 { 57 pmConfigDone(); 58 59 psList *list = psStringSplit(path, ":", false); 60 configPath = psListToArray(list); 61 psFree(list); 62 } 63 54 64 void pmConfigDone(void) 55 65 { 56 66 psFree(configPath); 67 configPath = NULL; 57 68 } 58 69 … … 100 111 101 112 if (configPath == NULL) { 102 psError(PS_ERR_IO, false, "Cannot find %s configuration file (%s) in path\n", description, name);113 psError(PS_ERR_IO, true, "Cannot find %s configuration file (%s) in path\n", description, name); 103 114 return false; 104 115 } … … 121 132 } 122 133 123 psError(PS_ERR_IO, false, "Cannot find %s configuration file %s in path\n", description, name);134 psError(PS_ERR_IO, true, "Cannot find %s configuration file %s in path\n", description, name); 124 135 return false; 125 136 … … 127 138 *config = psMetadataConfigParse(NULL, &numBadLines, realName, true); 128 139 if (numBadLines > 0) { 129 psLogMsg(__func__, PS_LOG_WARN, "%d bad lines in %s configuration file (%s)\n", 130 description, realName); 140 psError(PS_ERR_IO, false, "%d bad lines in %s configuration file (%s)", 141 numBadLines, description, realName); 142 psFree (realName); 143 144 return false; 131 145 } 132 146 if (!*config) { 133 psError(PS_ERR_IO, false, "Unable to read %s configuration from %s\n",147 psError(PS_ERR_IO, true, "Unable to read %s configuration from %s", 134 148 description, realName); 135 149 psFree (realName); … … 214 228 return NULL; 215 229 } 230 231 // define the config-file search path (configPath). Ensure that 232 // it contains the directory where we found the config file in 233 // the first place 234 if (configPath) { 235 pmConfigDone(); 236 } 237 238 psString siteNameDir = psStringCopy(dirname(siteName)); 216 239 psFree(siteName); 217 240 218 // define the config-file search path (configPath) 219 if (configPath) { 220 psFree(configPath); 221 configPath = NULL; 222 } 223 char *path = psMetadataLookupStr(NULL, config->site, "PATH"); 241 psString path = psMetadataLookupStr(NULL, config->site, "PATH"); 224 242 if (path) { 225 psList *list = psStringSplit(path, ":", false); 226 configPath = psListToArray(list); 227 psFree(list); 228 } 243 psStringAppend(&path, ":%s", siteNameDir); 244 } else { 245 path = psMemIncrRefCounter(siteNameDir); 246 } 247 pmConfigSet(path); 248 psFree(siteNameDir); 229 249 230 250 // Next, we do a similar thing for the camera configuration file. The … … 349 369 } 350 370 371 psErrorClear(); // we may have failed to find some items in the metadata 372 351 373 return config; 352 374 } … … 468 490 psMetadata *cameras = psMetadataLookupMD(&mdok, config->site, "CAMERAS"); 469 491 if (! mdok) { 470 psError(PS_ERR_IO, false, "Unable to find CAMERAS in the configuration.\n");492 psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration."); 471 493 return false; 472 494 } … … 502 524 503 525 if (! config->camera) { 504 psError(PS_ERR_IO, true, "Unable to find a camera that matches input FITS header!\n");526 psError(PS_ERR_IO, false, "Unable to find a camera that matches input FITS header!"); 505 527 return NULL; 506 528 } … … 611 633 psMetadata *rules = psMetadataLookupMD(&mdok, format, "RULE"); // How to identify this format 612 634 if (!mdok || !rules) { 613 psError(PS_ERR_IO, false, "Unable to find RULE in camera format.\n");635 psError(PS_ERR_IO, true, "Unable to find RULE in camera format.\n"); 614 636 return false; 615 637 } … … 651 673 globList.gl_offs = 0; 652 674 glob (argv[Narg], 0, NULL, &globList); 675 676 if (globList.gl_pathc == 0) { 677 psError(PS_ERR_IO, true, "No match for %s", argv[Narg]); 678 return input; 679 } 680 653 681 for (int i = 0; i < globList.gl_pathc; i++) { 654 682 char *filename = psStringCopy (globList.gl_pathv[i]); … … 706 734 PS_ASSERT_INT_POSITIVE(strlen(list), NULL); 707 735 736 psErrorClear(); // pmConfigFileSets may or may not call psError, so 737 // if files->n == 0 we'll want to call psError(..., false, ...) 708 738 psArray *files = pmConfigFileSets (argc, argv, file, list); 709 739 if (files->n == 0) { 740 psError(PS_ERR_IO, false, "pmConfigFileSets failed to find desired files in metadata"); 710 741 psFree (files); 711 742 return false; -
trunk/psModules/src/config/pmConfig.h
r7026 r7311 3 3 * @author PAP, IfA 4 4 * 5 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-0 5-02 00:47:01$5 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-06-03 01:02:08 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 29 29 pmConfig *pmConfigAlloc(void); 30 31 void pmConfigSet(const char *path); // set the configPath 30 32 31 33 // Free static variables -
trunk/psModules/src/objects/pmPSF.c
r6960 r7311 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-0 4-23 01:07:51$8 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-06-03 01:02:08 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 97 97 // the ApTrend components are (x, y, r2rflux, flux) 98 98 psf->ApTrend = psPolynomial4DAlloc (PS_POLYNOMIAL_ORD, 2, 2, 1, 1); 99 pmPSF_MaskApTrend (psf , PM_PSF_SKYBIAS);99 pmPSF_MaskApTrend (psf->ApTrend, PM_PSF_SKYBIAS); 100 100 101 101 if (psf->poissonErrors) { … … 239 239 * to enable the specific subset of the coefficients 240 240 **********************************************/ 241 bool pmPSF_MaskApTrend (pmPSF *psf, pmPSF_ApTrendOptions option) 241 bool pmPSF_MaskApTrend (psPolynomial4D *trend, 242 pmPSF_ApTrendOptions option) 242 243 { 243 244 244 245 switch (option) { 245 246 case PM_PSF_NONE: 246 maskAllTerms ( psf->ApTrend);247 maskAllTerms (trend); 247 248 return true; 248 249 249 250 case PM_PSF_CONSTANT: 250 maskAllTerms ( psf->ApTrend);251 psf->ApTrend->mask[0][0][0][0] = 0; // unmask constant251 maskAllTerms (trend); 252 trend->mask[0][0][0][0] = 0; // unmask constant 252 253 return true; 253 254 254 255 case PM_PSF_SKYBIAS: 255 maskAllTerms ( psf->ApTrend);256 psf->ApTrend->mask[0][0][0][0] = 0; // unmask constant257 psf->ApTrend->mask[0][0][1][0] = 0; // unmask skybias256 maskAllTerms (trend); 257 trend->mask[0][0][0][0] = 0; // unmask constant 258 trend->mask[0][0][1][0] = 0; // unmask skybias 258 259 return true; 259 260 260 261 case PM_PSF_SKYSAT: 261 maskAllTerms ( psf->ApTrend);262 psf->ApTrend->mask[0][0][0][0] = 0; // unmask constant263 psf->ApTrend->mask[0][0][1][0] = 0; // unmask skybias264 psf->ApTrend->mask[0][0][0][1] = 0; // unmask skybias262 maskAllTerms (trend); 263 trend->mask[0][0][0][0] = 0; // unmask constant 264 trend->mask[0][0][1][0] = 0; // unmask skybias 265 trend->mask[0][0][0][1] = 0; // unmask skysat 265 266 return true; 266 267 267 268 case PM_PSF_XY_LIN: 268 maskAllTerms ( psf->ApTrend);269 psf->ApTrend->mask[0][0][0][0] = 0; // unmask constant270 psf->ApTrend->mask[1][0][0][0] = 0; // unmask x271 psf->ApTrend->mask[0][1][0][0] = 0; // unmask y269 maskAllTerms (trend); 270 trend->mask[0][0][0][0] = 0; // unmask constant 271 trend->mask[1][0][0][0] = 0; // unmask x 272 trend->mask[0][1][0][0] = 0; // unmask y 272 273 return true; 273 274 274 275 case PM_PSF_XY_QUAD: 275 maskAllTerms ( psf->ApTrend);276 psf->ApTrend->mask[0][0][0][0] = 0; // unmask constant277 psf->ApTrend->mask[1][0][0][0] = 0; // unmask x278 psf->ApTrend->mask[2][0][0][0] = 0; // unmask x^2279 psf->ApTrend->mask[1][1][0][0] = 0; // unmask x y280 psf->ApTrend->mask[0][1][0][0] = 0; // unmask y281 psf->ApTrend->mask[0][2][0][0] = 0; // unmask y^2276 maskAllTerms (trend); 277 trend->mask[0][0][0][0] = 0; // unmask constant 278 trend->mask[1][0][0][0] = 0; // unmask x 279 trend->mask[2][0][0][0] = 0; // unmask x^2 280 trend->mask[1][1][0][0] = 0; // unmask x y 281 trend->mask[0][1][0][0] = 0; // unmask y 282 trend->mask[0][2][0][0] = 0; // unmask y^2 282 283 return true; 283 284 284 285 case PM_PSF_SKY_XY_LIN: 285 maskAllTerms ( psf->ApTrend);286 psf->ApTrend->mask[0][0][0][0] = 0; // unmask constant287 psf->ApTrend->mask[1][0][0][0] = 0; // unmask x288 psf->ApTrend->mask[0][1][0][0] = 0; // unmask y289 psf->ApTrend->mask[0][0][1][0] = 0; // unmask skybias286 maskAllTerms (trend); 287 trend->mask[0][0][0][0] = 0; // unmask constant 288 trend->mask[1][0][0][0] = 0; // unmask x 289 trend->mask[0][1][0][0] = 0; // unmask y 290 trend->mask[0][0][1][0] = 0; // unmask skybias 290 291 return true; 291 292 292 293 case PM_PSF_SKYSAT_XY_LIN: 293 maskAllTerms ( psf->ApTrend);294 psf->ApTrend->mask[0][0][0][0] = 0; // unmask constant295 psf->ApTrend->mask[1][0][0][0] = 0; // unmask x296 psf->ApTrend->mask[0][1][0][0] = 0; // unmask y297 psf->ApTrend->mask[0][0][1][0] = 0; // unmask skybias298 psf->ApTrend->mask[0][0][0][1] = 0; // unmask skysat294 maskAllTerms (trend); 295 trend->mask[0][0][0][0] = 0; // unmask constant 296 trend->mask[1][0][0][0] = 0; // unmask x 297 trend->mask[0][1][0][0] = 0; // unmask y 298 trend->mask[0][0][1][0] = 0; // unmask skybias 299 trend->mask[0][0][0][1] = 0; // unmask skysat 299 300 return true; 300 301 301 302 case PM_PSF_ALL: 302 303 default: 303 maskAllTerms ( psf->ApTrend);304 psf->ApTrend->mask[0][0][0][0] = 0; // unmask constant305 psf->ApTrend->mask[0][0][1][0] = 0; // unmask skybias306 psf->ApTrend->mask[0][0][0][1] = 0; // unmask skysat307 308 psf->ApTrend->mask[1][0][0][0] = 0; // unmask x309 psf->ApTrend->mask[2][0][0][0] = 0; // unmask x^2310 psf->ApTrend->mask[1][1][0][0] = 0; // unmask x y311 psf->ApTrend->mask[0][1][0][0] = 0; // unmask y312 psf->ApTrend->mask[0][2][0][0] = 0; // unmask y^2304 maskAllTerms (trend); 305 trend->mask[0][0][0][0] = 0; // unmask constant 306 trend->mask[0][0][1][0] = 0; // unmask skybias 307 trend->mask[0][0][0][1] = 0; // unmask skysat 308 309 trend->mask[1][0][0][0] = 0; // unmask x 310 trend->mask[2][0][0][0] = 0; // unmask x^2 311 trend->mask[1][1][0][0] = 0; // unmask x y 312 trend->mask[0][1][0][0] = 0; // unmask y 313 trend->mask[0][2][0][0] = 0; // unmask y^2 313 314 return true; 314 315 } -
trunk/psModules/src/objects/pmPSF.h
r6873 r7311 31 31 psArray *params; ///< Model parameters (psPolynomial2D) 32 32 psPolynomial1D *ChiTrend; ///< Chisq vs flux fit (correction for systematic errors) 33 psPolynomial4D *ApTrend; ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst) 34 pmGrowthCurve *growth; ///< apMag vs Radius33 psPolynomial4D *ApTrend; ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst)) 34 //pmGrowthCurve *growth; ///< apMag vs Radius // move to end as gdb is confused by it here 35 35 float ApResid; ///< apMag - psfMag (for PSF stars) 36 36 float dApResid; ///< scatter of ApResid … … 41 41 int nApResid; ///< number of stars used to measure ApResid 42 42 bool poissonErrors; 43 pmGrowthCurve *growth; ///< apMag vs Radius 43 44 } 44 45 pmPSF; … … 100 101 ); 101 102 102 bool pmPSF_MaskApTrend (p mPSF *psf, pmPSF_ApTrendOptions option);103 bool pmPSF_MaskApTrend (psPolynomial4D *trend, pmPSF_ApTrendOptions option); 103 104 104 105 # endif -
trunk/psModules/src/objects/pmPSF_IO.c
r6872 r7311 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-0 4-17 18:01:05$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-06-03 01:02:08 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 287 287 { 288 288 289 int Nfail;289 unsigned int Nfail; 290 290 char *filename; 291 291 -
trunk/psModules/src/objects/pmPSFtry.c
r7283 r7311 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-06-0 2 02:16:05$7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-06-03 01:02:08 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 263 263 psLogMsg ("pmPSFtryMetric", 4, "fit stats: %f +/- %f\n", stats->sampleMedian, stats->sampleStdev); 264 264 265 pmPSF_MaskApTrend (psfTry->psf , PM_PSF_SKYBIAS);265 pmPSF_MaskApTrend (psfTry->psf->ApTrend, PM_PSF_SKYBIAS); 266 266 psfTry->psf->ApTrend->coeff[0][0][0][0] = poly->coeff[0]; 267 267 psfTry->psf->ApTrend->coeff[0][0][1][0] = 0; -
trunk/psModules/src/objects/pmPSFtry.h
r6873 r7311 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-06-03 01:02:08 $ 8 10 * 9 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 76 78 * 77 79 */ 78 pmPSFtry *pmPSFtryAlloc( 79 psArray *stars, ///< Add comment. 80 char *modelName, ///< Add comment. 81 bool poissonErrors // use poissonian or constant errors? 82 ); 83 80 pmPSFtry *pmPSFtryAlloc (psArray *sources, char *modelName, bool poissonErrors); 84 81 85 82 /** pmPSFtryModel() … … 90 87 * 91 88 */ 92 pmPSFtry *pmPSFtryModel( 93 psArray *sources, ///< Add comment. 94 char *modelName, ///< Add comment. 95 float radius, ///< Add comment. 96 bool poissonErrors // use poissonian or constant errors? 97 ); 98 89 pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors); 99 90 100 91 /** pmPSFtryMetric() -
trunk/psModules/src/objects/pmPeaks.c
r6943 r7311 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-0 4-21 21:26:44$8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-06-03 01:02:08 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 94 94 pmPeakAlloc(): Allocate the pmPeak data structure and set appropriate members. 95 95 *****************************************************************************/ 96 static void peakFree(pmPeak *tmp) 97 {} // used by pmIsPeak() 98 96 99 pmPeak *pmPeakAlloc(psS32 x, 97 100 psS32 y, … … 100 103 { 101 104 psTrace(__func__, 3, "---- %s() begin ----\n", __func__); 105 static int id = 1; 102 106 pmPeak *tmp = (pmPeak *) psAlloc(sizeof(pmPeak)); 107 *(int *)&tmp->id = id++; 103 108 tmp->x = x; 104 109 tmp->y = y; … … 106 111 tmp->type = type; 107 112 113 psMemSetDeallocator(tmp, (psFreeFunc) peakFree); 114 108 115 psTrace(__func__, 3, "---- %s() end ----\n", __func__); 109 116 return(tmp); 117 } 118 119 bool pmIsPeak(const psPtr ptr) 120 { 121 return (psMemGetDeallocator(ptr) == (psFreeFunc)peakFree); 110 122 } 111 123 -
trunk/psModules/src/objects/pmPeaks.h
r6872 r7311 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-0 4-17 18:01:05$12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-06-03 01:02:08 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 47 47 typedef struct 48 48 { 49 const int id; ///< Unique ID for object 49 50 int x; ///< X-coordinate of peak pixel. 50 51 int y; ///< Y-coordinate of peak pixel. … … 66 67 ); 67 68 69 bool pmIsPeak(const psPtr ptr); 68 70 69 71 /** pmFindVectorPeaks() -
trunk/psModules/src/objects/pmSource.c
r7283 r7311 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-06-0 2 02:16:05$8 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-06-03 01:02:08 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 46 46 { 47 47 psTrace(__func__, 3, "---- %s() begin ----\n", __func__); 48 static int id = 1; 48 49 pmSource *tmp = (pmSource *) psAlloc(sizeof(pmSource)); 50 *(int *)&tmp->id = id++; 49 51 tmp->peak = NULL; 50 52 tmp->pixels = NULL; … … 69 71 } 70 72 73 bool pmIsSource(const psPtr ptr) 74 { 75 return (psMemGetDeallocator(ptr) == (psFreeFunc)sourceFree); 76 } 77 71 78 // x,y are defined in the parent image coords of readout->image 72 79 bool pmSourceDefinePixels(pmSource *mySource, … … 82 89 srcRegion = psRegionForImage (readout->image, srcRegion); 83 90 84 mySource->pixels = ps ImageSubset(readout->image, srcRegion);85 mySource->weight = ps ImageSubset(readout->weight, srcRegion);86 mySource->mask = ps ImageSubset(readout->mask, srcRegion);91 mySource->pixels = psMemIncrRefCounter(psImageSubset(readout->image, srcRegion)); 92 mySource->weight = psMemIncrRefCounter(psImageSubset(readout->weight, srcRegion)); 93 mySource->mask = psMemIncrRefCounter(psImageSubset(readout->mask, srcRegion)); 87 94 mySource->region = srcRegion; 88 95 … … 123 130 psFree (mySource->mask); 124 131 125 mySource->pixels = ps ImageSubset(readout->image, newRegion);126 mySource->weight = ps ImageSubset(readout->weight, newRegion);127 mySource->mask = ps ImageSubset(readout->mask, newRegion);132 mySource->pixels = psMemIncrRefCounter(psImageSubset(readout->image, newRegion)); 133 mySource->weight = psMemIncrRefCounter(psImageSubset(readout->weight, newRegion)); 134 mySource->mask = psMemIncrRefCounter(psImageSubset(readout->mask, newRegion)); 128 135 mySource->region = newRegion; 129 136 } -
trunk/psModules/src/objects/pmSource.h
r6905 r7311 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-0 4-19 20:29:57$5 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-06-03 01:02:08 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 73 73 typedef struct 74 74 { 75 const int id; ///< Unique ID for object 75 76 pmPeak *peak; ///< Description of peak pixel. 76 77 psImage *pixels; ///< Rectangular region including object pixels. … … 114 115 pmSource *pmSourceAlloc(); 115 116 117 bool pmIsSource(const psPtr ptr); 116 118 117 119 /** pmSourceDefinePixels() -
trunk/psModules/src/objects/pmSourceFitModel.c
r6960 r7311 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-0 4-23 01:07:51$8 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-06-03 01:02:08 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 515 515 psTrace (__func__, 5, "fitting function\n"); 516 516 fitStatus = psMinimizeLMChi2(myMin, covar, params, constrain, x, y, yErr, pmModelFitSet); 517 if (!fitStatus) { 518 psError(PS_ERR_UNKNOWN, false, "Failed to fit model\n"); 519 } 517 520 518 521 // parameter errors from the covariance matrix -
trunk/psModules/src/objects/pmSourceIO.c
r7306 r7311 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-06-03 0 0:40:28 $5 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-06-03 01:02:08 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 57 57 } 58 58 59 // Given a FITS file pointer, readthe table of object data59 // Given a FITS file pointer, write the table of object data 60 60 bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file) 61 61 { … … 64 64 65 65 if (view->chip == -1) { 66 pmFPAWriteObjects (fpa, view, file); 66 if (!pmFPAWriteObjects (fpa, view, file)) { 67 psError(PS_ERR_IO, false, "Failed to write objects from fpa"); 68 return false; 69 } 67 70 return true; 68 71 } 69 72 70 73 if (view->chip >= fpa->chips->n) { 74 psError(PS_ERR_UNKNOWN, false, "Writing chip == %d (>= chips->n == %d)", view->chip, fpa->chips->n); 71 75 return false; 72 76 } … … 74 78 75 79 if (view->cell == -1) { 76 pmChipWriteObjects (chip, view, file); 80 if (!pmChipWriteObjects (chip, view, file)) { 81 psError(PS_ERR_IO, false, "Failed to write objects from chip"); 82 return false; 83 } 77 84 return true; 78 85 } 79 86 80 87 if (view->cell >= chip->cells->n) { 88 psError(PS_ERR_UNKNOWN, false, "Writing cell == %d (>= cells->n == %d)", 89 view->cell, chip->cells->n); 81 90 return false; 82 91 } … … 84 93 85 94 if (view->readout == -1) { 86 pmCellWriteObjects (cell, view, file); 95 if (!pmCellWriteObjects (cell, view, file)) { 96 psError(PS_ERR_IO, false, "Failed to write objects from cell"); 97 return false; 98 } 99 87 100 return true; 88 101 } 89 102 90 103 if (view->readout >= cell->readouts->n) { 104 psError(PS_ERR_UNKNOWN, false, "Writing readout == %d (>= readouts->n == %d)", 105 view->readout, cell->readouts->n); 91 106 return false; 92 107 } 93 108 pmReadout *readout = cell->readouts->data[view->readout]; 94 109 95 pmReadoutWriteObjects (readout, view, file); 110 if (!pmReadoutWriteObjects (readout, view, file)) { 111 psError(PS_ERR_IO, false, "Failed to write objects from readout %d", view->readout); 112 return false; 113 } 114 96 115 return true; 97 116 } … … 104 123 105 124 pmChip *chip = fpa->chips->data[i]; 106 pmChipWriteObjects (chip, view, file); 125 if (!pmChipWriteObjects (chip, view, file)) { 126 psError(PS_ERR_IO, false, "Failed to write %dth chip", i); 127 return false; 128 } 107 129 } 108 130 return true; … … 116 138 117 139 pmCell *cell = chip->cells->data[i]; 118 pmCellWriteObjects (cell, view, file); 140 if (!pmCellWriteObjects (cell, view, file)) { 141 psError(PS_ERR_IO, false, "Failed to write %dth cell", i); 142 return false; 143 } 119 144 } 120 145 return true; … … 128 153 129 154 pmReadout *readout = cell->readouts->data[i]; 130 pmReadoutWriteObjects (readout, view, file); 155 if (!pmReadoutWriteObjects (readout, view, file)) { 156 psError(PS_ERR_IO, false, "Failed to write %dth readout", i); 157 return false; 158 } 131 159 } 132 160 return true; … … 181 209 psMetadataCopy (outhead, updates); 182 210 183 pmSourcesWriteCMP (sources, filename, outhead);211 bool status = pmSourcesWriteCMP (sources, filename, outhead); 184 212 psFree (outhead); 185 213 psFree (filename); 214 215 if (!status) { 216 psError(PS_ERR_IO, false, "Failed to write CMP file\n"); 217 return false; 218 } 186 219 break; 187 220 -
trunk/psModules/src/objects/pmSourceIO_CMP.c
r7306 r7311 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-06-03 0 0:40:46$5 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-06-03 01:02:08 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 69 69 70 70 psFits *fits = psFitsOpen (filename, "w"); 71 psFitsWriteBlank(fits, header); 72 psFitsClose (fits); 71 if (fits == NULL) { 72 psError(PS_ERR_IO, false, "can't open output file for write %s\n", filename); 73 return false; 74 } 75 if (!psFitsWriteBlank(fits, header)) { 76 psError(PS_ERR_IO, false, "Writing header to %s\n", filename); 77 (void)psFitsClose(fits); 78 return false; 79 } 80 if (!psFitsClose(fits)) { 81 const psErrorCode code = psErrorCodeLast(); 82 83 if (code == PS_ERR_BAD_FITS) { 84 psErrorClear(); 85 } else { 86 psError(PS_ERR_IO, false, "Closing %s\n", filename); 87 return false; 88 } 89 } 73 90 74 91 // re-open, add data to end of file 75 92 FILE *f = fopen (filename, "a+"); 76 93 if (f == NULL) { 77 psLogMsg ("WriteSourceOBJ", 3, "can't open output file for output %s\n", filename); 94 psLogMsg ("WriteSourceOBJ", 3, "can't reopen output file for append %s\n", filename); 95 psError(PS_ERR_IO, false, "can't open output file for output %s\n", filename); 78 96 return false; 79 97 } -
trunk/psModules/src/pslib/psAdditionals.c
r7238 r7311 68 68 fits_get_errstatus (status, fitsErr); 69 69 psError (PS_ERR_IO, true, PS_ERRORTEXT_psFits_WRITE_FAILED, fitsErr); 70 exit (2);70 return false; 71 71 } 72 72 -
trunk/psModules/src/pslib/psImageUnbin.c
r6872 r7311 143 143 } 144 144 // Nx,Ny 145 V = vIn[n x-1][ny-1];145 V = vIn[ny-1][nx-1]; 146 146 for (int iy = ny*DY - dy; iy < Ny; iy++) 147 147 { … … 161 161 static int MAX_SAMPLE_PIXELS; 162 162 163 void psImageClippedStatsInit (int nMax )163 void psImageClippedStatsInit (int nMax, unsigned long seed) 164 164 { 165 165 166 166 MAX_SAMPLE_PIXELS = nMax; 167 167 168 if (rnd && seed) { 169 psFree(rnd); 170 rnd = NULL; 171 } 168 172 if (!rnd) { 169 rnd = psRandomAlloc (PS_RANDOM_TAUS, 0);173 rnd = psRandomAlloc (PS_RANDOM_TAUS, seed); 170 174 } 171 175 return; -
trunk/psModules/src/pslib/psImageUnbin.h
r6872 r7311 7 7 psImage *psImageUnbin (psImage *out, psImage *in, int DX, int DY, int dx, int dy); 8 8 9 void psImageClippedStatsInit (int nMax );9 void psImageClippedStatsInit (int nMax, unsigned long seed); 10 10 void psImageClippedStatsCleanup (); 11 11 -
trunk/psModules/src/pslib/psMetadataItemParse.c
r6997 r7311 228 228 return value; } \ 229 229 230 psString psMetadataItemParseString( psMetadataItem *item230 psString psMetadataItemParseString(const psMetadataItem *item 231 231 ) 232 232 { -
trunk/psModules/src/pslib/psMetadataItemParse.h
r6997 r7311 4 4 #include "pslib.h" 5 5 6 psBool psMetadataItemParseBool( psMetadataItem *item);6 psBool psMetadataItemParseBool(const psMetadataItem *item); 7 7 8 psF32 psMetadataItemParseF32( psMetadataItem *item);9 psF64 psMetadataItemParseF64( psMetadataItem *item);8 psF32 psMetadataItemParseF32(const psMetadataItem *item); 9 psF64 psMetadataItemParseF64(const psMetadataItem *item); 10 10 11 psS8 psMetadataItemParseS8 ( psMetadataItem *item);12 psS16 psMetadataItemParseS16( psMetadataItem *item);13 psS32 psMetadataItemParseS32( psMetadataItem *item);11 psS8 psMetadataItemParseS8 (const psMetadataItem *item); 12 psS16 psMetadataItemParseS16(const psMetadataItem *item); 13 psS32 psMetadataItemParseS32(const psMetadataItem *item); 14 14 15 psU8 psMetadataItemParseU8 ( psMetadataItem *item);16 psU16 psMetadataItemParseU16( psMetadataItem *item);17 psU32 psMetadataItemParseU32( psMetadataItem *item);15 psU8 psMetadataItemParseU8 (const psMetadataItem *item); 16 psU16 psMetadataItemParseU16(const psMetadataItem *item); 17 psU32 psMetadataItemParseU32(const psMetadataItem *item); 18 18 19 psString psMetadataItemParseString( psMetadataItem *item);19 psString psMetadataItemParseString(const psMetadataItem *item); 20 20 21 21 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
