IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 14, 2012, 6:10:32 PM (14 years ago)
Author:
watersc1
Message:

Still doesn't work correctly. I've simplified and corrected the problems I was having before, but I still have residuals of ~50 pixels in the warped background model relative to the science warp. I'm beginning to think that there's some issue with the interpolated background model, and that it's not quite the correct size? That's pretty much all I can think of at this point.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20120906/pswarp/src/pswarpLoop.c

    r34411 r34442  
    159159        }
    160160    }
    161 
     161    pmAstromWCS *WCSF = pmAstromWCSfromHeader(phu->header);
     162   
     163    fprintf(stderr,"WCSFI: %g %g : %g %g : %g %g : %g %g %g %g : %g %g\n",
     164            WCSF->crval1,WCSF->crval2,
     165            WCSF->crpix1,WCSF->crpix2,
     166            WCSF->cdelt1,WCSF->cdelt2,
     167            WCSF->trans->x->coeff[1][0],
     168            WCSF->trans->x->coeff[0][1],
     169            WCSF->trans->y->coeff[1][0],
     170            WCSF->trans->y->coeff[0][1],
     171            -1.0,-1.0);
     172    psFree(WCSF);
    162173    psList *cells = psListAlloc(NULL);  // List of cells, for concepts averaging
    163174
     
    197208            }
    198209        }
     210    pmAstromWCS *WCSF = pmAstromWCSfromHeader(hdu->header);
     211   
     212    fprintf(stderr,"WCSFIB: %g %g : %g %g : %g %g : %g %g %g %g : %g %g\n",
     213            WCSF->crval1,WCSF->crval2,
     214            WCSF->crpix1,WCSF->crpix2,
     215            WCSF->cdelt1,WCSF->cdelt2,
     216            WCSF->trans->x->coeff[1][0],
     217            WCSF->trans->x->coeff[0][1],
     218            WCSF->trans->y->coeff[1][0],
     219            WCSF->trans->y->coeff[0][1],
     220            -1.0,-1.0);
     221    psFree(WCSF);
    199222
    200223       
     
    574597    bool bilevelAstrometry = false;
    575598    pmHDU *phu = pmFPAviewThisPHU(view, astrom->fpa);
     599
     600    pmAstromWCS *WCSF = pmAstromWCSfromHeader(phu->header);
     601   
     602    fprintf(stderr,"WCSF: %g %g : %g %g : %g %g : %g %g %g %g : %g %g\n",
     603            WCSF->crval1,WCSF->crval2,
     604            WCSF->crpix1,WCSF->crpix2,
     605            WCSF->cdelt1,WCSF->cdelt2,
     606            WCSF->trans->x->coeff[1][0],
     607            WCSF->trans->x->coeff[0][1],
     608            WCSF->trans->y->coeff[1][0],
     609            WCSF->trans->y->coeff[0][1],
     610            -1.0,-1.0);
     611/* #define CORRECT_INPUT_WCS 1 */
     612/* #if CORRECT_INPUT_WCS */
     613/*      // Correct the input WCS */
     614/*      pmAstromWCS *WCS = pmAstromWCSfromHeader(phu->header); */
     615
     616/*      double cd1f = 1.0 * 400; */
     617/*      double cd2f = 1.0 * 400; */
     618/*      fprintf(stderr,"WCS: %g %g : %g %g : %g %g : %g %g %g %g : %g %g\n", */
     619/*              WCS->crval1,WCS->crval2, */
     620/*              WCS->crpix1,WCS->crpix2, */
     621/*              WCS->cdelt1,WCS->cdelt2, */
     622/*              WCS->trans->x->coeff[1][0], */
     623/*              WCS->trans->x->coeff[0][1], */
     624/*              WCS->trans->y->coeff[1][0], */
     625/*              WCS->trans->y->coeff[0][1], */
     626/*              cd1f,cd2f); */
     627
     628/*      WCS->crpix1 = WCS->crpix1 / cd1f; */
     629/*      WCS->crpix2 = WCS->crpix2 / cd2f; */
     630
     631/*      WCS->cdelt1 *= cd1f; */
     632/*      WCS->cdelt2 *= cd2f; */
     633
     634/*      // WCS->trans->x->nX/nY */
     635/*      for (int q = 0; q < WCS->trans->x->nX; q++) { */
     636/*        for (int r = 0; r < WCS->trans->x->nY; r++) { */
     637/*          WCS->trans->x->coeff[q][r] *= cd1f; */
     638/*        } */
     639/*      } */
     640/*      for (int q = 0; q < WCS->trans->y->nX; q++) { */
     641/*        for (int r = 0; r < WCS->trans->y->nY; r++) { */
     642/*          WCS->trans->y->coeff[q][r] *= cd2f; */
     643/*        } */
     644/*      } */
     645/*      fprintf(stderr,"WCS: %g %g : %g %g : %g %g : %g %g %g %g : %g %g\n", */
     646/*              WCS->crval1,WCS->crval2, */
     647/*              WCS->crpix1,WCS->crpix2, */
     648/*              WCS->cdelt1,WCS->cdelt2, */
     649/*              WCS->trans->x->coeff[1][0], */
     650/*              WCS->trans->x->coeff[0][1], */
     651/*              WCS->trans->y->coeff[1][0], */
     652/*              WCS->trans->y->coeff[0][1], */
     653/*              cd1f,cd2f); */
     654/*      pmAstromWCStoHeader (phu->header,WCS); */
     655/*      // End WCS work. */
     656/* #endif */
     657
     658
     659   
     660   
    576661    if (phu) {
    577662        char *ctype = psMetadataLookupStr(NULL, phu->header, "CTYPE1");
     
    610695        // read WCS data from the corresponding header
    611696        pmHDU *hdu = pmFPAviewThisHDU (view, astrom->fpa);
    612         psMetadataAddS32(config->arguments,PS_LIST_TAIL,
    613                          "INTERPOLATION.MODE",PS_META_REPLACE,"", PS_INTERPOLATE_BILINEAR); ///< Mode
    614         psMetadataAddS32(config->arguments,PS_LIST_TAIL,
    615                          "INTERPOLATION.NUM",PS_META_REPLACE,"", 64); ///< Mode
     697
     698        pmAstromWCS *WCS = pmAstromWCSfromHeader(hdu->header);
     699
     700        double cd1f = 1.0 * 400;
     701        double cd2f = 1.0 * 400;
     702        fprintf(stderr,"WCSC: %g %g : %g %g : %g %g : %g %g %g %g : %g %g\n",
     703                WCS->crval1,WCS->crval2,
     704                WCS->crpix1,WCS->crpix2,
     705                WCS->cdelt1,WCS->cdelt2,
     706                WCS->trans->x->coeff[1][0],
     707                WCS->trans->x->coeff[0][1],
     708                WCS->trans->y->coeff[1][0],
     709                WCS->trans->y->coeff[0][1],
     710                cd1f,cd2f);
     711
     712
     713        WCS->cdelt1 *= cd1f;
     714        WCS->cdelt2 *= cd2f;
     715        WCS->crpix1 = WCS->crpix1 / cd1f + 46.0 / 400.0;
     716        WCS->crpix2 = WCS->crpix2 / cd2f + 68.0 / 400.0;
     717
     718        // WCS->trans->x->nX/nY
     719        for (int q = 0; q < WCS->trans->x->nX; q++) {
     720          for (int r = 0; r < WCS->trans->x->nY; r++) {
     721            fprintf(stderr,"%d %d %g\n",q,r,WCS->trans->x->coeff[q][r]);
     722            WCS->trans->x->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r);
     723            fprintf(stderr,"%d %d %g\n",q,r,WCS->trans->x->coeff[q][r]);
     724          }
     725        }
     726        for (int q = 0; q < WCS->trans->y->nX; q++) {
     727          for (int r = 0; r < WCS->trans->y->nY; r++) {
     728            fprintf(stderr,"%d %d %g\n",q,r,WCS->trans->y->coeff[q][r]);
     729            WCS->trans->y->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r);
     730            fprintf(stderr,"%d %d %g\n",q,r,WCS->trans->y->coeff[q][r]);
     731          }
     732        }
     733        fprintf(stderr,"WCSO: %g %g : %g %g : %g %g : %g %g %g %g : %g %g\n",
     734                WCS->crval1,WCS->crval2,
     735                WCS->crpix1,WCS->crpix2,
     736                WCS->cdelt1,WCS->cdelt2,
     737                WCS->trans->x->coeff[1][0],
     738                WCS->trans->x->coeff[0][1],
     739                WCS->trans->y->coeff[1][0],
     740                WCS->trans->y->coeff[0][1],
     741                cd1f,cd2f);
     742
     743        fprintf(stderr,"Size: %d %d %d %d\n",WCS->trans->x->nX,WCS->trans->x->nY,WCS->trans->y->nX,WCS->trans->y->nY);
     744        pmAstromWCStoHeader (hdu->header,WCS);
    616745       
    617746        if (bilevelAstrometry) {
     
    624753        } else {
    625754            // we use a default FPA pixel scale of 1.0
    626             if (!pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0)) {
     755            if (!pmAstromReadWCS (astrom->fpa, chip, hdu->header, 1.0)) {
    627756                psError(psErrorCodeLast(), false, "Unable to read WCS astrometry for input FPA.");
    628757                psFree(view);
     
    631760            }
    632761        }
    633 #define CORRECT_INPUT_WCS 1
    634 #if CORRECT_INPUT_WCS
    635         // Correct the input WCS
    636         pmAstromWCS *WCS = pmAstromWCSfromHeader(hdu->header);
    637 
    638         double cd1f = 1.0 * 400;
    639         double cd2f = 1.0 * 400;
    640 
    641         WCS->crpix1 = WCS->crpix1 / cd1f + 0.5;
    642         WCS->crpix2 = WCS->crpix2 / cd2f - 0.5;
    643 
    644         WCS->cdelt1 *= cd1f;
    645         WCS->cdelt2 *= cd2f;
    646 
    647         WCS->trans->x->coeff[1][0] *= cd1f;
    648         WCS->trans->x->coeff[0][1] *= cd2f;
    649         WCS->trans->y->coeff[1][0] *= cd1f;
    650         WCS->trans->y->coeff[0][1] *= cd2f;
    651 
    652 
    653         pmAstromWCStoHeader (hdu->header,WCS);
    654         // End WCS work.
    655 #endif
     762        // Modify structure here.
     763
    656764       
    657765        pmCell *cell;
     
    679787                // Copy the detections from the astrometry carrier to the input, so they can be accessed by
    680788                // pswarpTransformReadout
    681                 pmReadout *astromRO = pmFPAviewThisReadout(view, astrom->fpa); // Readout for astrometry
    682                 pmDetections *detections = psMetadataLookupPtr(&mdok, astromRO->analysis, "PSPHOT.DETECTIONS"); // Sources from astrometry
    683                 if (detections) {
    684                     psMetadataAddPtr(readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_ARRAY, "Sources from input astrometry", detections);
    685                 }
    686 
     789/*                 pmReadout *astromRO = pmFPAviewThisReadout(view, astrom->fpa); // Readout for astrometry */
     790/*                 pmDetections *detections = psMetadataLookupPtr(&mdok, astromRO->analysis, "PSPHOT.DETECTIONS"); // Sources from astrometry */
     791/*                 if (detections) { */
     792/*                     psMetadataAddPtr(readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_ARRAY | PS_META_REPLACE, "Sources from input astrometry", detections); */
     793/*                 } */
     794               
    687795                for (int x = 0; x < readout->image->numCols; x++) {
    688796                  for (int y = 0; y < readout->image->numRows; y++) {
     
    692800                  }
    693801                }
    694                 psMetadataAddS32(config->arguments,PS_LIST_TAIL, "INTERPOLATION.MODE", PS_META_REPLACE, "", 2);
    695 /*              psMetadataAddS32(config->arguments,PS_LIST_TAIL, "GRID.NX",PS_META_REPLACE,"",100); ///< Number of grid points in x */
    696 /*              psMetadataAddS32(config->arguments,PS_LIST_TAIL, "GRID.NY",PS_META_REPLACE,"",100); ///< Number of grid points in y */
    697 
     802               
     803                psMetadataAddS32(config->arguments,PS_LIST_TAIL, "INTERPOLATION.MODE", PS_META_REPLACE, "", 8);
     804
     805                fprintf(stderr,"Transforming Readout!\n");
    698806                pswarpTransformReadout(output, readout, config);
    699807               
Note: See TracChangeset for help on using the changeset viewer.