IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

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

Location:
trunk/Ohana/src/libdvo
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.