Index: /trunk/Ohana/src/imregister/imreg/db.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/db.c	(revision 2453)
+++ /trunk/Ohana/src/imregister/imreg/db.c	(revision 2454)
@@ -71,6 +71,6 @@
   table.header = &theader;
   if (!fits_fread_header (f, &header))                  escape (UNLOCK, "ERROR: can't read primary header"); 
-  if (!fits_fread_matrix (f, &matrix, &header))         escape (UNLOCK, "ERROR: can't read primary header");
-  if (!fits_fread_ftable (f, &table, "IMAGE_DATABASE")) escape (UNLOCK, "ERROR: can't read primary header");
+  if (!fits_fread_matrix (f, &matrix, &header))         escape (UNLOCK, "ERROR: can't read primary matrix");
+  if (!fits_fread_ftable (f, &table, "IMAGE_DATABASE")) escape (UNLOCK, "ERROR: can't read table");
 
   /* convert to internal format */
@@ -81,5 +81,5 @@
 
   if (!ConvertStruct ((char *) image, sizeof (RegImage), Nimage, "regimage"))
-    escape (UNLOCK, "ERROR: can't read primary header"); 
+    escape (UNLOCK, "ERROR: can't convert data"); 
 
   return (1);
Index: /trunk/Ohana/src/imregister/photreg/args.photreg.c
===================================================================
--- /trunk/Ohana/src/imregister/photreg/args.photreg.c	(revision 2453)
+++ /trunk/Ohana/src/imregister/photreg/args.photreg.c	(revision 2454)
@@ -6,8 +6,9 @@
 int regargs (int argc, char **argv, PhotPars *newdata) {
 
+  int *list, Nlist;
   int N, required, Ntimes;
   double dtime;
   unsigned long *tstart, *tstop;
-  PhotCode *photcode;
+  PhotCode *photcode, *depcode;
 
   ConfigInit (&argc, argv);
@@ -106,12 +107,16 @@
   */
   
+  /* find first (!) dep photcode which is equivalent to this code */
+  list = GetPhotcodeEquivList (photcode[0].code, &Nlist);
+  depcode = GetPhotcodebyCode (list[0]);
+
   newdata[0].photcode = photcode[0].code;
   newdata[0].refcode  = photcode[0].equiv;
-  newdata[0].K        = photcode[0].K;
-  newdata[0].X        = photcode[0].X;
+  newdata[0].X        = photcode[0].X[0];
   newdata[0].c1       = photcode[0].c1;
   newdata[0].c2       = photcode[0].c2;
   
-  newdata[0].ZPo      = 0.001*photcode[0].C;
+  newdata[0].K        = depcode[0].K;
+  newdata[0].ZPo      = 0.001*photcode[0].C + 0.001*depcode[0].C;
   if (output.offset) newdata[0].ZP += newdata[0].ZPo;
 }
@@ -125,4 +130,6 @@
    
    photreg -photcode B -zp 26.1 -dzp 0.02 -date 2003/1/1,10:00:00 -Nmeas 5 -Ntime 1 -db trans
+   photreg -photcode B -zp 26.1 -dzp 0.02 -date 2003/1/1,10:00:00 -Nmeas 5 -Ntime 1 -db trans
+
    photsearch -db trans
    photsearch -db phot
Index: /trunk/Ohana/src/imregister/photreg/getImageData.c
===================================================================
--- /trunk/Ohana/src/imregister/photreg/getImageData.c	(revision 2453)
+++ /trunk/Ohana/src/imregister/photreg/getImageData.c	(revision 2454)
@@ -62,5 +62,5 @@
   sprintf (photcode, "%s.%s.%02d", detector, filter, ccd);
   if (!(criteria.photcode = GetPhotcodeCodebyName (photcode))) {
-    fprintf (stderr, "ERROR: photcode not found table\n");
+    fprintf (stderr, "ERR: photcode not found table\n");
     exit (1);
   }
