Index: trunk/psModules/src/camera/pmFPA.h
===================================================================
--- trunk/psModules/src/camera/pmFPA.h	(revision 14636)
+++ trunk/psModules/src/camera/pmFPA.h	(revision 14647)
@@ -6,6 +6,6 @@
  * @author Eugene Magnier, IfA
  *
- * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-07-14 03:17:18 $
+ * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-08-23 23:42:41 $
  * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -18,4 +18,20 @@
 
 #define FPA_ASTROM 1                    ///< Include astrometry information in the structures?
+
+// Return chip position, given FPA position; calculations are all done in pixel units
+#define PM_FPA_TO_CHIP(pos, chip0, chipParity) \
+    (((pos) - (chip0))*(chipParity))
+
+// Return cell position, given chip position; calculations are all done in pixel units
+#define PM_CHIP_TO_CELL(pos, cell0, cellParity, binning) \
+    (((pos) - (cell0))*(cellParity)/(binning))
+
+// Return chip position, given a cell position; calculations are all done in pixel units
+#define PM_CELL_TO_CHIP(pos, cell0, cellParity, binning) \
+    ((pos)*(binning)*(cellParity) + (cell0))
+
+// Return FPA position, given a chip position; calculations are all done in pixel units
+#define PM_CHIP_TO_FPA(pos, chip0, chipParity) \
+    ((pos)*(chipParity) + (chip0))
 
 /// Focal plane array (the entirety of the camera)
Index: trunk/psModules/src/camera/pmFPAfile.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfile.c	(revision 14636)
+++ trunk/psModules/src/camera/pmFPAfile.c	(revision 14647)
@@ -32,4 +32,5 @@
     psFree (file->camera);
     psFree (file->format);
+    psFree (file->formatName);
     psFree (file->name);
 
@@ -73,4 +74,5 @@
     file->camera = NULL;
     file->format = NULL;
+    file->formatName = NULL;
     file->name = NULL;
 
Index: trunk/psModules/src/camera/pmFPAfile.h
===================================================================
--- trunk/psModules/src/camera/pmFPAfile.h	(revision 14636)
+++ trunk/psModules/src/camera/pmFPAfile.h	(revision 14647)
@@ -4,6 +4,6 @@
  * @author EAM, IfA
  *
- * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-07-14 03:17:44 $
+ * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-08-23 23:42:41 $
  * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
  */
@@ -91,4 +91,5 @@
     psMetadata *camera;                 // Camera configuration
     psMetadata *format;                 // Camera format
+    char *formatName;                   // name of the camera format
 }
 pmFPAfile;
Index: trunk/psModules/src/camera/pmFPAfileDefine.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfileDefine.c	(revision 14636)
+++ trunk/psModules/src/camera/pmFPAfileDefine.c	(revision 14647)
@@ -203,4 +203,5 @@
     }
     file->format = psMemIncrRefCounter(format);
+    file->formatName = psStringCopy(formatName);
 
     if (fpa) {
@@ -351,4 +352,5 @@
     psFree (format);
     file->format = psMemIncrRefCounter(format);
+    file->formatName = psStringCopy(config->formatName);
 
     // adjust the rules to identify these files in the file->names data
@@ -440,5 +442,5 @@
 // save the pmFPAfile on config->files
 // return the pmFPAfile (a view to the one saved on config->files)
-pmFPAfile *pmFPAfileBindFromArgs (bool *success, pmFPAfile *input, const pmConfig *config, const char *filename, const char *argname)
+pmFPAfile *pmFPAfileBindFromArgs (bool *success, pmFPAfile *input, pmConfig *config, const char *filename, const char *argname)
 {
     PS_ASSERT_PTR_NON_NULL(input, NULL);
@@ -511,5 +513,5 @@
 
         if (!format) {
-            format = pmConfigCameraFormatFromHeader((pmConfig*)config, phu, true);
+            format = pmConfigCameraFormatFromHeader(config, phu, true);
             if (!format) {
                 psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", realName);
@@ -562,4 +564,5 @@
     psFree(file->format);
     file->format = format;
+    file->formatName = psStringCopy(config->formatName);
 
     if (success) *success = true;
@@ -639,4 +642,5 @@
     psFree (file->format);
     file->format = format;
+    file->formatName = psStringCopy(config->formatName);
 
     // adjust the rules to identify these files in the file->names data
@@ -925,5 +929,5 @@
     pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename);
     if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
         return NULL;
     }
@@ -944,9 +948,9 @@
     pmFPAfile *file = pmFPAfileDefineOutput (config, NULL, filename);
     if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
         return NULL;
     }
     if (!file->camera) {
-        psErrorStackPrint(stderr, "file %s does not define a new camera\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s does not define a new camera\n", filename);
         return NULL;
     }
@@ -987,5 +991,5 @@
     }
     if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
         return NULL;
     }
