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