Index: /trunk/Ohana/src/imregister/photreg/output.c
===================================================================
--- /trunk/Ohana/src/imregister/photreg/output.c	(revision 2453)
+++ /trunk/Ohana/src/imregister/photreg/output.c	(revision 2454)
@@ -2,4 +2,6 @@
 # include "photreg.h"
 
+static char PhotError[] = "unknown";
+static char PhotNA[] = "unknown";
 static char *ASCIIName = (char *) NULL;
 
@@ -33,5 +35,5 @@
 void DumpFitsBintable (char *filename, PhotPars *photdata, int *match, int Nmatch) {
 
-  int i, j, Nx;
+  int i, j;
   Header header, theader;
   Matrix matrix;
@@ -65,6 +67,6 @@
   FILE *f;
   char *startstr, *stopstr, *datestr, *line;
-  char *c1, *c2, *code;
-  int i, n;
+  char *c1, *c2, *code, *photsys;
+  int i;
   unsigned int tsecond;
 
@@ -87,17 +89,18 @@
      
   /* define table layout */
-  fits_define_table_column (&theader, "F8.4", "ZP_OBS",     "measured zero point",       "mag");
-  fits_define_table_column (&theader, "F8.4", "ZP_REF",     "nominal zero point",        "mag");
-  fits_define_table_column (&theader, "F7.4", "ZP_ERR",     "error on zero point",       "mag");
-  fits_define_table_column (&theader, "F7.3", "C_AIRMASS",  "airmass coeff",             "mag per airmass"); 
-  fits_define_table_column (&theader, "F6.3", "C_COLOR",    "color coeff",               "mag per mag");
-  fits_define_table_column (&theader, "A20",  "START_TIME", "start time of measurement", "yyyy/mm/dd,hh:mm:ss");
-  fits_define_table_column (&theader, "A20",  "STOP_TIME",  "stop time of measurement",  "yyyy/mm/dd,hh:mm:ss");
-  fits_define_table_column (&theader, "A12",  "C1_NAME",    "filter 1 for color",        "");
-  fits_define_table_column (&theader, "A12",  "C2_NAME",    "filter 2 for color",        "");
-  fits_define_table_column (&theader, "I6",   "NSTARS",     "number of stars used",      "");
-  fits_define_table_column (&theader, "I6",   "NTIMES",     "number of unique images",   "");
-  fits_define_table_column (&theader, "A12",  "FILTER",     "filter",                    "");
-  fits_define_table_column (&theader, "A70",  "LABEL",      "data label",                "");
+  fits_define_table_column (&theader, "F8.4", "ZP_OBS",       "measured zero point",       "mag");
+  fits_define_table_column (&theader, "F8.4", "ZP_REF",       "nominal zero point",        "mag");
+  fits_define_table_column (&theader, "F7.4", "ZP_ERR",       "error on zero point",       "mag");
+  fits_define_table_column (&theader, "F7.3", "C_AIRMASS",    "airmass coeff",             "mag per airmass"); 
+  fits_define_table_column (&theader, "F6.3", "C_COLOR",      "color coeff",               "mag per mag");
+  fits_define_table_column (&theader, "A20",  "START_TIME",   "start time of measurement", "yyyy/mm/dd,hh:mm:ss");
+  fits_define_table_column (&theader, "A20",  "STOP_TIME",    "stop time of measurement",  "yyyy/mm/dd,hh:mm:ss");
+  fits_define_table_column (&theader, "A12",  "C1_NAME",      "filter 1 for color",        "");
+  fits_define_table_column (&theader, "A12",  "C2_NAME",      "filter 2 for color",        "");
+  fits_define_table_column (&theader, "I6",   "NSTARS",       "number of stars used",      "");
+  fits_define_table_column (&theader, "I6",   "NTIMES",       "number of unique images",   "");
+  fits_define_table_column (&theader, "A12",  "INT_PHOT_SYS", "internal photom system",    "");
+  fits_define_table_column (&theader, "A12",  "REF_PHOT_SYS", "reference photom system",   "");
+  fits_define_table_column (&theader, "A70",  "LABEL",        "data label",                "");
   
   /* define TNULL, TNVAL values */
@@ -113,20 +116,22 @@
   fits_modify (&theader, "TNULL10", "%s", 1, "NULL");  /* NSTARS     */
   fits_modify (&theader, "TNULL11", "%s", 1, "NULL");  /* NTIMES     */
-  fits_modify (&theader, "TNULL12", "%s", 1, "NULL");  /* FILTER     */
-  fits_modify (&theader, "TNULL13", "%s", 1, "NULL");  /* LABEL      */
-
-  fits_modify (&theader, "TNVAL1",  "%s", 1, "Inf");   /* ZP_OBS     */
-  fits_modify (&theader, "TNVAL2",  "%s", 1, "Inf");   /* ZP_REF     */
-  fits_modify (&theader, "TNVAL3",  "%s", 1, "Inf");   /* ZP_ERR     */
-  fits_modify (&theader, "TNVAL4",  "%s", 1, "Inf");   /* C_AIRMASS  */
-  fits_modify (&theader, "TNVAL5",  "%s", 1, "Inf");   /* C_COLOR    */
-  fits_modify (&theader, "TNVAL6",  "%s", 1, "NA");    /* START_TIME */
-  fits_modify (&theader, "TNVAL7",  "%s", 1, "NA");    /* STOP_TIME  */
-  fits_modify (&theader, "TNVAL8",  "%s", 1, "NA");    /* C1_NAME    */
-  fits_modify (&theader, "TNVAL9",  "%s", 1, "NA");    /* C2_NAME    */
-  fits_modify (&theader, "TNVAL10", "%s", 1, "NA");    /* NSTARS     */
-  fits_modify (&theader, "TNVAL11", "%s", 1, "NA");    /* NTIMES     */
-  fits_modify (&theader, "TNVAL12", "%s", 1, "NA");    /* FILTER     */
-  fits_modify (&theader, "TNVAL13", "%s", 1, "NA");    /* LABEL      */
+  fits_modify (&theader, "TNULL12", "%s", 1, "NULL");  /* INT_PHOT_SYS */
+  fits_modify (&theader, "TNULL13", "%s", 1, "NULL");  /* REF_PHOT_SYS */
+  fits_modify (&theader, "TNULL14", "%s", 1, "NULL");  /* LABEL      */
+
+  fits_modify (&theader, "TNVAL1",  "%s", 1, "Inf");   /* ZP_OBS       */
+  fits_modify (&theader, "TNVAL2",  "%s", 1, "Inf");   /* ZP_REF       */
+  fits_modify (&theader, "TNVAL3",  "%s", 1, "Inf");   /* ZP_ERR       */
+  fits_modify (&theader, "TNVAL4",  "%s", 1, "Inf");   /* C_AIRMASS    */
+  fits_modify (&theader, "TNVAL5",  "%s", 1, "Inf");   /* C_COLOR      */
+  fits_modify (&theader, "TNVAL6",  "%s", 1, "NA");    /* START_TIME   */
+  fits_modify (&theader, "TNVAL7",  "%s", 1, "NA");    /* STOP_TIME    */
+  fits_modify (&theader, "TNVAL8",  "%s", 1, "NA");    /* C1_NAME      */
+  fits_modify (&theader, "TNVAL9",  "%s", 1, "NA");    /* C2_NAME      */
+  fits_modify (&theader, "TNVAL10", "%s", 1, "NA");    /* NSTARS       */
+  fits_modify (&theader, "TNVAL11", "%s", 1, "NA");    /* NTIMES       */
+  fits_modify (&theader, "TNVAL12", "%s", 1, "NA");    /* INT_PHOT_SYS */
+  fits_modify (&theader, "TNVAL13", "%s", 1, "NA");    /* REF_PHOT_SYS */
+  fits_modify (&theader, "TNVAL14", "%s", 1, "NA");    /* LABEL        */
 
   /* create table, add data values */
@@ -138,14 +143,16 @@
     startstr = sec_to_date (newdata[0].tstart);
     stopstr = sec_to_date (newdata[0].tstop);
-    n = photcodes.hashcode[newdata[0].c1];
-    c1 = photcodes.code[n].name;
-    n = photcodes.hashcode[newdata[0].c2];
-    c2 = photcodes.code[n].name;
-    n = photcodes.hashcode[newdata[0].photcode];
-    code = photcodes.code[n].name;
+    code    = GetPhotcodeNamebyCode (newdata[0].photcode);
+    photsys = GetPhotcodeNamebyCode (newdata[0].refcode);
+    c1      = GetPhotcodeNamebyCode (newdata[0].c1);
+    c2      = GetPhotcodeNamebyCode (newdata[0].c2);
+    if (code    == (char *) NULL) code    = PhotNA;
+    if (photsys == (char *) NULL) photsys = PhotNA;
+    if (c1      == (char *) NULL) c1      = PhotNA;
+    if (c2      == (char *) NULL) c2      = PhotNA;
 
     line = fits_table_print (&table, newdata[0].ZP, newdata[0].ZPo, newdata[0].dZP, 
 	      newdata[0].K, newdata[0].X, startstr, stopstr,
-	      c1, c2, newdata[0].Nmeas, newdata[0].Ntime, code, newdata[0].label);
+	      c1, c2, newdata[0].Nmeas, newdata[0].Ntime, code, photsys, newdata[0].label);
     if (!fits_add_rows (&table, line, 1, strlen(line))) escape (IGNORE, (FILE *) NULL, (char *) NULL, NULL, "error writing dataline");
 
