Index: trunk/tools/run.relastro
===================================================================
--- trunk/tools/run.relastro	(revision 34869)
+++ trunk/tools/run.relastro	(revision 34870)
@@ -1,52 +1,25 @@
 #!/bin/csh -f
 
-set catdir_3pi = /data/ipp064.0/eugene/3pi.20111229/catdir.3pi
-
-# run update-objects on the whole sky
-if (1) then
-  # for a test, only run -pm
-  # set options = "-update-objects -pmpar"
-  set options = "-update-objects -pm"
-  set options = "$options -D PM_DT_MIN 1.0"
-  set options = "$options -D PAR_FACTOR_MIN 0.25"
-  set options = "$options -update"
-  set options = "$options -parallel"
-  set options = "$options -v"
-
-  set region = "-region 0 360 -60 90"
-  
-  # run relastro -update-objects
-  echo -n "--- starting relastro $catdir_3pi ---"; date
-  echo relastro $options $region -D CATDIR $catdir_3pi
-  relastro $options $region -D CATDIR $catdir_3pi
+if ($#argv != 5) then 
+  echo "USAGE: run.relastro (catdir) (Rmin) (Rmax) (Dmin) (Dmax)"
+  exit 2
 endif
 
-# run update-offsets for 300-335
-if (0) then
-  set options = "-update-offsets"
-  set options = "$options -D RELASTRO_SRC_MEAS_TOOFEW 1"
-  set options = "$options -D RELASTRO_SIGMA_LIM 0.1"
-  set options = "$options -nloop 6"
-  set options = "$options -basic-image-search"
-  set options = "$options -reset"
-  set options = "$options -update"
-  set options = "$options -parallel"
-  set options = "$options -max-density 3000"
-  set options = "$options -threads 4"
-  set options = "$options -v"
+set REALRUN = 0
 
-  set ra_min = 300
-  set ra_max = $ra_min
-  @ ra_max += 35
-  set region = "-region $ra_min $ra_max -60 60"
-  
-  # run relastro -update-chips
-  echo -n "--- starting relastro $catdir_3pi ---"; date
-  echo relastro $options $region -D CATDIR $catdir_3pi
-  relastro $options $region -D CATDIR $catdir_3pi
-endif
+set  catdir = $argv[1]
+set  ra_min = $argv[2]
+set  ra_max = $argv[3]
+set dec_min = $argv[4]
+set dec_max = $argv[5]
 
+alias run.relastro \
+  'echo -n "--- starting relastro $catdir --- "; date; \
+   echo          relastro $options $region -D CATDIR $catdir; \
+   if ($REALRUN) relastro $options $region -D CATDIR $catdir'
+
+# -update-chips : determine improved astrometry calibrations
 # try 1000 meas per deg^2, but if memory if available, go to more
-if (0) then
+if (1) then
   set options = "-update-chips"
   set options = "$options -D RELASTRO_SRC_MEAS_TOOFEW 1"
@@ -56,38 +29,39 @@
   set options = "$options -reset"
   set options = "$options -update"
-  set options = "$options -parallel"
   set options = "$options -max-density 3000"
   set options = "$options -threads 4"
   set options = "$options -v"
 
-  # set ra_min = 0
-  # set ra_min = 150
-  set ra_min = 300
-  while ($ra_min < 360) 
-    set ra_max = $ra_min
-    @ ra_max += 35
-    set region = "-region $ra_min $ra_max -60 60"
-  
-    # test region (SDSS)
-    # set region = "-region 120 140 0 20"
-    # set region = "-region 180 240 10 50"
+  # enable parallel operations for parallel databases
+  # set options = "$options -parallel"
 
-    # run relastro -update-chips
-    echo -n "--- starting relastro $catdir_3pi ---"; date
-    echo relastro $options $region -D CATDIR $catdir_3pi
-    relastro $options $region -D CATDIR $catdir_3pi
-
-    @ ra_min += 30
-    # exit
-  end
-
-  # pole region 
-  set region = "-region 0 360 55 90"
-
-  # run relastro -update-chips
-  echo -n "--- starting relastro $catdir_3pi ---"; date
-  echo relastro $options $region -D CATDIR $catdir_3pi
-  relastro $options $region -D CATDIR $catdir_3pi
+  set region = "-region $ra_min $ra_max $dec_min $dec_max"
+  run.relastro
+  if ($status) then
+    echo "ERROR : failure running relastro"
+    echo -n "--- done with relastro --- "; date
+    exit 1
+  endif
 endif
 
-echo -n "--- done with relastro ---"; date
+# -update-objects : determine improved positions, including parallax and proper motions
+if (1) then
+  set options = "-update-objects -pmpar"
+  set options = "$options -D PM_DT_MIN 1.0"
+  set options = "$options -D PAR_FACTOR_MIN 0.25"
+  set options = "$options -update"
+  set options = "$options -v"
+
+  # enable parallel operations for parallel databases
+  # set options = "$options -parallel"
+
+  set region = "-region $ra_min $ra_max $dec_min $dec_max"
+  run.relastro
+  if ($status) then
+    echo "ERROR : failure running relastro"
+    echo -n "--- done with relastro --- "; date
+    exit 1
+  endif
+endif
+
+echo -n "--- done with relastro --- "; date
Index: trunk/tools/run.relphot
===================================================================
--- trunk/tools/run.relphot	(revision 34869)
+++ trunk/tools/run.relphot	(revision 34870)
@@ -1,6 +1,21 @@
 #!/bin/csh -f
 
-set catdir_3pi = /data/ipp064.0/eugene/3pi.20111229/catdir.3pi
-set REALRUN = 1
+if ($#argv != 5) then 
+  echo "USAGE: run.relphot (catdir) (Rmin) (Rmax) (Dmin) (Dmax)"
+  exit 2
+endif
+
+set REALRUN = 0
+
+set  catdir = $argv[1]
+set  ra_min = $argv[2]
+set  ra_max = $argv[3]
+set dec_min = $argv[4]
+set dec_max = $argv[5]
+
+alias run.relphot \
+  'echo -n "--- starting relphot $catdir --- "; date; \
+   echo          relphot $options $region -D CATDIR $catdir; \
+   if ($REALRUN) relphot $options $region -D CATDIR $catdir'
 
 # try 2000 meas per deg^2
@@ -13,12 +28,6 @@
   set options = "$options -D IMAGE_OFFSET 2.0"
 
-  # some cpt files on some machines did not get updates -- force them all to update!
-  # (turn off -reset and run iterations)
-  # set options = "$options -nloop 0"
-  # set options = "$options -reset"
-
   set filters = "g,r,i,z,y"
 
-  # trying again : I had to re-run setphot, so I am re-running relphot (bump up the nloop & no -reset)
   set options = "$options -nloop 25"
 
@@ -27,196 +36,22 @@
   set options = "$options -update"
   set options = "$options -threads 4"
-  set options = "$options -parallel"
   set options = "$options -statmode WT_MEAN"
   set options = "$options -max-density 2000"
-  set options = "$options -update-catformat PS1_V3"
 
-  # re-run the last 2 slices + pole with lower density
-  # rest was done successfully with 3000 deg^-2
-  set ra_min = 0
-  # set ra_min = 300
-  while ($ra_min < 360) 
-    set ra_max = $ra_min
-    @ ra_max += 35
+  # activate parallel mode when catdir is parallel
+  # set options = "$options -parallel"
 
-    set region = "-region $ra_min $ra_max -60 60"
-  
-    if (($ra_min == 240) || ($ra_min == 270)) then 
-      set region = "-region $ra_min $ra_max -60 0"
+  # option to change the schema
+  # set options = "$options -update-catformat PS1_V3"
 
-      # run relphot g,r,i,z,y
-      echo -n "--- starting relphot $catdir_3pi ---"; date
-      echo relphot $filters $options $region -D CATDIR $catdir_3pi
-      if ($REALRUN) relphot $filters $options $region -D CATDIR $catdir_3pi
-      set region = "-region $ra_min $ra_max -5 60"
-  
-      # run relphot g,r,i,z,y
-      echo -n "--- starting relphot $catdir_3pi ---"; date
-      echo relphot $filters $options $region -D CATDIR $catdir_3pi
-      if ($REALRUN) relphot $filters $options $region -D CATDIR $catdir_3pi
-
-      @ ra_min += 30
-      continue
-    endif
-
-    # run relphot g,r,i,z,y
-    echo -n "--- starting relphot $catdir_3pi ---"; date
-    echo relphot $filters $options $region -D CATDIR $catdir_3pi
-    if ($REALRUN) relphot $filters $options $region -D CATDIR $catdir_3pi
-
-    @ ra_min += 30
-  end
-
-  # pole region 
-  set region = "-region 0 360 55 90"
-  
-  # run relphot g,r,i,z,y
-  echo -n "--- starting relphot $catdir_3pi ---"; date
-  echo relphot $filters $options $region -D CATDIR $catdir_3pi
-  if ($REALRUN) relphot $filters $options $region -D CATDIR $catdir_3pi
-
-  echo -n "--- starting dvo.stats $catdir_3pi ---"; date
-  echo dvo.stats.client.sh 0 360 -45 90 allsky.stats.20120518.v0.fits
-  if ($REALRUN) dvo.stats.client.sh 0 360 -45 90 allsky.stats/allsky.stats.20120530.v0.fits
+  set region = "-region $ra_min $ra_max $dec_min $dec_max"
+  run.relphot
+  if ($status) then
+    echo "ERROR : failure running relphot"
+    echo -n "--- done with relphot --- "; date
+    exit 1
+  endif
 endif
 
-# redo (had a segfault)
-if (0) then
-  relphot g,r,i,z,y,J,H,K -imfreeze -mosaic -D MAG_LIM 32.0 -D SIGMA_LIM 0.1 -D STAR_TOOFEW 1 -D STAR_CHISQ 20.0 -D IMAGE_OFFSET 2.0 -nloop 25 -D CAMERA gpc1 -basic-image-search -update -threads 4 -parallel -statmode WT_MEAN -max-density 3000 -update-catformat PS1_V3 -region 30 65 -60 60 -D CATDIR /data/ipp064.0/eugene/3pi.20111229/catdir.3pi >& logs/log.relphot.20120420.t0 &
-endif
-
-if (0) then
-  relphot g,r,i,z,y,J,H,K -imfreeze -mosaic -D MAG_LIM 32.0 -D SIGMA_LIM 0.1 -D STAR_TOOFEW 1 -D STAR_CHISQ 20.0 -D IMAGE_OFFSET 2.0 -nloop 25 -D CAMERA gpc1 -basic-image-search -update -threads 4 -parallel -statmode WT_MEAN -max-density 3000 -update-catformat PS1_V3 -region 270 305 -5 60 -D CATDIR /data/ipp064.0/eugene/3pi.20111229/catdir.3pi >& logs/log.relphot.20120420.t1 &
-endif 
-
-# test region (all filters)
-if (0) then
-  set options = "-imfreeze -mosaic"
-  set options = "$options -D MAG_LIM 32.0"
-  set options = "$options -D SIGMA_LIM 0.1"
-  set options = "$options -D STAR_TOOFEW 1"
-  set options = "$options -D STAR_CHISQ 20.0"
-  set options = "$options -D IMAGE_OFFSET 2.0"
-  set options = "$options -nloop 25"
-  set options = "$options -D CAMERA gpc1"
-  set options = "$options -basic-image-search"
-  set options = "$options -update"
-  # set options = "$options -reset"
-  set options = "$options -parallel"
-  set options = "$options -statmode WT_MEAN"
-  set options = "$options -max-density 3000"
-  set options = "$options -update-catformat PS1_V3"
-
-  # run relphot g,r,i,z,y
-  echo -n "--- starting relphot $catdir_3pi ---"; date
-  set region = "-region 310 320 0 10"
-  echo relphot g,r,i,z,y $options $region -D CATDIR $catdir_3pi
-  if ($REALRUN) relphot g,r,i,z,y $options $region -D CATDIR $catdir_3pi
-
-  # echo dvo.stats.client.sh 0 360 60 90 pole.stats.20120430.v5.fits >& logs/log.dvostats.20120430.v5
-  # if ($REALRUN) dvo.stats.client.sh 0 360 60 90 pole.stats.20120430.v5.fits >& logs/log.dvostats.20120430.v5
-endif
-
-# g-test allsky (3 passes)
-if (0) then
-  set options = "-imfreeze -mosaic"
-  set options = "$options -D MAG_LIM 32.0"
-  set options = "$options -D SIGMA_LIM 0.1"
-  set options = "$options -D STAR_TOOFEW 1"
-  set options = "$options -D STAR_CHISQ 20.0"
-  set options = "$options -D IMAGE_OFFSET 2.0"
-  set options = "$options -nloop 25"
-  set options = "$options -D CAMERA gpc1"
-  set options = "$options -basic-image-search"
-  set options = "$options -update"
-  set options = "$options -threads 4"
-  set options = "$options -parallel"
-  set options = "$options -statmode WT_MEAN"
-  set options = "$options -max-density 3000"
-  set options = "$options -update-catformat PS1_V3"
-
-  # run relphot g (-65 to 95 -- 160 deg)
-  echo -n "--- starting relphot $catdir_3pi ---"; date
-  set region = "-region -65 95 -45 90"
-  echo relphot g $options $region -D CATDIR $catdir_3pi
-  if ($REALRUN) relphot g $options $region -D CATDIR $catdir_3pi
-  
-  #  
-  # # run relphot g (85 to 245 -- 160 deg)
-  # echo -n "--- starting relphot $catdir_3pi ---"; date
-  # set region = "-region 85 245 -45 90"
-  # echo relphot g $options $region -D CATDIR $catdir_3pi
-  # if ($REALRUN) relphot g $options $region -D CATDIR $catdir_3pi
-  # 
-  # # run relphot g (240 to 300 -- 60 deg)
-  # echo -n "--- starting relphot $catdir_3pi ---"; date
-  # set region = "-region 240 300 -45 90"
-  # echo relphot g $options $region -D CATDIR $catdir_3pi
-  # if ($REALRUN) relphot g $options $region -D CATDIR $catdir_3pi
-endif
-
-# test region (just g)
-if (0) then
-  set region = "-region 210 270 -20 5"
-  
-  set options = "-imfreeze -mosaic"
-  set options = "$options -D MAG_LIM 32.0"
-  set options = "$options -D SIGMA_LIM 0.1"
-  set options = "$options -D STAR_TOOFEW 1"
-  set options = "$options -D STAR_CHISQ 20.0"
-  set options = "$options -D IMAGE_OFFSET 2.0"
-  set options = "$options -nloop 25"
-  set options = "$options -D CAMERA gpc1"
-  set options = "$options -basic-image-search"
-  set options = "$options -update"
-  set options = "$options -threads 4"
-  set options = "$options -parallel"
-  set options = "$options -statmode WT_MEAN"
-  set options = "$options -max-density 3000"
-  set options = "$options -update-catformat PS1_V3"
-  # set options = "$options -plotdelay 1.0"
-
-  # run relphot g,r,i,z,y
-  echo -n "--- starting relphot $catdir_3pi ---"; date
-  echo relphot g $options $region -D CATDIR $catdir_3pi
-  if ($REALRUN) relphot g $options $region -D CATDIR $catdir_3pi
-endif
-
-if (0) then
-  # run relphot -averages
-  echo -n "--- starting relphot $catdir_3pi ---"; date
-  set options = "-D CAMERA gpc1"
-  set options = "$options -basic-image-search"
-  set options = "$options -update"
-  set options = "$options -reset"
-  set options = "$options -parallel"
-  set options = "$options -statmode WT_MEAN"
-  echo relphot -averages $options $region -D CATDIR $catdir_3pi
-  if ($REALRUN) relphot -averages $options $region -D CATDIR $catdir_3pi
-endif
-
-echo -n "--- done with relphot ---"; date
-
-## Note from Eddie re overall zero point
-## I compare to each of JT's 8 absolutely calibrated fields.  I compute
-## for each field the best zero point bringing my and his data into
-## agreement.  I report the mean and standard deviations of those zero
-## points over the eight fields.  The sign of the mean is such that mean
-## = < ubercal - JT >, so that these values should be subtracted from the
-## noref2.fits zero points in order to absolutely calibrate them.
-## 
-## filter g: mean = -0.013, sigma =  0.013
-## filter r: mean =  0.012, sigma =  0.007
-## filter i: mean =  0.001, sigma =  0.006
-## filter z: mean = -0.016, sigma =  0.007
-## filter y: mean = -0.021, sigma =  0.010
-## 
-## I think we're going to be adding a hundredth uncertainty in quadrature
-## with everything else getting this right.  John trusts his MD09 data
-## most; that gives results different from what I've given here by about
-## -0.01 in all of the bands.  The choice of whether to average over the
-## 8 fields or just use MD09 depends on whether you believe it's an
-## absolute calibration or relative calibration problem; I don't know.
-## Since the ~1 hundredth scatter is comparable with what we think the
-## uncertainty in ubercal is, I'm recommending using the values above,
-## averaged over the 8 fields.
+echo -n "--- done with relphot --- "; date
+exit 0
Index: trunk/tools/run.setphot
===================================================================
--- trunk/tools/run.setphot	(revision 34869)
+++ trunk/tools/run.setphot	(revision 34870)
@@ -1,8 +1,37 @@
 #!/bin/csh -f
 
-set ubercal = ucalqv_noref.fits
-set catdir_3pi = ../3pi.20111229/catdir.3pi
+if ($#argv != 1) then 
+  echo "USAGE: run.setphot (catdir)"
+  exit 2
+endif
 
-echo -n "--- starting setphot $catdir_3pi ---"; date
+set REALRUN = 0
+
+set  catdir = $argv[1]
+set ubercal = ~ipp/ucalqw_noref.fits
+
+alias run.setphot \
+  'echo -n "--- starting setphot $catdir --- "; date; \
+   echo          setphot $options -D CATDIR $catdir $ubercal; \
+   if ($REALRUN) setphot $options -D CATDIR $catdir $ubercal'
+
+set options = ""
+set options = "$options -update"
+set options = "$options -ubercal"
+set options = "$options -no-metadata"
+
+# activate parallel mode when catdir is parallel
+# set options = "$options -parallel"
+
+# the new ubercal file includes Eddie's offsets relative to JT (so, no need to supply -zpt-offsets)
+run.setphot
+if ($status) then
+  echo "failed setphot"
+  echo -n "--- done with setphot ---"; date
+  exit 1
+endif
+echo -n "--- done with setphot ---"; date
+exit 0
+
 
 # old command lines with zpt offsets
@@ -10,9 +39,2 @@
 # setphot -images-only -parallel -reset -zpt-offsets g,r,i,z,y -0.013,+0.012,+0.001,-0.016,-0.021 -update -ubercal -no-metadata -D CATDIR $catdir_3pi $ubercal
 
-# the new ubercal file includes Eddie's offsets relative to JT (so, no need to supply -zpt-offsets)
-echo setphot -parallel -update -ubercal -no-metadata -D CATDIR $catdir_3pi $ubercal
-setphot -parallel -update -ubercal -no-metadata -D CATDIR $catdir_3pi $ubercal
-if ($status) then
-  echo "failed setphot"
-endif
-echo -n "--- done with setphot ---"; date
