Index: trunk/Ohana/src/opihi/cmd.astro/Makefile
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/Makefile	(revision 34340)
+++ trunk/Ohana/src/opihi/cmd.astro/Makefile	(revision 34342)
@@ -43,4 +43,5 @@
 $(SRC)/galsectors.$(ARCH).o	   \
 $(SRC)/galprofiles.$(ARCH).o	   \
+$(SRC)/getcoords.$(ARCH).o	   \
 $(SRC)/elliprofile.$(ARCH).o	   \
 $(SRC)/ringflux.$(ARCH).o	   \
Index: trunk/Ohana/src/opihi/cmd.astro/csystem.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/csystem.c	(revision 34340)
+++ trunk/Ohana/src/opihi/cmd.astro/csystem.c	(revision 34342)
@@ -11,8 +11,5 @@
   CoordTransform *transform;
 
-  if (argc != 5) {
-    gprint (GP_ERR, "USAGE: csystems [C/G/E/H] [C/G/E/H] X Y\n");
-    return (FALSE);
-  }
+  if (argc != 5) goto syntax;
 
   switch (argv[1][0]) {
@@ -20,5 +17,5 @@
     case 'G': input = COORD_GALACTIC; break;
     case 'E': input = COORD_ECLIPTIC; break;
-    default: abort();
+    default: goto syntax;
   }
 
@@ -27,5 +24,5 @@
     case 'G': output = COORD_GALACTIC; break;
     case 'E': output = COORD_ECLIPTIC; break;
-    default: abort();
+    default: goto syntax;
   }
 
@@ -66,3 +63,6 @@
   return (TRUE);
 
+syntax:
+  gprint (GP_ERR, "USAGE: csystems [C/G/E/H] [C/G/E/H] X Y\n");
+  return (FALSE);
 }
