Index: /trunk/ppTranslate/src/ppMopsWrite.c
===================================================================
--- /trunk/ppTranslate/src/ppMopsWrite.c	(revision 34438)
+++ /trunk/ppTranslate/src/ppMopsWrite.c	(revision 34439)
@@ -45,8 +45,8 @@
     if (detections->data[d] != NULL) {
       if (det == NULL) {
-	det = detections->data[d];
-      }
-      if (isfinite(detections->data[d]->seeing)) {
-	validSeeingCount += 1;
+        det = detections->data[d];
+      }
+      if (isfinite(((ppMopsDetections*) detections->data[d])->seeing)) {
+        validSeeingCount += 1;
       }
     }
@@ -54,10 +54,10 @@
   if (det != NULL) {
     //Get the SEEING median
-    seeingValues = psVectorAlloc(validSeeingCount, PS_TYPE_F32);
-    psVectorInit(validSeeingCount, NAN);
+    psVector* seeingValues = psVectorAlloc(validSeeingCount, PS_TYPE_F32);
+    psVectorInit(seeingValues, NAN);
     validSeeingCount = 0;
     for (int d = 0; d < detections->n; d++) {
-      if ( (detections->data[d] != NULL) && (isfinite(detections->data[d]->seeing)) ){
-	seeingValues->data.F32[validSeeingCount++] = detections->data[d]->seeing;
+      if ( (detections->data[d] != NULL) && (isfinite(((ppMopsDetections*) detections->data[d])->seeing)) ){
+        seeingValues->data.F32[validSeeingCount++] = ((ppMopsDetections*) detections->data[d])->seeing;
       }
     }
@@ -133,59 +133,59 @@
       // Write data of version 2 (see ICD)
       psMetadataAdd (row, PS_LIST_TAIL, "IPP_IDET",         PS_DATA_U32, "IPP detection identifier index",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX",    PS_DATA_F32, "PSF fit instrumental magnitude",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental magnitude",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG",           PS_DATA_F32, "magnitude in standard aperture",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RAW",       PS_DATA_F32, "magnitude in real aperture",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS",    PS_DATA_F32, "radius used for aperture mags",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX",          PS_DATA_F32, "instrumental flux in standard aperture",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX_SIG",      PS_DATA_F32, "aperture flux error",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG",      PS_DATA_F32, "PSF Magnitude using supplied calibration",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG_SIG",  PS_DATA_F32, "measured scatter of zero point calibration",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "SKY",              PS_DATA_F32, "Sky level",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "SKY_SIGMA",        PS_DATA_F32, "Sigma of sky level",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF_PERFECT",   PS_DATA_F32, "PSF coverage/quality factor (poor)",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_R1",       PS_DATA_F32, "first radial moment",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_RH",       PS_DATA_F32, "half radial moment",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX",        PS_DATA_F32, "Kron Flux (in 2.5 R1)",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_ERR",    PS_DATA_F32, "Kron Flux Error",
-		     NAN);
-      psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER",  PS_DATA_F32, "Kron Flux (in 1.0 R1)", 
-		     NAN);
+                     NAN);
+      psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER",  PS_DATA_F32, "Kron Flux (in 1.0 R1)",
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_OUTER",  PS_DATA_F32, "Kron Flux (in 4.0 R1)",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "DIFF_R_P",         PS_DATA_F32, "distance to positive match source",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_P",        PS_DATA_F32, "signal-to-noise of pos match src",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "DIFF_R_M",         PS_DATA_F32, "distance to negative match source",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_M",        PS_DATA_F32, "signal-to-noise of neg match src",
-		     NAN);
+                     NAN);
       psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2",           PS_DATA_U32, "psphot analysis flags (group 2)",
-		     0);
-      psMetadataAdd (row, PS_LIST_TAIL, "N_FRAMES",         PS_DATA_U16, "Number of frames overlapping source center", 
-		     0);
-      psMetadataAdd (row, PS_LIST_TAIL, "PADDING",          PS_DATA_S16, "padding", 
-		     0);
+                     0);
+      psMetadataAdd (row, PS_LIST_TAIL, "N_FRAMES",         PS_DATA_U16, "Number of frames overlapping source center",
+                     0);
+      psMetadataAdd (row, PS_LIST_TAIL, "PADDING",          PS_DATA_S16, "padding",
+                     0);
       if (args->version == 3) {
-	// TODO: Write data of version 3 (see ICD)
+        // TODO: Write data of version 3 (see ICD)
       }
     }
