Index: /trunk/psLib/pslib.kdevses
===================================================================
--- /trunk/psLib/pslib.kdevses	(revision 4190)
+++ /trunk/psLib/pslib.kdevses	(revision 4191)
@@ -2,5 +2,9 @@
 <!DOCTYPE KDevPrjSession>
 <KDevPrjSession>
- <DocsAndViews NumberOfDocuments="0" />
+ <DocsAndViews NumberOfDocuments="1" >
+  <Doc0 NumberOfViews="1" URL="file:///home/desonia/panstarrs/psLib/src/dataIO/psFits.h" >
+   <View0 line="242" Type="Source" />
+  </Doc0>
+ </DocsAndViews>
  <pluginList>
   <kdevdebugger>
Index: /trunk/psLib/src/dataIO/psFits.c
===================================================================
--- /trunk/psLib/src/dataIO/psFits.c	(revision 4190)
+++ /trunk/psLib/src/dataIO/psFits.c	(revision 4191)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-08 21:07:59 $
+ *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-09 19:40:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -797,6 +797,5 @@
                       const psMetadata* header,
                       const psImage* input,
-                      int numZPlanes,
-                      char* extname)
+                      int numZPlanes)
 {
 
@@ -837,8 +836,4 @@
 
     fits_create_img(fits->p_fd, bitPix, naxis, naxes, &status);
-
-    if (extname != NULL) {
-        fits_update_key_str(fits->p_fd, "EXTNAME", (char*)extname, NULL, &status);
-    }
 
     if (bZero != 0) {        // set the bscale/bzero
@@ -1453,6 +1448,5 @@
 bool psFitsWriteTable(const psFits* fits,
                       psMetadata* header,
-                      psArray* table,
-                      char* extname)
+                      psArray* table)
 {
     int status = 0;
@@ -1524,4 +1518,13 @@
         }
         columnTypes->data[n] = fitsType;
+    }
+
+    psBool mStatus = false;
+    char* extname = psMetadataLookupPtr(&mStatus, header, "EXTNAME");
+    if ( ! mStatus) {
+        extname = psMetadataLookupPtr(&mStatus, header, "HDUNAME");
+        if (! mStatus) {
+            extname = NULL;
+        }
     }
 
Index: /trunk/psLib/src/dataIO/psFits.h
===================================================================
--- /trunk/psLib/src/dataIO/psFits.h	(revision 4190)
+++ /trunk/psLib/src/dataIO/psFits.h	(revision 4191)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-09 19:26:48 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-09 19:40:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -178,6 +178,5 @@
     const psMetadata* header,          ///< header items for the new HDU.  Can be NULL.
     const psImage* input,              ///< the image to output
-    int depth,                         ///< the number of z-planes of the FITS image data cube
-    char* extname                      ///< extension name
+    int depth                          ///< the number of z-planes of the FITS image data cube
 );
 
@@ -248,7 +247,6 @@
     const psFits* fits,                ///< the psFits object
     psMetadata* header,                ///< header items for the new HDU.  Can be NULL.
-    psArray* table,
+    psArray* table
     ///< Array of psMetadata items, which contains the output data items of each row.
-    char* extname                      ///< extension name
 );
 
Index: /trunk/psLib/src/fits/psFits.c
===================================================================
--- /trunk/psLib/src/fits/psFits.c	(revision 4190)
+++ /trunk/psLib/src/fits/psFits.c	(revision 4191)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-08 21:07:59 $
+ *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-09 19:40:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -797,6 +797,5 @@
                       const psMetadata* header,
                       const psImage* input,
-                      int numZPlanes,
-                      char* extname)
+                      int numZPlanes)
 {
 
@@ -837,8 +836,4 @@
 
     fits_create_img(fits->p_fd, bitPix, naxis, naxes, &status);
-
-    if (extname != NULL) {
-        fits_update_key_str(fits->p_fd, "EXTNAME", (char*)extname, NULL, &status);
-    }
 
     if (bZero != 0) {        // set the bscale/bzero
@@ -1453,6 +1448,5 @@
 bool psFitsWriteTable(const psFits* fits,
                       psMetadata* header,
-                      psArray* table,
-                      char* extname)
+                      psArray* table)
 {
     int status = 0;
@@ -1524,4 +1518,13 @@
         }
         columnTypes->data[n] = fitsType;
+    }
+
+    psBool mStatus = false;
+    char* extname = psMetadataLookupPtr(&mStatus, header, "EXTNAME");
+    if ( ! mStatus) {
+        extname = psMetadataLookupPtr(&mStatus, header, "HDUNAME");
+        if (! mStatus) {
+            extname = NULL;
+        }
     }
 
Index: /trunk/psLib/src/fits/psFits.h
===================================================================
--- /trunk/psLib/src/fits/psFits.h	(revision 4190)
+++ /trunk/psLib/src/fits/psFits.h	(revision 4191)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-09 19:26:48 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-09 19:40:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -178,6 +178,5 @@
     const psMetadata* header,          ///< header items for the new HDU.  Can be NULL.
     const psImage* input,              ///< the image to output
-    int depth,                         ///< the number of z-planes of the FITS image data cube
-    char* extname                      ///< extension name
+    int depth                          ///< the number of z-planes of the FITS image data cube
 );
 
@@ -248,7 +247,6 @@
     const psFits* fits,                ///< the psFits object
     psMetadata* header,                ///< header items for the new HDU.  Can be NULL.