@@ -172,5 +179,5 @@
   
   int i, j;
-  char *photstr, *timestr, *c1, *c2;
+  char *photstr, *timestr, *c1, *c2, *refcode;
   
   /* print the selected entries */
@@ -183,13 +190,16 @@
     
     /* convert photcode to filter name */
-    photstr = GetPhotnamebyCode (&photcodes, photdata[i].photcode);
-    c1      = GetPhotnamebyCode (&photcodes, photdata[i].c1);
-    c2      = GetPhotnamebyCode (&photcodes, photdata[i].c2);
+    photstr = GetPhotcodeNamebyCode (photdata[i].photcode);
+    refcode = GetPhotcodeNamebyCode (photdata[i].refcode);
+    c1      = GetPhotcodeNamebyCode (photdata[i].c1);
+    c2      = GetPhotcodeNamebyCode (photdata[i].c2);
     if (photstr == (char *) NULL) photstr = PhotError;
-    if (c1      == (char *) NULL) photstr = PhotError;
-    if (c2      == (char *) NULL) photstr = PhotError;
+    if (refcode == (char *) NULL) refcode = PhotError;
+    if (c1      == (char *) NULL) c1      = PhotError;
+    if (c2      == (char *) NULL) c2      = PhotError;
       
-    fprintf (stdout, "%s %s  %7.4f %7.4f %7.4f  %3d %3d  %7.4f %7.4f  %s %s %s\n", 
-	     photstr, timestr, photdata[i].ZP, photdata[i].ZPo, photdata[i].dZP, photdata[i].Nmeas, photdata[i].Ntime, photdata[i].X, photdata[i].K, c1, c2, photdata[i].label); 
+    fprintf (stdout, "%s %s  %7.4f %7.4f %7.4f  %3d %3d  %7.4f %7.4f  %s  %s %s %s\n", 
+	     photstr, timestr, photdata[i].ZP, photdata[i].ZPo, photdata[i].dZP, photdata[i].Nmeas, photdata[i].Ntime, 
+	     photdata[i].X, photdata[i].K, refcode, c1, c2, photdata[i].label); 
     free (timestr);
   }