@@ -1030,5 +1034,5 @@
     }
     if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
         return NULL;
     }
@@ -1075,5 +1079,5 @@
     }
     if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
+        psError(PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);
         return NULL;
     }
Index: trunk/psModules/src/camera/pmFPAfileDefine.h
===================================================================
--- trunk/psModules/src/camera/pmFPAfileDefine.h	(revision 14636)
+++ trunk/psModules/src/camera/pmFPAfileDefine.h	(revision 14647)
@@ -4,6 +4,6 @@
  * @author EAM, IfA
  *
- * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-06-21 22:45:27 $
+ * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-08-23 23:42:41 $
  * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
  */
@@ -49,5 +49,5 @@
 // Note that the returned pmFPAfile is a view only, so it should not be freed by the caller --- the only
 // reference count is held by the config->files metadata.
-pmFPAfile *pmFPAfileBindFromArgs (bool *found, pmFPAfile *input, const pmConfig *config, const char *filename, const char *argname);
+pmFPAfile *pmFPAfileBindFromArgs (bool *found, pmFPAfile *input, pmConfig *config, const char *filename, const char *argname);
 
 // look for the given argname on the argument list.  find the give filename from the file rules
Index: trunk/psModules/src/camera/pmFPAfileIO.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfileIO.c	(revision 14636)
+++ trunk/psModules/src/camera/pmFPAfileIO.c	(revision 14647)
@@ -26,10 +26,10 @@
 #include "pmMoments.h"
 #include "pmResiduals.h"
+#include "pmGrowthCurve.h"
+#include "pmPSF.h"
 #include "pmModel.h"
 #include "pmSource.h"
 #include "pmSourceIO.h"
-#include "pmGrowthCurve.h"
 #include "pmResiduals.h"
-#include "pmPSF.h"
 #include "pmPSF_IO.h"
 #include "pmFPA_JPEG.h"
@@ -188,5 +188,5 @@
         break;
       case PM_FPA_FILE_PSF:
-        status = pmFPAviewReadPSFmodel (view, file, config);
+        status = pmPSFmodelReadForView (view, file, config);
         break;
       case PM_FPA_FILE_JPEG:
@@ -335,5 +335,5 @@
     // (existing) fpa
     if (file->type == PM_FPA_FILE_PSF) {
-      if (!pmFPAviewCheckDataStatusForPSFmodel (view, file)) {
+      if (!pmPSFmodelCheckDataStatusForView (view, file)) {
         psTrace("psModules.camera", 6, "skip write for %s, no data for this entry", file->name);
         return true;
@@ -402,5 +402,5 @@
 
       case PM_FPA_FILE_PSF:
-        status = pmFPAviewWritePSFmodel (view, file, config);
+        status = pmPSFmodelWriteForView (view, file, config);
         break;
 
@@ -757,4 +757,6 @@
             return false;
         }
+	file->formatName = psStringCopy(config->formatName);
+
     } else {
         bool valid;
@@ -798,5 +800,5 @@
 	break;
       case PM_FPA_FILE_PSF:
-	status = pmPSF_WritePHU (view, file, config);
+	status = pmPSFmodelWritePHU (view, file, config);
 	break;
       case PM_FPA_FILE_SX:
