Index: /trunk/psModules/src/concepts/pmConceptsStandard.c
===================================================================
--- /trunk/psModules/src/concepts/pmConceptsStandard.c	(revision 13741)
+++ /trunk/psModules/src/concepts/pmConceptsStandard.c	(revision 13742)
@@ -49,10 +49,10 @@
 // FPA.FILTER
 psMetadataItem *p_pmConceptParse_FPA_FILTER(const psMetadataItem *concept,
-        const psMetadataItem *pattern,
+					    const psMetadataItem *pattern,
                                             pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					    const psMetadata *cameraFormat,
+					    const pmFPA *fpa,
+					    const pmChip *chip,
+					    const pmCell *cell)
 {
     assert(concept);
@@ -86,9 +86,9 @@
 
 psMetadataItem *p_pmConceptFormat_FPA_FILTER(const psMetadataItem *concept,
-                                            pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					     pmConceptSource source,
+					     const psMetadata *cameraFormat,
+					     const pmFPA *fpa,
+					     const pmChip *chip,
+					     const pmCell *cell)
 {
     assert(concept);
@@ -137,10 +137,10 @@
 // FPA.RA and FPA.DEC
 psMetadataItem *p_pmConceptParse_FPA_Coords(const psMetadataItem *concept,
-        const psMetadataItem *pattern,
+					    const psMetadataItem *pattern,
                                             pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					    const psMetadata *cameraFormat,
+					    const pmFPA *fpa,
+					    const pmChip *chip,
+					    const pmCell *cell)
 {
     assert(concept);
@@ -150,11 +150,11 @@
     double coords = NAN;                // The coordinates
     switch (concept->type) {
-    case PS_TYPE_F32:
+      case PS_TYPE_F32:
         coords = concept->data.F32;
         break;
-    case PS_TYPE_F64:
+      case PS_TYPE_F64:
         coords = concept->data.F64;
         break;
-    case PS_DATA_STRING:
+      case PS_DATA_STRING:
         // Sexagesimal format
         {
@@ -163,5 +163,5 @@
             // XXX: Upgrade path is to allow dd:mm.mmm
             if (sscanf(concept->data.V, "%d:%d:%f", &big, &medium, &small) != 3 &&
-                    sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3)
+		sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3)
             {
                 psError(PS_ERR_UNKNOWN, true, "Cannot interpret %s: %s\n", pattern->name, concept->data.str);
@@ -175,5 +175,5 @@
         }
         break;
-    default:
+      default:
         psError(PS_ERR_UNKNOWN, true, "%s concept is of an unexpected type: %x\n",
                 pattern->name, concept->type);
@@ -208,9 +208,9 @@
 // FPA.RA and FPA.DEC
 psMetadataItem *p_pmConceptFormat_FPA_Coords(const psMetadataItem *concept,
-                                            pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					     pmConceptSource source,
+					     const psMetadata *cameraFormat,
+					     const pmFPA *fpa,
+					     const pmChip *chip,
+					     const pmCell *cell)
 {
     assert(concept);
@@ -226,6 +226,6 @@
     bool mdok = true;                   // Status of MD lookup
     psMetadata *formats = psMetadataLookupMetadata(&mdok,
-                          cameraFormat,
-                          "FORMATS");
+						   cameraFormat,
+						   "FORMATS");
     if (mdok && formats) {
         psString format = psMetadataLookupStr(&mdok,formats, concept->name);
@@ -270,10 +270,10 @@
 
 psMetadataItem *p_pmConceptParse_CELL_TRIMSEC(const psMetadataItem *concept,
-        const psMetadataItem *pattern,
-                                            pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					      const psMetadataItem *pattern,
+					      pmConceptSource source,
+					      const psMetadata *cameraFormat,
+					      const pmFPA *fpa,
+					      const pmChip *chip,
+					      const pmCell *cell)
 {
     assert(concept);
@@ -281,4 +281,6 @@
     assert(pattern);
 
+    int xParity = 0;
+    int yParity = 0;
     psRegion *trimsec = psRegionAlloc(0, 0, 0, 0);
 
@@ -288,5 +290,6 @@
         return NULL;
     } else {
-        *trimsec = psRegionFromString(concept->data.V);
+	// allow for x and y flips in regions
+        *trimsec = psRegionAndParityFromString(&xParity, &yParity, concept->data.V);
     }
 
@@ -304,10 +307,10 @@
 
 psMetadataItem *p_pmConceptParse_CELL_BIASSEC(const psMetadataItem *concept,
-        const psMetadataItem *pattern,
-                                            pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					      const psMetadataItem *pattern,
+					      pmConceptSource source,
+					      const psMetadata *cameraFormat,
+					      const pmFPA *fpa,
+					      const pmChip *chip,
+					      const pmCell *cell)
 {
     assert(concept);
@@ -321,4 +324,6 @@
 	  // a single BIASSEC is of the form [AAAA]
 	  // we may have multiple BIASSEC entries separated by space, commas, or semicolons
+	  int xParity = 0;
+	  int yParity = 0;
 	  char *p = strchr (concept->data.V, '[');
 	  while (p != NULL) {
@@ -330,5 +335,5 @@
 	  
 	      psRegion *region = psAlloc(sizeof(psRegion)); // The region
-	      *region = psRegionFromString(regionString);
+	      *region = psRegionAndParityFromString(&xParity, &yParity, regionString);
 	      psListAdd(biassecs, PS_LIST_TAIL, region);
 	      psFree(region);           // Drop reference
@@ -340,21 +345,23 @@
       }
       case PS_DATA_LIST: {
-            psList *regions = concept->data.V; // The list of regions
-            psListIterator *regionsIter = psListIteratorAlloc(regions, PS_LIST_HEAD, false); // Iterator
-            psMetadataItem *regionItem = NULL; // Item from list iteration
-            while ((regionItem = psListGetAndIncrement(regionsIter))) {
-                if (regionItem->type != PS_DATA_STRING) {
-                    psWarning("CELL.BIASSEC member is not of type STR --- ignored.\n");
-                    continue;
-                }
-                psRegion *region = psAlloc(sizeof(psRegion)); // The region
-                *region = psRegionFromString(regionItem->data.V);
-                psListAdd(biassecs, PS_LIST_TAIL, region);
-                psFree(region);           // Drop reference
-            }
-            psFree(regionsIter);
-            break;
-        }
-    default:
+	  psList *regions = concept->data.V; // The list of regions
+	  psListIterator *regionsIter = psListIteratorAlloc(regions, PS_LIST_HEAD, false); // Iterator
+	  psMetadataItem *regionItem = NULL; // Item from list iteration
+	  while ((regionItem = psListGetAndIncrement(regionsIter))) {
+	      if (regionItem->type != PS_DATA_STRING) {
+		  psWarning("CELL.BIASSEC member is not of type STR --- ignored.\n");
+		  continue;
+	      }
+	      int xParity = 0;
+	      int yParity = 0;
+	      psRegion *region = psAlloc(sizeof(psRegion)); // The region
+	      *region = psRegionAndParityFromString(&xParity, &yParity, regionItem->data.V);
+	      psListAdd(biassecs, PS_LIST_TAIL, region);
+	      psFree(region);           // Drop reference
+	  }
+	  psFree(regionsIter);
+	  break;
+      }
+      default:
         psError(PS_ERR_UNKNOWN, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming "
                 "blank.\n");
@@ -375,10 +382,10 @@
 // CELL.XBIN and CELL.YBIN
 psMetadataItem *p_pmConceptParse_CELL_Binning(const psMetadataItem *concept,
-        const psMetadataItem *pattern,
-                                            pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					      const psMetadataItem *pattern,
+					      pmConceptSource source,
+					      const psMetadata *cameraFormat,
+					      const pmFPA *fpa,
+					      const pmChip *chip,
+					      const pmCell *cell)
 {
     assert(concept);
@@ -387,14 +394,14 @@
     int binning = 1;                    // Binning factor in x
     switch (concept->type) {
-    case PS_DATA_STRING: {
-            psString binString = concept->data.V; // The string containing the binning
-            if ((strcmp(pattern->name, "CELL.XBIN") == 0 && sscanf(binString, "%d %*d", &binning) != 1 &&
-                    sscanf(binString, "%d,%*d", &binning) != 1) ||
-                    (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
-                     sscanf(binString, "%*d,%d", &binning) != 1)) {
-                psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
-            }
-            break;
-        }
+      case PS_DATA_STRING: {
+	  psString binString = concept->data.V; // The string containing the binning
+	  if ((strcmp(pattern->name, "CELL.XBIN") == 0 && sscanf(binString, "%d %*d", &binning) != 1 &&
+	       sscanf(binString, "%d,%*d", &binning) != 1) ||
+	      (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
+	       sscanf(binString, "%*d,%d", &binning) != 1)) {
+	      psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
+	  }
+	  break;
+      }
         TYPE_CASE(binning, concept, U8);
         TYPE_CASE(binning, concept, U16);
@@ -403,5 +410,5 @@
         TYPE_CASE(binning, concept, S16);
         TYPE_CASE(binning, concept, S32);
-    default:
+      default:
         psError(PS_ERR_UNKNOWN, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
                 concept->type);
@@ -413,10 +420,10 @@
 
 psMetadataItem *p_pmConceptParse_TIMESYS(const psMetadataItem *concept,
-        const psMetadataItem *pattern,
-                                            pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					 const psMetadataItem *pattern,
+					 pmConceptSource source,
+					 const psMetadata *cameraFormat,
+					 const pmFPA *fpa,
+					 const pmChip *chip,
+					 const pmCell *cell)
 {
     assert(concept);
@@ -444,5 +451,5 @@
 psMetadataItem *p_pmConceptParse_TIME(const psMetadataItem *concept,
                                       const psMetadataItem *pattern,
-                                            pmConceptSource source,
+				      pmConceptSource source,
                                       const psMetadata *cameraFormat,
                                       const pmFPA *fpa,
@@ -469,5 +476,5 @@
     if (!mdok || (timeSys == 0xffffffff)) {
         psWarning("Unable to find %s in concepts when parsing %s --- assuming UTC.\n",
-                 timesysName, pattern->name);
+		  timesysName, pattern->name);
         timeSys = PS_TIME_UTC;
     }
@@ -548,132 +555,132 @@
     psTime *time = NULL;                // The time
     switch (concept->type) {
-    case PS_DATA_LIST: {
-            if (!separateTime) {
-                psWarning ("DATE and TIME stored separately, but not specified in format\n");
-            }
-            // The date and time are stored separately
-            // Assume the date is first and the time second
-            psList *dateTime = concept->data.V; // The list containing items for date and time
-            if (psListLength(dateTime) != 2) {
-                psError(PS_ERR_BAD_PARAMETER_SIZE, false,
-                        "Unable to parse %s: date and time are not both available.", pattern->name);
-                return NULL;
-            }
-            psMetadataItem *dateItem = psListGet(dateTime, PS_LIST_HEAD); // Item containing the date
-            if (!dateItem) {
-                psError(PS_ERR_UNKNOWN, true, "Date is not found.\n");
-                return NULL;
-            }
-            if (dateItem->type != PS_DATA_STRING) {
-                psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n");
-                return NULL;
-            }
-            psString dateString = dateItem->data.V; // The string with the date
-            int day = 0, month = 0, year = 0;
-            if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 &&
-                    sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) {
-                psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString);
-                return NULL;
-            }
-            if (backwardsTime) {
-                // Need to switch days and years
-                int temp = day;
-                day = year;
-                year = temp;
-            }
-            if (usaTime) {
-                // Need to switch everything around.... Yanks!
-                int temp = day;
-                day = month;
-                month = year;
-                year = temp;
-            }
-            if (year < 100) {
-                if (pre2000Time) {
-                    year += 1900;
-                } else {
-                    year += 2000;
-                }
-            }
-            sprintf(dateString,"%04d-%02d-%02d", year, month, day);
-
-            psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time
-            if (!timeItem) {
-                psError(PS_ERR_UNKNOWN, true, "Time is not found.\n");
-                return NULL;
-            }
-            psString timeString = NULL; // The string with the time
-            if (timeItem->type == PS_DATA_STRING) {
-                timeString = timeItem->data.V;
-            } else {
-                // Assume that time is specified in Second of Day (!)
-                double seconds = NAN;
-                switch (timeItem->type) {
-                    TYPE_CASE(seconds, timeItem, U8);
-                    TYPE_CASE(seconds, timeItem, U16);
-                    TYPE_CASE(seconds, timeItem, U32);
-                    TYPE_CASE(seconds, timeItem, S8);
-                    TYPE_CASE(seconds, timeItem, S16);
-                    TYPE_CASE(seconds, timeItem, S32);
-                    TYPE_CASE(seconds, timeItem, F32);
-                    TYPE_CASE(seconds, timeItem, F64);
+      case PS_DATA_LIST: {
+	  if (!separateTime) {
+	      psWarning ("DATE and TIME stored separately, but not specified in format\n");
+	  }
+	  // The date and time are stored separately
+	  // Assume the date is first and the time second
+	  psList *dateTime = concept->data.V; // The list containing items for date and time
+	  if (psListLength(dateTime) != 2) {
+	      psError(PS_ERR_BAD_PARAMETER_SIZE, false,
+		      "Unable to parse %s: date and time are not both available.", pattern->name);
+	      return NULL;
+	  }
+	  psMetadataItem *dateItem = psListGet(dateTime, PS_LIST_HEAD); // Item containing the date
+	  if (!dateItem) {
+	      psError(PS_ERR_UNKNOWN, true, "Date is not found.\n");
+	      return NULL;
+	  }
+	  if (dateItem->type != PS_DATA_STRING) {
+	      psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n");
+	      return NULL;
+	  }
+	  psString dateString = dateItem->data.V; // The string with the date
+	  int day = 0, month = 0, year = 0;
+	  if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 &&
+	      sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) {
+	      psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString);
+	      return NULL;
+	  }
+	  if (backwardsTime) {
+	      // Need to switch days and years
+	      int temp = day;
+	      day = year;
+	      year = temp;
+	  }
+	  if (usaTime) {
+	      // Need to switch everything around.... Yanks!
+	      int temp = day;
+	      day = month;
+	      month = year;
+	      year = temp;
+	  }
+	  if (year < 100) {
+	      if (pre2000Time) {
+		  year += 1900;
+	      } else {
+		  year += 2000;
+	      }
+	  }
+	  sprintf(dateString,"%04d-%02d-%02d", year, month, day);
+
+	  psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time
+	  if (!timeItem) {
+	      psError(PS_ERR_UNKNOWN, true, "Time is not found.\n");
+	      return NULL;
+	  }
+	  psString timeString = NULL; // The string with the time
+	  if (timeItem->type == PS_DATA_STRING) {
+	      timeString = timeItem->data.V;
+	  } else {
+	      // Assume that time is specified in Second of Day (!)
+	      double seconds = NAN;
+	      switch (timeItem->type) {
+		  TYPE_CASE(seconds, timeItem, U8);
+		  TYPE_CASE(seconds, timeItem, U16);
+		  TYPE_CASE(seconds, timeItem, U32);
+		  TYPE_CASE(seconds, timeItem, S8);
+		  TYPE_CASE(seconds, timeItem, S16);
+		  TYPE_CASE(seconds, timeItem, S32);
+		  TYPE_CASE(seconds, timeItem, F32);
+		  TYPE_CASE(seconds, timeItem, F64);
                 default:
-                    psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type);
-                    return NULL;
-                }
-                // Now print to timeString as "hh:mm:ss.ss"
-                int hours = seconds / 3600;
-                seconds -= (double)hours * 3600.0;
-                int minutes = seconds / 60;
-                seconds -= (double)minutes * 60.0;
-                psStringAppend(&timeString, "%02d:%02d:%02f", hours, minutes, seconds);
-            }
-            psString dateTimeString = NULL;
-            psStringAppend(&dateTimeString, "%sT%s", dateString, timeString);
-            time = psTimeFromISO(dateTimeString, timeSys);
-            psFree(dateTimeString);
-            break;
-        }
-    case PS_DATA_STRING: {
-            psString timeString = concept->data.V;   // String with the time
-            if (jdTime) {
-                double timeValue = strtod (timeString, NULL);
-                time = psTimeFromJD(timeValue);
-            } else if (mjdTime) {
-                double timeValue = strtod (timeString, NULL);
-                time = psTimeFromMJD(timeValue);
-            } else {
-                // It's ISO
-                time = psTimeFromISO(timeString, timeSys);
-            } // Interpreting the time string
-            break;
-        }
-    case PS_TYPE_F32: {
-            double timeValue = (double)concept->data.F32;
-            if (jdTime) {
-                time = psTimeFromJD(timeValue);
-            } else if (mjdTime) {
-                time = psTimeFromMJD(timeValue);
-            } else {
-                psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
-                        pattern->name, timeValue);
-                time = psTimeFromJD(timeValue);
-            }
-            break;
-        }
-    case PS_TYPE_F64: {
-            double timeValue = (double)concept->data.F64;
-            if (jdTime) {
-                time = psTimeFromJD(timeValue);
-            } else if (mjdTime) {
-                time = psTimeFromMJD(timeValue);
-            } else {
-                psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
-                        pattern->name, timeValue);
-                time = psTimeFromJD(timeValue);
-            }
-            break;
-        }
-    default:
+		  psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type);
+		  return NULL;
+	      }
+	      // Now print to timeString as "hh:mm:ss.ss"
+	      int hours = seconds / 3600;
+	      seconds -= (double)hours * 3600.0;
+	      int minutes = seconds / 60;
+	      seconds -= (double)minutes * 60.0;
+	      psStringAppend(&timeString, "%02d:%02d:%02f", hours, minutes, seconds);
+	  }
+	  psString dateTimeString = NULL;
+	  psStringAppend(&dateTimeString, "%sT%s", dateString, timeString);
+	  time = psTimeFromISO(dateTimeString, timeSys);
+	  psFree(dateTimeString);
+	  break;
+      }
+      case PS_DATA_STRING: {
+	  psString timeString = concept->data.V;   // String with the time
+	  if (jdTime) {
+	      double timeValue = strtod (timeString, NULL);
+	      time = psTimeFromJD(timeValue);
+	  } else if (mjdTime) {
+	      double timeValue = strtod (timeString, NULL);
+	      time = psTimeFromMJD(timeValue);
+	  } else {
+	      // It's ISO
+	      time = psTimeFromISO(timeString, timeSys);
+	  } // Interpreting the time string
+	  break;
+      }
+      case PS_TYPE_F32: {
+	  double timeValue = (double)concept->data.F32;
+	  if (jdTime) {
+	      time = psTimeFromJD(timeValue);
+	  } else if (mjdTime) {
+	      time = psTimeFromMJD(timeValue);
+	  } else {
+	      psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
+		      pattern->name, timeValue);
+	      time = psTimeFromJD(timeValue);
+	  }
+	  break;
+      }
+      case PS_TYPE_F64: {
+	  double timeValue = (double)concept->data.F64;
+	  if (jdTime) {
+	      time = psTimeFromJD(timeValue);
+	  } else if (mjdTime) {
+	      time = psTimeFromMJD(timeValue);
+	  } else {
+	      psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
+		      pattern->name, timeValue);
+	      time = psTimeFromJD(timeValue);
+	  }
+	  break;
+      }
+      default:
         psError(PS_ERR_UNKNOWN, true, "Unable to parse %s.\n", pattern->name);
         return NULL;
