IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15694


Ignore:
Timestamp:
Nov 26, 2007, 4:36:14 PM (18 years ago)
Author:
eugene
Message:

adding new photcode I/O formats; adding fields for astrometric error to photcode

Location:
trunk/Ohana/src
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libautocode/Makefile.Targets

    r15540 r15694  
    2222$(ASRC)/missing.$(ARCH).o \
    2323$(ASRC)/photcode.$(ARCH).o \
     24$(ASRC)/photcode-elixir.$(ARCH).o \
     25$(ASRC)/photcode-ps1-dev-1.$(ARCH).o \
    2426$(ASRC)/image.$(ARCH).o \
    2527$(ASRC)/image-loneos.$(ARCH).o \
     
    6769$(AINC)/missing.h \
    6870$(AINC)/photcode.h \
     71$(AINC)/photcode-elixir.h \
     72$(AINC)/photcode-ps1-dev-1.h \
    6973$(AINC)/image.h \
    7074$(AINC)/image-loneos.h \
  • trunk/Ohana/src/libautocode/def/photcode.d

    r12332 r15694  
    11STRUCT       PhotCode
    2 EXTNAME      DVO_PHOTCODE
     2EXTNAME      DVO_PHOTCODE_RAW
    33TYPE         BINTABLE
    4 SIZE         80
     4SIZE         104
    55DESCRIPTION  DVO Photcode Description Table
    66
    77# elements of data structure / FITS table
    8 FIELD  code,        CODE,        unsigned short, code number (stored in Measure.source)
    9 FIELD  name,        NAME,        char[32],       name for filter combination
    10 FIELD  type,        TYPE,        char,           PRI/SEC/DEP/REF
    11 FIELD  dummy,       DUMMY,       char[3],        padding
    12 FIELD  C,           C_LAM,       short,          primary phot calibration terms (millimags)
    13 FIELD  dC,          C_LAM_ERR,   short,          primary phot calibration terms (millimags)
    14 FIELD  dX,          X_ERR,       short,          primary phot calibration terms (millimags)
    15 FIELD  K,           K,           float,          secondary phot calibration terms (millimags)
    16 FIELD  c1,          C1,          int,            color is average.M[c1] - average.M[c2]
    17 FIELD  c2,          C2,          int,            color is average.M[c1] - average.M[c2]
    18 FIELD  equiv,       EQUIV,       int,            this dependent filter is equivalent to equiv PRI/SEC
    19 FIELD  Nc,          NC,          int,            number of color terms
    20 FIELD  X,           X,           float[4],       color terms $X[0]*mc + X[1]*mc^2 + X[2]*mc^3$, etc
     8FIELD  code,         CODE,          unsigned short, code number (stored in Measure.source)
     9FIELD  name,         NAME,          char[32],       name for filter combination
     10FIELD  type,         TYPE,          char,           PRI/SEC/DEP/REF
     11FIELD  dummy,        DUMMY,         char[3],        padding
     12FIELD  C,            C_LAM,         short,          primary phot calibration terms (millimags)
     13FIELD  dC,           C_LAM_ERR,     short,          primary phot calibration terms (millimags)
     14FIELD  dX,           X_ERR,         short,          primary phot calibration terms (millimags)
     15FIELD  K,            K,             float,          secondary phot calibration terms (millimags)
     16FIELD  c1,           C1,            int,            color is average.M[c1] - average.M[c2]
     17FIELD  c2,           C2,            int,            color is average.M[c1] - average.M[c2]
     18FIELD  equiv,        EQUIV,         int,            this dependent filter is equivalent to equiv PRI/SEC
     19FIELD  Nc,           NC,            int,            number of color terms
     20FIELD  X,            X,             float[4],       color terms $X[0]*mc + X[1]*mc^2 + X[2]*mc^3$, etc
     21FIELD  astromScale,  ASTROM_SCALE,  float,          astrom error = mag error * astromScale
     22FIELD  photSysErr,   PHOT_SYS_ERR,  float,          systematic photometric error
     23FIELD  padding,      PADDING,       float[4],       placeholder
  • trunk/Ohana/src/libdvo/Makefile

    r15621 r15694  
    3636$(SRC)/version.$(ARCH).o         \
    3737$(SRC)/coordops.$(ARCH).o        \
     38$(SRC)/dvo_photcode_ops.$(ARCH).o \
     39$(SRC)/dvo_photcode_convert_elixir.$(ARCH).o \
     40$(SRC)/dvo_photcode_convert_ps1_dev_1.$(ARCH).o \
    3841$(SRC)/dvo_photcode_ops.$(ARCH).o \
    3942$(SRC)/LoadPhotcodes.$(ARCH).o   \
  • trunk/Ohana/src/libdvo/include/elixir_defs.h

    r15035 r15694  
    77SecFilt                 *SecFilt_Elixir_ToInternal (SecFilt_Elixir *in, int Nvalues);
    88SecFilt_Elixir          *SecFiltInternalTo_Elixir (SecFilt *in, int Nvalues);
     9
     10PhotCode *PhotCode_Elixir_To_Internal (PhotCode_Elixir *in, int Nvalues);
     11PhotCode_Elixir *PhotCode_Internal_To_Elixir (PhotCode *in, int Nvalues);
  • trunk/Ohana/src/libdvo/include/ps1_dev_1_defs.h

    r15035 r15694  
    77SecFilt                 *SecFilt_PS1_DEV_1_ToInternal (SecFilt_PS1_DEV_1 *in, int Nvalues);
    88SecFilt_PS1_DEV_1       *SecFiltInternalTo_PS1_DEV_1 (SecFilt *in, int Nvalues);
     9
     10PhotCode *PhotCode_PS1_DEV_1_To_Internal (PhotCode_PS1_DEV_1 *in, int Nvalues);
     11PhotCode_PS1_DEV_1 *PhotCode_Internal_To_PS1_DEV_1 (PhotCode *in, int Nvalues);
  • trunk/Ohana/src/libdvo/src/LoadPhotcodesFITS.c

    r12332 r15694  
    99  PhotCode *photcode;
    1010  FITS_DB db;
     11  char extname[80];
    1112
    1213  int i, code, Ncode, Nsec, Nsecfilt;
     
    3738
    3839  /* convert FITS format data to internal format (just byteswaps) */
    39   photcode = gfits_table_get_PhotCode (&db.ftable, &Ncode, &db.swapped);
     40  gfits_scan (&db.theader, "EXTNAME", "%s", 1, extname);
     41
     42  if (!strcmp (extname, "DVO_PHOTCODE") || !strcmp (extname, "DVO_PHOTCODE_ELIXIR")) {
     43    PhotCode_Elixir *photcode_elixir = gfits_table_get_PhotCode_Elixir (&db.ftable, &Ncode, &db.swapped);
     44    photcode = PhotCode_Elixir_To_Internal (photcode_elixir, Ncode);
     45    free (photcode_elixir);
     46  }
     47
     48  if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_1")) {
     49    PhotCode_PS1_DEV_1 *photcode_ps1_dev_1 = gfits_table_get_PhotCode_PS1_DEV_1 (&db.ftable, &Ncode, &db.swapped);
     50    photcode = PhotCode_PS1_DEV_1_To_Internal (photcode_ps1_dev_1, Ncode);
     51    free (photcode_ps1_dev_1);
     52  }
    4053
    4154  table = GetPhotcodeTable ();
  • trunk/Ohana/src/libdvo/src/LoadPhotcodesText.c

    r12332 r15694  
    11# include <dvo.h>
     2
     3static int PhotcodeNumberOrName (char *word) {
     4
     5  int value;
     6  char *endpt;
     7
     8  if (!strcmp (word, "-")) return (0);
     9
     10  value = strtol (word, &endpt, 10);
     11  if (endpt != word + strlen(word)) {
     12    value = GetPhotcodeCodebyName (word);
     13  }
     14  return (value);
     15}
    216
    317/* load the text photcode table */
     
    1226  int code;
    1327  char *c;
    14   char line[256];
     28  char line[256], **c1_names, **c2_names, **eq_names;
    1529  char name[32], type[32], Zero[32], Airmass[32], Offset[32],
    1630    C1[32], C2[32], Slope[32], Color[32], Primary[32];
    17   int c1, c2;
    1831
    1932  table = GetPhotcodeTable ();
     
    4053  NPHOTCODE = 10;
    4154  ALLOCATE (photcode, PhotCode, NPHOTCODE);
     55  ALLOCATE (eq_names, char *,   NPHOTCODE);
     56  ALLOCATE (c1_names, char *,   NPHOTCODE);
     57  ALLOCATE (c2_names, char *,   NPHOTCODE);
    4258
    4359  while (scan_line (f, line) != EOF) {
     
    4662    Nfield = sscanf (c, "%d %s %s %s %s %s %s %s %s %s %s",
    4763                     &code, name, type, Zero, Airmass, Offset, C1, C2, Slope, Color, Primary);
     64
     65    // XXX to add the AstromError (and PhotError) terms, we need to add them to the photcode structure, and
     66    // define methods to read (at least) the old and the new photcode versions.
     67
    4868    if (Nfield != 11) { continue; }
    4969   
    50     c1 = atof (C1);
    51     c2 = atof (C2);
    52     if (!strcmp (C1, "-")) { c1 = 0; }
    53     if (!strcmp (C2, "-")) { c2 = 0; }
    54 
    5570    if (!code) {
    5671        fprintf (stderr, "photcode values may not be 0: fix %s\n", name);
     
    6277    memset (photcode[Ncode].name, 0, 32);
    6378    strcpy (photcode[Ncode].name, name);
     79
    6480    if (!strncasecmp (type, "pri", 3)) {
    6581      photcode[Ncode].type  = PHOT_SEC;
    66       photcode[Ncode].C     = 1000*atof (Zero);
    67       photcode[Ncode].K     = atof (Airmass);
    68       photcode[Ncode].dC    = 1000*atof (Offset);
    69       photcode[Ncode].dX    = 1000*atof (Color);
    70       photcode[Ncode].c1    = c1;
    71       photcode[Ncode].c2    = c2;
    72       photcode[Ncode].equiv = atoi (Primary);
    73       ParseColorTerms (Slope, photcode[Ncode].X, &photcode[Ncode].Nc);
    74     }     
     82    }
    7583    if (!strncasecmp (type, "sec", 3)) {
    7684      photcode[Ncode].type  = PHOT_SEC;
    77       photcode[Ncode].C     = 1000*atof (Zero);
    78       photcode[Ncode].K     = atof (Airmass);
    79       photcode[Ncode].dC    = 1000*atof (Offset);
    80       photcode[Ncode].dX    = 1000*atof (Color);
    81       photcode[Ncode].c1    = c1;
    82       photcode[Ncode].c2    = c2;
    83       photcode[Ncode].equiv = atoi (Primary);
    84       ParseColorTerms (Slope, photcode[Ncode].X, &photcode[Ncode].Nc);
    85     }     
     85    }
    8686    if (!strncasecmp (type, "dep", 3)) {
    8787      photcode[Ncode].type  = PHOT_DEP;
    88       photcode[Ncode].C     = 1000*atof (Zero);    /* zero point in millimags */
    89       photcode[Ncode].K     = atof (Airmass);      /* airmass coeff (millimag / millimag) */
    90       photcode[Ncode].dC    = 1000*atof (Offset);  /* color ref z.p. (millimag) */
    91       photcode[Ncode].dX    = 1000*atof (Color);   /* average color (millimag) */
    92       photcode[Ncode].c1    = c1;
    93       photcode[Ncode].c2    = c2;
    94       photcode[Ncode].equiv = atoi (Primary);
    95       ParseColorTerms (Slope, photcode[Ncode].X, &photcode[Ncode].Nc);
    96     }     
     88    }
    9789    if (!strncasecmp (type, "ref", 3)) {
    9890      photcode[Ncode].type  = PHOT_REF;
    99       photcode[Ncode].C     = 0;
    100       photcode[Ncode].K     = 0;
    101       photcode[Ncode].dC    = 0;
    102       photcode[Ncode].dX    = 0;
    103       photcode[Ncode].c1    = 0;
    104       photcode[Ncode].c2    = 0;
    105       photcode[Ncode].equiv = atoi (Primary);
    106       photcode[Ncode].X[0]  = 0;
    107       photcode[Ncode].Nc    = 0;
    108     }
    109 
    110     /* alt photcodes are a little different: they have the SAME photcode as an existing
    111        pri/sec photcode, but define an alternate transformation for that code */
     91    }
    11292    if (!strncasecmp (type, "alt", 3)) {
     93      /* alt photcodes are a little different: they have the SAME photcode as an existing
     94         pri/sec photcode, but define an alternate transformation for that code */
    11395      photcode[Ncode].type  = PHOT_ALT;
    114       photcode[Ncode].C     = 1000*atof (Zero);    /* zero point in millimags */
    115       photcode[Ncode].K     = atof (Airmass);      /* airmass coeff (millimag / millimag) */
    116       photcode[Ncode].dC    = 1000*atof (Offset);  /* color ref z.p. (millimag) */
    117       photcode[Ncode].dX    = 1000*atof (Color);   /* average color (millimag) */
    118       photcode[Ncode].c1    = c1;
    119       photcode[Ncode].c2    = c2;
    120       photcode[Ncode].equiv = atoi (Primary);
    121       ParseColorTerms (Slope, photcode[Ncode].X, &photcode[Ncode].Nc);
    122     }
     96    }
     97
     98    switch (photcode[Ncode].type) {
     99      case PHOT_SEC:
     100      case PHOT_ALT:
     101      case PHOT_DEP:
     102        photcode[Ncode].C     = 1000*atof (Zero);
     103        photcode[Ncode].K     = atof (Airmass);
     104        photcode[Ncode].dC    = 1000*atof (Offset);
     105        photcode[Ncode].dX    = 1000*atof (Color);
     106        c1_names[Ncode]       = strcreate (C1);
     107        c2_names[Ncode]       = strcreate (C2);
     108        eq_names[Ncode]       = strcreate (Primary);
     109        ParseColorTerms (Slope, photcode[Ncode].X, &photcode[Ncode].Nc);
     110        break;
     111
     112      case PHOT_REF:
     113        photcode[Ncode].C     = 0;
     114        photcode[Ncode].K     = 0;
     115        photcode[Ncode].dC    = 0;
     116        photcode[Ncode].dX    = 0;
     117        c1_names[Ncode]       = strcreate ("0");
     118        c2_names[Ncode]       = strcreate ("0");
     119        eq_names[Ncode]       = strcreate (Primary);
     120        photcode[Ncode].X[0]  = 0;
     121        photcode[Ncode].Nc    = 0;
     122        break;
     123
     124      default:
     125        fprintf (stderr, "error: invalid photcode type\n");
     126        exit (2);
     127    }     
     128
    123129    if (!photcode[Ncode].type) {
    124130      fprintf (stderr, "error in Photfile: unknown type %s\n", type);
     
    129135      NPHOTCODE += 10;
    130136      REALLOCATE (photcode, PhotCode, NPHOTCODE);
     137      REALLOCATE (eq_names, char *,   NPHOTCODE);
     138      REALLOCATE (c1_names, char *,   NPHOTCODE);
     139      REALLOCATE (c2_names, char *,   NPHOTCODE);
    131140    }
    132141  }
    133142  fclose (f);
    134143 
     144  // convert the named references (c1, c2, equiv) to code values
     145  for (i = 0; i < Ncode; i++) {
     146    photcode[i].c1    = PhotcodeNumberOrName (c1_names[i]);
     147    photcode[i].c2    = PhotcodeNumberOrName (c2_names[i]);
     148    photcode[i].equiv = PhotcodeNumberOrName (eq_names[i]);
     149    free (c1_names[i]);
     150    free (c2_names[i]);
     151    free (eq_names[i]);
     152  }
     153  free (c1_names);
     154  free (c2_names);
     155  free (eq_names);
     156
    135157  /* set up photcode indexes (see dvo_photcode_ops.c) */
    136158  Nsecfilt = 0;
  • trunk/Ohana/src/libdvo/src/SavePhotcodesFITS.c

    r14590 r15694  
    2727  }
    2828
    29   /* convert FITS format data to internal format (just byteswaps) */
     29  // for the moment, we simply support the latest photcode format for output
     30  // XXX update this as needed as new formats are defined
     31  PhotCode_PS1_DEV_1 *photcode_output = PhotCode_Internal_To_PS1_DEV_1 (table[0].code, table[0].Ncode);
     32
     33  /* convert FITS format data to internal format (byteswaps & EXTNAME) */
    3034  gfits_db_create (&db);
    31   gfits_table_set_PhotCode (&db.ftable, table[0].code, table[0].Ncode);
     35  gfits_table_set_PhotCode_PS1_DEV_1 (&db.ftable, photcode_output, table[0].Ncode);
    3236  gfits_db_save (&db);
    3337  gfits_db_close (&db);
    3438
    35   /* gfits_table_set_PhotCode performs the needed byte swap.  swap back */
    36   gfits_convert_PhotCode (table[0].code, sizeof(PhotCode), table[0].Ncode);
     39  free (photcode_output);
     40
    3741  return TRUE;
    3842}
  • trunk/Ohana/src/relastro/src/UpdateObjects.c

    r15600 r15694  
    4747  int mode, Nave, Npm, Npar, Nskip;
    4848  double Tmin, Tmax;
     49  float errorScale;
     50  PhotCode *code;
    4951
    5052  initObjectData (catalog, Ncatalog);
     
    9698        /* the astrometric errors are not being carried yet (but should be!) */
    9799        /* we use the photometric mag error as a weighting term */
    98         dR[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR);
    99         dD[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR);
     100
     101        code = GetPhotcodebyCode (catalog[0].measure[m].photcode);
     102        errorScale = code[0].astromScale;
     103        dR[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR) * errorScale;
     104        dD[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR) * errorScale;
    100105        dT[N] = catalog[i].measure[m].dt;
    101106
Note: See TracChangeset for help on using the changeset viewer.