Changeset 40129

Show
Ignore:
Timestamp:
09/08/17 15:28:50 (3 months ago)
Author:
watersc1
Message:

Changes to setphot to deal with HSC data, and to force it to apply the correction requested.

Location:
branches/czw_branch/20170908/Ohana/src/uniphot/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20170908/Ohana/src/uniphot/src/cam_zpt_correction.c

    r39288 r40129  
    100100    char field[256]; 
    101101    double value; 
    102  
     102     
    103103    snprintf (field, 256, "TS_%03d", i); 
    104104    if (!gfits_scan (phu, field, "%lf", 1, &value)) return FALSE; 
    105105    cam->tstart[i] = ohana_mjd_to_sec(value); 
    106  
     106     
    107107    snprintf (field, 256, "TE_%03d", i); 
    108108    if (!gfits_scan (phu, field, "%lf", 1, &value)) return FALSE; 
     
    174174  if (!flat_id) return 0.0; 
    175175 
    176   myAssert (flat_id > 0, "flat_id out of range"); 
    177   myAssert (flat_id <= cam->Nvalues, "flat_id out of range"); 
    178  
     176  //  myAssert (flat_id > 0, "flat_id out of range"); 
     177  // myAssert (flat_id <= cam->Nvalues, "flat_id out of range"); 
     178  if ((flat_id < 0)||(flat_id > cam->Nvalues)) { return 0.0; } 
     179   
    179180  // validate the flat_id (not out of range?) 
    180181  // NOTE: we are setting the ID to be the sequence + 1 (match_camcorr_to_images.c:39) 
  • branches/czw_branch/20170908/Ohana/src/uniphot/src/initialize_setphot.c

    r39926 r40129  
    217217   
    218218 
    219   if (argc != 2) { 
     219  if (argc > 2) { 
    220220    fprintf (stderr, "USAGE: setphot (zptfile) [options]\n"); 
    221221    fprintf (stderr, "  options:\n"); 
  • branches/czw_branch/20170908/Ohana/src/uniphot/src/match_camcorr_to_images.c

    r39288 r40129  
    1414  // season comes from the date/time 
    1515 
    16   int minCode = 10000; 
    17   int maxCode = 10576; 
     16  int minCodeGPC1 = 10000; 
     17  int maxCodeGPC1 = 10576; 
     18 
     19  int minCodeHSC  = 20000; 
     20  int maxCodeHSC  = 26111; 
    1821 
    1922  int Nmissed = 0; 
     23 
     24  int isGPC1 = FALSE; 
     25  int isHSC  = FALSE; 
    2026   
    2127  for (i = 0; i < Nimage; i++) { 
    2228    if (!image[i].photcode) continue; // skip PHU images 
    2329 
    24     if (image[i].photcode < minCode) continue; // skip non-gpc1-chip images 
    25     if (image[i].photcode > maxCode) continue; // skip non-gpc1-chip images 
     30    if ((image[i].photcode >= minCodeGPC1)&&(image[i].photcode <= maxCodeGPC1)) { 
     31      isGPC1 = TRUE; 
     32      isHSC  = FALSE; 
     33    } 
     34    else if ((image[i].photcode >= minCodeHSC)&&(image[i].photcode <= maxCodeHSC)) { 
     35      isGPC1 = FALSE; 
     36      isHSC  = TRUE; 
     37    } 
    2638 
     39    if (!(isGPC1) && !(isHSC)) { continue; } 
     40     
    2741    int found = FALSE; 
    2842    for (j = 0; !found && (j < camcorr->Nseason); j++) { 
     
    3044      if (image[i].tzero > camcorr->tstop[j]) continue; 
    3145 
     46      int seq; 
    3247      int photcode = image[i].photcode; 
    33       int iy =  photcode % 10; 
    34       int ix = (int)(photcode / 10) % 10; 
    35       int filter = (int)(photcode / 100) % 10; 
     48 
     49      if (isGPC1) {  
     50        int iy =  photcode % 10; 
     51        int ix = (int)(photcode / 10) % 10; 
     52        int filter = (int)(photcode / 100) % 10; 
     53 
     54        seq = ix + iy * camcorr->Nx + filter * camcorr->Nchips + j * camcorr->Nflats; 
     55      } 
     56      else if (isHSC) { 
     57        int ix = photcode % 112; 
     58        int filter = (int)(photcode / 1000) % 10; 
     59 
     60        seq = ix + filter * camcorr->Nchips + j * camcorr->Nflats; 
     61      } 
    3662 
    3763      // we add one so photom_map_id = 0 can mean no map 
    38       int seq = ix + iy * camcorr->Nx + filter * camcorr->Nchips + j * camcorr->Nflats; 
    3964      image[i].photom_map_id = seq + 1; 
    4065      found = TRUE; 
  • branches/czw_branch/20170908/Ohana/src/uniphot/src/setphot.c

    r39288 r40129  
    3737    } 
    3838    camcorr = merge_flatcorr_and_camcorr (&flatcorrTable, rawcorr); 
    39  
     39     
    4040    char newflatfile[DVO_MAX_PATH]; 
    4141    size = snprintf (newflatfile, DVO_MAX_PATH, "%s/flatfield.fits", CATDIR); 
     
    4343    CamPhotomCorrectionSave (camcorr, newflatfile); 
    4444  } else { 
    45     zpts = load_zpt_table (argv[1], &Nzpts); 
     45    //    zpts = load_zpt_table (argv[1], &Nzpts); 
    4646  } 
    4747 
    48   if (!zpts) Shutdown ("failed to load zero points, or empty table"); 
     48  if ((CAM_PHOTOM_FILE)&&(!camcorr)) { 
     49    CamPhotomCorrection *rawcorr = CamPhotomCorrectionLoad(CAM_PHOTOM_FILE); 
     50    if (!rawcorr) { 
     51      fprintf (stderr, "failed to load camera-static flat-field correction\n"); 
     52      exit (2); 
     53    } 
     54    camcorr = rawcorr; 
     55    char newflatfile[DVO_MAX_PATH]; 
     56    int size = snprintf (newflatfile, DVO_MAX_PATH, "%s/flatfield.fits", CATDIR); 
     57    assert (size < DVO_MAX_PATH); 
     58    CamPhotomCorrectionSave (camcorr, newflatfile); 
     59 
     60    //    zpts = load_zpt_table (argv[1], &Nzpts); 
     61  }     
     62 
     63   
     64  //  if (!zpts) Shutdown ("failed to load zero points, or empty table"); 
    4965 
    5066  // load images  
     
    5268  if (!UPDATE) dvo_image_unlock (&db);  
    5369   
    54   match_zpts_to_images (image, Nimage, zpts, Nzpts); 
     70  //  match_zpts_to_images (image, Nimage, zpts, Nzpts); 
    5571 
    56   if (UBERCAL) { 
     72  //  if (UBERCAL) { 
    5773    // we are going to deprecate the flatcorr imaage lookup 
    5874    // match_flatcorr_to_images (image, Nimage, &flatcorrTable); 
    5975    match_camcorr_to_images (image, Nimage, camcorr); 
    60   }  
     76    //  }  
    6177 
    6278  if (!IMAGES_ONLY) {