IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 20, 2010, 11:15:36 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/dvomergeCreate.c

    r27583 r28993  
    1010  SkyList *inlist;
    1111  Catalog incatalog, outcatalog;
    12   char filename[256], *input1, *input2, *output;
     12  char filename[256];
     13  char filename1[256];
     14  char *codesFilename;
     15  char *input1, *input2, *output;
    1316  IDmapType IDmap1, IDmap2;
    1417
     
    2225  dvomergeImagesCreate (&IDmap1, input1, &IDmap2, input2, output);
    2326
    24   // the first input defines the photcode table & db layout
    25   sprintf (filename, "%s/Photcodes.dat", input1);
     27  PhotCodeData *input1Photcodes = NULL;
     28  PhotCodeData *input2Photcodes = NULL;
     29  PhotCodeData *outputPhotcodes = NULL;
     30  int *secfiltMap1 = NULL;
     31  int *secfiltMap2 = NULL;
     32
     33  // Read the input1 photcodes
     34  SetPhotcodeTable(NULL);
     35  sprintf (filename1, "%s/Photcodes.dat", input1);
     36  if (!LoadPhotcodes (filename1, NULL, FALSE)) {
     37    fprintf (stderr, "error loading photcode table %s\n", filename1);
     38    exit (1);
     39  }
     40  input1Photcodes = GetPhotcodeTable();
     41
     42  // Read the input2 photcodes
     43  SetPhotcodeTable(NULL);
     44  sprintf (filename, "%s/Photcodes.dat", input2);
    2645  if (!LoadPhotcodes (filename, NULL, FALSE)) {
    2746    fprintf (stderr, "error loading photcode table %s\n", filename);
    2847    exit (1);
    2948  }
    30   // save the photcodes in the output catdir
     49  input2Photcodes = GetPhotcodeTable();
     50
     51  if (ALTERNATE_PHOTCODE_FILE) {
     52    SetPhotcodeTable(NULL);
     53    // First attempt to read file as fits table ...
     54    if (!LoadPhotcodes(ALTERNATE_PHOTCODE_FILE, NULL, FALSE)) {
     55      // and if that fails try it as a text file
     56      if (!LoadPhotcodesText(ALTERNATE_PHOTCODE_FILE)) {
     57        fprintf (stderr, "failed to read photcode file %s\n", ALTERNATE_PHOTCODE_FILE);
     58        exit (1);
     59      }
     60    }
     61    outputPhotcodes = GetPhotcodeTable();
     62
     63    secfiltMap1 = GetSecFiltMap(outputPhotcodes, input1Photcodes);
     64    if (!secfiltMap1) {
     65      fprintf (stderr, "failed to map %s secfilt photcodes to alternate photcodes table %s\n", input1,
     66        ALTERNATE_PHOTCODE_FILE);
     67      exit (1);
     68    }
     69
     70    codesFilename = ALTERNATE_PHOTCODE_FILE;
     71
     72  } else {
     73    // Use the first input file's photcodes
     74    outputPhotcodes = input1Photcodes;
     75    codesFilename = filename1;
     76    // secfitMap1 can remain NULL since input1 defines the set of codes
     77  }
     78
     79  secfiltMap2 = GetSecFiltMap(outputPhotcodes, input2Photcodes);
     80  if (!secfiltMap2) {
     81    fprintf (stderr, "falied to map %s secfilt photcodes to output photcodes table %s\n", input2,
     82      codesFilename);
     83    exit (1);
     84  }
     85
     86  // save the output photcodes in the output catdir
     87  SetPhotcodeTable(outputPhotcodes);
    3188  sprintf (filename, "%s/Photcodes.dat", output);
    3289  if (!check_file_access (filename, TRUE, TRUE, VERBOSE)) {
     
    64121    if (VERBOSE) fprintf (stderr, "output: %s\n", outsky[0].regions[i].name);
    65122
     123    if (outputPhotcodes) {
     124        SetPhotcodeTable(outputPhotcodes);
     125    }
    66126    // load / create output catalog
    67127    LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w");
    68128
     129    if (input1Photcodes) {
     130        SetPhotcodeTable(input1Photcodes);
     131    }
    69132    // combine only tables at equal or larger depth
    70133     
     
    84147      }
    85148      dvo_update_image_IDs (&IDmap1, &incatalog);
    86       merge_catalogs_new (&outsky[0].regions[i], &outcatalog, &incatalog);
     149      merge_catalogs_new (&outsky[0].regions[i], &outcatalog, &incatalog, secfiltMap1);
    87150      dvo_catalog_unlock (&incatalog);
    88151      dvo_catalog_free (&incatalog);
    89152    }
    90153    SkyListFree (inlist);
     154
     155    if (input2Photcodes) {
     156      SetPhotcodeTable(input2Photcodes);
     157    }
    91158
    92159    // load in all of the tables from input2 for this region
     
    95162      if (VERBOSE) fprintf (stderr, "input 2: %s\n", inlist[0].regions[j][0].name);
    96163
    97       // load input catalog (1)
     164      // load input catalog (2)
    98165      LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r");
    99166
     
    105172      }
    106173      dvo_update_image_IDs (&IDmap2, &incatalog);
    107       merge_catalogs_old (&outsky[0].regions[i], &outcatalog, &incatalog, RADIUS);
     174      merge_catalogs_old (&outsky[0].regions[i], &outcatalog, &incatalog, RADIUS, secfiltMap2);
    108175      dvo_catalog_unlock (&incatalog);
    109176      dvo_catalog_free (&incatalog);
Note: See TracChangeset for help on using the changeset viewer.