IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39267 for trunk/Ohana


Ignore:
Timestamp:
Dec 13, 2015, 8:56:10 AM (11 years ago)
Author:
eugene
Message:

adding cam zpts

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

Legend:

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

    r39263 r39267  
    8787
    8888  while (TRUE) {
    89     Header theader;
     89    Header *header = NULL;
     90    ALLOCATE (header, H
    9091
    9192    // load data for this header : if not found, assume we hit the end of the file
     
    113114    // assert that cam->matrix[index] is NULL?
    114115    cam->matrix[index] = matrix;
    115   }
     116    cam->header[index] = header;
     117  }
     118  return TRUE;
     119}
     120
     121int save_cam_correction (char *filename) {
     122
     123  int i, ix, iy, dir, filter;
     124  Header header;
     125
     126  /* open file for input */
     127  FILE *f = fopen (filename, "r");
     128  if (f == (FILE *) NULL) {
     129    gprint (GP_ERR, "can't open file for read : %s\n", filename);
     130    return FALSE;
     131  }
     132
     133  gfits_init_header (&header);
     134  header.extend = TRUE;
     135  gfits_create_header (&header);
     136  gfits_create_matrix (&header, &matrix);
     137
     138  gfits_modify (&header, "NSEASON",  "%d", 1, camcoor->Nseason);
     139  gfits_modify (&header, "NFILTER",  "%d", 1, camcoor->Nfilter);
     140  gfits_modify (&header, "NX",       "%d", 1, camcoor->Nx);
     141  gfits_modify (&header, "NY",       "%d", 1, camcoor->Ny);
     142  gfits_modify (&header, "DX",       "%d", 1, camcoor->dX);
     143  gfits_modify (&header, "DY",       "%d", 1, camcoor->dY);
     144  gfits_modify (&header, "NX_CHIP",  "%d", 1, camcoor->NxCCD);
     145  gfits_modify (&header, "NY_CHIP",  "%d", 1, camcoor->NyCCD);
     146
     147  gfits_fwrite_header  (f, &header);
     148  gfits_fwrite_matrix  (f, &matrix);
     149  gfits_free_header (&header);
     150  gfits_free_matrix (&matrix);
     151
     152  for (i = 0; i < camcorr->Nvalues; i++) {
     153
     154    // I don't need to do this, do I?
     155    // if (!gfits_scan (&theader, "FILTER", "%d", 1, &filter));
     156    // if (!gfits_scan (&theader, "SEASON", "%d", 1, &season));
     157    // if (!gfits_scan (&theader, "X_CHIP",  "%d", 1, &ix));   
     158    // if (!gfits_scan (&theader, "Y_CHIP",  "%d", 1, &iy));   
     159
     160    if (!cam->matrix[i]) continue;
     161
     162    gfits_fwrite_header  (f, whatHeader);
     163    gfits_fwrite_matrix  (f, cam->matrix[i]);
     164  }
     165
    116166  return TRUE;
    117167}
     
    239289    myAssert (flatcorrTable->IDtoSeq[ID] == i, "oops");
    240290
     291    // find the season (these are inherited from flatcorr, so they must match
    241292    int season = -1;
    242293    for (j = 0; j < newcorr->Nseason; j++) {
     
    248299    int photcode = flatcorr->image[i].photcode;
    249300
     301    // find the chip and filter from photcode:
    250302    iy = flatcorr->image[i].photcode % 10;
    251303    ix = (int)(flatcorr->image[i].photcode / 10) % 10;
    252304    filter = (int)(flatcorr->image[i].photcode / 100) % 10;
    253305             
     306    // seq is the flatcorr entry of interest
    254307    int seq = ix + iy * newcorr->Nx + filter * newcorr->Nchips + season * camcorr->Nflat;
    255308
    256309    // we now have newcorr->matrix[seq]
    257     newcorr->matrix[seq];
     310    Matrix *newDelta = newcorr->matrix[seq];
     311
     312    int jx, jy;
    258313
    259314    // now loop over the newcorr pixels to get the flatcorr value:
     
    261316      for (jy = 0; jy < newcorr->NyCCD; jy++) {
    262317       
    263         // convert jx,jy in newcorr pixels to Jx,Jy in flatcorr pixels
    264         newcorr->matrix[seq]->buffer[jx + jy*NxCCD] += flatcorr->offset[i][Jx][Jy];
    265 
     318        int chipX = jx * newcorr->dX;
     319        int chipY = jy * newcorr->dY;
     320
     321        // get the flatcorr offset from this chip coordinate
     322        float delta = FlatCorrectionOffset (flatcorr, flatcorr->image[i].ID, chipX, chipY);
     323
     324        newDelta->buffer[jx + jy*NxCCD] += flatcorr->offset[i][Jx][Jy];
    266325      }
    267326    }
     
    271330}
    272331
     332
  • trunk/Ohana/src/uniphot/src/setphot.c

    r39262 r39267  
    3030    FlatCorrectionSave(&flatcorrTable, flatcorrfile);
    3131    // XXX should this program save any old copy of this file?
    32   } else {
    33     zpts = load_zpt_table (argv[1], &Nzpts);
    34   }
    3532
    36   // if supplied, read in the camera-static flat-field correction
    37   if (CAM_FILE) {
    3833    if (!load_cam_correction (CAM_FILE)) {
    3934      fprintf (stderr, "failed to load camera-static flat-field correction\n");
     
    4136    }
    4237    merge_flatcorr_with_cam (flatcorrTable);
    43   } else {
    44     convert_flatcorr_to_cam (flatcorrTable);
    45   }
    4638
    47   {
    4839    char newflatfile[DVO_MAX_PATH];
    4940    int size = snprintf (newflatfile, DVO_MAX_PATH, "%s/flatfield.fits", CATDIR);
    5041    assert (size < DVO_MAX_PATH);
    5142    save_cam_correction (newflatfile);
     43  } else {
     44    zpts = load_zpt_table (argv[1], &Nzpts);
    5245  }
    5346
Note: See TracChangeset for help on using the changeset viewer.