IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40488


Ignore:
Timestamp:
Jun 27, 2018, 3:58:54 PM (8 years ago)
Author:
eugene
Message:

allow setphot to apply HSC corrections as well as GPC1

Location:
trunk/Ohana/src/uniphot/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/uniphot/src/cam_zpt_correction.c

    r39288 r40488  
    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)
     
    285286  // table->offset[seq][ix][iy] with dM values for image[seq]
    286287
     288  // Set up HSC/GPC1 distinguishing limits
     289
     290  int minCodeGPC1 = 10000;
     291  int maxCodeGPC1 = 10576;
     292
     293  int minCodeHSC  = 20000;
     294  int maxCodeHSC  = 26111;
     295
     296  int isGPC1 = FALSE;
     297  int isHSC  = FALSE;
     298   
    287299  // loop over the flatcorr images and match from image[seq] to newcorr:
    288300  for (i = 0; i < flatcorr->Nimage; i++) {
     
    301313    int photcode = flatcorr->image[i].photcode;
    302314
     315    if ((photcode >= minCodeGPC1)&&(photcode <= maxCodeGPC1)) {
     316      isGPC1 = TRUE;
     317      isHSC  = FALSE;
     318    }
     319    else if ((photcode >= minCodeHSC)&&(photcode <= maxCodeHSC)) {
     320      isGPC1 = FALSE;
     321      isHSC  = TRUE;
     322    }
     323    if (!(isGPC1) && !(isHSC)) { continue; }
     324
     325    int iy, ix, filter;
     326
     327   
    303328    // find the chip and filter from photcode:
    304     int iy = photcode % 10;
    305     int ix = (int)(photcode / 10) % 10;
    306     int filter = (int)(photcode / 100) % 10;
     329    if (isGPC1) {
     330      iy = photcode % 10;
     331      ix = (int)(photcode / 10) % 10;
     332      filter = (int)(photcode / 100) % 10;
     333    }
     334    else if (isHSC) {
     335      iy = 0;
     336      ix = (int) photcode % 112;
     337      filter = (int)(photcode / 1000) % 10;
     338    }
    307339             
    308340    myAssert (ix     < newcorr->Nx, "oops");
  • trunk/Ohana/src/uniphot/src/initialize_setphot.c

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

    r39288 r40488  
    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 filter = (int)(photcode / 1000) % 10;
     58        int ix = photcode - 20000 - filter * 1000;
     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;
  • trunk/Ohana/src/uniphot/src/setphot.c

    r39288 r40488  
    2121  if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename);
    2222
     23  fprintf (stderr, "this program needs to be fixed to allow a zpt lookup table\n");
     24  exit (3);
     25
    2326  if (UBERCAL) {
    2427    zpts = load_zpt_ubercal (argv[1], &Nzpts, &flatcorrTable);
     
    3740    }
    3841    camcorr = merge_flatcorr_and_camcorr (&flatcorrTable, rawcorr);
    39 
     42   
    4043    char newflatfile[DVO_MAX_PATH];
    4144    size = snprintf (newflatfile, DVO_MAX_PATH, "%s/flatfield.fits", CATDIR);
     
    4346    CamPhotomCorrectionSave (camcorr, newflatfile);
    4447  } else {
    45     zpts = load_zpt_table (argv[1], &Nzpts);
     48    //    zpts = load_zpt_table (argv[1], &Nzpts);
    4649  }
    4750
    48   if (!zpts) Shutdown ("failed to load zero points, or empty table");
     51  if ((CAM_PHOTOM_FILE)&&(!camcorr)) {
     52    CamPhotomCorrection *rawcorr = CamPhotomCorrectionLoad(CAM_PHOTOM_FILE);
     53    if (!rawcorr) {
     54      fprintf (stderr, "failed to load camera-static flat-field correction\n");
     55      exit (2);
     56    }
     57    camcorr = rawcorr;
     58    char newflatfile[DVO_MAX_PATH];
     59    int size = snprintf (newflatfile, DVO_MAX_PATH, "%s/flatfield.fits", CATDIR);
     60    assert (size < DVO_MAX_PATH);
     61    CamPhotomCorrectionSave (camcorr, newflatfile);
     62
     63    //    zpts = load_zpt_table (argv[1], &Nzpts);
     64  }   
     65
     66 
     67  //  if (!zpts) Shutdown ("failed to load zero points, or empty table");
    4968
    5069  // load images
     
    5271  if (!UPDATE) dvo_image_unlock (&db);
    5372 
    54   match_zpts_to_images (image, Nimage, zpts, Nzpts);
     73  //  match_zpts_to_images (image, Nimage, zpts, Nzpts);
    5574
    56   if (UBERCAL) {
     75  //  if (UBERCAL) {
    5776    // we are going to deprecate the flatcorr imaage lookup
    5877    // match_flatcorr_to_images (image, Nimage, &flatcorrTable);
    59     match_camcorr_to_images (image, Nimage, camcorr);
    60   }
     78  match_camcorr_to_images (image, Nimage, camcorr);
     79    //  }
    6180
    6281  if (!IMAGES_ONLY) {
Note: See TracChangeset for help on using the changeset viewer.