@@ -688,5 +695,5 @@
 static int fortranCorr(const psMetadata *cameraFormat, // The camera format description
                        const char *name // Name of concept to check for FORTRAN indexing
-                      )
+    )
 {
     bool mdok = false;                  // Result of MD lookup
@@ -702,10 +709,10 @@
 
 psMetadataItem *p_pmConceptParse_Positions(const psMetadataItem *concept,
-        const psMetadataItem *pattern,
-                                            pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					   const psMetadataItem *pattern,
+					   pmConceptSource source,
+					   const psMetadata *cameraFormat,
+					   const pmFPA *fpa,
+					   const pmChip *chip,
+					   const pmCell *cell)
 {
     assert(concept);
@@ -721,27 +728,29 @@
         TYPE_CASE(offset, concept, S16);
         TYPE_CASE(offset, concept, S32);
-        #if 0
-
-    case PS_DATA_STRING: {
-            // Interpret as a region specifier [x0:x1,y0:y1]
-            psRegion region = psRegionFromString(concept->data.V);
-            if (strstr(pattern->name, ".X0")) {
-                offset = region.x0;
-            } else if (strstr(pattern->name, ".Y0")) {
-                offset = region.y0;
-            } else if (strstr(pattern->name, ".X1")) {
-                offset = region.x1;
-            } else if (strstr(pattern->name, ".Y1")) {
-                offset = region.y1;
-            } else {
-                psError(PS_ERR_UNKNOWN, true,
-                        "Unable to interpret %s because unable to determine if concept is X or Y.\n",
-                        pattern->name);
-                return NULL;
-            }
-            break;
-        }
-        #endif
-    default:
+#if 0
+
+      case PS_DATA_STRING: {
+	  // Interpret as a region specifier [x0:x1,y0:y1]
+	  int xParity = 0;
+	  int yParity = 0;
+	  psRegion region = psRegionAndParityFromString(&xParity, &yParity, concept->data.V);
+	  if (strstr(pattern->name, ".X0")) {
+	      offset = region.x0;
+	  } else if (strstr(pattern->name, ".Y0")) {
+	      offset = region.y0;
+	  } else if (strstr(pattern->name, ".X1")) {
+	      offset = region.x1;
+	  } else if (strstr(pattern->name, ".Y1")) {
+	      offset = region.y1;
+	  } else {
+	      psError(PS_ERR_UNKNOWN, true,
+		      "Unable to interpret %s because unable to determine if concept is X or Y.\n",
+		      pattern->name);
+	      return NULL;
+	  }
+	  break;
+      }
+#endif
+      default:
         if (concept->type == PS_TYPE_F32 && concept->data.F32 - (int)concept->data.F32 == 0) {
             offset = concept->data.F32;
@@ -759,9 +768,9 @@
 
 psMetadataItem *p_pmConceptFormat_CELL_TRIMSEC(const psMetadataItem *concept,
-                                            pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					       pmConceptSource source,
+					       const psMetadata *cameraFormat,
+					       const pmFPA *fpa,
+					       const pmChip *chip,
+					       const pmCell *cell)
 {
     assert(concept);
@@ -788,5 +797,5 @@
     psFree(trimsec);
     psMetadataItem *formatted = psMetadataItemAllocStr(concept->name, concept->comment,
-                                trimsecString);
+						       trimsecString);
     psFree(trimsecString);
     return formatted;
@@ -794,9 +803,9 @@
 
 psMetadataItem *p_pmConceptFormat_CELL_BIASSEC(const psMetadataItem *concept,
-                                            pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					       pmConceptSource source,
+					       const psMetadata *cameraFormat,
+					       const pmFPA *fpa,
+					       const pmChip *chip,
+					       const pmCell *cell)
 {
     // Return a metadata item containing a list of metadata items of region strings
@@ -840,8 +849,8 @@
 psMetadataItem *p_pmConceptFormat_CELL_XBIN(const psMetadataItem *concept,
                                             pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					    const psMetadata *cameraFormat,
+					    const pmFPA *fpa,
+					    const pmChip *chip,
+					    const pmCell *cell)
 {
     assert(concept);
@@ -852,5 +861,5 @@
     psString yKeyword = psMetadataLookupStr(&yBinOK, translation, "CELL.YBIN");
     if (xBinOK && yBinOK && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
-            strcasecmp(xKeyword, yKeyword) == 0) {
+	strcasecmp(xKeyword, yKeyword) == 0) {
         psMetadataItem *yBinItem = psMetadataLookup(cell->concepts, "CELL.YBIN"); // Binning factor in y
         psString binString = NULL;
@@ -868,8 +877,8 @@
 psMetadataItem *p_pmConceptFormat_CELL_YBIN(const psMetadataItem *concept,
                                             pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					    const psMetadata *cameraFormat,
+					    const pmFPA *fpa,
+					    const pmChip *chip,
+					    const pmCell *cell)
 {
     assert(concept);
@@ -880,5 +889,5 @@
     psString yKeyword = psMetadataLookupStr(&yBinOK, translation, "CELL.YBIN");
     if (xBinOK && yBinOK && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
-            strcasecmp(xKeyword, yKeyword) == 0) {
+	strcasecmp(xKeyword, yKeyword) == 0) {
         // Censor this --- it's already done (though no harm if it's done twice
         return NULL;
@@ -891,25 +900,25 @@
 
 psMetadataItem *p_pmConceptFormat_TIMESYS(const psMetadataItem *concept,
-                                            pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					  pmConceptSource source,
+					  const psMetadata *cameraFormat,
+					  const pmFPA *fpa,
+					  const pmChip *chip,
+					  const pmCell *cell)
 {
     psString sys = NULL;            // String to store
     switch (concept->data.S32) {
-    case PS_TIME_TAI:
+      case PS_TIME_TAI:
         sys = psStringCopy("TAI");
         break;
-    case PS_TIME_UTC:
+      case PS_TIME_UTC:
         sys = psStringCopy("UTC");
         break;
-    case PS_TIME_UT1:
+      case PS_TIME_UT1:
         sys = psStringCopy("UT1");
         break;
-    case PS_TIME_TT:
+      case PS_TIME_TT:
         sys = psStringCopy("TT");
         break;
-    default:
+      default:
         sys = psStringCopy("Unknown");
     }
@@ -921,5 +930,5 @@
 
 psMetadataItem *p_pmConceptFormat_TIME(const psMetadataItem *concept,
-                                            pmConceptSource source,
+				       pmConceptSource source,
                                        const psMetadata *cameraFormat,
                                        const pmFPA *fpa,
@@ -980,5 +989,5 @@
                 } else {
                     psWarning("Unrecognised FORMATS option for %s: %s --- "
-                             "ignored.\n", concept->name, format);
+			      "ignored.\n", concept->name, format);
                 }
             }
@@ -1021,7 +1030,7 @@
 
         psMetadataItem *dateItem = psMetadataItemAllocStr(concept->name, "The date of observation",
-                                   dateString);
+							  dateString);
         psMetadataItem *timeItem = psMetadataItemAllocStr(concept->name, "The time of observation",
-                                   timeString);
+							  timeString);
 
         psListRemove(dateTime, PS_LIST_HEAD);
@@ -1032,5 +1041,5 @@
 
         psMetadataItem *item = psMetadataItemAllocPtr(concept->name, PS_DATA_LIST, concept->comment,
-                               dateTime);
+						      dateTime);
         psFree (dateItem);
         psFree (timeItem);
@@ -1057,8 +1066,8 @@
 psMetadataItem *p_pmConceptFormat_Positions(const psMetadataItem *concept,
                                             pmConceptSource source,
-        const psMetadata *cameraFormat,
-        const pmFPA *fpa,
-        const pmChip *chip,
-        const pmCell *cell)
+					    const psMetadata *cameraFormat,
+					    const pmFPA *fpa,
+					    const pmChip *chip,
+					    const pmCell *cell)
 {
     assert(concept);
@@ -1070,5 +1079,5 @@
     }
 
-    #if 0
+#if 0
     // If both the X0 and Y0 positions are specified by the same header keyword, write both together, as part
     // of the call for the X0 position.
@@ -1090,5 +1099,5 @@
         psString yKeyword = psMetadataLookupStr(&yFound, translation, companion);
         if (xFound && yFound && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
-                strcasecmp(xKeyword, yKeyword) == 0) {
+	    strcasecmp(xKeyword, yKeyword) == 0) {
             psMetadataItem *yItem = psMetadataLookup(cell->concepts, companion); // Corresponding y value
 
@@ -1115,9 +1124,9 @@
         psFree(companion);
         if (xFound && yFound && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
-                strcasecmp(xKeyword, yKeyword) == 0) {
+	    strcasecmp(xKeyword, yKeyword) == 0) {
             return NULL;                // We did it with the X; don't do anything.
         }
     }
-    #endif
+#endif
 
     int offset = concept->data.S32;
