Index: trunk/Ohana/doc/www/html/DVO/addstar.htm
===================================================================
--- trunk/Ohana/doc/www/html/DVO/addstar.htm	(revision 5135)
+++ trunk/Ohana/doc/www/html/DVO/addstar.htm	(revision 5144)
@@ -0,0 +1,208 @@
+<meta name=file  content=addstar>
+<meta name=title content=addstar>
+<meta name=page  content=addstar>
+
+<p>
+This program takes a photometry file, with astrometry, provided by
+earlier routines and incorporates the stellar measurements into the
+photometry database.  This routine does NOT try to calibrate or check
+the photometry, nor does it try to improve the coordinate
+determinations or calculate chisquares for position or photometry -
+those tasks are performed by other routines.
+
+<p>
+Addstar starts by loading in the photometry file and converting the
+pixel coordinates to sky coordinates using the astrometry information
+in the header of the file.  It also gets the detection limits and
+stores the image astrometry information.
+
+<p>
+Next, addstar determines which of all the previous images overlaps
+with this image and also which of the catalog regions overlaps with
+this image.
+
+<p>
+Addstar considers each catalog region in turn, and compares the
+positions of stars in the catalog with stars in the image.  If a
+catalog star is detected, a new measurement is added to the catalog.
+If a catalog star is not detected, but is in the field of view of this
+image, the detection limit for this image is added to the list of
+measurements as an upper limit.  If the image contains a star which is
+not already included in the catalog, the star is added to the catalog,
+and all previous images are checked to see if they included this
+location.  If so, upper limits are added to the list of measurements.
+
+<p>
+To deal with blended images, we have taken the philosophy that all
+measurements compatible with the coordinates of a given star should be
+included in the list of measurements.  This assumes that programs or people
+downstream will figure out which is the "correct" measurement.  To
+this end, if a catalog star is consistent with multiple measurements,
+they are all added to the catalog measurement and the measurements are
+given a flag to say that there was blending in the catalog (ie, it is
+probably the catalog star which is a blend).  If multiple catalog
+stars are consistent with the same image star, that measurement is
+added to each catalog star, and given a flag to say that there was
+blending on the image.
+
+<p>
+After all catalogs have been checked, updated, and written to disk,
+the image is added to the database of images.
+
+<p>
+see <a href=database.html> DVO database </a> for discussion of the
+database storage format.   
+
+<hr>
+
+<h2> Usage </h2>
+
+<pre>
+ addstar (filename)
+ addstar -cat (catalog)
+ addstar -ref (filename)
+</pre>
+
+<p>
+In the first form, addstar loads the photometry information for a
+single image into the database.  The file must be in one of the Elixir
+cmp/smp/smf formats, and must have been astrometrized (eg, with
+gastro, gastro2, and/or mosastro).  The file must also be provided
+with a valid photcode in the header (keyword PHOTCODE) or the photcode
+must be supplied as an option to addstar (see below).  The photcode
+must be listed in the photcode table (see config variable
+PHOTCODE_FILE).  In the case that the image has been astrometrized
+with mosastro (two-level mosaic astrometry), the corresponding mosaic
+header unit must be supplied as an option (see below).  
+
+<p>
+In the second form, addstar will load photometry from the specified
+reference catalog, located in a known location, and will load it into
+the database.  Allowed catalog names are: <tt> USNO, GSC, 2MASS,
+2MASS-ALLSKY, 2MASS-DR </tt>.  Note that USNO corresponds to the
+USNO-A catalog, 2MASS corresponds to the 2MASS-ALLSKY catalog.  It is
+necessary to have defined an appropriate photcode for the given
+catalog.  The following photcodes are expected to exist:
+
+<table>
+<tr><th> catalog </th><th> allowed photcodes   	     </th></tr>
+<tr><td> GSC     </td><td> GSC_M               	     </th></tr>
+<tr><td> USNO    </td><td> USNO_RED, USNO_BLUE 	     </th></tr>
+<tr><td> 2MASS*  </td><td> 2MASS_J, 2MASS_H, 2MASS_K </th></tr>
+</table>
+
+When more than one photcode is allowed, one must be selected; there
+are no defaults in that case. <em>It is advised that addstar -cat be
+used with a restricted region of the sky; the default behavior will
+load the reference catalog for the entire sky into the DB!</em>
+
+<p>
+In the third form, addstar will load data from the specified ASCII
+text file with a fixed format.  The file must contain lines with one
+line per star.  The first four columns must contain the values RA,
+DEC, Magnitude, Magnitude error.  The RA and DEC must be in J2000
+decimal degrees.  Blank lines are allowed, and lines may be commented
+with the hash sign (#).  The provided photometry must all be for a
+single photcode, which must be provided as a command-line option.
+
+<h2> Additional Options </h2>
+
+<pre>
+  -region ra ra dec dec           : only add data in specified region (-ref mode only)
+  -p (photcode)                   : specify photcode (override header)
+  -time (YYYY/MM/DD,HH:MM:SS)     : specify date/time (override header)
+  -mosaic (filename)              : identify associated mosaic frame for chip image
+  -fits                           : input file is FITS table, not TEXT table
+  -existing-regions               : only add measurements to existing catalog files
+  -only-match                     : only add measurements to existing objects
+  -missed                         : skipped 'missed' entries
+  -replace                        : replace time/photcode measurements (no duplication)
+  -image                          : only insert image data
+  -cal                            : perform zero-point calibration
+  -skyprobe                       : specify skyprobe mode
+  -2massquality                   : define 2MASS quality flags to keep
+  -accept                         : accept bad astrometry from header
+  -force                          : force read of database with inconsistent info
+  -v                              : verbose mode
+  -dump (mode)                    : output test data
+  -help                           : print this list
+  -h                              : print this list
+</pre>
+
+
+<h2> Elixir Configuration Data </h2>
+
+addstar uses the following Elixir configuration variables:
+
+<ul>
+<li> EXPTIME-KEYWORD  : header keyword defining exposure time
+<li> DATE-KEYWORD  : header keyword defining the date 
+<li> DATE-MODE  : mode for header date information: use a combination
+of Ys, Ms, Ds to specify order.  If only 2 digits are specified for
+the year, numbers greater than 50 are assumed in the 1900s, less than
+in the 2000s.  eg YYYY/MM/DD
+<li> UT-KEYWORD  : header keyword defining UT
+<li> MJD-KEYWORD  : header keyword defining MJD
+<li> JD-KEYWORD  : header keyword defining JD
+<li> AIRMASS-KEYWORD
+<li> CCDNUM-KEYWORD
+<li> ST-KEYWORD
+
+<li> RADIUS : radius for matches; may have the value "header", in which
+case the astrometric error listed in the header, along with
+<tt>NSIGMA</tt> is used to define a match.  Otherwise, defines a
+radius in arcseconds.
+
+<li> NSIGMA : number of astrometric error sigma to use for match
+radius (see <tt>RADIUS</tt>).
+
+<li> XOVERSCAN : used to define valid pixels in the image. subtracted
+from image NAXIS1 value to define image box. 
+
+<li> YOVERSCAN : used to define valid pixels in the image. subtracted
+from image NAXIS2 value to define image box. 
+
+<li> ADDSTAR_XMIN : this value, and the following three, are used to
+define a region on the image where the photometry is considered
+reliable.  Stars outside this region are marked as having poor
+measurements.
+
+<li> ADDSTAR_XMAX : see <tt>ADDSTAR_XMIN</tt>
+<li> ADDSTAR_YMIN : see <tt>ADDSTAR_XMIN</tt>
+<li> ADDSTAR_YMAX : see <tt>ADDSTAR_XMIN</tt>
+
+<li> MIN_SN_FSTAT : only include objects in the DB with S/N greater
+than this value.
+
+<li> GSCDIR        : location of the HST Guide Star Catalog
+<li> USNO_CDROM    : location of the USNO-A data
+<li> 2MASS_DIR_AS  : location of the 2MASS allsky data 
+<li> 2MASS_DIR_DR2 : location of the 2MASS DR2 data 
+
+2MASS, USNO, and GSC are all loaded from their idiosyncratic formats.
+
+<li> GSCFILE  : location of the GSC layout file (for GSC and ptolemy)
+<li> CATDIR  : location of the ptolemy data
+<li> IMAGE_CATALOG : location of the image database table
+
+<li> CATMODE : storage mode for the database.  may be one of RAW,
+MEF, SPLIT, MYSQL.  SPLIT and MYSQL are currently unsupported.  This
+defines the output format for new tables; the input format is auto-detected.
+
+<li> CATFORMAT : data format for the database.  may be one of LONEOS,
+ELIXIR, PANSTARRS.
+
+<li> PHOTCODE_FILE : location of the photcode file describing the
+photometry system of interest.
+
+<li> OBSERVATORY-LATITUDE : hard-wired observatory latitude.  used for
+precision airmass for skyprobe.  <em> should be replaced with a more
+sophisticated approach</em>
+
+<li> SUBPIX_DATAFILE : table for subpixel structure corrections (skyprobe)
+
+<li> IMAGE_CATALOG_TEMPLATE : deprecated, was used to supply a FITS
+header template
+<li> CATALOG_TEMPLATE : deprecated, was used to supply a FITS
+header template
+</ul>
Index: trunk/Ohana/doc/www/html/DVO/database.htm
===================================================================
--- trunk/Ohana/doc/www/html/DVO/database.htm	(revision 5144)
+++ trunk/Ohana/doc/www/html/DVO/database.htm	(revision 5144)
@@ -0,0 +1,121 @@
+
+This discussion is somewhat short, and only valid for the original
+Elixir-RAW style format/mode.  
+
+<pre>
+The format for a catalog region file is as follows:
+
+-- 
+Header
+--
+Averages
+--
+Measurements
+--
+</pre>
+
+<p>
+The Header follows the format of a FITS header but always stored with
+3 blocks to speed up read time: 2880 x 3 bytes.  Two important
+keywords in the header: NSTARS & NMEAS
+
+<p>
+All average values are stored consecutively in a single block.  They
+are written as an array with NSTARS elements of the Average structure
+defined below.  The individual measurements follow the averages as a
+block.  To find a measurement for a given star, you need to get the
+value of the offset for the star.  this is the element number for the
+first measurement of this star, and are followed by next measurements
+for this star, until the value Nm is reached.
+
+Here are the structures being used for the average and measurement
+values:
+
+<pre>
+
+typedef struct {
+  float R;                    /* RA  in decimal degrees */
+  float D;                    /* DEC in decimal degrees */
+  short int M;                /* thousandths of mag (-32.000 to 32.000 valid range) */
+  unsigned short int Nm;      /* number of measurements */
+  unsigned short int Xp, Xm;  /* chisq values in tenths */
+  unsigned int offset;        /* offset to first Measure-ment */
+} Average;                    /* = 20 bytes / average */
+
+typedef struct {
+  char dR, dD;                /* tenths of arcsec (-12.7 to +12.7 valid range) */
+  short int M;                /* thousandths of mag (-32.000 to 32.000 valid range) */
+  unsigned char dM;           /* thousandths of mag (0.000 -- 0.255 valid range) */
+  float t;                    /* time in seconds (what is reference?) */
+  unsigned int average;       /* reference to corresponding Average entry, 
+				 upper byte of value contains flags.
+				 limit of 16,777,215 stars (Naverage) 
+				 in a file (=0xFFFFFF).
+				 flags = average & 0x1000000 */
+} Measure;                    /* = 13 bytes / measure */
+</pre>
+
+<p>
+The above two structures define the entries in the photometry
+database.  The database consists of a large number of files
+representing a small patch on the sky (roughly 1.5 degree$^2$ in most
+places).  These files are organized into directories representing
+bands of Declination.  A reference file determines the coordinate
+boundaries for each of the files so that a given point on the sky can
+unambiguously be associated with a specific file in a specific
+directory.  The sky coordinates for each file is the same as those
+used by the HST Guide Star catalog, except for the region around the
+North celestial pole, for which all stars are included in a single
+file.  
+
+<p>
+Within a given file, the data are stored in a binary format, with an
+ASCII FITS-like header.  The header is examply in the format of a
+normal FITS header, but with the exception that all files have a fixed
+number of header blocks (for now 3 blocks = 8640 bytes).  This is done
+to speed loading the header and finding the beginning of the binary
+data.  The number of 3 blocks seems quite generous, as currently only
+a few FITS keywords have been defined for each file, basically
+keywords to define the number of stars and the total number of
+measurements stored in the file, as well as values to define the RA
+and DEC range of the file.  
+
+<p>
+The first section of data following the header blocks consists of
+average measurements for each uniquely observed star.  Each star
+occupies 20 bytes, the size of the Average structure defined above.
+The Average structure contains the average Ra, Dec, and Magnitude for
+the star, as well as the number of measurements, and \chisq\ values
+for the magnitude and position.  Finally, there is a 32 bit integer
+which defines the offset to the first measurement for this star.  This
+offset is defined as the number of Measure records from the start of
+the Measure structure.
+
+<p>
+The second section of data, following the Average data contains all
+measurements for each star listed in Average.  Each measurement
+occupies 13 bytes, the size of the Measure structure.  This structure
+contains the difference of this position from the average RA and DEC,
+and the instrumental magnitude of this measurement (in the units
+defined by the fstat program, which give m = -2.5*log(cts) + Mo, where
+Mo is currently 24.5 [10/15]).  There is also the magnitude error for
+this measurement, the time of the measurement (in seconds relative to
+a to-be-determined zero point), and a reference to the entry in the
+Average structure so we can relate a given measurement with a given star.
+This last entry also includes a byte of flags, of which only 4 have
+currently been defined.  This means the Average offset can only be as
+large as  16,777,215 (0xffffff), limiting the possible number of stars
+allowed in a given file.  This does not seem like a long term problem,
+though:  aside from the fact that this number is very large and we
+only expect in the vicinity of 20,000 stars per file, the file can
+easily be divided into pieces at a later date if needed.  this last
+step is trivial, consisting of splitting the data up into smaller
+RA,DEC regions, and updating the reference catalog.  With the above
+definitions for the Average and Measure structures, we will typically
+expect 20,000 * 15 measurements per year and 20,000 average entries in
+a given file.  This implies a file size of about 4.3 MB at the end of
+a year.  It is also possible that we will choose to split the files up
+in the future if the number of measurements makes their size
+unweildy.  4.3 MB is sufficiently small that this is not a problem,
+but after only 5 years, the files will be over 21 MB each, getting to
+be fairly significant.  
Index: trunk/Ohana/doc/www/html/DVO/extract.htm
===================================================================
--- trunk/Ohana/doc/www/html/DVO/extract.htm	(revision 5144)
+++ trunk/Ohana/doc/www/html/DVO/extract.htm	(revision 5144)
@@ -0,0 +1,147 @@
+<meta name=title content=DVO extractions>
+<meta name=page  content=extractions>
+
+<p>
+DVO provides several ways to access the photometry information stored
+in the database.  Several simple commands allow the user to extract 1
+dimensional information directly from one of the primary database
+tables.  The commands are:
+<ul>
+<li> imextract
+<li> avextract
+<li> mextract
+<li> imsearch
+<li> detsearch
+</ul>
+
+<h3> imextract </h3> 
+
+This command allows the user to extract one of the columns from the
+image table, applying filtering as desired:
+
+<pre>
+  dvo: imextract
+  USAGE: imextract (value) [-region] [-time start range] [-photcode photcode]
+  dvo: imextract help
+  value may be one of the following:
+   ra dec airmass Mcal dMcal Xm photcode time fwhm exptime nstar ncal sky flag
+</pre>
+
+<p>
+The extracted data is saved in a vector with the same name used to
+select the column.  The vector name will have the same case as the
+choice given, but the column selection is case-insensitive (since
+there are no ambiguities in the database columns names by case).  
+
+<h3> avextract </h3>
+
+This command allows the user to extract data from one of the Average
+table columns:
+
+<pre>
+  dvo: avextract
+  USAGE: avextract (from) (value) [options]
+    from: cpt name or 'all'
+    value: average.parameter or photcode
+  dvo: avextract all help
+  value may be one of the following:
+   ra dec dmag Nmeas Nmiss Xm Xp Nphot Ncode flag type
+</pre>
+
+<p>
+This command takes as the first argument the name of one of the
+database regions.  Alternatively, all regions currently displayed may
+be selection with the word 'all'.  The second option specifies which
+column to select from the Average table.  In addition to the basic
+data columns (ra, dec, etc), the magnitude-related average values
+(mag, dmag, Xm, Nphot, Ncode) are coupled to a photcode, which is thus
+required for these selections.  The value 'mag' may also be subsituted
+with a primary or secondary photcode.  Eg:
+
+<pre>
+  avextract all ra : select ra for all objects in displayed region
+  avextract all g  : select g magnitudes
+  avextract all mag -photcode r : select r magnitudes 
+  avextract all Xm -photcode r  : select chisq values for r average mags
+</pre>
+
+<h3> mextract </h3>
+
+This command allows the user to extract data from one of the Measure
+table columns:
+
+<pre>
+  dvo: mextract
+  USAGE: mextract (from) (value) [options]
+    from: cpt name or 'all'
+    value: measure.parameter or photcode
+  dvo: mextract all help
+  value may be one of the following:
+   ra dR dec dD mag dmag Mrel Mcal photcode time fwhm dophot xccd yccd xmosaic ymosaic flags
+</pre>
+
+<p>
+This command takes as the first argument the name of one of the
+database regions.  Alternatively, all regions currently displayed may
+be selection with the word 'all'.  The second option specifies which
+column to select from the Measure table.  In addition to the basic
+data columns (ra, dec, etc), the magnitude-related average values
+(mag, dmag) are coupled to a photcode, which is thus required for
+these selections.  The value 'mag' may also be subsituted with a
+primary or secondary photcode.  Eg:
+
+<pre>
+  mextract all ra : select ra for all objects in displayed region
+  mextract all g  : select g magnitudes
+  mextract all mag -photcode r : select r magnitudes 
+  mextract all Xm -photcode r  : select chisq values for r average mags
+</pre>
+
+<h3> option filtering </h3>
+
+The following extraction options allow the user to restrict the
+selections:
+
+<p>
+<tt> -time (start) (range)<tt><br> 
+
+select data for images within the given time range.  The start date is
+given in the format YYYY/MM/DD,hh:mm:ss (any of these element may be
+dropped, in which case they default to 00 [for hh,mm,ss] or 01 [for
+MM,DD]).  The date may also be written as a number of days followed by
+j (JD) or J (MJD).  The two special date names "now" and "today" are
+also valid.  The range is written as a number followed by a unit, with
+valid units of s (seconds), m (minutes), h (hours), d (days).  Times
+are in UT.  For example:
+
+<pre>
+ -time 2001/1/1 30d : select the range starting at midnight on 2001/1/1
+  and ending 30 days (86400*30 seconds) later.
+
+ -time now -3h : select the time range starting three hours ago and
+  ending now.
+</pre>
+
+<tt> -region<tt><br> 
+
+restrict the selection to the currently display portion of the sky.
+This filter expects a portion of the sky to be plotted, and will only
+select data for images in the part of the sky.  The algorithm for
+selecting the displayed region may not be perfect, so images near the
+boundaries may be unexpected included or excluded (this depends on the
+exact overlap details).  Multiple queries with the same region will
+result in the same subset of images selected.
+
+<tt>-photcode (photcode) </tt><br>
+
+This restricts the selection to the given photcode.  Images may only
+have photcodes of 'Dependent' type (eg, CFH12K.R.00).  This filter
+allows the selection of images by exact match (selected photcode is
+Dependent type) or by equivalence match (selected photcode is Primary
+or Secondary type).  Thus, selecting images based on CFH12K.R.00 will
+ignore images with photcode CFH12K.R.10, while selecting images based
+on photcode 'r' will return all images with CFH12K.R.*, since all are
+equivalent to 'r'.  (NOTE: these details depend on the layout of the
+photcode table).
+
+<em> fill this out with all other restrictions provided by photometry.c</em>
Index: trunk/Ohana/doc/www/html/DVO/navigate.htm
===================================================================
--- trunk/Ohana/doc/www/html/DVO/navigate.htm	(revision 5144)
+++ trunk/Ohana/doc/www/html/DVO/navigate.htm	(revision 5144)
@@ -0,0 +1,44 @@
+
+<p>
+The <a href=navigate.pro>navigate</a> script provides a convenient
+graphical user interface to the DVO shell and database.  To use it,
+simply load it into the DVO shell with the <tt>input</tt> command.  It
+is useful to always load this script by including the input command in
+your <tt>~/.dvorc</tt> file.  Once you have loaded the script, you
+can start it by typing <tt>navigate</tt>.  You can navigate around the
+sky, then exit the script at any time by typing 'q'.  This allows you
+to issue DVO commands related to your current position.  You can then
+resume navigating by restarting the script.
+
+<p>
+The navigate script lets you move about the sky by placing your cursor
+in the display window and clicking various keys.  Below is a summary
+of the basic key stokes:
+
+<pre>
+1 - zoom in factor of 2
+2 - zoom in factor of 1.2
+3 - recenter at cursor
+4 - zoom out factor of 1.2
+5 - zoom out factor of 2
+6 - zoom out factor of 10
+z - zoom to radius (requires 2nd keystroke)
+f - show full sky
+
+q - quit
+g - toggle skygrid on/off
+r - plot detected asteroids (rocks)
+l - plot HST GSC
+L - plot Landolt stars
+m - list measurements for stars within 1 pixel of cursor
+M - list measurements for stars within 1.8 arcsec of cursor
+i - list info about images touching cursor location 
+I - list info about images, with pixel coords of cursor position
+x - plot stars scaled by magnitude Chisq
+X - plot stars by magnitude scatter
+S - toggle auto-plotting of stars
+t - plot light curve for star within 2 arcsec of cursor position
+T - plot 'galaxy' light curve for star within 2 arcsec of cursor position
+c - plot status catalog boundaries
+C - list catalog at cursor location
+</pre>
Index: trunk/Ohana/doc/www/html/DVO/navigate.pro
===================================================================
--- trunk/Ohana/doc/www/html/DVO/navigate.pro	(revision 5144)
+++ trunk/Ohana/doc/www/html/DVO/navigate.pro	(revision 5144)
@@ -0,0 +1,379 @@
+# -*- perl -*-
+
+macro navigate
+  style -n 0
+  limits
+  $DSTARS = -1
+  $ZOOM = 180 / ($YMAX - $YMIN)
+  for i 1 100
+    $REDRAW = 0
+    cursor -g 1
+    # zoom controls
+    if ("$KEY" == "1")
+      $ZOOM = $ZOOM * 2
+      $REDRAW = 1
+      $Rnum = $R$KEY		      
+      $Dnum = $D$KEY
+      $KEY = num
+    end
+    if ("$KEY" == "2")
+      $ZOOM = $ZOOM * 1.2
+      $REDRAW = 1
+      $Rnum = $R$KEY		      
+      $Dnum = $D$KEY
+      $KEY = num
+    end
+    if ("$KEY" == "3")
+      $REDRAW = 1
+      $Rnum = $R$KEY		      
+      $Dnum = $D$KEY
+      $KEY = num
+    end
+    if ("$KEY" == "4")
+      $ZOOM = $ZOOM / 1.2
+      $REDRAW = 1
+      $Rnum = $R$KEY		      
+      $Dnum = $D$KEY
+      $KEY = num
+    end
+    if ("$KEY" == "5")
+      $ZOOM = $ZOOM / 2
+      $REDRAW = 1
+      $Rnum = $R$KEY		      
+      $Dnum = $D$KEY
+      $KEY = num
+    end
+    if ("$KEY" == "6")
+      $ZOOM = $ZOOM / 20
+      $REDRAW = 1
+      $Rnum = $R$KEY		      
+      $Dnum = $D$KEY
+      $KEY = num
+    end
+
+    # help list
+    if ("$KEY" == "h")
+     echo "1 - zoom in factor of 2"
+     echo "2 - zoom in factor of 1.2"
+     echo "3 - recenter at cursor"
+     echo "4 - zoom out factor of 1.2"
+     echo "5 - zoom out factor of 2"
+     echo "6 - zoom out factor of 10"
+     echo "z - zoom to radius (requires 2nd keystroke)"
+     echo "f - show full sky"
+     echo ""
+     echo "q - quit"
+     echo "g - toggle skygrid on/off"
+     echo "r - plot detected asteroids (rocks)"
+     echo "l - plot HST GSC"
+     echo "L - plot Landolt stars"
+     echo "m - list measurements for stars within 1 pixel of cursor"
+     echo "M - list measurements for stars within 1.8 arcsec of cursor"
+     echo "i - list info about images touching cursor location" 
+     echo "I - list info about images, with pixel coords of cursor position"
+     echo "x - plot stars scaled by magnitude Chisq"
+     echo "X - plot stars by magnitude scatter"
+     echo "S - toggle auto-plotting of stars"
+     echo "t - plot light curve for star within 2 arcsec of cursor position"
+     echo "T - plot 'galaxy' light curve for star within 2 arcsec of cursor position"
+     echo "c - plot status catalog boundaries"
+     echo "C - list catalog at cursor location"
+    end
+
+    # quit from navigate
+    if ("$KEY" == "q") 
+      break
+    end
+
+    # measure distance
+    if ("$KEY" == "d")
+      $r0 = $R$KEY
+      $d0 = $D$KEY
+      $ok = $KEY
+      echo "type at radius"
+      cursor -g 1
+      $r1 = $R$KEY
+      $d1 = $D$KEY
+      $dr = 3600*((dcos($d0)*($r0-$r1))^2 + ($d0-$d1)^2)^0.5
+      echo "$dr arcsec"
+    end
+    # show ra, dec
+    if ("$KEY" == "w")
+      $tmp = $R$KEY
+      if ($tmp < 0) 
+        $tmp = $R$KEY + 360.0
+      end
+      echo "$tmp $D$KEY" 
+      exec echo $tmp $D$KEY | radec -hh
+    end
+    # zoom to radius
+    if ("$KEY" == "z")
+      $r0 = $R$KEY
+      $d0 = $D$KEY
+      $ok = $KEY
+      echo "type at radius"
+      cursor -g 1
+      $r1 = $R$KEY
+      $d1 = $D$KEY
+      $dr = (($r0-$r1)^2 + ($d0-$d1)^2)^0.5
+      $ZOOM = $RAD / $dr
+      $REDRAW = 1
+      $KEY = $ok
+      $R$KEY = $r0
+      $D$KEY = $d0
+    end
+
+    # adjust mag scaling
+    if ("$KEY" == "J")
+      $MAG = $MAG - 0.5
+      $REDRAW = 2
+    end
+    if ("$KEY" == "K")
+      $MAG = $MAG + 0.5
+      $REDRAW = 2
+    end
+    if ("$KEY" == "j")
+      $dMAG = $dMAG * 0.8
+      $REDRAW = 2
+    end
+    if ("$KEY" == "k")
+      $dMAG = $dMAG * 1.25
+      $REDRAW = 2
+    end
+    echo "mag, dmag: $MAG, $dMAG"
+
+    # redraw region 
+    if ($REDRAW == 1)
+      region $R$KEY $D$KEY {$RAD/$ZOOM} sin
+      $RMIN = $R$KEY + $XMIN
+      $RMAX = $R$KEY + $XMAX
+      $DMIN = $D$KEY + $YMIN
+      $DMAX = $D$KEY + $YMAX
+      if (($ZOOM < 20) && ($GRID == 1)) 
+        style -c red; cgrid
+      end
+      if (($ZOOM > 20) && ($DSTARS == 1))
+        style -pt 7
+	pmeasure -all -m $MAG {$MAG + $dMAG}
+      end    
+      style -c black
+       images
+#       showtile
+    end
+
+    # redraw region 
+    if ($REDRAW == 2)
+      clear
+      if (($ZOOM < 20) && ($GRID == 1)) 
+        style -c red; cgrid
+      end
+      if (($ZOOM > 20) && ($DSTARS == 1))
+        style -pt 2
+	pmeasure -all -m $MAG {$MAG + $dMAG}
+      end    
+      style -c black
+      images
+    end
+
+    # turn grid on / off
+    if ("$KEY" == "g")
+      if ($GRID == 1) 
+        $GRID = 0
+        style -c white; cgrid
+        style -c black
+      else
+        $GRID = 1 
+        style -c black; cgrid
+      end
+    end
+
+    # plot full sky
+    if ("$KEY" == "f") 
+      echo "full"
+      $ZOOM = 1
+      resize 1150 600		      
+      region 0 0 90 ait
+      $RMIN = 0
+      $RMAX = 360
+      $DMIN = -90
+      $DMAX = +90
+      style -c red; cgrid
+      style -c black
+      images
+    end
+
+    # plot rocks
+    if ("$KEY" == "r") 
+#      plot.rocks
+      style -c blue   -pt 1; procks -speed 0.0041 1
+      style -c red    -pt 1; procks -speed 0.00041 0.0041
+      style -c indigo -pt 1; procks -speed 0 0.00041
+      style -c black -lw 0;
+    end
+    # plot HST-GSC
+    if ("$KEY" == "l") 
+      style -c blue -pt 7; cat -all -g -m 9 16
+      style -c black
+    end
+    # plot Landolt
+    if ("$KEY" == "L") 
+#      style -c red  -lw 2 -pt 3; cat -a 1 2 3 /data/elixir/srcdir/refs/stetson/stetsonBn.txt -m 9 18
+#      style -c blue -lw 2 -pt 3; cat -a 25 26 8 /data/elixir/srcdir/refs/landolt/new/Landolt92.fix -m 9 18
+      style -c red -lw 2 -pt 7; cat -a 1 2 3 /data/elixir/srcdir/refs/sdss/g_SDSS.dat -m 9 14
+#      style -c red -lw 2 -pt 3; cat -a 25 26 8 /data/elixir/srcdir/refs/landolt/new/Landolt92.hq -m 9 18
+#      style -c red -lw 2 -pt 3; cat -a 22 23 8 /data/elixir/srcdir/refs/landolt/new/Landolt92.unfix -m 9 18
+#      style -c blue -lw 2 -pt 7; cat -a 1 2 4 /data/elixir/srcdir/refs/landolt/extreme/extreme.match -m 0 20
+#      style -x 2 -c red -pt 7 ; cplot RA DEC
+      style -c black -lw 0
+    end
+
+    # list star measurements
+    if ("$KEY" == "m") 
+        $dR = $RAD/$ZOOM/300
+        if ($dR < 0.0005)
+	 $dR = 0.0005
+        end
+	gstar $R$KEY $D$KEY $dR -m
+    end
+
+    # plot mag residuals
+    if ("$KEY" == "R") 
+      echo "filter: "
+      cursor 1
+      clear -n 1 -s; lim 10 22 -0.2 0.2; clear; box
+      dmags $KEY\:rel - $KEY : $KEY -type 0
+      plot -x 2 -pt 0 -sz 0.3 -c red yv xv
+      dmags $KEY\:rel - $KEY : $KEY -type 0 -flag 0 -nphot +3 -chisq 2.0
+      plot -x 2 -pt 2 -sz 0.5 -c black yv xv
+      $KEY = R
+      style -n 0
+    end
+
+    if ("$KEY" == "M") 
+	gstar $R$KEY $D$KEY 0.0005 -m
+    end
+    # list images
+    if ("$KEY" == "i") 
+	gimages $R$KEY $D$KEY
+    end
+    if ("$KEY" == "I") 
+	gimages $R$KEY $D$KEY -pix
+    end
+    # turn stars on / off
+    if ("$KEY" == "S")
+      $DSTARS = $DSTARS * -1
+      if (($ZOOM > 20) && ($DSTARS == 1))
+       style -pt 7
+       pmeasure -all -m $MAG {$MAG + $dMAG}
+      end
+    end
+    # plot light-curve interactive
+    if ("$KEY" == "t")
+      style -n 1 -pt 2 -x 2
+      clear
+      if ($R$KEY < 0) 
+       $R$KEY = $R$KEY + 360
+      end
+      lcurve -l $R$KEY $D$KEY {30/3600} -d -v time mag
+      box
+      lcv
+      style -n 0
+    end
+    # plot light-curve 
+    if ("$KEY" == "T")
+      style -n 1 -pt 1 -c red -x 2
+      lcurve $R$KEY $D$KEY {30/3600} -d
+      style -c black
+      style -n 0 
+    end
+    # plot catalogs
+    if ("$KEY" == "c")
+      style -c blue; pcat; style -c black
+    end
+    # list catalogs
+    if ("$KEY" == "C")
+      gcat $R$KEY $D$KEY
+    end
+
+    # plot image chisqs
+    if ("$KEY" == "x") 
+       gcat $R$KEY $D$KEY
+       extract $CATNAME Xm -photcode R
+       extract $CATNAME ra
+       extract $CATNAME dec
+       style -x 2 -pt 7 -c blue
+       czplot ra dec Xm 3 30
+       style -c black -pt 1
+    end
+    # plot meas errors
+    if ("$KEY" == "X") 
+       gcat $R$KEY $D$KEY
+       extract $CATNAME dM -photcode R
+       extract $CATNAME ra
+       extract $CATNAME dec
+       style -x 2 -pt 7 -c red
+       czplot ra dec dM 0 30
+       style -c black -pt 1
+    end
+    # temp plot for skyprobe
+    if ("$KEY" == "u") 
+      imextract -region time
+      imextract -region mcal
+      imextract -region airmass
+      imextract -region nstar
+      vstat time
+      clear -n 1;
+      section a 0 0.00 1 0.33
+      lim {$MEDIAN-0.3} {$MEDIAN+0.3} -0.8 -0.5; box; plot time mcal
+      section b 0 0.33 1 0.33
+      lim {$MEDIAN-0.3} {$MEDIAN+0.3}  0.95 3.0; box; plot time airmass
+      section c 0 0.66 1 0.33
+      lim {$MEDIAN-0.3} {$MEDIAN+0.3} 0 3000; box; plot time nstar
+      style -n 0
+    end
+    if ("$KEY" == "s")
+      $tmp = $R$KEY
+      if ($tmp < 0) 
+        $tmp = $R$KEY + 360.0
+      end
+      $line = `echo $tmp $D$KEY | radec -hh`
+      imextract -region photcode
+      imextract -region time
+     
+      subset t = time if (int(photcode/100) == 1)
+      uniq t T
+      $Bn = t[]
+      $BN = T[]
+      
+      subset t = time if (int(photcode/100) == 2)
+      uniq t T
+      $Vn = t[]
+      $VN = T[]
+      
+      subset t = time if (int(photcode/100) == 3)
+      uniq t T
+      $Rn = t[]
+      $RN = T[]
+      
+      subset t = time if (int(photcode/100) == 4)
+      uniq t T
+      $In = t[]
+      $IN = T[]
+     
+      echo "$line  $Bn $BN  $Vn $VN  $Rn $RN  $In $IN"
+    end
+
+    if ("$KEY" == "p") 
+      echo "P - new coords; p - old coords"
+      cursor -g 1
+      exec echo $Rp $Dp $RP $DP >> fix.coords
+    end
+
+    if ("$KEY" == "y")
+      ccd I - 2MASS_J : 2MASS_J - 2MASS_K
+      lim -n 1 -1 10 -1 3; clear; box; plot -x 2 -pt 2 -sz 0.5 xv yv
+      dev -n 0 -g
+    end
+  end
+end
+
Index: trunk/Ohana/doc/www/html/DVO/photcodes.htm
===================================================================
--- trunk/Ohana/doc/www/html/DVO/photcodes.htm	(revision 5144)
+++ trunk/Ohana/doc/www/html/DVO/photcodes.htm	(revision 5144)
@@ -0,0 +1,30 @@
+<meta name=file  content=photcodes>
+<meta name=title content=photcodes>
+<meta name=page  content=photcodes>
+
+<p>
+The DVO photcodes define a photometric system, consisting of a
+detector, a filter, and a telescope.  
+
+<p>
+Many DVO commands which accept a photcode as an argument allow for
+the photcode name to be appended with a modifier which changes
+slightly the type of magnitude returned to the user.  
+
+<p>
+The type of photcode is
+specified by adding :type to a photcode.  Valid types consist of:
+<ul>
+<li> inst : instrumental magnitude
+<li>  cat : catalog magnitude = inst + nominal ZP
+<li>  sys : system magnitude = color + airmass corrected mag
+<li>  rel : relative magnitude = applies color, airmass, and relative magnitude offset
+corrections
+<li>  cal : calibrated magnitude : applies zero-point and color
+terms from dependent to primary/secondary magnitude system)
+<li>  ref : reference system
+</ul>
+
+<p>
+<em>This page needs serious work to clarify the meaning of a photcode,
+and the selection criteria </em>
Index: trunk/Ohana/doc/www/html/DVO/relphot.htm
===================================================================
--- trunk/Ohana/doc/www/html/DVO/relphot.htm	(revision 5135)
+++ trunk/Ohana/doc/www/html/DVO/relphot.htm	(revision 5144)
@@ -0,0 +1,224 @@
+
+<h2> relphot outline </h2>
+
+<ul>
+<li> load data
+     <ul>
+     <li> images: match photcode and time range, reset flags
+     <li> measure: select subset matching restritions on:
+          photcode, time, dM, Minst, Mag, dophot == 1
+     </ul>
+<li> iterate to find Mcal, image.flags:
+<li> write out modified Mcal values to image table
+<li> write out modified Mcal values to measure table
+<li> write out modified Mrel values to average table
+</ul>
+
+<h2> relphot overview </h2>
+
+<p> relphot has two primary purposes:<br>
+<ul>
+<li> calculate <b>Mcal</b> for images / measures
+<li> calculate <b>Mrel</b> for stars
+</ul>
+
+<p> relphot can also be used to determine the mosaic grid used to generate
+photometrically corrected flats (-grid option).
+
+<h2> data exclusion </h2>
+
+<p> relphot uses only a subset of the photometry data to calculate
+Mcal and Mrel.  In the first stage, calculation of the Mcal values,
+relphot loads the photometry data from each relevant catalog and
+creates an internal subset catalog with the function
+<em>bcatalog</em>, excluding some of the irrelevant data.  In
+addition, it uses flags to mark some of the data as invalid for the
+processing.
+
+<b> bcatalog exclusions </b>
+<ul>
+<li> measure.photcode not equivalent to requested photcode
+<li> measure.dophot != 1
+<li> measure.Mcat > MAG_LIM
+<li> measure.dM > SIGMA_LIM
+<li> measure.Minst out of range (ImagMin - ImagMax) [optional]
+<li> measure.t out of range (TSTART, TSTOP)
+</ul>
+
+<b> flagged data </b>
+
+<b> flagged image data </b>
+
+images can be flagged by setting bits of <b>image.code</b>
+
+stars can be flagged by setting bits of <b>average.code</b>
+
+measures can be flagged by setting bits of <b>measure.flag</b>
+
+<b>image.code</b>
+
+ID_IMAGE_NOCAL : ignore, irrelevant
+ID_IMAGE_POOR  : image measured bad
+ID_IMAGE_SKIP  : externally known bad
+
+dMcal > VALUE       FLAG_IMAGE_SCATTER <em>clean_images</em>
+fabs(Mcal) > VALUE  FLAG_IMAGE_ZEROPT  <em>clean_images</em>
+
+dMcal > VALUE       FLAG_IMAGE_SCATTER <em>clean_mosaics</em>
+fabs(Mcal) > VALUE  FLAG_IMAGE_ZEROPT  <em>clean_mosaics</em>
+
+<em> mark_images </em> does not seem to do anything useful?
+
+<b>average.code</b>
+
+Ngood < MEAS_TOOFEW                     <em>setMrel</em>
+Ngood < MEAS_TOOFEW                     <em>clean_measures</em>
+ChiSq > STAR_CHISQ                      <em>clean_stars</em>
+dM    > STAR_SCATTER                    <em>clean_stars</em>
+
+average.code (STAR_BAD) is not saved by relphot: it is set by
+clean_stars, clean_measures, and setMrel, but not setMrelOutput.
+STAR_BAD should only be internal since it depends on the photcode, but
+is not associated with a specific photcode in the data.  Just in case,
+it is reset to 0 in setMrelFinal.
+
+<b>measure.flag</b>
+
+X,Y out of range                        <em>setExclusions</em>
+3 sigma clipping                        <em>clean_measures</em>
+
+<h2> setting Mrel final value </h2>
+
+setMrelFinal is used to set the final average.Mrel values.  We do this
+in 4 stages.  In each stage, we set the Mrel values for stars which
+have not already been set, based on the current exclusion settings.
+At successive stages, we relax the exclusions, allowing the more
+spurious objects to have a valid Mrel value to be set.  In this loop,
+we actually run setMrelOutput twice: once to get the approximate Mrel
+value, then we flag the outlier measurements with clean_measure,
+then we redetermine the Mrel values on this basis, and mark the stars
+for exclusion from the next iteration.  
+
+<pre>
+exclude on
+ photcode       0 1 2 3
+ time range     0 1 2 3
+ MEAS_POOR      0 1 2 3
+ MEAS_TOOFEW    0 1 2 3
+ dophot == 10   0 1 2 
+ inst mag       0 1 2 
+ dophot != 1,2  0 1  
+ ID_IMAGE_POOR  0 1
+ ID_IMAGE_SKIP  0 1
+ dophot != 1    0
+ measure.dM     0 
+</pre>
+
+for all relphot runs, Mrel is re-calculated, and measures are marked
+at least if they are outliers in mag or ccd area.
+
+setMrel.output needs to do a few things differently from setMrel:
+<ul>
+<li> set measure.Mcal (skipped in setMrel.basic)
+<li> set average.Mrel if N < TOO_FEW (not STAR_BAD) (optional!)
+<li> use MAX (stats.error, stats.sigma) (optionally)
+<li> allow STAR_BAD?
+</ul>
+
+<h2> imphotset </h2>
+
+imphotset allows you to set certain phot.image table entries.  here
+are the options:
+
+imphotset [-photcode code] [-name foo] [-trange (start) (stop)] -flag and value
+
+
+Here is a complete list of relphot configuration variable names, a
+quick description, and reasonable values to start with:
+
+<pre>
+--- configuration variables used by relphot ---
+MAG_LIM : float
+  ignore measurements fainter than this absolute magnitude
+
+SIGMA_LIM : float
+  ignore measurements with magnitude error larger than this value
+
+STAR_SCATTER : float
+  mark stars as bad if their scatter is larger than this value
+
+IMAGE_SCATTER : float
+  mark images as bad if their scatter is larger than this value
+
+IMAGE_OFFSET : float
+  mark images as bad if the absolute value of thie zero point offset
+  is larger than this number
+
+STAR_CHISQ : float
+  mark stars as variable if their reduced chisq are larger than this value
+
+STAR_TOOFEW : int
+  mark stars as bad if the have fewer than this number of valid measurements
+
+IMAGE_TOOFEW : int
+  mark images as bad if the have fewer than this number of valid measurements
+
+IMAGE_GOOD_FRACTION : float
+  mark images as bad if the have fewer than this fraction of valid measurements  
+
+IMAGE_CATALOG : string
+  name of the image catalog file
+
+IMAGE_CATALOG_TEMPLATE : string
+  name of the template file to create the image catalog file
+
+CATALOG_TEMPLATE : string
+  name of the template file to create the catalog file
+
+GSCFILE : string
+  name of the GSC region table
+
+CATDIR : string
+  directory where the database is stored
+
+PHOTCODE_FILE : string
+  file containing photometry code information
+
+ZERO_PT : float
+  default zero point for random data
+
+RELPHOT_GRID_X : int
+  scale of mosaic correction grid 
+
+RELPHOT_GRID_Y : int
+  scale of mosaic correction grid 
+
+RELPHOT_GRID_BINNING : int
+  deprecated
+
+CAMERA_CONFIG : string
+  name of the file containing descriptive information about the camera
+
+--- sample ConfigFile entries with typical values ---
+
+MAG_LIM                	 24.0
+SIGMA_LIM              	  0.05
+STAR_SCATTER           	  0.05
+IMAGE_SCATTER          	  0.05
+IMAGE_OFFSET           	  0.2
+STAR_CHISQ             	 10.0
+STAR_TOOFEW            	  3
+IMAGE_TOOFEW           	 10
+IMAGE_GOOD_FRACTION    	 
+IMAGE_CATALOG          	 $CATDIR/Images.dat
+IMAGE_CATALOG_TEMPLATE 	 $REFSDIR/elixir/template.cat
+CATALOG_TEMPLATE       	 $REFSDIR/elixir/template.cat
+GSCFILE                	 $REFSDIR/gsc/GSCregions.tbl
+CATDIR                 	 $CATDIR
+PHOTCODE_FILE          	 $CONFDIR/camera/$CAMERA.photcode
+ZERO_PT                	 25.0
+RELPHOT_GRID_X         	 4
+RELPHOT_GRID_Y         	 8
+RELPHOT_GRID_BINNING   	 512
+CAMERA_CONFIG          	 $CONFDIR/camera/$CAMERA.config
+</pre>
Index: trunk/Ohana/doc/www/html/Elixir-Tools/mosastro.htm
===================================================================
--- trunk/Ohana/doc/www/html/Elixir-Tools/mosastro.htm	(revision 5135)
+++ trunk/Ohana/doc/www/html/Elixir-Tools/mosastro.htm	(revision 5144)
@@ -157,13 +157,14 @@
 values are <tt>GSC, USNO, 2MASS, PTOLEMY, STONE</tt>.  
 