Index: trunk/Ohana/src/opihi/cmd.astro/getcoords.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/getcoords.c	(revision 34342)
+++ trunk/Ohana/src/opihi/cmd.astro/getcoords.c	(revision 34342)
@@ -0,0 +1,105 @@
+# include "astro.h"
+
+enum {NONE, SKY, PIXEL, VECTOR, SCALAR};
+
+int getcoords (int argc, char **argv) {
+
+  int ix, iy, N;
+  double c1, c2, t1, t2;
+  Coords coords, moscoords;
+  Buffer *input, *mosbuffer, *outC1, *outC2;
+  CoordTransformSystem inTrans, outTrans;
+
+  CoordTransform *transform = NULL;
+  if ((N = get_argument (argc, argv, "-transform"))) {
+    if (argc < N + 3) goto syntax;
+    remove_argument (N, &argc, argv);
+
+    switch (argv[N][0]) {
+      case 'C': inTrans = COORD_CELESTIAL; break;
+      case 'G': inTrans = COORD_GALACTIC; break;
+      case 'E': inTrans = COORD_ECLIPTIC; break;
+      default: goto syntax;
+    }
+    remove_argument (N, &argc, argv);
+
+    switch (argv[N][0]) {
+      case 'C': outTrans = COORD_CELESTIAL; break;
+      case 'G': outTrans = COORD_GALACTIC; break;
+      case 'E': outTrans = COORD_ECLIPTIC; break;
+      default: goto syntax;
+    }
+    remove_argument (N, &argc, argv);
+    
+    transform = InitTransform (inTrans, outTrans);
+    if (transform == NULL) {
+      gprint (GP_ERR, "transform %c to %c is not yet defined\n", argv[1][0], argv[2][0]);
+      return (FALSE);
+    }
+  }
+
+  char *MOSAIC = NULL;
+  if ((N = get_argument (argc, argv, "-mosaic"))) {
+    remove_argument (N, &argc, argv);
+    MOSAIC = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if (argc != 4) goto syntax;
+  if ((input = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) goto syntax;
+  if ((outC1 = SelectBuffer (argv[2], ANYBUFFER, TRUE)) == NULL) goto syntax;
+  if ((outC2 = SelectBuffer (argv[3], ANYBUFFER, TRUE)) == NULL) goto syntax;
+
+  GetCoords (&coords, &input[0].header);
+  if (!strcmp(&coords.ctype[4], "-WRP")) {
+    if (MOSAIC == NULL) {
+      gprint (GP_ERR, "must supply mosaic for WRP coords\n");
+      return (FALSE);
+    }
+    if ((mosbuffer = SelectBuffer (MOSAIC, OLDBUFFER, TRUE)) == NULL) goto escape;
+    GetCoords (&moscoords, &mosbuffer[0].header);
+    RegisterMosaic (&moscoords);
+  }
+  
+  int Nx = input[0].matrix.Naxis[0];
+  int Ny = input[0].matrix.Naxis[1];
+
+  gfits_free_matrix (&outC1[0].matrix);
+  gfits_free_header (&outC1[0].header);
+  CreateBuffer (outC1, Nx, Ny, -32, 1.0, 0.0);
+
+  gfits_free_matrix (&outC2[0].matrix);
+  gfits_free_header (&outC2[0].header);
+  CreateBuffer (outC2, Nx, Ny, -32, 1.0, 0.0);
+
+  float *valC1 = (float *) outC1[0].matrix.buffer;
+  float *valC2 = (float *) outC2[0].matrix.buffer;
+
+  for (ix = 0; ix < Nx; ix++) {
+    for (iy = 0; iy < Ny; iy++) {
+      int status = XY_to_RD (&c1, &c2, (double) ix, (double) iy, &coords);
+      if (!status) {
+	valC1[ix + Nx*iy] = NAN;
+	valC2[ix + Nx*iy] = NAN;
+	continue;
+      }
+      if (transform) {
+	ApplyTransform (&t1, &t2, c1, c2, transform);
+	c1 = t1;
+	c2 = t2;
+      }
+      valC1[ix + Nx*iy] = c1;
+      valC2[ix + Nx*iy] = c2;
+    }
+  }
+  if (transform) free (transform);
+
+  return (TRUE);
+
+ syntax:
+  gprint (GP_ERR, "USAGE: getcoords [buffer] (crval1) (crval2) [-transform C/E/G C/E/G]\n");
+  gprint (GP_ERR, "generate images of the two coordinate dimensions for the image WCS\n");
+ escape:
+  if (MOSAIC != NULL) free (MOSAIC);
+  return (FALSE);
+}
Index: trunk/Ohana/src/opihi/cmd.astro/init.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/init.c	(revision 34340)
+++ trunk/Ohana/src/opihi/cmd.astro/init.c	(revision 34342)
@@ -29,4 +29,5 @@
 int galradius               PROTO((int, char **));
 int galradbins              PROTO((int, char **));
+int getcoords               PROTO((int, char **));
 int elliprofile             PROTO((int, char **));
 int ringflux                PROTO((int, char **));
@@ -86,4 +87,5 @@
   {1, "galradius",   galradius,    "generate radial vectors with interpolation along paths"},
   {1, "galradbins",  galradbins,   "generate radial vectors with interpolation along paths"},
+  {1, "getcoords",   getcoords,    "generate images containing the RA,DEC coord for each pixel"},
   {1, "elliprofile", elliprofile,  "generate radial vectors with interpolation along paths"},
   {1, "ringflux",    ringflux,     "mean flux in a ring"},
Index: trunk/Ohana/src/opihi/cmd.basic/fprintf.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.basic/fprintf.c	(revision 34340)
+++ trunk/Ohana/src/opihi/cmd.basic/fprintf.c	(revision 34342)
@@ -45,5 +45,5 @@
       case 'F':
       case 'G':
-	sprintf (tmp, fmt, atof(argv[i]));
+	sprintf (tmp, fmt, strtod (argv[i], NULL));
 	break;
       case 's':
@@ -57,5 +57,5 @@
       case 'x':
       case 'X':
-	sprintf (tmp, fmt, atoi(argv[i]));
+	sprintf (tmp, fmt, strtol(argv[i], NULL, 0));
 	break;
       default:
Index: trunk/Ohana/src/opihi/lib.shell/stack_math.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/stack_math.c	(revision 34340)
+++ trunk/Ohana/src/opihi/lib.shell/stack_math.c	(revision 34342)
@@ -86,5 +86,5 @@
     case '*': VV_FUNC('s', *M1 * *M2);
     case '/': VV_FUNC('S', *M1 / (opihi_flt) *M2);
-    case '%': VV_FUNC('s', (int)*M1 % (int)*M2);
+    case '%': VV_FUNC('s', (long long)*M1 % (long long)*M2);
     case '^': VV_FUNC('S', pow (*M1, *M2));
     case '@': VV_FUNC('S', DEG_RAD*atan2 (*M1, *M2));
@@ -93,6 +93,6 @@
     case '<': VV_FUNC('s', (*M1 < *M2) ? 1 : 0);
     case '>': VV_FUNC('s', (*M1 > *M2) ? 1 : 0);
-    case '&': VV_FUNC('s', ((int)*M1 & (int)*M2));
-    case '|': VV_FUNC('s', ((int)*M1 | (int)*M2));
+    case '&': VV_FUNC('s', ((long long)*M1 & (long long)*M2));
+    case '|': VV_FUNC('s', ((long long)*M1 | (long long)*M2));
     case 'E': VV_FUNC('s', (*M1 == *M2) ? 1 : 0);
     case 'N': VV_FUNC('s', (*M1 != *M2) ? 1 : 0);
@@ -196,5 +196,5 @@
     case '*': SV_FUNC('s', M1 * *M2);
     case '/': SV_FUNC('S', M1 / (opihi_flt) *M2);
-    case '%': SV_FUNC('s', (int) M1 % (int) *M2);
+    case '%': SV_FUNC('s', (long long) M1 % (long long) *M2);
     case '^': SV_FUNC('S', pow (M1, *M2));
     case '@': SV_FUNC('S', DEG_RAD*atan2 (M1, *M2));
@@ -203,6 +203,6 @@
     case '<': SV_FUNC('s', (M1 < *M2) ? 1 : 0);
     case '>': SV_FUNC('s', (M1 > *M2) ? 1 : 0);
-    case '&': SV_FUNC('s', ((int)M1 & (int)*M2));
-    case '|': SV_FUNC('s', ((int)M1 | (int)*M2));
+    case '&': SV_FUNC('s', ((long long)M1 & (long long)*M2));
+    case '|': SV_FUNC('s', ((long long)M1 | (long long)*M2));
     case 'E': SV_FUNC('s', (M1 == *M2) ? 1 : 0);
     case 'N': SV_FUNC('s', (M1 != *M2) ? 1 : 0);
@@ -302,5 +302,5 @@
     case '*': VS_FUNC('s', *M1 * M2);
     case '/': VS_FUNC('S', *M1 / (opihi_flt) M2);
-    case '%': VS_FUNC('s', (int) *M1 % (int) M2);
+    case '%': VS_FUNC('s', (long long) *M1 % (long long) M2);
     case '^': VS_FUNC('S', pow (*M1, M2));
     case '@': VS_FUNC('S', DEG_RAD*atan2 (*M1, M2));
@@ -309,6 +309,6 @@
     case '<': VS_FUNC('s', (*M1 < M2) ? 1 : 0);
     case '>': VS_FUNC('s', (*M1 > M2) ? 1 : 0);
-    case '&': VS_FUNC('s', ((int)*M1 & (int)M2));
-    case '|': VS_FUNC('s', ((int)*M1 | (int)M2));
+    case '&': VS_FUNC('s', ((long long)*M1 & (long long)M2));
+    case '|': VS_FUNC('s', ((long long)*M1 | (long long)M2));
     case 'E': VS_FUNC('s', (*M1 == M2) ? 1 : 0);
     case 'N': VS_FUNC('s', (*M1 != M2) ? 1 : 0);
@@ -392,5 +392,5 @@
     case '*': MV_FUNC(*M1 * *M2);
     case '/': MV_FUNC(*M1 / (opihi_flt) *M2);
-    case '%': MV_FUNC((int) *M1 % (int) *M2);
+    case '%': MV_FUNC((long long) *M1 % (long long) *M2);
     case '^': MV_FUNC(pow (*M1, *M2));
     case '@': MV_FUNC(DEG_RAD*atan2 (*M1, *M2));
@@ -399,6 +399,6 @@
     case '<': MV_FUNC((*M1 < *M2) ? 1 : 0);
     case '>': MV_FUNC((*M1 > *M2) ? 1 : 0);
-    case '&': MV_FUNC(((int)*M1 & (int)*M2));
-    case '|': MV_FUNC(((int)*M1 | (int)*M2));
+    case '&': MV_FUNC(((long long)*M1 & (long long)*M2));
+    case '|': MV_FUNC(((long long)*M1 | (long long)*M2));
     case 'E': MV_FUNC((*M1 == *M2) ? 1 : 0);
     case 'N': MV_FUNC((*M1 != *M2) ? 1 : 0);
@@ -484,5 +484,5 @@
     case '*': VM_FUNC(*M1 * *M2);
     case '/': VM_FUNC(*M1 / (opihi_flt) *M2);
-    case '%': VM_FUNC((int) *M1 % (int) *M2);
+    case '%': VM_FUNC((long long) *M1 % (long long) *M2);
     case '^': VM_FUNC(pow (*M1, *M2));
     case '@': VM_FUNC(DEG_RAD*atan2 (*M1, *M2));
@@ -491,6 +491,6 @@
     case '<': VM_FUNC((*M1 < *M2) ? 1 : 0);
     case '>': VM_FUNC((*M1 > *M2) ? 1 : 0);
-    case '&': VM_FUNC(((int)*M1 & (int)*M2));
-    case '|': VM_FUNC(((int)*M1 | (int)*M2));
+    case '&': VM_FUNC(((long long)*M1 & (long long)*M2));
+    case '|': VM_FUNC(((long long)*M1 | (long long)*M2));
     case 'E': VM_FUNC((*M1 == *M2) ? 1 : 0);
     case 'N': VM_FUNC((*M1 != *M2) ? 1 : 0);
@@ -564,5 +564,5 @@
     case '*': MM_FUNC(*M1 * *M2);
     case '/': MM_FUNC(*M1 / (float) *M2);
-    case '%': MM_FUNC((int) *M1 % (int) *M2);
+    case '%': MM_FUNC((long long) *M1 % (long long) *M2);
     case '^': MM_FUNC(pow (*M1, *M2));
     case '@': MM_FUNC(DEG_RAD*atan2 (*M1, *M2));
@@ -571,6 +571,6 @@
     case '<': MM_FUNC((*M1 < *M2) ? 1 : 0);
     case '>': MM_FUNC((*M1 > *M2) ? 1 : 0);
-    case '&': MM_FUNC(((int)*M1 & (int)*M2));
-    case '|': MM_FUNC(((int)*M1 | (int)*M2));
+    case '&': MM_FUNC(((long long)*M1 & (long long)*M2));
+    case '|': MM_FUNC(((long long)*M1 | (long long)*M2));
     case 'E': MM_FUNC((*M1 == *M2) ? 1 : 0);
     case 'N': MM_FUNC((*M1 != *M2) ? 1 : 0);
@@ -649,5 +649,5 @@
     case '*': MS_FUNC(*M1 * M2);
     case '/': MS_FUNC(*M1 / (float) M2);
-    case '%': MS_FUNC((int) *M1 % (int) M2);
+    case '%': MS_FUNC((long long) *M1 % (long long) M2);
     case '^': MS_FUNC(pow (*M1, M2));
     case '@': MS_FUNC(DEG_RAD*atan2 (*M1, M2));
@@ -656,6 +656,6 @@
     case '<': MS_FUNC((*M1 < M2) ? 1 : 0);
     case '>': MS_FUNC((*M1 > M2) ? 1 : 0);
-    case '&': MS_FUNC(((int)*M1 & (int)M2));
-    case '|': MS_FUNC(((int)*M1 | (int)M2));
+    case '&': MS_FUNC(((long long)*M1 & (long long)M2));
+    case '|': MS_FUNC(((long long)*M1 | (long long)M2));
     case 'E': MS_FUNC((*M1 == M2) ? 1 : 0);
     case 'N': MS_FUNC((*M1 != M2) ? 1 : 0);
@@ -725,5 +725,5 @@
     case '*': SM_FUNC(M1 * *M2);
     case '/': SM_FUNC(M1 / (float) *M2);
-    case '%': SM_FUNC((int) M1 % (int) *M2);
+    case '%': SM_FUNC((long long) M1 % (long long) *M2);
     case '^': SM_FUNC(pow (M1, *M2));
     case '@': SM_FUNC(DEG_RAD*atan2 (M1, *M2));
@@ -732,6 +732,6 @@
     case '<': SM_FUNC((M1 < *M2) ? 1 : 0);
     case '>': SM_FUNC((M1 > *M2) ? 1 : 0);
-    case '&': SM_FUNC(((int)M1 & (int)*M2));
-    case '|': SM_FUNC(((int)M1 | (int)*M2));
+    case '&': SM_FUNC(((long long)M1 & (long long)*M2));
+    case '|': SM_FUNC(((long long)M1 | (long long)*M2));
     case 'E': SM_FUNC((M1 == *M2) ? 1 : 0);
     case 'N': SM_FUNC((M1 != *M2) ? 1 : 0);
@@ -806,5 +806,5 @@
     case '*': SS_FUNC('s', M1 * M2);
     case '/': SS_FUNC('S', M1 / (opihi_flt) M2);
-    case '%': SS_FUNC('s', (int) M1 % (int) M2);
+    case '%': SS_FUNC('s', (long long) M1 % (long long) M2);
     case '^': SS_FUNC('S', pow (M1, M2));
     case '@': SS_FUNC('S', DEG_RAD*atan2 (M1, M2));
@@ -813,6 +813,6 @@
     case '<': SS_FUNC('s', (M1 < M2) ? 1 : 0);
     case '>': SS_FUNC('s', (M1 > M2) ? 1 : 0);
-    case '&': SS_FUNC('s', ((int)M1 & (int)M2));
-    case '|': SS_FUNC('s', ((int)M1 | (int)M2));
+    case '&': SS_FUNC('s', ((long long)M1 & (long long)M2));
+    case '|': SS_FUNC('s', ((long long)M1 | (long long)M2));
     case 'E': SS_FUNC('s', (M1 == M2) ? 1 : 0);
     case 'N': SS_FUNC('s', (M1 != M2) ? 1 : 0);
@@ -916,5 +916,5 @@
   if (!strcmp (op, "="))      S_FUNC(M1, 's');
   if (!strcmp (op, "abs"))    S_FUNC(fabs(M1), 's');
-  if (!strcmp (op, "int"))    S_FUNC((int)(M1), 's');
+  if (!strcmp (op, "int"))    S_FUNC((long long)(M1), 's');
   if (!strcmp (op, "exp"))    S_FUNC(exp (M1), 'S');
   if (!strcmp (op, "ten"))    S_FUNC(pow (10.0,M1), 'S');
@@ -995,5 +995,5 @@
   if (!strcmp (op, "="))      V_FUNC(*M1, 's');
   if (!strcmp (op, "abs"))    V_FUNC(fabs(*M1), 's');
-  if (!strcmp (op, "int"))    V_FUNC((int)(*M1), 's');
+  if (!strcmp (op, "int"))    V_FUNC((long long)(*M1), 's');
   if (!strcmp (op, "exp"))    V_FUNC(exp(*M1), 'S');
   if (!strcmp (op, "ten"))    V_FUNC(pow(10.0,*M1), 'S');
@@ -1066,5 +1066,5 @@
   if (!strcmp (op, "="))     { }
   if (!strcmp (op, "abs"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = fabs(*M1);         }}
-  if (!strcmp (op, "int"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = (opihi_flt)(int)(*M1); }}
+  if (!strcmp (op, "int"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = (opihi_flt)(long long)(*M1); }}
   if (!strcmp (op, "exp"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = exp(*M1);          }}
   if (!strcmp (op, "ten"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = pow(10.0,*M1);     }}