-    psArray* table,
+    psArray* table
     ///< Array of psMetadata items, which contains the output data items of each row.
-    char* extname                      ///< extension name
 );
 
Index: /trunk/psLib/test/dataIO/tst_psFits.c
===================================================================
--- /trunk/psLib/test/dataIO/tst_psFits.c	(revision 4190)
+++ /trunk/psLib/test/dataIO/tst_psFits.c	(revision 4191)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-06-08 21:07:59 $
+*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-06-09 19:40:51 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -122,7 +122,12 @@
                       extname);
 
+        psMetadataAdd(header,PS_LIST_TAIL, "MYSTR",
+                      PS_META_STR,
+                      "Extension Name",
+                      extname);
+
         // set the pixels in the image
         psBinaryOp(image,image,"=",psScalarAlloc(lcv,PS_TYPE_F32));
-        if (! psFitsWriteImage(fitsFile,header,image,1, extname) ) {
+        if (! psFitsWriteImage(fitsFile,header,image,1) ) {
             psError(PS_ERR_UNKNOWN, false,
                     "Could not write image.");
@@ -155,5 +160,5 @@
     psImage* image = psImageAlloc(16,16,PS_TYPE_F32);
 
-    if (! psFitsWriteImage(fitsFile,NULL,image,1,"primary") ) {
+    if (! psFitsWriteImage(fitsFile,NULL,image,1) ) {
         psError(PS_ERR_UNKNOWN, false,
                 "Could not write PHU image.");
@@ -192,5 +197,5 @@
     }
 
-    psFitsWriteTable(fitsFile, NULL, table, "table-1");
+    psFitsWriteTable(fitsFile, NULL, table);
 
     psFree(table);
@@ -1275,5 +1280,5 @@
         psFits* fits = psFitsAlloc(filename); \
         psRegion region = {0,0,0,0}; \
-        if (! psFitsWriteImage(fits, NULL, img, 2, "primary")) { \
+        if (! psFitsWriteImage(fits, NULL, img, 2)) { \
             psError(PS_ERR_UNKNOWN, true,"Failed to write test image %s",filename); \
             return 1; \
@@ -1283,5 +1288,5 @@
             return 2; \
         } \
-        if (! psFitsWriteImage(fits,NULL, img3, 2, "extension")) { \
+        if (! psFitsWriteImage(fits,NULL, img3, 2)) { \
             psError(PS_ERR_UNKNOWN, true,"Failed to write test image %s",filename); \
             return 3; \
@@ -1441,5 +1446,5 @@
     psFits* fits = psFitsAlloc("tmpImages/writeTest.fits");
 
-    if (! psFitsWriteImage(fits, NULL, img,1,NULL)) {
+    if (! psFitsWriteImage(fits, NULL, img,1)) {
         psError(PS_ERR_UNKNOWN, true,"Couldn't write writeTest.fits.");
         return 14;
@@ -1478,5 +1483,5 @@
     */
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message because input image is null.");
-    if ( psFitsWriteImage(fits,NULL,NULL, 1, NULL) ) {
+    if ( psFitsWriteImage(fits,NULL,NULL, 1) ) {
         psError(PS_ERR_UNKNOWN, true,"psImageWriteSection did not return false when input image is NULL.");
         return 20;
Index: /trunk/psLib/test/image/tst_psImageGeomManip.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageGeomManip.c	(revision 4190)
+++ /trunk/psLib/test/image/tst_psImageGeomManip.c	(revision 4191)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-07 02:29:44 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-09 19:40:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -559,10 +559,8 @@
     }
 
-    char hduName[80];
     psRegion regionAll = psRegionSet(0,0,0,0);
     for (psS32 rot=-180;rot<=180;rot+=45) {
         psImage* oldOut = fOut;
         psImage* oldBiOut = fBiOut;
-        snprintf(hduName, 80, "%+d", rot);
         if (rot == 90) {
             radianRot = M_PI_2;
@@ -590,17 +588,17 @@
         sBiOut = psImageRotate(sBiOut,sImg,radianRot,-1.0,PS_INTERPOLATE_BILINEAR);
 
-        if (! psFitsWriteImage(fOutFile, NULL, fOut, 1, hduName) ) {
+        if (! psFitsWriteImage(fOutFile, NULL, fOut, 1) ) {
             psError(PS_ERR_UNKNOWN, true,"Can not write fOut.");
             return 20;
         }
-        if (! psFitsWriteImage(sOutFile, NULL, sOut, 1, hduName) ) {
+        if (! psFitsWriteImage(sOutFile, NULL, sOut, 1) ) {
             psError(PS_ERR_UNKNOWN, true,"Can not write sOut.");
             return 21;
         }
-        if (! psFitsWriteImage(fBiOutFile, NULL, fBiOut, 1, hduName) ) {
+        if (! psFitsWriteImage(fBiOutFile, NULL, fBiOut, 1) ) {
             psError(PS_ERR_UNKNOWN, true,"Can not write fBiOut.fits.");
             return 40;
         }
-        if (! psFitsWriteImage(sBiOutFile, NULL, sBiOut, 1, hduName) ) {
+        if (! psFitsWriteImage(sBiOutFile, NULL, sBiOut, 1) ) {
             psError(PS_ERR_UNKNOWN, true,"Can not write sBiOut.fits.");
             return 41;
