Changeset 7227 for trunk/psLib/src/fits/psFitsImage.c
- Timestamp:
- May 25, 2006, 5:24:49 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/fits/psFitsImage.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fits/psFitsImage.c
r7224 r7227 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-05-26 0 0:48:20$9 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-05-26 03:24:49 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 296 296 { 297 297 298 if (fits == NULL) { 299 psError(PS_ERR_BAD_PARAMETER_NULL, true, 300 PS_ERRORTEXT_psFits_NULL); 301 return false; 302 } 303 304 if (input == NULL) { 305 psError(PS_ERR_BAD_PARAMETER_NULL, true, 306 PS_ERRORTEXT_psFits_IMAGE_NULL); 307 return false; 308 } 309 int numCols = input->numCols; 310 int numRows = input->numRows; 311 312 int status = 0; 298 if (!fits) { 299 psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psFits_NULL); 300 return false; 301 } 302 303 if (!input) { 304 psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psFits_IMAGE_NULL); 305 return false; 306 } 307 308 int numCols = input->numCols; // Number of columns for image 309 int numRows = input->numRows; // Number of rows for image 310 int status = 0; // Status from cfitsio 313 311 314 312 // determine the FITS-equivalent parameters 315 int bitPix; 316 double bZero; 317 int dataType; 313 int bitPix; // Bits per pixel 314 double bZero; // Zero offset 315 int dataType; // cfitsio data type 318 316 if (! convertPsTypeToFits(input->type.type, &bitPix, &bZero, &dataType) ) { 319 317 return false; 320 318 } 321 319 322 int naxis = 3; 323 long naxes[3]; 324 320 int naxis = 3; // Number of axes 321 long naxes[3]; // Length of each axis 325 322 naxes[0] = numCols; 326 323 naxes[1] = numRows; … … 331 328 } 332 329 333 int chdu = psFitsGetExtNum(fits); // Current HDU number330 // Create the image HDU 334 331 int hdus = psFitsGetSize(fits); // Number of HDUs in file 335 if (! after) {336 if (chdu == 0) {337 // set status to signal fits_insert_img to insert a new primary HDU338 status = PREPEND_PRIMARY;339 } else if (hdus > 0) {340 // move back one to perform an insert after the previous HDU341 psFitsMoveExtNum(fits, -1, true);342 }343 }344 345 332 if (hdus == 0) { 346 status = 0;333 // We're creating the first image 347 334 fits_create_img(fits->fd, bitPix, naxis, naxes, &status); 348 335 } else { 336 if (!after) { 337 int chdu = psFitsGetExtNum(fits); // Current HDU number 338 if (chdu == 0) { 339 // We're creating a replacement primary HDU. 340 // Set status to signal fits_insert_img to insert a new primary HDU 341 status = PREPEND_PRIMARY; 342 } else { 343 // Move back one to perform an insert after the previous HDU 344 psFitsMoveExtNum(fits, -1, true); 345 } 346 } 347 // Insert after the current position 349 348 fits_insert_img(fits->fd, bitPix, naxis, naxes, &status); 349 } 350 351 if (header && !p_psFitsWriteHeader(header, fits)) { 352 psError(PS_ERR_IO, false, "Unable to write FITS header.\n"); 353 return false; 350 354 } 351 355 … … 361 365 } 362 366 363 if (header) {364 psFitsWriteHeader(header, fits);365 }366 367 if (input->parent == NULL) { // if no parent, assume that the image data is contiguous 367 368 fits_write_img(fits->fd,
Note:
See TracChangeset
for help on using the changeset viewer.
