Index: trunk/doc/ipptools/outline.tex
===================================================================
--- trunk/doc/ipptools/outline.tex	(revision 4986)
+++ trunk/doc/ipptools/outline.tex	(revision 4986)
@@ -0,0 +1,354 @@
+\documentclass[panstarrs,spec]{panstarrs}
+
+\begin{document}
+
+\begin{verbatim}
+** data concepts:
+
+url: unique filename resource location
+    http://machine/file
+    neb:storageID
+    file:/path/to/filename
+
+exp.ID: a unique exposure identifier
+    765432o.fits (MegaPrime)
+    20050901.001.fits (vysos?)
+     
+camera: name of camera
+    GPC-1
+    TC-3
+    MegaPrime
+
+class: highest valid data hierarchy level for the files
+    FPA
+    Chip
+    Cell
+
+class.ID: name of specific class entry (need not be unique over all cameras)
+    ccd00 (CFH12K)
+    chip03 (GPC)
+    MegaPrime (MegaPrime - class is FPA!)
+
+table.ID: unique table identifier (unique for all metadata FITS tables)
+    otis.9876234t.fits (?)
+
+table.type: name of metadata table
+    NewImages
+    PendingImages
+\end{verbatim}
+
+\newpage
+
+\begin{verbatim}
+** psTool outlines 
+
+new_images
+
+  USAGE: new_images 
+
+    - perform query on the summit web server for new images
+    - parse the returned list
+    - write data to the PendingImageFiles table in the Metadata DB
+
+    * PendingImageFiles: url, exp.ID, camera, class, class.ID, state
+    * Perl or C?
+    o this tool may either receive all needed info from the query,
+      or it may need to supply information based on the camera
+
+copy_image
+
+  USAGE: copy_image (url) (exp.ID) (camera) (class) (class.ID)
+  
+    - read image from the given url
+    - read camera recipe file (specifies output)
+    - write image to nebulous or filesystem
+    - write the data to the NewImageFiles table
+      (write the IPP URL, not the SUMMIT URL!)
+    - upon success, notify the summit web server for this file
+    - upon success, update status in PendingImageFiles table
+
+    * NewImageFiles: url, exp.ID, camera, class, class.ID
+    * Perl or C?
+    o target URL may be in Nebulous or filesystem, depending on camera recipe
+
+new_tables
+
+  USAGE: new_tables
+
+    - perform query on the summit web server for new tables
+    - parse the returned list
+    - write data to the PendingTables table in the Metadata DB
+
+    * PendingTables: url
+    * Perl or C?
+
+copy_table
+
+  USAGE: copy_table (url) (table.ID) (table.type)
+  
+    - read table from the given url
+    - determine table type (from header?)
+    - parse table data
+    - write table data to corresponding Metadata table
+    - write summary info to the MetadataTables table
+    - update status in PendingTables table
+    - upon success, notify the summit web server for this file
+
+    * MetadataTables: url, table.ID, table.type, date.copied
+    * Perl or C?
+    o tables are not camera-specific!
+
+\end{verbatim}
+
+\newpage
+
+\begin{verbatim}
+classify_image
+
+  USAGE: classify_image (url) 
+	 classify_image (exp.ID) (class.ID)
+
+    - if given (exp.ID + class.ID) find url from NewImageFiles table
+    - read image header
+    - determine image type
+    - write data to the RawImageFiles table
+    - select from NewExposures table, match on exp.ID
+    - select from RawImageFiles table, match on exp.ID
+    - if numbers of entries match
+      - write RawScienceExposure entry
+      - if (mosaic && type == OBJECT)
+	- write P1.Exposure entry
+      - else
+	- write P2.Exposure entry
+
+    o this program should have a user-only mode which
+      only writes the raw image file info to stdout
+      and does not update the DB.
+
+Phase.1
+
+  USAGE: Phase.1 (exp.ID) (version) (recipe) (out.url)
+	 Phase.1 (file) (version) (recipe) (out.url)
+	 Phase.1 (class.list) (version) (recipe) (out.url)
+
+    - if input from MDDB:
+      - select from RawImageFiles, match on exp.ID
+    - if input from FPA:
+      - read input data from header
+    - if input from class.list
+      - load list of files
+      - read input data from first header
+    - find exposure RA,DEC,Position Angle
+    - load reference stars 
+    - load rough astrometry data
+    - if guide stars on
+      - load guide star table
+      - convert tables to (X,Y),(R,D)
+    - else 
+      - select guide-star pixels
+      - read raster on guide-stars
+      - centroid on raster
+      - result is (X,Y),(R,D)
+    - imastro (solve for X,Y -> R,D)
+    - write output file (filename.P1.ver.smf)
+      * output file is header with astrometry, astrometry table, star table
+    - update P1.Exposures table
+    - write to P2.ImageFiles table
+    - write to P2.Exposures table
+
+Submit.P2
+
+  USAGE: Submit.P2 [-ID exp.ID] [-time start stop] [-camera camera] [-filter filter]  [-P1 version]
+
+    - must have at least one of -time or -ID
+    - select from RawScienceExposures, match on all retrictions
+    - select from RawImageFiles, match on exp.IDs
+    - write new entries in P2.ImageFiles, P2.Exposures
+
+    * if version is not supplied, use the highest for each?
+    * match on recipe?
+
+\end{verbatim}
+
+\newpage
+
+\begin{verbatim}
+Phase.2
+
+  USAGE: Phase.2 (url)
+	 Phase.2 (exp.ID + class.ID)
+
+    - if (exp.ID + class.ID), get url from P2.ImageFiles
+    - read file
+    - select matching detrend images
+    - bias
+    - dark
+    - non-linear
+    - convolve flat
+    - flatten
+    - mask
+    - splice
+    - measure fringe amplitude
+    - subtract fringe frame
+    - subtract smooth background
+    * note: propagate noise map for steps above!
+    - psphot
+    - load reference stars
+    - load astrometry info
+    - imastro (X,Y -> R,D)
+    - imphoto (m -> M)
+    - write output images
+    - write output object files
+    - write summary stats to P2.ImageFiles
+    - check P2.ImageFiles & P2.Exposures for P2 completion
+    - write P2.Exposures if all ImageFiles are done
+
+    * are the last two steps a race condition?
+    * should a (single) separate task check P2.ImageFiles and P2.Exposures?
+
+Submit.P3
+
+  USAGE: Submit.P3 [-ID exp.ID] [-time start stop] [-camera camera] [-filter filter] [-P2 version]
+
+    - must have at least one of -time or -ID
+    - select from RawScienceExposures, match on all retrictions
+    - select from P2.Exposures, match on P2.version, (state == done)
+    - write new entries in P3.Exposures
+
+    * if version is not supplied, use the highest for each?
+    * match on recipe?
+
+Phase.3
+
+  USAGE: Phase.3 (exp.ID)
+	 Phase.3 (FPA file)
+	 Phase.3 (list of chips)
+
+    - find input files
+    - read objects
+    - read astrometry data
+    - load reference stars
+    - mosastro
+    - mosphoto
+    - mosfringe / mossky??
+    - write output images
+    - write output files
+
+    - update P3.Exposures
+    - addstar? (write to DVO)
+\end{verbatim}
+
+\newpage
+
+\begin{verbatim}
+Detrend.init
+
+  USAGE: Detrend.init type label [-time start stop] [-filter filter] [others] [-group group.ID]
+
+    - if group.IDs
+      - select from RawDetrendExposures match on exp.ID
+    - else
+      - select from RawDetrendExposures match on criteria
+    - set the det.ID based on type,label,criteria
+    - add an entry to the MasterDetrendRun table (iteration == 0, state == new)
+
+    * some criteria are required (eg. light type -> filter)
+    * allow multiple groupIDs, if not conflicting types / filters?
+
+Detrend.get.input.exposures
+
+  USAGE: Detrend.get.input.exposures 
+
+    - select from MasterDetrendRun where (state == new)
+    - loop over selected detrend runs
+      - select from RawDetrendExposures exposures matching criteria
+      - add an entry to the MasterDetrendFrame table
+      - add entries to the InputDetrendExposures table (state == new)
+    - update MasterDetrendRun (state == init)
+
+    * this program could be defined to work on the det.ID, in which
+      case a second process is needed to select the detrend runds from
+      the table.  (probably not the better choice).
+
+Detrend.get.image.files
+
+  USAGE: Detrend.get.image.files
+
+    - select from InputDetrendExposures table where (state == new)
+    - loop over selected detrend exposures
+      - select from RawImageFiles match by exp.ID
+      - add entries to the InputDetrendImageFiles table (state == new)
+    - update InputDetrendExposures (state == init)
+
+    * this program could be defined to work on the exp.ID, in which
+      case a second process is needed to select the exposures from the
+      table.  (probably not the better choice).
+
+Detrend.process
+
+  USAGE: Detrend.process (url) (recipe) (type?)
+
+    - load the image
+    - perform the preprocessing (depends on the detrend type)
+    - write output image
+    - update the InputDetrendImageFiles table
+    - check the InputDetrendExposures table
+    - if Nfiles == Ndone
+      - update the InputDetrendExposure 
+    - check the MasterDetrendFrames table
+    - if Nframes == Ndone
+      - update the MasterDetrendFrames table (state == proc)
+\end{verbatim}
+
+\newpage
+
+\begin{verbatim}
+Detrend.stack
+
+  USAGE: Detrend.stack (det.ID) (version) (iteration) (class.ID)
+	 Detrend.stack (list of files)
+
+    - if (det.ID, etc) given
+      - select from InputDetrendExposure match det.ID
+
+    - load & scale each input image	 
+    - construct stacking
+    - write entry in MasterDetrendImages
+    - check MasterDetrendFrames
+    - if (Nclass == Ndone)
+      - update MasterDetrendFrames (state == stack)
+
+Detrend.merge
+
+  USAGE: Detrend.merge (det.ID) (version) (iteration)
+
+    - load master detrend image stats
+    - calculate appropriate normalization
+    - update MasterDetrendFrames table
+
+Detrend.residuals
+
+  USAGE: Detrend.residuals (url) (det.ID) (version) (iteration) (recipe) (type)
+
+    - load image
+    - select appropriate master 
+    - apply detrend master to image
+    - measure statistics
+    - write image
+    - update ResidImageFiles table     
+
+Detrend.assess 
+
+  USAGE: Detrend.assess (det.ID) (version) (iteration)
+
+    - select from ResidImageTable match on det.ID,version,iteration
+    - calculate summary statistics for each frame
+    - calculate summary statistics for master frame
+    - do input images pass?
+    - does master frame pass?
+    - update ResidExposures (does not exit?)
+    - update MasterDetrendFrames 
+    - update MasterDetrendRun
+
+\end{verbatim}
+\end{document}
Index: trunk/doc/ipptools/pstask.tex
===================================================================
--- trunk/doc/ipptools/pstask.tex	(revision 4976)
+++ trunk/doc/ipptools/pstask.tex	(revision 4986)
@@ -638,5 +638,5 @@
 
 Phase.2
-  input: (url) or (exp ID + class I)
+  input: (url) or (exp ID + class ID)
 
   This program reads in the selected image file, determines the
