Index: /trunk/Ohana/src/libohana/include/ohana.h
===================================================================
--- /trunk/Ohana/src/libohana/include/ohana.h	(revision 7963)
+++ /trunk/Ohana/src/libohana/include/ohana.h	(revision 7964)
@@ -156,4 +156,5 @@
 double  sec_to_mjd             PROTO((time_t second));
 time_t  mjd_to_sec             PROTO((double mjd));
+double  ohana_lst              PROTO((double jd, double longitude));
 
 int     hstgsc_hms_to_deg      PROTO((double *h0, double *h1, double *d0, double *d1, char *string));
Index: /trunk/Ohana/src/libohana/src/time.c
===================================================================
--- /trunk/Ohana/src/libohana/src/time.c	(revision 7963)
+++ /trunk/Ohana/src/libohana/src/time.c	(revision 7964)
@@ -395,2 +395,41 @@
  * 99:02:15:12h23m30s
  */
+
+
+/* returns the local MEAN sidereal time (dec hrs) at julian date jd
+   at west longitude long (decimal hours).  Follows
+   definitions in 1992 Astronomical Almanac, pp. B7 and L2.
+   Expression for GMST at 0h ut referenced to Aoki et al, A&A 105,
+   p.359, 1982.  On workstations, accuracy (numerical only!)
+   is about a millisecond in the 1990s.
+   EAM: function from skycalc (thorstensen) 
+*/
+#define  J2000             2451545.        /* Julian date at standard epoch */
+#define  SEC_IN_DAY        86400.
+
+double ohana_lst (double jd, double longitude) {
+
+  double t, ut, jdmid, jdint, jdfrac, sid_g, sid;
+  long sid_int;
+
+  jdint = (int) jd;
+  jdfrac = jd - jdint;
+
+  if (jdfrac < 0.5) {
+    jdmid = jdint - 0.5;
+    ut = jdfrac + 0.5;
+  } else {
+    jdmid = jdint + 0.5;
+    ut = jdfrac - 0.5;
+  }
+
+  t = (jdmid - J2000)/36525;
+  sid_g = (24110.54841+8640184.812866*t+0.093104*t*t-6.2e-6*t*t*t)/SEC_IN_DAY;
+  sid_int = sid_g;
+  sid_g = sid_g - (double) sid_int;
+  sid_g = sid_g + 1.0027379093 * ut - longitude/24.;
+  sid_int = sid_g;
+  sid_g = (sid_g - (double) sid_int) * 24.;
+  if (sid_g < 0.) sid_g = sid_g + 24.;
+  return (sid_g);
+}
Index: /trunk/Ohana/src/opihi/cmd.astro/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/Makefile	(revision 7963)
+++ /trunk/Ohana/src/opihi/cmd.astro/Makefile	(revision 7964)
@@ -33,4 +33,5 @@
 $(SDIR)/gauss.$(ARCH).o		   \
 $(SDIR)/getvel.$(ARCH).o	   \
+$(SDIR)/getlst.$(ARCH).o	   \
 $(SDIR)/medianmap.$(ARCH).o	   \
 $(SDIR)/mkgauss.$(ARCH).o	   \
Index: /trunk/Ohana/src/opihi/cmd.astro/getlst.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/getlst.c	(revision 7964)
+++ /trunk/Ohana/src/opihi/cmd.astro/getlst.c	(revision 7964)
@@ -0,0 +1,41 @@
+# include "astro.h"
+
+int getlst (int argc, char **argv) {
+
+  int N;
+  time_t time;
+  double jd, lst, longitude;
+  char *Variable;
+
+  Variable = NULL;
+  if ((N = get_argument (argc, argv, "-var"))) {
+    remove_argument (N, &argc, argv);
+    Variable = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if (argc != 3) goto syntax;
+
+  if (!str_to_time (argv[1], &time)) {
+      if (Variable != NULL) free (Variable);
+      return (FALSE);
+  }
+
+  longitude = atof (argv[2]);
+
+  jd = sec_to_jd (time);
+  fprintf (stderr, "jd: %f\n", jd);
+
+  lst = ohana_lst (jd, longitude);
+
+  if (Variable != NULL) {
+      set_variable (Variable, lst);
+      free (Variable);
+      return (TRUE);
+  }
+  gprint (GP_ERR, "lst: %f\n", lst);
+  return (TRUE);
+
+ syntax:
+  gprint (GP_ERR, "USAGE: getlst (time) (longitude) [-var name]\n");
+  return (FALSE);
+}
Index: /trunk/Ohana/src/opihi/cmd.astro/init.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/init.c	(revision 7963)
+++ /trunk/Ohana/src/opihi/cmd.astro/init.c	(revision 7964)
@@ -15,4 +15,5 @@
 int gaussfit		    PROTO((int, char **));
 int getvel		    PROTO((int, char **));
+int getlst		    PROTO((int, char **));
 int imfit		    PROTO((int, char **));
 int imsub		    PROTO((int, char **));
@@ -48,4 +49,5 @@
   {"gauss",   	  gauss,        "get statistics on a star, assuming gaussian profile"},
   {"getvel",      getvel,       "rotcurve to velocities"},
+  {"getlst",      getlst,       "return LST given time and longitude"},
   {"imfit",   	  imfit,        "fit function"},
   {"imsub",   	  imsub,        "subtract function"},
