Changeset 15168 for branches/pap_branch_070920/psLib/src/fits/psFitsImage.c
- Timestamp:
- Oct 2, 2007, 5:01:45 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_070920/psLib/src/fits/psFitsImage.c
r15110 r15168 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.17.14. 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2007- 09-29 21:55:05 $9 * @version $Revision: 1.17.14.2 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-10-03 03:01:45 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 54 54 ) 55 55 { 56 PS_ASSERT_ PTR_NON_NULL(fits, NULL);56 PS_ASSERT_FITS_NON_NULL(fits, NULL); 57 57 PS_ASSERT_INT_NONNEGATIVE(z, NULL); 58 58 … … 219 219 ) 220 220 { 221 PS_ASSERT_FITS_NON_NULL(fits, NULL); 222 PS_ASSERT_INT_NONNEGATIVE(z, NULL); 223 224 if (psFitsCheckSingleCompressedImagePHU(fits, NULL)) { 225 // This is really what we want, not the empty PHU 226 psTrace("psLib.fits", 1, 227 "This PHU should really be a compressed image --- reading that image instead."); 228 } 229 221 230 p_psFitsReadInfo *info = p_psFitsReadInfoAlloc(fits, region, z); 222 231 … … 241 250 ) 242 251 { 252 PS_ASSERT_FITS_NON_NULL(fits, NULL); 253 PS_ASSERT_INT_NONNEGATIVE(z, NULL); 254 243 255 if (output && output->parent) { 244 256 psError(PS_ERR_IO, true, "Unable to read into a buffer for a child image.\n"); 245 257 return NULL; 258 } 259 260 if (psFitsCheckSingleCompressedImagePHU(fits, NULL)) { 261 // This is really what we want, not the empty PHU 262 psTrace("psLib.fits", 1, 263 "This PHU should really be a compressed image --- reading that image instead."); 246 264 } 247 265 … … 268 286 const char* extname) 269 287 { 288 PS_ASSERT_FITS_NON_NULL(fits, false); 289 PS_ASSERT_IMAGE_NON_NULL(input, false); 270 290 // this is equivalent to insert after the last HDU 271 291 … … 281 301 bool after) 282 302 { 283 284 if (!fits) { 285 psError(PS_ERR_BAD_PARAMETER_NULL, true, _("The input psFits object can not NULL.")); 286 return false; 287 } 288 289 if (!input) { 290 psError(PS_ERR_BAD_PARAMETER_NULL, true, _("The input psImage was NULL. Need a non-NULL psImage for operation to be performed.")); 291 return false; 292 } 303 PS_ASSERT_FITS_NON_NULL(fits, false); 304 PS_ASSERT_IMAGE_NON_NULL(input, false); 293 305 294 306 int numCols = input->numCols; // Number of columns for image … … 389 401 int z) 390 402 { 403 PS_ASSERT_FITS_NON_NULL(fits, false); 404 PS_ASSERT_IMAGE_NON_NULL(input, false); 405 391 406 int status = 0; 392 393 if (fits == NULL) {394 psError(PS_ERR_BAD_PARAMETER_NULL, true,395 _("The input psFits object can not NULL."));396 return false;397 }398 399 if (input == NULL) {400 psError(PS_ERR_BAD_PARAMETER_NULL, true,401 _("The input psImage was NULL. Need a non-NULL psImage for operation to be performed."));402 return false;403 }404 407 405 408 // check to see if we are positioned on an image HDU … … 497 500 psArray *psFitsReadImageCube(const psFits *fits, psRegion region) 498 501 { 502 PS_ASSERT_FITS_NON_NULL(fits, NULL); 503 499 504 int nAxis = 0; // Number of axes 500 505 long nAxes[3]; // Number of pixels on each axis … … 502 507 char fitsErr[80] = ""; // CFITSIO error message string 503 508 504 if (fits == NULL) {505 psError(PS_ERR_BAD_PARAMETER_NULL, true,506 _("The input psFits object can not NULL."));507 return NULL;508 }509 510 509 // Some of this replicates what is in psFitsReadImage, so it's a little inefficient. But it saves 511 510 // code replication, and should be sufficient for our needs. 511 512 if (psFitsCheckSingleCompressedImagePHU(fits, NULL)) { 513 // This is really what we want, not the empty PHU 514 psTrace("psLib.fits", 1, 515 "This PHU should really be a compressed image --- reading that image instead."); 516 } 512 517 513 518 if (fits_get_img_dim(fits->fd, &nAxis, &status) != 0) { … … 542 547 543 548 // Bad dimensionality 544 psError(PS_ERR_IO, true, _("Image number of dimensions, %d, is not valid. Only two or three dimensions supported for FITS I/O."), nAxis); 549 psError(PS_ERR_IO, true, 550 _("Image number of dimensions, %d, is not valid." 551 " Only two or three dimensions supported for FITS I/O."), nAxis); 545 552 return NULL; 546 553 } … … 548 555 bool psFitsWriteImageCube(psFits *fits, psMetadata *header, const psArray *input, const char *extname) 549 556 { 550 if (fits == NULL) { 551 psError(PS_ERR_BAD_PARAMETER_NULL, true, 552 _("The input psFits object can not NULL.")); 553 return false; 554 } 555 556 if (input == NULL) { 557 psError(PS_ERR_BAD_PARAMETER_NULL, true, 558 _("The input psImage was NULL. Need a non-NULL psImage for operation to be performed.")); 559 return false; 560 } 557 PS_ASSERT_FITS_NON_NULL(fits, false); 558 PS_ASSERT_ARRAY_NON_NULL(input, false); 561 559 562 560 if (input->n == 0) { … … 590 588 } 591 589 bool update = psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS", PS_META_REPLACE, "Dimensionality", 3) && 592 psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS1", PS_META_REPLACE, "Number of columns", numCols) &&593 psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS2", PS_META_REPLACE, "Number of rows", numRows) &&594 psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS3", PS_META_REPLACE, "Number of image planes",595 input->n);590 psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS1", PS_META_REPLACE, "Number of columns", numCols) && 591 psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS2", PS_META_REPLACE, "Number of rows", numRows) && 592 psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS3", PS_META_REPLACE, "Number of image planes", 593 input->n); 596 594 if (! update) { 597 595 psError(PS_ERR_UNKNOWN, false, _("Failed to add metadata item, %s."), … … 623 621 bool psFitsUpdateImageCube(psFits *fits, const psArray *input, int x0, int y0) 624 622 { 625 if (fits == NULL) { 626 psError(PS_ERR_BAD_PARAMETER_NULL, true, 627 _("The input psFits object can not NULL.")); 628 return false; 629 } 630 631 if (input == NULL) { 632 psError(PS_ERR_BAD_PARAMETER_NULL, true, 633 _("The input psImage was NULL. Need a non-NULL psImage for operation to be performed.")); 634 return false; 635 } 623 PS_ASSERT_FITS_NON_NULL(fits, false); 624 PS_ASSERT_ARRAY_NON_NULL(input, false); 636 625 637 626 if (input->n == 0) {
Note:
See TracChangeset
for help on using the changeset viewer.
