Index: /trunk/Ohana/src/kii/doc/notes.txt
===================================================================
--- /trunk/Ohana/src/kii/doc/notes.txt	(revision 6822)
+++ /trunk/Ohana/src/kii/doc/notes.txt	(revision 6822)
@@ -0,0 +1,29 @@
+
+2005.12.05
+
+  I have been making some improvements to Kapa / Kii, and am
+  planning on further advances.  Here are some of the features
+  I'd like to add:
+
+  - library function calls (see libfuncs.txt)
+
+  - named plotting styles (line, histogram, points)
+  - add y-based histogram 
+  - move point-to-point to a style
+  - explore standard colormaps to get better greyscale
+  - merge kapa and kii common code?
+  - kapa / kii device Number in title bar
+
+  - complete kapa plotting features in kii 
+  - axis labels on kii image
+  - kapa (and kii) axis labels, frame in color
+  - image-plotting in kapa
+
+  - three selectable kii image buffers
+  - true-color kii representation 
+  
+  - color PS for kii (currently only B&W)
+  - refresh picture after new colormap
+  - DVO regions corresponding to Kapa 'sections' on any window
+
+  - push argv/argc entries all into args, push options into globals.
Index: /trunk/Ohana/src/relastro/doc/notes.txt
===================================================================
--- /trunk/Ohana/src/relastro/doc/notes.txt	(revision 6822)
+++ /trunk/Ohana/src/relastro/doc/notes.txt	(revision 6822)
@@ -0,0 +1,40 @@
+
+2006.04.08 : relphot contemplations
+
+relastro will perform the astrometry equivalent to relphot.  For
+region, it loads in the average objects, detections, and image
+parameters.  The goal is to determine improved astrometric positions
+of objects in the images and to determine improved astrometric
+parameters for the images.  Just like relphot, this is an iterative
+process in which the object postions are improved in one step, the
+image parameters are improved in the next, then back to the images.
+
+Relastro needs to deal with outlier objects in a robust way.  There
+are a few reasons why objects should have poor astrometric solutions,
+and these can be flagged up front: saturation and too many bad pixels.
+For detections which come from psphot, we can use the quality
+parameter to exclude objects which have excessively high bad pixel
+counts.  For detections from sextractor or other analysis tools,
+this information is missing.  In this case, we can use the distance
+from the image boundaries as a trigger.
+
+An open question to be addressed is the issue of external calibration
+sources.  Unlike photometry, external astrometric measurements do not
+need to have an unknown filter transformation applied.  They can thus
+be included as part of the solution automatically.  It is not clear,
+however, how to include *proper-motion* data in the analysis.  If I
+introduce, for example, USNO objects with proper motions, the
+information provided consists in practice of a velocity vector and
+errors.  How does this get folded into the fit?  One answer is to
+construct additional artificial datapoints for each entry with the
+proper errors and epochs.  Seems like something of a hack.  
+
+We may want to allow for different errors / weightings for the
+different external sources.
+
+After the initial iterations, we will can solve for proper-motion and
+parallax for (all?) objects
+
+- calculate the parallax normal vector for each image
+- calculate the atmospheric / orbital motion effects for each image
+
Index: /trunk/Ohana/src/relastro/src/relastro.c
===================================================================
--- /trunk/Ohana/src/relastro/src/relastro.c	(revision 6822)
+++ /trunk/Ohana/src/relastro/src/relastro.c	(revision 6822)
@@ -0,0 +1,95 @@
+# include "relphot.h"
+/** I'm not currently setting the lockfiles.  this should be fixed! **/
+
+int main (int argc, char **argv) {
+
+  int i, status, Ncatalog;
+  Catalog *catalog;
+  GSCRegion fullregion, *region;
+  FITS_DB db;
+
+  /* get configuration info, args */
+  initialize (argc, argv);
+
+  set_db (&db);
+  status = dvo_image_lock (&db, ImageCat, 60.0, (UPDATE ? LCK_XCLD : LCK_SOFT));
+  if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
+  if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename);
+
+  /* load regions and images based on seed region */
+  // XXX EAM : load images and regions based on bounds, not name
+  region = load_images (&db, argv[1], &Ncatalog, &fullregion);
+  if (!UPDATE) dvo_image_unlock (&db); 
+
+  /* load catalog data from region files */
+  catalog = load_catalogs (region, Ncatalog, &fullregion);
+
+  /* match measurements with images, mosaics */
+  initImageBins  (catalog, Ncatalog);
+  initMosaicBins (catalog, Ncatalog);
+  initGridBins   (catalog, Ncatalog);
+  initMrel (catalog, Ncatalog);
+
+  findImages (catalog, Ncatalog);
+  findMosaics (catalog, Ncatalog);  /* also sets Grid values */
+  SAVEPLOT = FALSE;
+
+  setExclusions (catalog, Ncatalog);
+
+  if (PLOTSTUFF) {
+    plot_star_coords (catalog, Ncatalog);
+    plot_mosaic_fields (catalog);
+  }
+
+  /* determine fit values */
+  for (i = 0; i < NLOOP; i++) {
+    setMrel  (catalog, Ncatalog);
+    setMcal  (catalog, FALSE);
+    setMmos  (catalog, FALSE);
+    setMgrid (catalog);
+    
+    if (PLOTSTUFF) {
+      plot_scatter (catalog, Ncatalog); 
+      plot_grid (catalog); 
+      plot_mosaics ();
+      plot_images ();
+      plot_stars (catalog, Ncatalog);
+      plot_chisq (catalog, Ncatalog);
+    }
+    if ((i == 1) || (i == 5) || (i ==  9) || (i == 13)) clean_measures (catalog, Ncatalog, FALSE); 
+    if ((i == 2) || (i == 6) || (i == 10) || (i == 14)) clean_stars (catalog, Ncatalog);
+    if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_mosaics (catalog, Ncatalog);
+    if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_images ();
+    global_stats (catalog, Ncatalog);
+  }
+
+  SAVEPLOT = TRUE;
+  plot_scatter (catalog, Ncatalog); 
+  plot_grid (catalog); 
+  plot_mosaics ();
+  plot_images ();
+  plot_stars (catalog, Ncatalog);
+  plot_chisq (catalog, Ncatalog);
+
+  if (USE_GRID) dump_grid ();
+  if (!UPDATE) exit (0);
+
+  /* set Mcal & Mmos for bad images */
+  setMcal  (catalog, TRUE);
+  setMmos  (catalog, TRUE);
+
+  /* at this point, we have correct cal coeffs in the image/mosaic structures */
+  free_catalogs (catalog, Ncatalog);
+  freeImageBins (Ncatalog);
+  freeMosaicBins (Ncatalog);
+  freeGridBins (Ncatalog);
+
+  /* load catalog data from region files, update Mrel include all data */
+  reload_catalogs (region, Ncatalog, &fullregion);
+  setMcalFinal ();
+  dvo_image_update (&db, VERBOSE);
+  dvo_image_unlock (&db); 
+
+  exit (0);
+}
+
