IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33156


Ignore:
Timestamp:
Jan 26, 2012, 5:20:00 AM (14 years ago)
Author:
eugene
Message:

fix sign on Mcal & flatcorr

Location:
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/load_zpt_table.c

    r33137 r33156  
    7373  int CHIP_DY;
    7474
    75   FILE *f;
    76 
    77   f = fopen (filename, "r");
     75  *nzpts = 0;
     76
     77  FILE *f = fopen (filename, "r");
    7878  if (!f) {
    7979    fprintf (stderr, "ERROR: cannot open zpt table file %s\n", filename);
     
    178178  ftable.header = &theader;
    179179  for (nfilter = 0; nfilter < NFILTER; nfilter++) {
     180    // *** load the ZERO POINT table ***
     181
    180182    // load data for this header
    181183    if (!gfits_load_header (f, &theader)) return (NULL);
     
    202204      zpts[i+Nzpts].time = ohana_mjd_to_sec(mjd[i]);
    203205      zpts[i+Nzpts].zpt = zp[i];
    204       // zpts[i+Nzpts].zpt_err = zperr[i];
     206      zpts[i+Nzpts].zpt_err = 0.0;
     207      zpts[i+Nzpts].found = FALSE;
    205208    }
    206209    Nzpts += Nrow;
     210
     211    // *** load the flat-field correction image ***
    207212
    208213    // the image contains the flat-field corrections for a specific filter
     
    211216    if (!gfits_load_header (f, &header)) return (NULL);
    212217
    213     if (!gfits_scan (&theader, "FILTER", "%s", 1, filter)) {
     218    if (!gfits_scan (&header, "FILTER", "%s", 1, filter)) {
    214219      fprintf (stderr, "cannot find FILTER in header of %s\n", filename);
    215220      fclose (f);
     
    218223
    219224    // read the fits table bytes
     225    double *offset64 = NULL;
     226    float *offset32 = NULL;
     227    int use32 = TRUE;
     228
    220229    if (!gfits_fread_matrix (f, &matrix, &header)) return (NULL);
    221     assert (header.bitpix == -64); // hardwired as a double
    222     double *offset = (double *) matrix.buffer;
     230    switch (header.bitpix) {
     231      case -32: // float
     232        offset32 = (float *) matrix.buffer;
     233        use32 = TRUE;
     234        break;
     235      case -64: // double
     236        offset64 = (double *) matrix.buffer;
     237        use32 = FALSE;
     238        break;
     239      default:
     240        fprintf (stderr, "invalid bitpix for flat-field correction image: %d\n", header.bitpix);
     241        exit (2);
     242    }
    223243
    224244    for (nseason = 0; nseason < NSEASON; nseason++) { // seasons
     
    244264            for (ixc = 0; ixc < NCELL_X; ixc++) {
    245265              if (ix > 3) {
     266                // XXX I think this is backwards : chips ix < 4 should be flipped
    246267                seq = nfilter*NSEASON*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y + nseason*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y + (iy*NCELL_Y + NCELL_Y - 1 - iyc)*NCHIP_X*NCELL_X + (ix*NCELL_X + NCELL_X - 1 - ixc);
    247268              } else {
     
    251272              flatcorrTable->corr[seq].x = ixc;
    252273              flatcorrTable->corr[seq].y = iyc;
    253               flatcorrTable->corr[seq].offset = offset[seq];
     274              if (use32) {
     275                flatcorrTable->corr[seq].offset = offset32[seq];
     276              } else {
     277                flatcorrTable->corr[seq].offset = offset64[seq];
     278              }
    254279              flatcorrTable->corr[seq].ID = corrID;
    255280            }
  • branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/setphot.c

    r33133 r33156  
    3434    zpts = load_zpt_table (argv[1], &Nzpts);
    3535  }
     36
     37  if (!zpts) Shutdown ("failed to load zero points, or empty table");
    3638
    3739  // load images
  • branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_catalog_setphot.c

    r33133 r33156  
    9494      }
    9595
    96       catalog[0].measure[m].Mcal = Mcal + Mcal_offset;
     96      catalog[0].measure[m].Mcal = Mcal - Mcal_offset;
    9797      catalog[0].measure[m].dMcal = dMcal;
    9898
Note: See TracChangeset for help on using the changeset viewer.