-<li> USNO_CDROM  : directory where USNO data is stored
-<li> STONE_DIR  : location of the Stone et al reference data
-<li> 2MASS_DIR  : location of the 2MASS data 
-<li> CATDIR  : location of the ptolemy data
-<li> GSCDIR  : location of the HST Guide Star Catalog
-<li> GSCFILE  : location of the GSC layout file (for GSC and ptolemy)
+<li> GSCDIR      : location of the HST Guide Star Catalog
+<li> USNO_CDROM  : location of the USNO-A data
+<li> STONE_DIR   : location of the Stone et al reference data
+<li> 2MASS_DIR   : location of the 2MASS data 
+<li> CATDIR      : location of the ptolemy data
+<li> GSCFILE     : location of the GSC layout file (for GSC and ptolemy)
 
 note that 'ptolemy' refers to data using the DVO format.  2MASS data
-must be in a DVO format database.
+must be in a DVO format database.  USNO and GSC are both loaded from
+their idiosyncratic formats.  
 
 <li> RADIUS  : matching radius in arcsec to select reference stars
@@ -178,11 +179,2 @@
 systematic error limit.
 </ul>
- 
-</pre>
-
-
-
-
-
-
-
Index: trunk/Ohana/doc/www/html/download.htm
===================================================================
--- trunk/Ohana/doc/www/html/download.htm	(revision 5135)
+++ trunk/Ohana/doc/www/html/download.htm	(revision 5144)
@@ -40,4 +40,5 @@
 
 <ul>
+<li><a href=download/tarballs/elixir-ohana-head.tgz>elixir-ohana-head.tgz </a>
 <li><a href=download/tarballs/elixir-ohana-1.3.tgz>elixir-ohana-1.3.tgz </a>
 <li><a href=download/tarballs/elixir-ohana-1.2.tgz>elixir-ohana-1.2.tgz </a>