@@ -200,8 +200,8 @@
   } else {
 
-#define addColumn(_outName, _inName, _convertTo32)			\
+#define addColumn(_outName, _inName, _convertTo32)                      \
     if (!addOutputColumn(table, detections, total, _outName, _inName, _convertTo32)) { \
       psError(PS_ERR_UNKNOWN, false, "Failed to add column %s", _outName); \
-      return false;							\
+      return false;                                                     \
     }
 
@@ -219,8 +219,8 @@
     addColumn("EXT_SIGNIFICANCE", "EXT_NSIGMA", 0);
     addColumn("PSF_MAJOR", NULL, 0);
-    addColumn("PSF_MINOR", NULL, 0);     
-    addColumn("PSF_THETA", NULL, 0);    
-    addColumn("PSF_QUALITY", "PSF_QF", 0); 
-    addColumn("PSF_NPIX", NULL, 1);        
+    addColumn("PSF_MINOR", NULL, 0);
+    addColumn("PSF_THETA", NULL, 0);
+    addColumn("PSF_QUALITY", "PSF_QF", 0);
+    addColumn("PSF_NPIX", NULL, 1);
     addColumn("MOMENTS_XX", NULL, 0);
     addColumn("MOMENTS_XY", NULL, 0);
@@ -308,32 +308,32 @@
       ppMopsDetections *det = detections->data[i];
       if (!det || det->num == 0) {
-	// no detections survived for this input
-	continue;
+        // no detections survived for this input
+        continue;
       }
       psVector *in = NULL;
       in = psMetadataLookupVector(NULL, det->table, inColumnName);
       if (!in) {
-	psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is true)", inColumnName);
-	return false;
+        psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is true)", inColumnName);
+        return false;
       }
       if (in->type.type != PS_TYPE_S64 && in->type.type != PS_TYPE_U64) {
-	psError(PS_ERR_PROGRAMMING, true, "input column to convert is not S64 or U64: %s %d",
-		inColumnName, in->type.type);
-	return false;
+        psError(PS_ERR_PROGRAMMING, true, "input column to convert is not S64 or U64: %s %d",
+                inColumnName, in->type.type);
+        return false;
       }
       if (out == NULL) {
-	// First time through set up the output vector and the copy parameters
-	if (in->type.type == PS_TYPE_S64) {
-	  out = psVectorAlloc(outputSize, PS_TYPE_S32);
-	} else {
-	  out = psVectorAlloc(outputSize, PS_TYPE_U32);
-	}
+        // First time through set up the output vector and the copy parameters
+        if (in->type.type == PS_TYPE_S64) {
+          out = psVectorAlloc(outputSize, PS_TYPE_S32);
+        } else {
+          out = psVectorAlloc(outputSize, PS_TYPE_U32);
+        }
       }
       for (long d=0; d < det->num; d++) {
-	if (in->type.type == PS_TYPE_S64) {
-	  out->data.S32[next++] = in->data.S64[d];
-	} else {
-	  out->data.U32[next++] = in->data.U64[d];
-	}
+        if (in->type.type == PS_TYPE_S64) {
+          out->data.S32[next++] = in->data.S64[d];
+        } else {
+          out->data.U32[next++] = in->data.U64[d];
+        }
       }
     }
@@ -344,57 +344,57 @@
       ppMopsDetections *det = detections->data[i];
       if (!det || det->num == 0) {
-	// no detections survived for this input
-	continue;
+        // no detections survived for this input
+        continue;
       }
       psVector *in = NULL;
       in = psMetadataLookupVector(NULL, det->table, inColumnName);
       if (!in) {
-	psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is false)", inColumnName);
-	out = psVectorAlloc(outputSize, PS_TYPE_F32);
-	psVectorInit(out, NAN);
-	psMetadataAddVector(table, PS_LIST_TAIL, outColumnName, 0, NULL, out);
-	return false;
+        psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is false)", inColumnName);
+        out = psVectorAlloc(outputSize, PS_TYPE_F32);
+        psVectorInit(out, NAN);
+        psMetadataAddVector(table, PS_LIST_TAIL, outColumnName, 0, NULL, out);
+        return false;
       }
       if (out == NULL) {
-	// First time through set up the output vector and the copy parameters
-	out = psVectorAlloc(outputSize, in->type.type);
-	next = (void *) out->data.U8;
-	switch (in->type.type) {
-	case PS_TYPE_S8:
-	  elementSize = sizeof(psS8);
-	  break;
-	case PS_TYPE_U8:
-	  elementSize = sizeof(psU8);
-	  break;
-	case PS_TYPE_S16:
-	  elementSize = sizeof(psS16);
-	  break;
-	case PS_TYPE_U16:
-	  elementSize = sizeof(psU16);
-	  break;
-	case PS_TYPE_S32:
-	  elementSize = sizeof(psS32);
-	  break;
-	case PS_TYPE_U32:
-	  elementSize = sizeof(psU32);
-	  break;
-	case PS_TYPE_S64:
-	  elementSize = sizeof(psS64);
-	  break;
-	case PS_TYPE_U64:
-	  elementSize = sizeof(psU64);
-	  break;
-	case PS_TYPE_F32:
-	  elementSize = sizeof(psF32);
-	  break;
-	case PS_TYPE_F64:
-	  elementSize = sizeof(psF64);
-	  break;
-	default:
-	  psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unknown vector type %d", in->type.type);
-	  return false;
-	}
-      }
-      // We are doing nasty things here so we can use memcpy. 
+        // First time through set up the output vector and the copy parameters
+        out = psVectorAlloc(outputSize, in->type.type);
+        next = (void *) out->data.U8;
+        switch (in->type.type) {
+        case PS_TYPE_S8:
+          elementSize = sizeof(psS8);
+          break;
+        case PS_TYPE_U8:
+          elementSize = sizeof(psU8);
+          break;
+        case PS_TYPE_S16:
+          elementSize = sizeof(psS16);
+          break;
+        case PS_TYPE_U16:
+          elementSize = sizeof(psU16);
+          break;
+        case PS_TYPE_S32:
+          elementSize = sizeof(psS32);
+          break;
+        case PS_TYPE_U32:
+          elementSize = sizeof(psU32);
+          break;
+        case PS_TYPE_S64:
+          elementSize = sizeof(psS64);
+          break;
+        case PS_TYPE_U64:
+          elementSize = sizeof(psU64);
+          break;
+        case PS_TYPE_F32:
+          elementSize = sizeof(psF32);
+          break;
+        case PS_TYPE_F64:
+          elementSize = sizeof(psF64);
+          break;
+        default:
+          psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unknown vector type %d", in->type.type);
+          return false;
+        }
+      }
+      // We are doing nasty things here so we can use memcpy.
       // It would be safer to do a proper loop over the elements.
       long toCopy = det->num * elementSize;
