Index: /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/include/dvopsps.h
===================================================================
--- /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/include/dvopsps.h	(revision 36250)
+++ /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/include/dvopsps.h	(revision 36251)
@@ -3,4 +3,5 @@
 # include <signal.h>
 # include "mysql.h"
+# include "limits.h"
 
 # define DVO_MAX_PATH 1024
@@ -38,4 +39,10 @@
 int          PARALLEL_MANUAL;
 int          PARALLEL_SERIAL;
+
+char        *TIME_START;
+char        *TIME_END;
+
+int          PHOTCODE_START;
+int          PHOTCODE_END;
 
 char        *SINGLE_CPT;
Index: /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/src/initialize_dvopsps.c
===================================================================
--- /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/src/initialize_dvopsps.c	(revision 36250)
+++ /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/src/initialize_dvopsps.c	(revision 36251)
@@ -2,5 +2,5 @@
 
 void usage_dvopsps () {
-  fprintf (stderr, "USAGE: dvopsps (mode) [dbinfo] (mode) [options]\n");
+  fprintf (stderr, "USAGE: dvopsps (mode) [dbinfo] [options]\n");
   fprintf (stderr, "    mysql database info is supplied with these:\n");
   fprintf (stderr, "    -dbhost : database host machine\n");
@@ -11,9 +11,22 @@
   fprintf (stderr, "    -v : verbose mode\n");
   fprintf (stderr, "    -region Rmin Rmax Dmin Dmax\n");
+  fprintf (stderr, "    -cpt n0000/0000.00 : limit to the named cpt file\n");
   fprintf (stderr, "    -parallel : run in parallel mode\n");
+  fprintf (stderr, "    -insert-remote : in parallel mode, the client sends the data to the dbhost\n");
+  fprintf (stderr, "    -time-start YYYY/MM/DD,hh:mm:ss : limit detections to >= this time\n");
+  fprintf (stderr, "    -time-end   YYYY/MM/DD,hh:mm:ss : limit detections to <  this time\n");
+
+  fprintf (stderr, "    -photcode-start NN : limit detections to >= this photcode number\n");
+  fprintf (stderr, "    -photcode-end   NN : limit detections to <  this photcode number\n");
+  fprintf (stderr, "\n");
+
+  fprintf (stderr, " (mode) is one of detections, objects, skytable\n");
+
+  fprintf (stderr, "\n");
   fprintf (stderr, "    -h     : this help list\n");
   fprintf (stderr, "    -help  : this help list\n");
   fprintf (stderr, "    --h    : this help list\n");
   fprintf (stderr, "    --help : this help list\n");
+
   fprintf (stderr, "    Note that the dvo db can be specified by -D CATDIR (directory)\n");
   exit (2);
@@ -110,4 +123,42 @@
   if ((N = get_argument (argc, argv, "-insert-remote"))) {
     SAVE_REMOTE = FALSE;
+    remove_argument (N, &argc, argv);
+  }
+
+  TIME_START = NULL;
+  if ((N = get_argument (argc, argv, "-time-start"))) {
+    remove_argument (N, &argc, argv);
+    TIME_START = strcreate(argv[N]);
+    remove_argument (N, &argc, argv);
+    time_t TIME_START_SEC;
+    if (!ohana_str_to_time (TIME_START, &TIME_START_SEC)) {
+      fprintf (stderr, "error with starting time given by -time-start: %s\n", TIME_START);
+      exit (2);
+    }
+  }
+
+  TIME_END = NULL;
+  if ((N = get_argument (argc, argv, "-time-end"))) {
+    remove_argument (N, &argc, argv);
+    TIME_END = strcreate(argv[N]);
+    remove_argument (N, &argc, argv);
+    time_t TIME_END_SEC;
+    if (!ohana_str_to_time (TIME_END, &TIME_END_SEC)) {
+      fprintf (stderr, "error with starting time given by -time-end: %s\n", TIME_END);
+      exit (2);
+    }
+  }
+
+  PHOTCODE_START = 0;
+  if ((N = get_argument (argc, argv, "-photcode-start"))) {
+    remove_argument (N, &argc, argv);
+    PHOTCODE_START = atoi(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  PHOTCODE_END = INT_MAX;
+  if ((N = get_argument (argc, argv, "-photcode-end"))) {
+    remove_argument (N, &argc, argv);
+    PHOTCODE_END = atoi(argv[N]);
     remove_argument (N, &argc, argv);
   }
@@ -260,4 +311,42 @@
   } 
 
+  TIME_START = NULL;
+  if ((N = get_argument (argc, argv, "-time-start"))) {
+    remove_argument (N, &argc, argv);
+    TIME_START = strcreate(argv[N]);
+    remove_argument (N, &argc, argv);
+    time_t TIME_START_SEC;
+    if (!ohana_str_to_time (TIME_START, &TIME_START_SEC)) {
+      fprintf (stderr, "error with starting time given by -time-start: %s\n", TIME_START);
+      exit (2);
+    }
+  }
+
+  TIME_END = NULL;
+  if ((N = get_argument (argc, argv, "-time-end"))) {
+    remove_argument (N, &argc, argv);
+    TIME_END = strcreate(argv[N]);
+    remove_argument (N, &argc, argv);
+    time_t TIME_END_SEC;
+    if (!ohana_str_to_time (TIME_END, &TIME_END_SEC)) {
+      fprintf (stderr, "error with starting time given by -time-end: %s\n", TIME_END);
+      exit (2);
+    }
+  }
+
+  PHOTCODE_START = 0;
+  if ((N = get_argument (argc, argv, "-photcode-start"))) {
+    remove_argument (N, &argc, argv);
+    PHOTCODE_START = atoi(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  PHOTCODE_END = INT_MAX;
+  if ((N = get_argument (argc, argv, "-photcode-end"))) {
+    remove_argument (N, &argc, argv);
+    PHOTCODE_END = atoi(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
   VERBOSE = FALSE;
   if ((N = get_argument (argc, argv, "-v"))) {
Index: /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/src/insert_detections_dvopsps.c
===================================================================
--- /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/src/insert_detections_dvopsps.c	(revision 36250)
+++ /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/src/insert_detections_dvopsps.c	(revision 36251)
@@ -152,4 +152,11 @@
     if (VERBOSE)     { snprintf (tmpline, 1024, "%s -v",       command);                          strcpy (command, tmpline); }
     if (SAVE_REMOTE) { snprintf (tmpline, 1024, "%s -save %s", command, table->hosts[i].results); strcpy (command, tmpline); }
+
+    // some filters -- these are the detections we skip
+    if (TIME_START) { snprintf (tmpline, 1024, "%s -time-start %s", command, TIME_START); strcpy (command, tmpline); }
+    if (TIME_END)   { snprintf (tmpline, 1024, "%s -time-end %s",   command, TIME_END);   strcpy (command, tmpline); }
+    
+    if (PHOTCODE_START > 0)      { snprintf (tmpline, 1024, "%s -photcode-start %d", command, PHOTCODE_START); strcpy (command, tmpline); }
+    if (PHOTCODE_END <= INT_MAX) { snprintf (tmpline, 1024, "%s -photcode-end %d",   command, PHOTCODE_END);   strcpy (command, tmpline); }
 
     fprintf (stderr, "command: %s\n", command);
Index: /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c
===================================================================
--- /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c	(revision 36250)
+++ /branches/eam_branches/ipp-20130904/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c	(revision 36251)
@@ -29,4 +29,9 @@
   }
 
+  time_t TIME_START_SEC = 0;
+  time_t TIME_END_SEC   = 0;
+  if (TIME_START) ohana_str_to_time (TIME_START, &TIME_START_SEC); // we validate this in the args.c
+  if (TIME_END)   ohana_str_to_time (TIME_END,   &TIME_END_SEC);   // we validate this in the args.c
+
   for (i = 0; i < catalog[0].Naverage; i++) {
 
@@ -40,4 +45,12 @@
       Average *average = &catalog->average[i];
       Measure *measure = &catalog->measure[m + j];
+
+      // some filters -- these are the detections we skip
+      if (TIME_START && (measure->t < TIME_START_SEC)) continue;
+      if (TIME_END   && (measure->t >=  TIME_END_SEC)) continue;
+
+      if (measure->photcode < PHOTCODE_START) continue;
+      if (measure->photcode >=  PHOTCODE_END) continue;
+
       PhotCode *code = GetPhotcodebyCode(measure->photcode);
 
@@ -87,4 +100,7 @@
 }
 
+time_t TIME_START_SEC = 0;
+time_t TIME_END_SEC   = INT_MAX;
+
 int insert_detections_dvopsps_catalog (Catalog *catalog, MYSQL *mysql) {
 
@@ -108,4 +124,7 @@
   int status = TRUE;
 
+  if (TIME_START) ohana_str_to_time (TIME_START, &TIME_START_SEC); // we validate this in the args.c
+  if (TIME_END)   ohana_str_to_time (TIME_END,   &TIME_END_SEC);   // we validate this in the args.c
+
   // NOTE for testing, just do a few objects
   if (!mysql) {
@@ -121,6 +140,15 @@
     for (j = 0; j < average[i].Nmeasure; j++) {
 
+      off_t Nmeas = m + j;
+
+      // some filters -- these are the detections we skip (not an error, just skipped)
+      if (TIME_START && (measure[Nmeas].t < TIME_START_SEC)) continue;
+      if (TIME_END   && (measure[Nmeas].t >=  TIME_END_SEC)) continue;
+  
+      if (measure[Nmeas].photcode < PHOTCODE_START) continue;
+      if (measure[Nmeas].photcode >=  PHOTCODE_END) continue;
+
       // XXX check return status
-      if (!insert_detections_mysql_value (&buffer, &average[i], &measure[m+j])) {
+      if (!insert_detections_mysql_value (&buffer, &average[i], &measure[Nmeas])) {
 	fprintf (stderr, "failure to insert detections in mysql\n");
 	status = FALSE;
Index: /branches/eam_branches/ipp-20130904/Ohana/src/relphot/src/setMrelCatalog.c
===================================================================
--- /branches/eam_branches/ipp-20130904/Ohana/src/relphot/src/setMrelCatalog.c	(revision 36250)
+++ /branches/eam_branches/ipp-20130904/Ohana/src/relphot/src/setMrelCatalog.c	(revision 36251)
@@ -135,5 +135,5 @@
 
       // are we a PS1 exposure photcode?
-      if ((measure[k].photcode >= 10000) && (measure[k].photcode <= 10500)) {
+      if ((measureT[k].photcode >= 10000) && (measureT[k].photcode <= 10500)) {
 	NexpPS1 ++;
       }
