Changeset 15179 for trunk/psLib/src/fits/psFitsImage.c
- Timestamp:
- Oct 3, 2007, 11:27:21 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/fits/psFitsImage.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fits/psFitsImage.c
r10999 r15179 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $10 * @date $Date: 2007- 01-09 22:38:52$9 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-10-03 21:27:21 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 38 38 39 39 // Information required to read a FITS file 40 typedef struct 41 { 40 typedef struct { 42 41 int nAxis; // Number of axes 43 42 int bitPix; // Bits per pixel … … 48 47 int fitsDatatype; // cfitsio data type 49 48 int psDatatype; // psLib data type 50 } 51 p_psFitsReadInfo; 49 } p_psFitsReadInfo; 52 50 53 51 static p_psFitsReadInfo *p_psFitsReadInfoAlloc(const psFits *fits, // The FITS file handle … … 56 54 ) 57 55 { 58 PS_ASSERT_ PTR_NON_NULL(fits, NULL);56 PS_ASSERT_FITS_NON_NULL(fits, NULL); 59 57 PS_ASSERT_INT_NONNEGATIVE(z, NULL); 60 58 … … 221 219 ) 222 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 223 230 p_psFitsReadInfo *info = p_psFitsReadInfoAlloc(fits, region, z); 224 231 … … 243 250 ) 244 251 { 252 PS_ASSERT_FITS_NON_NULL(fits, NULL); 253 PS_ASSERT_INT_NONNEGATIVE(z, NULL); 254 245 255 if (output && output->parent) { 246 256 psError(PS_ERR_IO, true, "Unable to read into a buffer for a child image.\n"); 247 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."); 248 264 } 249 265 … … 270 286 const char* extname) 271 287 { 288 PS_ASSERT_FITS_NON_NULL(fits, false); 289 PS_ASSERT_IMAGE_NON_NULL(input, false); 272 290 // this is equivalent to insert after the last HDU 273 291 … … 283 301 bool after) 284 302 { 285 286 if (!fits) { 287 psError(PS_ERR_BAD_PARAMETER_NULL, true, _("The input psFits object can not NULL.")); 288 return false; 289 } 290 291 if (!input) { 292 psError(PS_ERR_BAD_PARAMETER_NULL, true, _("The input psImage was NULL. Need a non-NULL psImage for operation to be performed.")); 293 return false; 294 } 303 PS_ASSERT_FITS_NON_NULL(fits, false); 304 PS_ASSERT_IMAGE_NON_NULL(input, false); 295 305 296 306 int numCols = input->numCols; // Number of columns for image … … 391 401 int z) 392 402 { 403 PS_ASSERT_FITS_NON_NULL(fits, false); 404 PS_ASSERT_IMAGE_NON_NULL(input, false); 405 393 406 int status = 0; 394 395 if (fits == NULL) {396 psError(PS_ERR_BAD_PARAMETER_NULL, true,397 _("The input psFits object can not NULL."));398 return false;399 }400 401 if (input == NULL) {402 psError(PS_ERR_BAD_PARAMETER_NULL, true,403 _("The input psImage was NULL. Need a non-NULL psImage for operation to be performed."));404 return false;405 }406 407 407 408 // check to see if we are positioned on an image HDU … … 499 500 psArray *psFitsReadImageCube(const psFits *fits, psRegion region) 500 501 { 502 PS_ASSERT_FITS_NON_NULL(fits, NULL); 503 501 504 int nAxis = 0; // Number of axes 502 505 long nAxes[3]; // Number of pixels on each axis … … 504 507 char fitsErr[80] = ""; // CFITSIO error message string 505 508 506 if (fits == NULL) {507 psError(PS_ERR_BAD_PARAMETER_NULL, true,508 _("The input psFits object can not NULL."));509 return NULL;510 }511 512 509 // Some of this replicates what is in psFitsReadImage, so it's a little inefficient. But it saves 513 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 } 514 517 515 518 if (fits_get_img_dim(fits->fd, &nAxis, &status) != 0) { … … 544 547 545 548 // Bad dimensionality 546 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); 547 552 return NULL; 548 553 } … … 550 555 bool psFitsWriteImageCube(psFits *fits, psMetadata *header, const psArray *input, const char *extname) 551 556 { 552 if (fits == NULL) { 553 psError(PS_ERR_BAD_PARAMETER_NULL, true, 554 _("The input psFits object can not NULL.")); 555 return false; 556 } 557 558 if (input == NULL) { 559 psError(PS_ERR_BAD_PARAMETER_NULL, true, 560 _("The input psImage was NULL. Need a non-NULL psImage for operation to be performed.")); 561 return false; 562 } 557 PS_ASSERT_FITS_NON_NULL(fits, false); 558 PS_ASSERT_ARRAY_NON_NULL(input, false); 563 559 564 560 if (input->n == 0) { … … 592 588 } 593 589 bool update = psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS", PS_META_REPLACE, "Dimensionality", 3) && 594 psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS1", PS_META_REPLACE, "Number of columns", numCols) &&595 psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS2", PS_META_REPLACE, "Number of rows", numRows) &&596 psMetadataAddS32(headerCopy, PS_LIST_HEAD, "NAXIS3", PS_META_REPLACE, "Number of image planes",597 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); 598 594 if (! update) { 599 595 psError(PS_ERR_UNKNOWN, false, _("Failed to add metadata item, %s."), … … 625 621 bool psFitsUpdateImageCube(psFits *fits, const psArray *input, int x0, int y0) 626 622 { 627 if (fits == NULL) { 628 psError(PS_ERR_BAD_PARAMETER_NULL, true, 629 _("The input psFits object can not NULL.")); 630 return false; 631 } 632 633 if (input == NULL) { 634 psError(PS_ERR_BAD_PARAMETER_NULL, true, 635 _("The input psImage was NULL. Need a non-NULL psImage for operation to be performed.")); 636 return false; 637 } 623 PS_ASSERT_FITS_NON_NULL(fits, false); 624 PS_ASSERT_ARRAY_NON_NULL(input, false); 638 625 639 626 if (input->n == 0) {
Note:
See TracChangeset
for help on using the changeset viewer.
