Index: trunk/Ohana/src/opihi/dvo/dmags.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/dmags.c	(revision 4585)
+++ trunk/Ohana/src/opihi/dvo/dmags.c	(revision 4679)
@@ -7,5 +7,5 @@
   int i, j, m, i1, i3, N1, N3, N;
   int Npts, NPTS, mode[3];
-  int Nsec, Nregions;
+  int Nsec, Nregions, KeepNulls;
 
   PhotCode *code[3];
@@ -33,4 +33,10 @@
   if (!SetPhotSelections (&argc, argv, 3)) goto usage;
 
+  KeepNulls = FALSE;
+  if (N = get_argument (argc, argv, "-nulls")) {
+    KeepNulls = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
   /* interpret required command-line arguments: dmags F1 - F2 : F3 */
   if (argc != 6) { goto usage; }
@@ -40,5 +46,5 @@
   if (!GetPhotcodeInfo (argv[3], &code[1], &mode[1])) goto usage;
   if (!GetPhotcodeInfo (argv[5], &code[2], &mode[2])) goto usage;
-  if (!TestPhotSelections (&code[0], MEAS_ZERO)) goto escape;
+  if (!TestPhotSelections (&code[0], &mode[0], MEAS_ZERO)) goto escape;
 
   /* load region corresponding to selection above */
@@ -79,5 +85,13 @@
       SetSelectionParam (2);
       M3 = ExtractMagnitudes (code[2], mode[2], &catalog.average[i], &catalog.secfilt[i*Nsec], &catalog.measure[m], &N3);
-      if (N3 == 0) goto skip;
+      if (N3 == 0) {
+	if (KeepNulls) {
+	  ALLOCATE (M3, double, 1);
+	  N3 = 1;
+	  M3[0] = NO_MAG;
+	} else {
+	  goto skip;
+	}
+      }
 
       for (i1 = 0; i1 < N1; i1++) {
