IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12031


Ignore:
Timestamp:
Feb 23, 2007, 4:39:53 PM (19 years ago)
Author:
eugene
Message:

remove the concept of primary / secondary photcodes: all average mags go into the secfilt table

Location:
branches/dvo-mods-2007-02/Ohana/src
Files:
3 added
29 edited

Legend:

Unmodified
Added
Removed
  • branches/dvo-mods-2007-02/Ohana/src/addstar/src/ConfigInit.c

    r8639 r12031  
    77  char *config, *file;
    88  char RadiusWord[80];
    9   char PhotCodeFile[256];
     9  char CatdirPhotcodeFile[256];
     10  char MasterPhotcodeFile[256];
    1011  AddstarClientOptions options;
    1112
     
    6162  CAL_INSTMAG_MAX =  -9.0;
    6263  CAL_INSTMAG_MIN = -13.0;
    63   ScanConfig (config, "CAL_INSTMAG_MAX",   "%lf", 0, &CAL_INSTMAG_MAX);
    64   ScanConfig (config, "CAL_INSTMAG_MIN",   "%lf", 0, &CAL_INSTMAG_MIN);
     64  ScanConfig (config, "CAL_INSTMAG_MAX",        "%lf", 0, &CAL_INSTMAG_MAX);
     65  ScanConfig (config, "CAL_INSTMAG_MIN",        "%lf", 0, &CAL_INSTMAG_MIN);
    6566
    6667  /* location of needed data sources */
     
    6970  ScanConfig (config, "GSCDIR",                 "%s",  0, GSCDIR);
    7071
    71   if (!ScanConfig (config, "USNO_A_DIR",             "%s",  0, USNO_A_DIR)) {
    72     ScanConfig (config, "USNO_CDROM",             "%s",  0, USNO_A_DIR);
     72  if (!ScanConfig (config, "USNO_A_DIR",        "%s",  0, USNO_A_DIR)) {
     73    ScanConfig (config, "USNO_CDROM",           "%s",  0, USNO_A_DIR);
    7374  }
    7475  ScanConfig (config, "USNO_B_DIR",             "%s",  0, USNO_B_DIR);
    7576
    76   ScanConfig (config, "TYCHO_DIR",             "%s",  0, TYCHO_DIR);
     77  ScanConfig (config, "TYCHO_DIR",              "%s",  0, TYCHO_DIR);
    7778
    78   GetConfig (config, "GSCFILE",                "%s",  0, GSCFILE);
    79   GetConfig (config, "CATDIR",                 "%s",  0, CATDIR);
    80   GetConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
     79  GetConfig (config, "GSCFILE",                 "%s",  0, GSCFILE);
     80  GetConfig (config, "CATDIR",                  "%s",  0, CATDIR);
     81  GetConfig (config, "PHOTCODE_FILE",           "%s",  0, MasterPhotcodeFile);
    8182  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    8283  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
     
    147148  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    148149
    149   if (!LoadPhotcodes (PhotCodeFile)) {
    150     fprintf (stderr, "error loading photcode file %s\n", PhotCodeFile);
     150  /* XXX this does not yet write out the master photcode table */
     151  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     152  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     153    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    151154    exit (1);
    152155  }
  • branches/dvo-mods-2007-02/Ohana/src/delstar/src/ConfigInit.c

    r6684 r12031  
    44
    55  char *config, *file;
    6   char PhotCodeFile[256];
     6  char CatdirPhotcodeFile[256];
     7  char MasterPhotcodeFile[256];
    78
    89  /*** load configuration info ***/
     
    2223  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    2324  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
    24   ScanConfig (config, "PHOTCODE_FILE",          "%s", 0, PhotCodeFile);
     25  ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, MasterPhotcodeFile);
    2526
    2627  sprintf (ImageCat, "%s/Images.dat", CATDIR);
     
    4243  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    4344
    44   if (!LoadPhotcodes (PhotCodeFile)) {
    45     fprintf (stderr, "error loading photcodes\n");
     45  /* XXX this does not yet write out the master photcode table */
     46  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     47  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     48    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    4649    exit (1);
    4750  }
  • branches/dvo-mods-2007-02/Ohana/src/gastro/src/ConfigInit.c

    r8514 r12031  
    4444  ScanConfig (config, "CATDIR",            "%s",  0, CATDIR);           // location of ptolemy-format ref data
    4545  ScanConfig (config, "ROUGH_ASTROMETRY",  "%s",  0, ROUGH_ASTROMETRY); // where to get initial guess (header, config)
    46   ScanConfig (config, "PHOTCODE_FILE",     "%s",  0, PhotCodeFile);     // location of photcode table to convert supplied photcode
    4746
    4847  if (strcasecmp (ROUGH_ASTROMETRY, "header") &&
  • branches/dvo-mods-2007-02/Ohana/src/gastro/src/gheader.c

    r7080 r12031  
    1414  oldsize = header.size;
    1515
     16  /* validating the photcode name should be the job of DVO/addstar */
     17  /* here we are only writing the selected photcode name to the header */
    1618  if (NEWPHOTCODE) {
    17     /* we are going to write the photcode into the header
    18        here we are just checking that the photcode provided
    19        is a valid code */
    20     if (!LoadPhotcodes (PhotCodeFile)) {
    21       fprintf (stderr, "error loading photcodes\n");
    22       exit (0);
    23     }
    24     if (!GetPhotcodeCodebyName (PHOTCODE)) {
    25       fprintf (stderr, "ERROR: photcode not found in photcode table\n");
    26       exit (0);
    27     }
    2819    gfits_modify (&header, "PHOTCODE", "%s", 1, PHOTCODE);
    2920  }   
  • branches/dvo-mods-2007-02/Ohana/src/getstar/src/ConfigInit.c

    r6968 r12031  
    44
    55  char *config, *file;
    6   char PhotCodeFile[256];
     6  char CatdirPhotcodeFile[256];
     7  char MasterPhotcodeFile[256];
    78
    89  /*** load configuration info ***/
     
    2021  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    2122  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
    22   ScanConfig (config, "PHOTCODE_FILE",          "%s", 0, PhotCodeFile);
     23  ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, MasterPhotcodeFile);
    2324  if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) {
    2425    SKY_DEPTH = 2;
     
    3132  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    3233
    33   if (!LoadPhotcodes (PhotCodeFile)) {
    34     fprintf (stderr, "error loading photcodes\n");
     34  /* XXX this does not yet write out the master photcode table */
     35  sprintf (MasterPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     36  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     37    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3538    exit (1);
    3639  }
  • branches/dvo-mods-2007-02/Ohana/src/imclean/src/AdjustHeader.c

    r7080 r12031  
    1818  }
    1919
     20  /* validating the photcode name should be the job of DVO/addstar */
     21  /* here we are only writing the selected photcode name to the header */
    2022  if (NEWPHOTCODE) {
    21     /* we are going to write the photcode into the header
    22        here we are just checking that the photcode provided
    23        is a valid code */
    24     if (!LoadPhotcodes (PhotCodeFile)) {
    25       fprintf (stderr, "ERROR: can't load photcodes\n");
    26       exit (1);
    27     }
    28     if (!GetPhotcodebyName (PHOTCODE)) {
    29       fprintf (stderr, "ERROR: photcode not found in photcode table\n");
    30       exit (1);
    31     }
    3223    gfits_modify (header, "PHOTCODE", "%s", 1, PHOTCODE);
    3324  }   
  • branches/dvo-mods-2007-02/Ohana/src/imregister/base/ConfigInit.c

    r12008 r12031  
    77  int i, NDB;
    88  char *config, *file, ElixirBase[80], catdir[256];
     9  char CatdirPhotcodeFile[256];
     10  char MasterPhotcodeFile[256];
    911
    1012  /*** load configuration info ***/
     
    2527
    2628  WarnConfig (config, "CATDIR",                      "%s", 0, catdir);
     29  WarnConfig (config, "PHOTCODE_FILE",               "%s", 0, MasterPhotcodeFile);
    2730  sprintf (ImPhotDB, "%s/Images.dat", catdir);
    2831
    2932  /* small text databases: filters, camera defs */
    30   WarnConfig (config, "PHOTCODE_FILE",               "%s", 0, PhotCodeFile);
    3133  WarnConfig (config, "TEMPERATURE_LOG",             "%s", 0, TempLogFile);
    3234  WarnConfig (config, "FILTER_LIST",                 "%s", 0, FilterList);
     
    101103  }
    102104
     105  /* XXX this does not yet write out the master photcode table */
     106  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", catdir);
     107  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     108    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     109    exit (1);
     110  }
     111
    103112  free (config);
    104113  free (file);
  • branches/dvo-mods-2007-02/Ohana/src/imregister/imphot/ConfigInit.c

    r12008 r12031  
    88  int i, NDB;
    99  char *config, *file, ElixirBase[80], catdir[256];
     10  char CatdirPhotcodeFile[256];
     11  char MasterPhotcodeFile[256];
    1012
    1113  /*** load configuration info ***/
     
    2123
    2224  WarnConfig (config, "CATDIR",                      "%s", 0, catdir);
     25  WarnConfig (config, "PHOTCODE_FILE",               "%s", 0, MasterPhotcodeFile);
    2326  sprintf (ImPhotDB, "%s/Images.dat", catdir);
    2427
    2528  /* small text databases: filters, camera defs */
    26   WarnConfig (config, "PHOTCODE_FILE",               "%s", 0, PhotCodeFile);
    2729  WarnConfig (config, "TEMPERATURE_LOG",             "%s", 0, TempLogFile);
    2830  WarnConfig (config, "FILTER_LIST",                 "%s", 0, FilterList);
     
    9799  }
    98100
     101  /* XXX this does not yet write out the master photcode table */
     102  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     103  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     104    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     105    exit (1);
     106  }
     107
    99108  free (config);
    100109  free (file);
  • branches/dvo-mods-2007-02/Ohana/src/imregister/imphot/args.c

    r4772 r12031  
    88
    99  ConfigInit (&argc, argv); /* load elixir config data */
    10 
    11   /* load photcode data */
    12   if (!LoadPhotcodes (PhotCodeFile)) {
    13     fprintf (stderr, "error loading photcodes from %s\n", PhotCodeFile);
    14     exit (1);
    15   }
    1610
    1711  /* interpret command-line arguments */
  • branches/dvo-mods-2007-02/Ohana/src/imregister/photreg/args.photreg.c

    r3606 r12031  
    1919  if (get_argument (argc, argv, "-h")) usage ();
    2020  if (get_argument (argc, argv, "--help")) usage ();
    21 
    22   /* load photcode data */
    23   if (!LoadPhotcodes (PhotCodeFile)) {
    24     fprintf (stderr, "error loading photcodes from %s\n", PhotCodeFile);
    25     exit (1);
    26   }
    2721
    2822  /* set the required database */
  • branches/dvo-mods-2007-02/Ohana/src/imregister/photreg/args.photsearch.c

    r3606 r12031  
    99  ConfigCamera ();
    1010  ConfigFilter ();
    11 
    12   /* load photcode data */
    13   if (!LoadPhotcodes (PhotCodeFile)) {
    14     fprintf (stderr, "error loading photcodes from %s\n", PhotCodeFile);
    15     exit (1);
    16   }
    1711
    1812  criteria.Ntimes = 0;
  • branches/dvo-mods-2007-02/Ohana/src/imregister/src/imphotmerge.c

    r12008 r12031  
    44
    55Image *LoadImageTable (FILE *f, Header *header, int *nimage);
    6 static char *version = "imphotcopy $Revision: 1.5.4.1 $";
     6static char *version = "imphotcopy $Revision: 1.5.4.2 $";
    77
    88int main (int argc, char **argv) {
     
    2222  get_version (argc, argv, version);
    2323  ConfigInit (&argc, argv);
    24 
    25   /* load photcode data */
    26   if (!LoadPhotcodes (PhotCodeFile)) {
    27     fprintf (stderr, "error loading photcodes from %s\n", PhotCodeFile);
    28     exit (1);
    29   }
    3024
    3125  /* interpret command-line arguments */
  • branches/dvo-mods-2007-02/Ohana/src/libdvo/Makefile

    r12008 r12031  
    2929$(SRC)/version.$(ARCH).o         \
    3030$(SRC)/coordops.$(ARCH).o        \
     31$(SRC)/dvo_photcode_ops.$(ARCH).o \
    3132$(SRC)/LoadPhotcodes.$(ARCH).o   \
     33$(SRC)/LoadPhotcodesText.$(ARCH).o   \
     34$(SRC)/LoadPhotcodesFITS.$(ARCH).o   \
    3235$(SRC)/imreg_datatypes.$(ARCH).o \
    3336$(SRC)/mosaic_astrom.$(ARCH).o   \
  • branches/dvo-mods-2007-02/Ohana/src/libdvo/include/dvo.h

    r12011 r12031  
    3939
    4040/* photometry code types */
    41 # define PHOT_PRI 0x01
     41// # define PHOT_PRI 0x01
    4242# define PHOT_SEC 0x02
    4343# define PHOT_DEP 0x03
     
    133133
    134134typedef struct {
    135   int Ncode;
    136   int Nsecfilt;
    137   int hashcode[0x10000];
    138   int hashNsec[0x10000];
     135  int Ncode;                                      // number of photcodes
     136  int Nsecfilt;                                   // number of average magnitudes
     137  int hashcode[0x10000];                  // index from photcode value to sequence
     138  int hashNsec[0x10000];                  // index from photcode value to Nsec seq
     139  int codeNsec[0x10000];                  // index from Nsec seq to photcode value
    139140  PhotCode *code;
    140141} PhotCodeData;
     
    235236int PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color);
    236237
    237 int LoadPhotcodes (char *filename);
     238PhotCodeData *GetPhotcodeTable ();
     239
     240int LoadPhotcodes (char *catdir_file, char *master_file);
     241int LoadPhotcodesText (char *filename);
     242int LoadPhotcodesFITS (char *filename);
     243
    238244int GetPhotcodeCodebyName (char *name);
    239245int GetPhotcodeEquivCodebyName (char *name);
  • branches/dvo-mods-2007-02/Ohana/src/libdvo/src/LoadPhotcodes.c

    r12011 r12031  
    11# include <dvo.h>
    22
    3 # define NCTERMS 4
    4 # define F 0.001
    5 /* # define NO_MAG 100.0 */
     3int LoadPhotcodes (char *catdir_file, char *master_file) {
    64
    7 static PhotCodeData *photcodes = NULL;
    8 static double ZERO_POINT;
    9 static short int Nseclist[0x10000];
     5  /* first try to load the photcodes from the specified CATDIR location */
     6  if (LoadPhotcodesFITS (catdir_file)) return TRUE;
     7 
     8  /* next try to load the photcodes from the master text photcode file */
     9  if (LoadPhotcodesFITS (master_file)) return TRUE;
    1010
    11 /* static short int iZERO_POINT; */
    12 
    13 void SetZeroPoint (double ZP) {
    14   ZERO_POINT = ZP;
    15   /* iZERO_POINT = 1000 * ZP; */
     11  return FALSE;
    1612}
    17 
    18 int LoadPhotcodes (char *filename) {
    19  
    20   FILE *f;
    21   int i, Ns, Np, NPHOTCODE, Npri, Nfield;
    22   PhotCode *photcode;
    23   int code;
    24   char *c;
    25   char line[256];
    26   char name[32], type[32], Zero[32], Airmass[32], Offset[32],
    27     C1[32], C2[32], Slope[32], Color[32], Primary[32];
    28   int c1, c2;
    29 
    30   /* allocate space to photcode table, free existing data */
    31   if (photcodes == NULL) {
    32     ALLOCATE (photcodes, PhotCodeData, 1);
    33     photcodes[0].code = NULL;
    34   }
    35   if (photcodes[0].code != NULL) free (photcodes[0].code);
    36 
    37   f = fopen (filename, "r");
    38   if (f == (FILE *) NULL) {
    39     photcodes[0].Ncode    = 0;
    40     photcodes[0].Nsecfilt = 0;
    41     photcodes[0].code     = (PhotCode *) NULL;
    42     return (FALSE);
    43   }
    44 
    45   Np = 0;
    46   NPHOTCODE = 10;
    47   ALLOCATE (photcode, PhotCode, NPHOTCODE);
    48   photcodes[0].Nsecfilt = 0;
    49   for (i = 0; i < 0x10000; i++) {
    50     photcodes[0].hashcode[i] = -1;
    51     photcodes[0].hashNsec[i] = -1;
    52   }
    53 
    54   while (scan_line (f, line) != EOF) {
    55     for (c = line; isspace (*c); c++);
    56     if (*c == '#') continue;
    57     Nfield = sscanf (c, "%d %s %s %s %s %s %s %s %s %s %s",
    58                      &code, name, type, Zero, Airmass, Offset, C1, C2, Slope, Color, Primary);
    59     if (Nfield != 11) { continue; }
    60    
    61     c1 = atof (C1);
    62     c2 = atof (C2);
    63     if (!strcmp (C1, "-")) { c1 = 0; }
    64     if (!strcmp (C2, "-")) { c2 = 0; }
    65 
    66     photcode[Np].type = 0;
    67     photcode[Np].code = code;
    68     strcpy (photcode[Np].name, name);
    69     if (!strncasecmp (type, "pri", 3)) {
    70       photcode[Np].type  = PHOT_PRI;
    71       photcode[Np].C     = 1000*atof (Zero);
    72       photcode[Np].K     = atof (Airmass);
    73       photcode[Np].dC    = 1000*atof (Offset);
    74       photcode[Np].dX    = 1000*atof (Color);
    75       photcode[Np].c1    = c1;
    76       photcode[Np].c2    = c2;
    77       photcode[Np].equiv = atoi (Primary);
    78       ParseColorTerms (Slope, photcode[Np].X, &photcode[Np].Nc);
    79       Nseclist[0] = Np;
    80     }     
    81     if (!strncasecmp (type, "sec", 3)) {
    82       photcode[Np].type  = PHOT_SEC;
    83       photcode[Np].C     = 1000*atof (Zero);
    84       photcode[Np].K     = atof (Airmass);
    85       photcode[Np].dC    = 1000*atof (Offset);
    86       photcode[Np].dX    = 1000*atof (Color);
    87       photcode[Np].c1    = c1;
    88       photcode[Np].c2    = c2;
    89       photcode[Np].equiv = atoi (Primary);
    90       photcodes[0].Nsecfilt ++;
    91       ParseColorTerms (Slope, photcode[Np].X, &photcode[Np].Nc);
    92       Nseclist[photcodes[0].Nsecfilt] = Np;
    93     }     
    94     if (!strncasecmp (type, "dep", 3)) {
    95       photcode[Np].type  = PHOT_DEP;
    96       photcode[Np].C     = 1000*atof (Zero);    /* zero point in millimags */
    97       photcode[Np].K     = atof (Airmass);      /* airmass coeff (millimag / millimag) */
    98       photcode[Np].dC    = 1000*atof (Offset);  /* color ref z.p. (millimag) */
    99       photcode[Np].dX    = 1000*atof (Color);   /* average color (millimag) */
    100       photcode[Np].c1    = c1;
    101       photcode[Np].c2    = c2;
    102       photcode[Np].equiv = atoi (Primary);
    103       ParseColorTerms (Slope, photcode[Np].X, &photcode[Np].Nc);
    104     }     
    105     if (!strncasecmp (type, "ref", 3)) {
    106       photcode[Np].type  = PHOT_REF;
    107       photcode[Np].C     = 0;
    108       photcode[Np].K     = 0;
    109       photcode[Np].dC    = 0;
    110       photcode[Np].dX    = 0;
    111       photcode[Np].c1    = 0;
    112       photcode[Np].c2    = 0;
    113       photcode[Np].equiv = atoi (Primary);
    114       photcode[Np].X[0]  = 0;
    115       photcode[Np].Nc    = 0;
    116     }
    117 
    118     /* alt photcodes are a little different: they have the SAME photcode as an existing
    119        pri/sec photcode, but define an alternate transformation for that code */
    120     if (!strncasecmp (type, "alt", 3)) {
    121       photcode[Np].type  = PHOT_ALT;
    122       photcode[Np].C     = 1000*atof (Zero);    /* zero point in millimags */
    123       photcode[Np].K     = atof (Airmass);      /* airmass coeff (millimag / millimag) */
    124       photcode[Np].dC    = 1000*atof (Offset);  /* color ref z.p. (millimag) */
    125       photcode[Np].dX    = 1000*atof (Color);   /* average color (millimag) */
    126       photcode[Np].c1    = c1;
    127       photcode[Np].c2    = c2;
    128       photcode[Np].equiv = atoi (Primary);
    129       ParseColorTerms (Slope, photcode[Np].X, &photcode[Np].Nc);
    130     }
    131     if (!photcode[Np].type) {
    132       fprintf (stderr, "error in Photfile: unknown type %s\n", type);
    133     }
    134 
    135     Np++;
    136     if (Np == NPHOTCODE) {
    137       NPHOTCODE += 10;
    138       REALLOCATE (photcode, PhotCode, NPHOTCODE);
    139     }
    140   }
    141   fclose (f);
    142  
    143   /* set up hashcode for photcode refs:
    144    * the hashcode gives the structure sequence for a given photcode:
    145    * photcode[i].hashcode[photcode[i].code] == i
    146    */
    147 
    148   Ns = 0;
    149   for (i = 0; i < Np; i++) {
    150     if (photcode[i].type == PHOT_ALT) continue; /* no hashcode for ALT codes */
    151     if (photcodes[0].hashcode[photcode[i].code] != -1) {
    152       fprintf (stderr, "duplicate photcodes in file\n");
    153       code = photcodes[0].hashcode[photcode[i].code];
    154       fprintf (stderr, "conflict between %s (%d) and %s (%d)\n",
    155                photcode[i].name, photcode[i].code, photcode[code].name, photcode[code].code);
    156       free (photcode);
    157       return (FALSE);
    158     }
    159     photcodes[0].hashcode[photcode[i].code] = i;
    160     if (photcode[i].type == PHOT_SEC) {
    161       photcodes[0].hashNsec[photcode[i].code] = Ns;
    162       Ns ++;
    163     }
    164   }
    165   /* validity check for references */
    166   for (i = 0; i < Np; i++) {
    167     if (photcode[i].type == PHOT_DEP) {
    168       Npri = photcodes[0].hashcode[photcode[i].equiv];
    169       if ((Npri >= Np) || (Npri < 0)) {
    170         fprintf (stderr, "reference for dependent photcode is not in photcodes\n");
    171         free (photcode);
    172         return (FALSE);
    173       }
    174       if ((photcode[Npri].type != PHOT_PRI) && (photcode[Npri].type != PHOT_SEC)) {
    175         fprintf (stderr, "reference for dependent photcode is not a primary or secondary code\n");
    176         free (photcode);
    177         return (FALSE);
    178       }
    179     }
    180     if (photcode[i].type == PHOT_ALT) {
    181       Npri = photcodes[0].hashcode[photcode[i].code];
    182       if ((Npri >= Np) || (Npri < 0)) {
    183         fprintf (stderr, "reference for alternate photcode is not in photcodes\n");
    184         free (photcode);
    185         return (FALSE);
    186       }
    187       if ((photcode[Npri].type != PHOT_PRI) && (photcode[Npri].type != PHOT_SEC)) {
    188         fprintf (stderr, "reference for alternate photcode is not a primary or secondary code\n");
    189         free (photcode);
    190         return (FALSE);
    191       }
    192     }
    193   }
    194   photcodes[0].code = photcode;
    195   photcodes[0].Ncode = Np;
    196 
    197   return (TRUE);
    198 
    199 }
    200 
    201 void ParseColorTerms (char *terms, float *X, int *N) {
    202 
    203   int i;
    204   char *p;
    205 
    206   p = terms;
    207 
    208   for (i = 0; (p != NULL) && (i < NCTERMS); i++) {
    209     X[i] = atof (p);
    210     p = strchr (p, ',');
    211     if (p == (char *) NULL) continue;
    212     p ++;
    213   }
    214   *N = i;
    215 }
    216 
    217 /********** photcode lookups **********/
    218 
    219 /* return photcode for given name */
    220 PhotCode *GetPhotcodebyName (char *name) {
    221  
    222   int i;
    223 
    224   if (name == (char *) NULL ) return (NULL);
    225  
    226   for (i = 0; i < photcodes[0].Ncode; i++) {
    227     if (!strcmp (photcodes[0].code[i].name, name)) {
    228       return (&photcodes[0].code[i]);
    229     }
    230   }
    231   return (NULL);
    232 }
    233 /* return photcode.code for given name */
    234 int GetPhotcodeCodebyName (char *name) {
    235  
    236   int i;
    237  
    238   if (name == (char *) NULL ) return (0);
    239 
    240   for (i = 0; i < photcodes[0].Ncode; i++) {
    241     if (!strcmp (photcodes[0].code[i].name, name)) {
    242       return (photcodes[0].code[i].code);
    243     }
    244   }
    245   return (0);
    246 }
    247 /* return equivalent photcode for given name */
    248 PhotCode *GetPhotcodeEquivbyName (char *name) {
    249  
    250   int i, equiv;
    251  
    252   if (name == (char *) NULL ) return (NULL);
    253 
    254   for (i = 0; i < photcodes[0].Ncode; i++) {
    255     if (!strcmp (photcodes[0].code[i].name, name)) {
    256       if (photcodes[0].code[i].equiv == 0) return (NULL);
    257       equiv = photcodes[0].hashcode[photcodes[0].code[i].equiv];
    258       if (equiv == -1) return (NULL);
    259       return (&photcodes[0].code[equiv]);
    260     }
    261   }
    262   return (NULL);
    263 }
    264 /* return equivalent photcode.code for given name */
    265 int GetPhotcodeEquivCodebyName (char *name) {
    266  
    267   int i, equiv;
    268  
    269   if (name == (char *) NULL ) return (0);
    270 
    271   for (i = 0; i < photcodes[0].Ncode; i++) {
    272     if (!strcmp (photcodes[0].code[i].name, name)) {
    273       if (photcodes[0].code[i].equiv == 0) return (0);
    274       equiv = photcodes[0].hashcode[photcodes[0].code[i].equiv];
    275       if (equiv == -1) return (0);
    276       return (photcodes[0].code[equiv].code);
    277     }
    278   }
    279   return (0);
    280 }
    281 
    282 /* return photcode for given code */
    283 PhotCode *GetPhotcodebyCode (int code) {
    284  
    285   int entry;
    286  
    287   if (code < 0) return (NULL);
    288   if (code > 0x10000) return (NULL);
    289 
    290   entry = photcodes[0].hashcode[code];
    291   if (entry == -1) return (NULL);
    292 
    293   return (&photcodes[0].code[entry]);
    294 }
    295 /* return photcode.code for given code */
    296 char *GetPhotcodeNamebyCode (int code) {
    297  
    298   int entry;
    299  
    300   if (code < 0) return (NULL);
    301   if (code > 0x10000) return (NULL);
    302 
    303   entry = photcodes[0].hashcode[code];
    304   if (entry == -1) return (NULL);
    305 
    306   return (photcodes[0].code[entry].name);
    307 }
    308 /* return equivalent photcode for given code */
    309 PhotCode *GetPhotcodeEquivbyCode (int code) {
    310  
    311   int entry, equiv;
    312  
    313   if (code < 0) return (NULL);
    314   if (code > 0x10000) return (NULL);
    315 
    316   entry = photcodes[0].hashcode[code];
    317   if (entry == -1) return (NULL);
    318 
    319   if (photcodes[0].code[entry].equiv == 0) return (NULL);
    320   equiv = photcodes[0].hashcode[photcodes[0].code[entry].equiv];
    321 
    322   if (equiv == -1) return (NULL);
    323   return (&photcodes[0].code[equiv]);
    324 }
    325 /* return equivalent photcode.code for given code */
    326 int GetPhotcodeEquivCodebyCode (int code) {
    327  
    328   int entry;
    329  
    330   if (code < 0) return (0);
    331   if (code > 0x10000) return (0);
    332 
    333   entry = photcodes[0].hashcode[code];
    334   if (entry == -1) return (0);
    335   return (photcodes[0].code[entry].equiv);
    336 }
    337 
    338 int GetPhotcodeNsec (int code) {
    339  
    340   int Nsec;
    341  
    342   if (code < 0) return (-1);
    343   if (code > 0x10000) return (-1);
    344 
    345   Nsec = photcodes[0].hashNsec[code];
    346   return (Nsec);
    347 }
    348 
    349 /* Nsec of 0 is PRI */
    350 PhotCode *GetPhotcodebyNsec (int Nsec) {
    351  
    352   if (Nsec > photcodes[0].Nsecfilt) return (NULL);
    353   if (Nsec < 0) return (NULL);
    354  
    355   return (&photcodes[0].code[Nseclist[Nsec]]);
    356 }
    357 
    358 int GetPhotcodeNsecfilt () {
    359   return (photcodes[0].Nsecfilt);
    360 }
    361 
    362 /* ALLOCATE and return list of all photcodes
    363    with photcode.equiv == code */
    364 int *GetPhotcodeEquivList (int code, int *nlist) {
    365 
    366   int i, Nlist;
    367   int *list;
    368 
    369   ALLOCATE (list, int, MAX (1, photcodes[0].Ncode));
    370   Nlist = 0;
    371   for (i = 0; i < photcodes[0].Ncode; i++) {
    372     if (photcodes[0].code[i].equiv != code) continue;
    373     list[Nlist] = photcodes[0].code[i].code;
    374     Nlist ++;
    375   }
    376   REALLOCATE (list, int, MAX (1, Nlist));
    377 
    378   *nlist = Nlist;
    379   return (list);
    380 }
    381 
    382 /******** internal photometry conversions (keeps values in short int millimags) *********/
    383 float PhotInst (Measure *measure) {
    384 
    385   int Np;
    386   float M;
    387 
    388   Np = photcodes[0].hashcode[measure[0].photcode];
    389   if (Np == -1) return (NO_MAG);
    390 
    391   if (photcodes[0].code[Np].type == PHOT_REF) {
    392     M = measure[0].M;
    393     return (M);
    394   }
    395 
    396   M = measure[0].M - measure[0].dt - ZERO_POINT;
    397          
    398   return (M);
    399 
    400 }
    401 
    402 float PhotCat (Measure *measure) {
    403 
    404   int Np;
    405   float Mcat;
    406   PhotCode *code;
    407 
    408   Np = photcodes[0].hashcode[measure[0].photcode];
    409   if (Np == -1) return (NO_MAG);
    410 
    411   if (photcodes[0].code[Np].type == PHOT_REF) {
    412     Mcat = measure[0].M;
    413     return (Mcat);
    414   }
    415   code = &photcodes[0].code[Np];
    416   Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + F*code[0].C;
    417  
    418   return (Mcat);
    419 }
    420 
    421 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt) {
    422 
    423   int i, Np;
    424   float Mcat, Mcol, Msys, mc, Mc;
    425   PhotCode *code;
    426 
    427   Np = photcodes[0].hashcode[measure[0].photcode];
    428   if (Np == -1) return (NO_MAG);
    429 
    430   if (photcodes[0].code[Np].type == PHOT_REF) {
    431     Msys = measure[0].M;
    432     return (Msys);
    433   }
    434   code = &photcodes[0].code[Np];
    435   Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + F*code[0].C;
    436 
    437   /* for DEP, color must be made of PRI/SEC */
    438   mc = PhotColorForCode (average, secfilt, NULL, code);
    439   if (mc == NO_MAG) return (Mcat);
    440   mc = mc - F*code[0].dX;
    441 
    442   Mc = mc;
    443   Mcol = 0;
    444   for (i = 0; i < code[0].Nc; i++) {
    445     Mcol += code[0].X[i]*Mc;
    446     Mc *= mc;
    447   }
    448   Msys = Mcat + Mcol;
    449   return (Msys);
    450 }
    451 
    452 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt) {
    453 
    454   int i, Np;
    455   float Mcat, Mcol, Mrel, mc, Mc;
    456   PhotCode *code;
    457 
    458   Np = photcodes[0].hashcode[measure[0].photcode];
    459   if (Np == -1) return (NO_MAG);
    460 
    461   if (photcodes[0].code[Np].type == PHOT_REF) {
    462     Mcat = measure[0].M;
    463     return (Mcat);
    464   }
    465   code = &photcodes[0].code[Np];
    466   Mrel = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + F*code[0].C - measure[0].Mcal;
    467 
    468   /* for DEP, color must be made of PRI/SEC */
    469   mc = PhotColorForCode (average, secfilt, NULL, code);
    470   if (mc == NO_MAG) return (Mrel);
    471   mc = mc - F*code[0].dX;
    472 
    473   Mc = mc;
    474   Mcol = 0;
    475   for (i = 0; i < code[0].Nc; i++) {
    476     Mcol += code[0].X[i]*Mc;
    477     Mc *= mc;    /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */
    478   }
    479   Mrel += Mcol;
    480   return (Mrel);
    481 }
    482 
    483 /* return calibrated magnitude from measure for given photcode */
    484 float PhotCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) {
    485 
    486   int i, Np;
    487   float Mcal, Mrel, Mcol, mc, Mc;
    488 
    489   /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */
    490   Np = photcodes[0].hashcode[thisone[0].photcode];
    491   if (Np == -1) {
    492     return (NO_MAG);
    493   }
    494 
    495   if (photcodes[0].code[Np].type == PHOT_REF) {
    496     Mrel = thisone[0].M;
    497     return (Mrel);
    498   }
    499   if (code[0].code != photcodes[0].code[Np].equiv) {
    500     return (NO_MAG);
    501   }
    502 
    503   Mcal = PhotRel (thisone, average, secfilt) + F*code[0].C;
    504 
    505   mc = PhotColorForCode (average, secfilt, measure, code);
    506   if (mc == NO_MAG) return (Mcal);
    507   mc = mc - F*code[0].dX;
    508 
    509   Mc = mc;
    510   Mcol = 0;
    511   for (i = 0; i < code[0].Nc; i++) {
    512     Mcol += code[0].X[i]*Mc;
    513     Mc *= mc;
    514   }
    515   Mcal += Mcol;
    516   return (Mcal);
    517 }
    518 
    519 /* color term may not use DEP magnitude */
    520 float PhotColorForCode (Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) {
    521 
    522   int i, Ns1, Ns2, Ns;
    523   float m1, m2, mc;
    524   PhotCode *color;
    525 
    526   m1 = m2 = NO_MAG;
    527 
    528   if (measure == NULL) {
    529     Ns1 = photcodes[0].hashNsec[code[0].c1];
    530     Ns2 = photcodes[0].hashNsec[code[0].c2];
    531  
    532     m1 = (Ns1 == -1) ? NO_MAG : secfilt[Ns1].M;
    533     m2 = (Ns2 == -1) ? NO_MAG : secfilt[Ns2].M;
    534     mc = ((m1 == NO_MAG) || (m2 == NO_MAG)) ? NO_MAG : (m1 - m2);
    535     return (mc);
    536   }
    537 
    538   /* find magnitude matching first color term */
    539   color = GetPhotcodebyCode (code[0].c1);
    540   if (color == NULL) return (NO_MAG);
    541   if (color[0].type == PHOT_REF) {
    542     for (i = 0; (i < average[0].Nm) && (m1 == NO_MAG); i++) {
    543       if (measure[i].photcode == color[0].code) {
    544         m1 = measure[i].M;
    545       }
    546     }
    547   } else {
    548     Ns = photcodes[0].hashNsec[color[0].code];
    549     m1 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
    550   }     
    551 
    552   /* find magnitude matching second color term */
    553   color = GetPhotcodebyCode (code[0].c2);
    554   if (color == NULL) return (NO_MAG);
    555   if (color[0].type == PHOT_REF) {
    556     for (i = 0; (i < average[0].Nm) && (m2 == NO_MAG); i++) {
    557       if (measure[i].photcode == color[0].code) {
    558         m2 = measure[i].M;
    559       }
    560     }
    561   } else {
    562     Ns = photcodes[0].hashNsec[color[0].code];
    563     m2 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
    564   }     
    565   mc = ((m1 == NO_MAG) || (m2 == NO_MAG)) ? NO_MAG : (m1 - m2);
    566   return (mc);
    567 }
    568 
    569 /* return calibrated magnitude from average/secfilt for given photcode */
    570 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) {
    571 
    572   int i, Ns;
    573   float Mave, Mref, Mcol, mc;
    574   double Mc;
    575 
    576   Ns = photcodes[0].hashNsec[code[0].code];
    577   Mave = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
    578   Mref = Mave + F*code[0].C;
    579 
    580   mc = PhotColorForCode (average, secfilt, measure, code);
    581   if (mc == NO_MAG) return (Mref);
    582   mc = mc - F*code[0].dX;
    583 
    584   Mc = mc;
    585   Mcol = 0;
    586   for (i = 0; i < code[0].Nc; i++) {
    587     Mcol += code[0].X[i]*Mc;
    588     Mc *= mc;    /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */
    589   }
    590   Mref += Mcol;
    591   return (Mref);
    592 }
    593 
    594 /***/
    595 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt) {
    596 
    597   int Ns;
    598   float Mave;
    599 
    600   Ns = photcodes[0].hashNsec[code[0].code];
    601   Mave = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
    602   return (Mave);
    603 }
    604 
    605 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt) {
    606 
    607   int Ns;
    608   float dM;
    609 
    610   Ns = photcodes[0].hashNsec[code[0].code];
    611   dM  = (Ns == -1) ? NO_MAG : secfilt[Ns].dM;
    612   return (dM);
    613 }
    614 
    615 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) {
    616 
    617   int Ns;
    618   short Mi;
    619   float Xm;
    620 
    621   Ns = photcodes[0].hashNsec[code[0].code];
    622   Mi = (Ns == -1) ? NO_MAG : secfilt[Ns].Xm;
    623   Xm = (Mi == NO_MAG) ? -1.0 : pow (10.0, 0.01*Mi);
    624   return (Xm);
    625 }
    626 
    627 /* given a photcode pair c1 & c2, return the color of this star (NaN if not found) */
    628 int PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color) {
    629 
    630   int i, Ns;
    631   double M1, M2, dM;
    632   PhotCode *code;
    633  
    634   code = GetPhotcodebyCode (c1);
    635   if (code == NULL) return (FALSE);
    636   if (code[0].type == PHOT_REF) {
    637     for (i = 0; i < average[0].Nm; i++) {
    638       if (measure[i].photcode == c1) {
    639         M1 = measure[i].M;
    640         goto filter1;
    641       }
    642     }   
    643     return (FALSE);
    644   } else {
    645     Ns = photcodes[0].hashNsec[code[0].code];
    646     M1 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
    647   }     
    648 
    649 filter1:
    650   code = GetPhotcodebyCode (c2);
    651   if (code == NULL) return (FALSE);
    652   if (code[0].type == PHOT_REF) {
    653     for (i = 0; i < average[0].Nm; i++) {
    654       if (measure[i].photcode == c2) {
    655         M2 = measure[i].M;
    656         goto filter2;
    657       }
    658     }   
    659     return (FALSE);
    660   } else {
    661     Ns = photcodes[0].hashNsec[code[0].code];
    662     M2 = (Ns == -1) ? NO_MAG : secfilt[Ns].M;
    663   }     
    664  
    665 filter2:
    666 
    667   dM = M1 - M2;
    668   *color = dM;
    669  
    670   return (TRUE);
    671 }
    672 
    673 /* photcode table should have the following format:
    674 
    675 # code name     type  zero  airmass  offset  c1 c2  slope  <color>  primary
    676 1    B        pri   24.0  0.15     -       -  -   -      -        -
    677 2    B        pri   24.0  0.15     -       -  -   -      -        -
    678 3    B1       sec   22.5  0.18     0.15    1  2   0.10   0.50     1
    679 1000 USNO_B   ref   -     -        -       -  -   -      -        -
    680 
    681 */
    682 
    683 
    684 /*
    685   Nc1 = photcodes[0].code[Np].c1;
    686   Ns1 = photcodes[0].hashNsec[Nc1];
    687 
    688   Nc2 = photcodes[0].code[Np].c2;
    689   Ns2 = photcodes[0].hashNsec[Nc2];
    690 
    691   Xlam = photcodes[0].code[Np].X[0];
    692   Klam = photcodes[0].code[Np].K;
    693  
    694   m1 = (Ns1 == -1) ? average[0].M : secfilt[Ns1].M;
    695   m2 = (Ns2 == -1) ? average[0].M : secfilt[Ns2].M;
    696 */
  • branches/dvo-mods-2007-02/Ohana/src/markrock/src/ConfigInit.c

    r11903 r12031  
    44
    55  char *config, *file;
    6   char PhotCodeFile[256];
     6  char CatdirPhotcodeFile[256];
     7  char MasterPhotcodeFile[256];
    78
    89  /*** load configuration info ***/
     
    2021  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    2122  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
     23  ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, MasterPhotcodeFile);
    2224
    2325  /* unique to markrock */
     
    3032  ScanConfig (config, "ROCK_MAX_DELAY",         "%lf", 0, &MAX_DELAY);
    3133  ScanConfig (config, "ROCK_CATALOG",           "%s",  0, RockCat);
    32   ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
    3334
    3435  ScanConfig (config, "BRIGHT_HALO_MAG",        "%lf", 0, &BRIGHT_HALO_MAG);
     
    4142  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    4243
    43   if (!LoadPhotcodes (PhotCodeFile, &photcodes)) {
    44     fprintf (stderr, "error loading photcodes\n");
    45     exit (0);
     44  /* XXX this does not yet write out the master photcode table */
     45  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     46  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     47    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     48    exit (1);
    4649  }
    4750
  • branches/dvo-mods-2007-02/Ohana/src/markstar/src/ConfigInit.c

    r11903 r12031  
    44
    55  char *config, *file;
    6   char PhotCodeFile[256];
     6  char CatdirPhotcodeFile[256];
     7  char MasterPhotcodeFile[256];
    78
    89  /*** load configuration info ***/
     
    2021  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    2122  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
     23  ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, MasterPhotcodeFile);
    2224
    2325  sprintf (ImageCat, "%s/Images.dat", CATDIR);
     
    4648  ScanConfig (config, "OPTICAL_AXIS1",   "%lf", 0, &OPTICAL_AXIS1);
    4749  ScanConfig (config, "OPTICAL_AXIS2",   "%lf", 0, &OPTICAL_AXIS2);
    48   ScanConfig (config, "PHOTCODE_FILE",          "%s", 0, PhotCodeFile);
    4950 
    5051  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
    5152  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    5253
    53   if (!LoadPhotcodes (PhotCodeFile, &photcodes)) {
    54     fprintf (stderr, "error loading photcodes\n");
    55     exit (0);
     54  /* XXX this does not yet write out the master photcode table */
     55  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     56  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     57    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     58    exit (1);
    5659  }
    5760
  • branches/dvo-mods-2007-02/Ohana/src/opihi/dvo/dmt.c

    r12012 r12031  
    4444    return (FALSE);
    4545  }
    46   if ((code[0].type != PHOT_SEC) && (code[0].type != PHOT_PRI)) {
    47     gprint (GP_ERR, "first filter must be a PRIMARY or SECONDARY photometry type\n");
     46  if (code[0].type != PHOT_SEC) {
     47    gprint (GP_ERR, "first filter must be a average photometry type\n");
    4848    return (FALSE);
    4949  }
  • branches/dvo-mods-2007-02/Ohana/src/opihi/dvo/extract.c

    r12008 r12031  
    119119  if (PhotcodeSelect) {
    120120    Ns = GetPhotcodeNsec (code[0].code);
    121     if ((mode != REF) && (code[0].type != PHOT_SEC) && (code[0].type != PHOT_PRI)) {
    122       gprint (GP_ERR, "filter must be a PRIMARY or SECONDARY photometry type\n");
     121    if ((mode != REF) && (code[0].type != PHOT_SEC)) {
     122      gprint (GP_ERR, "filter must be a average photometry type\n");
    123123      return (FALSE);
    124124    }
  • branches/dvo-mods-2007-02/Ohana/src/opihi/dvo/gimages.c

    r12008 r12031  
    8383        if (code[0].code != image[i].photcode) continue;
    8484      }
    85       if ((code[0].type == PHOT_PRI) || (code[0].type == PHOT_SEC)) {
     85      if (code[0].type == PHOT_SEC) {
    8686        if (code[0].code != GetPhotcodeEquivCodebyCode (image[i].photcode)) continue;
    8787      }
  • branches/dvo-mods-2007-02/Ohana/src/opihi/dvo/imextract.c

    r12008 r12031  
    6363      return (FALSE);
    6464    }
    65     if ((code[0].type != PHOT_PRI) && (code[0].type != PHOT_SEC) && (code[0].type != PHOT_DEP)) {
     65    if ((code[0].type != PHOT_SEC) && (code[0].type != PHOT_DEP)) {
    6666      gprint (GP_ERR, "photcode must be primary, secondary, or dependent code\n");
    6767      return (FALSE);
  • branches/dvo-mods-2007-02/Ohana/src/opihi/dvo/lightcurve.c

    r12008 r12031  
    112112            if (code[0].code != catalog.measure[m].photcode) continue;
    113113          }
    114           if ((code[0].type == PHOT_PRI) || (code[0].type == PHOT_SEC)) {
     114          if (code[0].type == PHOT_SEC) {
    115115            if (code[0].code != GetPhotcodeEquivCodebyCode (catalog.measure[m].photcode)) continue;
    116116          }
  • branches/dvo-mods-2007-02/Ohana/src/opihi/dvo/photometry.c

    r12008 r12031  
    99      if (C[0].code != M.photcode) continue; \
    1010      break; \
    11     case PHOT_PRI: \
    1211    case PHOT_SEC: \
    1312      if (C[0].code != GetPhotcodeEquivCodebyCode (M.photcode)) continue; \
     
    134133    if (mode == MAG_CAL)  status = TRUE;
    135134  } 
    136   if ((code[0].type == PHOT_PRI) || (code[0].type == PHOT_SEC)) {
     135  if (code[0].type == PHOT_SEC) {
    137136    if (mode == MAG_NONE) mode  = MAG_AVE;
    138137    if (mode == MAG_INST) status = TRUE;
     
    302301  }
    303302  if (NeedPhotcode) {
    304     if (code[0][0].type == PHOT_PRI) return (TRUE);
    305303    if (code[0][0].type == PHOT_SEC) return (TRUE);
    306     gprint (GP_ERR, "photcode selection problem: average value requires PRI/SEC photcode\n");
     304    gprint (GP_ERR, "photcode selection problem: average value requires average photcode\n");
    307305    return (FALSE);
    308306  }
     
    322320
    323321  double ZERO_POINT;
    324   char PhotCodeFile[256];
     322  char MasterPhotcodeFile[256];
     323  char CatdirPhotcodeFile[256];
     324  char *catdir;
    325325
    326326  if (VarConfig ("ZERO_PT", "%lf", &ZERO_POINT) == (char *) NULL) {
     
    330330  SetZeroPoint (ZERO_POINT);
    331331
    332   if (VarConfig ("PHOTCODE_FILE", "%s", PhotCodeFile) == (char *) NULL) {
     332  catdir = GetCATDIR();
     333  if (catdir == NULL) {
     334    CatdirPhotcodeFile[0] = 0;
     335  } else {
     336    sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", catdir);
     337  }
     338
     339  if (VarConfig ("PHOTCODE_FILE", "%s", MasterPhotcodeFile) == (char *) NULL) {
    333340      gprint (GP_ERR, "PHOTCODE_FILE undefined in config\n");
    334341      return (FALSE);
    335342  }
    336   if (!LoadPhotcodes (PhotCodeFile)) {
    337     gprint (GP_ERR, "error loading photcodes\n");
     343  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     344    gprint (GP_ERR, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    338345    return (FALSE);
    339346  }
  • branches/dvo-mods-2007-02/Ohana/src/photdbc/src/ConfigInit.c

    r8630 r12031  
    1313
    1414  char *config, *file;
     15  char CatdirPhotcodeFile[256];
     16  char MasterPhotcodeFile[256];
    1517
    1618  /*** load configuration info ***/
     
    4648  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    4749  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
     50  ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, MasterPhotcodeFile);
     51
    4852  sprintf (ImageCat, "%s/Images.dat", CATDIR);
    4953
    50   WarnConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
    5154  WarnConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
    5255
     
    6164  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    6265
    63   if (!LoadPhotcodes (PhotCodeFile)) {
    64     fprintf (stderr, "error loading photcodes\n");
     66  /* XXX this does not yet write out the master photcode table */
     67  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     68  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     69    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    6570    exit (1);
    6671  }
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/ConfigInit.c

    r8390 r12031  
    55  double ZERO_POINT;
    66  char  *config, *file;
    7   char   PhotCodeFile[256];
     7  char CatdirPhotcodeFile[256];
     8  char MasterPhotcodeFile[256];
    89
    910  /*** load configuration info ***/
     
    3233  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    3334  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
     35  ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, MasterPhotcodeFile);
     36
    3437  sprintf (ImageCat, "%s/Images.dat", CATDIR);
    3538
     
    4144  }
    4245
    43   GetConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
    4446  GetConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
    4547
     
    5254  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    5355
    54   if (!LoadPhotcodes (PhotCodeFile)) {
    55     fprintf (stderr, "error loading photcodes\n");
     56  /* XXX this does not yet write out the master photcode table */
     57  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     58  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     59    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    5660    exit (1);
    5761  }
  • branches/dvo-mods-2007-02/Ohana/src/relastro/src/initialize.c

    r8390 r12031  
    1313    exit (1);
    1414  }
    15   if ((photcode[0].type != PHOT_PRI) && (photcode[0].type != PHOT_SEC)) {
     15  if (photcode[0].type != PHOT_SEC) {
    1616    fprintf (stderr, "photcode %s is not a primary or secondary filter\n", argv[N]);
    1717    exit (1);
    1818  }
    1919
    20   PhotPrimary = (photcode[0].type == PHOT_PRI);
    2120  PhotNsec = GetPhotcodeNsecfilt ();
    2221  PhotSec = GetPhotcodeNsec (photcode[0].code);
  • branches/dvo-mods-2007-02/Ohana/src/relphot/src/ConfigInit.c

    r7080 r12031  
    55  double ZERO_POINT;
    66  char  *config, *file;
    7   char   PhotCodeFile[256];
     7  char CatdirPhotcodeFile[256];
     8  char MasterPhotcodeFile[256];
    89
    910  /*** load configuration info ***/
     
    3233  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    3334  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
     35  ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, MasterPhotcodeFile);
     36
    3437  sprintf (ImageCat, "%s/Images.dat", CATDIR);
    3538
     
    4144  }
    4245
    43   GetConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
    4446  GetConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
    4547
     
    5254  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    5355
    54   if (!LoadPhotcodes (PhotCodeFile)) {
    55     fprintf (stderr, "error loading photcodes\n");
     56  /* XXX this does not yet write out the master photcode table */
     57  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     58  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     59    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    5660    exit (1);
    5761  }
  • branches/dvo-mods-2007-02/Ohana/src/relphot/src/initialize.c

    r12012 r12031  
    1313    exit (1);
    1414  }
    15   if ((photcode[0].type != PHOT_PRI) && (photcode[0].type != PHOT_SEC)) {
     15  if (photcode[0].type != PHOT_SEC) {
    1616    fprintf (stderr, "photcode %s is not a primary or secondary filter\n", argv[N]);
    1717    exit (1);
  • branches/dvo-mods-2007-02/Ohana/src/uniphot/src/ConfigInit.c

    r6684 r12031  
    55  double ZERO_POINT;
    66  char  *config, *file;
    7   char   PhotCodeFile[256];
     7  char CatdirPhotcodeFile[256];
     8  char MasterPhotcodeFile[256];
    89
    910  /*** load configuration info ***/
     
    2021  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    2122  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
     23  ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, MasterPhotcodeFile);
     24
    2225  sprintf (ImageCat, "%s/Images.dat", CATDIR);
    2326
    24   ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
    2527  ScanConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
    2628  SetZeroPoint (ZERO_POINT);
     
    3234  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    3335
    34   if (!LoadPhotcodes (PhotCodeFile)) {
    35     fprintf (stderr, "error loading photcodes\n");
    36     exit (0);
     36  /* XXX this does not yet write out the master photcode table */
     37  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
     38  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     39    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
     40    exit (1);
    3741  }
    3842
Note: See TracChangeset for help on using the changeset viewer.