IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7693


Ignore:
Timestamp:
Jun 26, 2006, 9:43:18 AM (20 years ago)
Author:
eugene
Message:

creating sedstar

Location:
trunk/Ohana/src/addstar
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/include/sedstar.h

    r7690 r7693  
     1
     2typedef structu {
     3  int Nfilter;
     4  float *wavecode;
     5  float *vegaToAB;
     6  int *hashcode;
     7  int codeP;
     8  int codeM;
     9  SEDtableRow **row;
     10  int Nrow;
     11} SEDtable;
    112
    213typedef struct {
  • trunk/Ohana/src/addstar/src/SEDops.c

    r7690 r7693  
     1# include "addstar.h"
     2# include "sedstar.h"
    13
    24// fit the data (with errors) to the given table row
  • trunk/Ohana/src/addstar/src/SEDtableLoad.c

    r7690 r7693  
    22# include "sedstar.h"
    33
    4 SEDtable *SEDtableLoad (char *filename, int *nrow) {
     4// XXX where do the colorP and colorM codes come from?
     5SEDtable *SEDtableLoad (char *filename) {
    56
    67  FILE *f;
     8  char line[1024], name[64];
     9  char colornameP[64], colornameM[64];
     10  int colorP, colorM;
     11  int i, Nrow, NROW;
     12
     13  ALLOCATE (table, SEDtable, 1);
    714
    815  // load SED table
     
    1219  // XXX add error checks for header data
    1320  scan_line (f, line);
    14   sscanf (line, "%*s %*s %d", &Nfilter);
     21  sscanf (line, "%*s %*s %d", &table[0].Nfilter);
    1522
    1623  // load SED table photcodes, generate the photcode hashtable
    17   ALLOCATE (hashcode, int, 0x10000);
    18   ALLOCATE (wavecode, float, Nfilter);
    19   ALLOCATE (vegaToAB, float, Nfilter);
     24  ALLOCATE (table[0].hashcode, int, 0x10000);
     25  ALLOCATE (table[0].wavecode, float, table[0].Nfilter);
     26  ALLOCATE (table[0].vegaToAB, float, table[0].Nfilter);
    2027
    21   for (i = 0; i < 0x10000; i++) hashcode[i] = -1;
    22   for (i = 0; i < Nfilter; i++) {
     28  for (i = 0; i < 0x10000; i++) table[0].hashcode[i] = -1;
     29  for (i = 0; i < table[0].Nfilter; i++) {
    2330    scan_line (f, line);
    24     sscanf (line, "%*s %s %f %f", name, &wavecode[i], &vegaToAB[i]);
     31    sscanf (line, "%*s %s %f %f", name, &table[0].wavecode[i], &table[0].vegaToAB[i]);
    2532    code = GetPhotcodeCodebyName (name);
    2633    if (code == 0) goto code_missing;
    27     hashcode[code] = i;
     34    table[0].hashcode[code] = i;
    2835  }
    29   codeP = hashcode[colorP];
    30   codeM = hashcode[colorM];
    31   if ((codeP == -1) || (codeM == -1)) goto color_missing;
     36
     37  // define the selection color codes
     38  sscanf (line, "# %s - %s", colornameP, colornameM);
     39  colorP = GetPhotcodeCodebyName (colornameP);
     40  colorM = GetPhotcodeCodebyName (colornameM);
     41  table[0].codeP = table[0].hashcode[colorP];
     42  table[0].codeM = table[0].hashcode[colorM];
     43  if (table[0].codeP == -1) Shutdown ("missing positive color filter");
     44  if (table[0].codeM == -1) Shutdown ("missing positive color filter");
    3245   
    3346  // skip remaining header lines
     
    3750  scan_line (f, line);
    3851 
    39   // load the SED table data
     52  // load the SED raw table rows
    4053  Nrow = 0;
    4154  NROW = 100;
     
    4457    fparse (&SEDtableRaw[Nrow].Temp, 1, line);
    4558    fparse (&SEDtableRaw[Nrow].Av, 2, line);
    46     ALLOCATE (SEDtableRaw[Nrow].mags, float, Nfilter);
    47     for (i = 0; i < Nfilter; i++) {
     59    ALLOCATE (SEDtableRaw[Nrow].mags, float, table[0].Nfilter);
     60    for (i = 0; i < table[0].Nfilter; i++) {
    4861      fparse (&SEDtableRaw[Nrow].mags[i], i + 3, line);
    4962    }
     
    5467
    5568  // sort the SEDtable by the reference colors
    56   SEDtable = sort_SEDtable (SEDtableRaw, Nrow);
     69  table[0].row = sort_SEDtable (SEDtableRaw, Nrow);
     70  table[0].Nrow = Nrow;
     71  return (table);
     72}
  • trunk/Ohana/src/addstar/src/args_sedstar.c

    r7690 r7693  
    3434    remove_argument (N, &argc, argv);
    3535  }
    36   /* override any header PHOTCODE values */
    37   options.photcode = 0;
    38   if ((N = get_argument (argc, argv, "-p"))) {
    39     remove_argument (N, &argc, argv);
    40     options.photcode = GetPhotcodeCodebyName (argv[N]);
    41     remove_argument (N, &argc, argv);
    42   }
    4336
    44   options.timeref = 0;
    45   options.mosaic = FALSE;
    46   options.existing_regions = FALSE;
    47   options.skip_missed = FALSE;
    48   options.closest = FALSE;
    49 
    50   /* only add to existing objects */
    51   options.only_match = FALSE;
    52   if ((N = get_argument (argc, argv, "-only-match"))) {
    53     options.only_match = TRUE;
    54     remove_argument (N, &argc, argv);
    55   }
    56   /* replace measurement, don't duplicate (ref/cat only) */
    57   options.replace = FALSE;
    58   if ((N = get_argument (argc, argv, "-replace"))) {
    59     options.replace = TRUE;
    60     remove_argument (N, &argc, argv);
    61   }
    62 
    63   /* select quality flags */
    64   SELECT_2MASS_QUALITY = NULL;
    65   if ((N = get_argument (argc, argv, "-2massquality"))) {
    66     remove_argument (N, &argc, argv);
    67     SELECT_2MASS_QUALITY = strcreate (argv[N]);
    68     remove_argument (N, &argc, argv);
    69   }
    7037  /* extra error messages */
    7138  VERBOSE = FALSE;
     
    7643
    7744  /* other defaults */
     45  options.timeref = 0;
     46  options.mosaic = FALSE;
     47  options.existing_regions = FALSE;
     48  options.skip_missed = FALSE;
     49  options.closest = FALSE;
     50  options.only_match = FALSE;
     51  options.replace = FALSE;
    7852  options.nosort = FALSE;
    7953  options.update = FALSE;
     
    8761  DUMP = NULL;
    8862
    89   if (argc != 1) {
    90     fprintf (stderr, "USAGE: load2mass\n");
     63  if (argc != 3) {
     64    fprintf (stderr, "USAGE: sedstar (sedtable) (outcatalog) [-region Rmin Rmax Dmin Dmax]\n");
    9165    exit (2);
    9266  }
     
    9771
    9872  fprintf (stderr, "USAGE\n");
    99   fprintf (stderr, "  load2mass");
    100   fprintf (stderr, "     add data from 2MASS catalog to fullsky\n\n");
     73  fprintf (stderr, "  sedstar (SEDtable)");
     74  fprintf (stderr, "     fit objects to stellar SEDs\n\n");
    10175
    10276  fprintf (stderr, "  optional flags:\n");
    103   fprintf (stderr, "  -p (photcode)               : specify photcode (override header)\n");
    104   fprintf (stderr, "  -only-match                 : only add measurements to existing objects\n");
    105   fprintf (stderr, "  -replace                    : replace time/photcode measurements (no duplication)\n");
     77  fprintf (stderr, "  -region Rmin Rmax Dmin Dmax : sky region for analysis\n");
    10678  fprintf (stderr, "  -v                          : verbose mode\n");
    10779  fprintf (stderr, "  -help                       : this list\n");
  • trunk/Ohana/src/addstar/src/sedstar.c

    r7690 r7693  
    77  SkyTable *sky, *sky2mass;
    88  AddstarClientOptions options;
     9  Catalog incatalog, outcatalog;
    910
    1011  // need to construct these options with args_load2mass...
     
    1617 
    1718  // select regions of interest
     19  skylist = SkyListByPatch (sky, -1, &UserPatch);
    1820
    1921  // load the SED data table
    20   sedtable = SEDtableLoad (SEDfile, &Nsedtable);
     22  sedtable = SEDtableLoad (argv[1]);
    2123
     24  for (i = 0; i < skylist[0].Nregions; i++) {
     25    incatalog.filename = skylist[0].filename[i];
     26    load_pt_catalog (&incatalog, skylist[0].regions[i]);
     27
     28    // create output catalog filename
     29    root = strstr (incatalog.filename, CATDIR);
     30    if (root == NULL) Shutdown ("error with input catalog name");
     31
     32    extension = incatalog.filename + strlen(CATDIR);
     33    ALLOCATE (outcatalog.filename, char, strlen(argv[2]) + strlen(extension) + 2);
     34    sprintf (outcatalog.filename, "%s/%s", argv[2], extension);
     35
     36    status = lock_catalog (outcatalog, LCK_XCLD);
     37    if (status != 2) Shutdown ("error: output catalog exists");
     38    mkcatalog (region, catalog); /* fills in new header info */
     39
     40    SEDfit (&outcatalog, &incatalog, sedtable);
     41   
     42    wcatalog (outcatalog);
     43    unlock_catalog (outcatalog);
     44    free (outcatalog.filename);
     45  }
    2246
    2347  exit (0);
Note: See TracChangeset for help on using the changeset viewer.