Index: trunk/psModules/src/objects/pmPSF_IO.c
===================================================================
--- trunk/psModules/src/objects/pmPSF_IO.c	(revision 13034)
+++ trunk/psModules/src/objects/pmPSF_IO.c	(revision 13191)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-04-26 01:20:29 $
+ *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-05-03 20:04:18 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,4 +43,83 @@
 #include "pmModelGroup.h"
 #include "pmSourceIO.h"
+
+bool pmFPAviewCheckDataStatusForPSFmodel (const pmFPAview *view, const pmFPAfile *file)
+{
+    pmFPA *fpa = file->fpa;
+
+    if (view->chip == -1) {
+	bool exists = pmFPACheckDataStatusForPSFmodel (fpa);
+        return exists;
+    }
+    if (view->chip >= fpa->chips->n) {
+	psError(PS_ERR_IO, true, "Requested chip == %d >= fpa->chips->n == %ld", view->chip, fpa->chips->n);
+        return false;
+    }
+    pmChip *chip = fpa->chips->data[view->chip];
+
+    if (view->cell == -1) {
+        bool exists = pmChipCheckDataStatusForPSFmodel (chip);
+        return exists;
+    }
+    if (view->cell >= chip->cells->n) {
+	psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %ld", view->cell, chip->cells->n);
+        return false;
+    }
+    pmCell *cell = chip->cells->data[view->cell];
+
+    if (view->readout == -1) {
+        bool exists = pmCellCheckDataStatusForPSFmodel (cell);
+        return exists;
+    }
+
+    if (view->readout >= cell->readouts->n) {
+	psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouds->n == %ld", view->readout, cell->readouts->n);
+        return false;
+    }
+    pmReadout *readout = cell->readouts->data[view->readout];
+
+    bool exists = pmReadoutCheckDataStatusForPSFmodel (readout);
+    return exists;
+}
+
+bool pmFPACheckDataStatusForPSFmodel (const pmFPA *fpa) {
+
+    for (int i = 0; i < fpa->chips->n; i++) {
+	pmChip *chip = fpa->chips->data[i];
+	if (!chip) continue;
+	if (pmChipCheckDataStatusForPSFmodel (chip)) return true;
+    }
+    return false;
+}
+
+bool pmChipCheckDataStatusForPSFmodel (const pmChip *chip) {
+
+    for (int i = 0; i < chip->cells->n; i++) {
+	pmCell *cell = chip->cells->data[i];
+	if (!cell) continue;
+	if (pmCellCheckDataStatusForPSFmodel (cell)) return true;
+    }
+    return false;
+}
+
+bool pmCellCheckDataStatusForPSFmodel (const pmCell *cell) {
+
+    for (int i = 0; i < cell->readouts->n; i++) {
+	pmReadout *readout = cell->readouts->data[i];
+	if (!readout) continue;
+	if (pmReadoutCheckDataStatusForPSFmodel (readout)) return true;
+    }
+    return false;
+}
+
+bool pmReadoutCheckDataStatusForPSFmodel (const pmReadout *readout) {
+
+    bool status;
+
+    // select the psf of interest
+    pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
+    if (!psf) return false;
+    return true;
+}
 
 bool pmFPAviewWritePSFmodel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
@@ -618,5 +697,5 @@
 
     switch (file->type) {
-    case PM_FPA_FILE_PSF:
+      case PM_FPA_FILE_PSF:
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
         bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
@@ -630,5 +709,5 @@
         return true;
 
-    default:
+      default:
         fprintf (stderr, "warning: type mismatch\n");
         break;
@@ -646,5 +725,5 @@
 
     switch (file->type) {
-    case PM_FPA_FILE_PSF:
+      case PM_FPA_FILE_PSF:
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
         bool create = file->mode == PM_FPA_MODE_WRITE ? true : false;
@@ -662,5 +741,5 @@
         return true;
 
-    default:
+      default:
         fprintf (stderr, "warning: type mismatch\n");
         break;
