Index: trunk/Ohana/src/opihi/cmd.astro/cgrid.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 41341)
+++ trunk/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 41515)
@@ -40,5 +40,5 @@
   OnPic = FALSE;							\
   First = TRUE;								\
-  for (d = firstDEC; (d < 90 + dD) && (LOnPic || NorthPole || SouthPole); d += dD) { \
+  for (d = firstDEC; (d < 90 + dD) && (LOnPic || NorthPole || SouthPole || InvalidCorner); d += dD) { \
     D = MAX (-90, MIN(90, d));						\
     ADD_COORDINATE((RA), D);						\
@@ -47,5 +47,5 @@
   First = TRUE;								\
   LOnPic = TRUE;							\
-  for (d = firstDEC; (d > -90 - dD) && (LOnPic || NorthPole || SouthPole); d -= dD) { \
+  for (d = firstDEC; (d > -90 - dD) && (LOnPic || NorthPole || SouthPole || InvalidCorner); d -= dD) { \
     D = MAX (-90, MIN(90, d));						\
     ADD_COORDINATE((RA), D);						\
@@ -59,5 +59,5 @@
   First = TRUE;								\
   lastRA = graphmode.coords.crval1 + 180.0;				\
-  for (r = firstRA; (r < lastRA + dR) && (LOnPic || NorthPole || SouthPole); r += dR) { \
+  for (r = firstRA; (r < lastRA + dR) && (LOnPic || NorthPole || SouthPole || InvalidCorner); r += dR) { \
     R = MIN (r, lastRA);					\
     ADD_COORDINATE(R, D);						\
@@ -67,5 +67,5 @@
   LOnPic = TRUE;							\
   lastRA = graphmode.coords.crval1 - 180.0;				\
-  for (r = firstRA; (r > lastRA - dR) && (LOnPic || NorthPole || SouthPole); r -= dR) { \
+  for (r = firstRA; (r > lastRA - dR) && (LOnPic || NorthPole || SouthPole || InvalidCorner); r -= dR) { \
     R = MAX (r, lastRA);					\
     ADD_COORDINATE(R, D);						\
@@ -167,6 +167,18 @@
     SouthPole = TRUE;
 
+  // PSEUDOCYL modes need center R,D to be 0,0 and center pixel to be adjusted
+  OhanaProjection proj = GetProjection (graphmode.coords.ctype);
+  OhanaProjectionMode mode = GetProjectionMode (proj);
+  int InvalidCorner = FALSE;
+  if (mode == PROJ_MODE_PSEUDOCYL) {
+    // for PSEUDOCYL, the ra range is 360 if the corners are invalid 
+    InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmin, graphmode.ymin, &graphmode.coords); 
+    InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmax, graphmode.ymin, &graphmode.coords); 
+    InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmax, graphmode.ymax, &graphmode.coords); 
+    InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmin, graphmode.ymax, &graphmode.coords); 
+  }    
+
   range = MIN (fabs(graphmode.coords.cdelt1*(graphmode.xmax-graphmode.xmin)), fabs(graphmode.coords.cdelt2*(graphmode.ymax-graphmode.ymin)));
-  if (NorthPole || SouthPole) range = 360;
+  if (NorthPole || SouthPole || InvalidCorner) range = 360;
   dR = range * GRID_SPACING;
   dD = range * GRID_SPACING;
