IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 20, 2014, 5:52:37 PM (12 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20140402
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140402

  • branches/eam_branches/ipp-20140402/ppBackground/src/ppBackgroundStackLoop.c

    r36635 r36677  
    99
    1010#include "ppBackgroundStack.h"
     11
     12#define WCS_TOLERANCE 0.001             // Tolerance for WCS
     13
    1114
    1215bool ppBackgroundStackLoop(ppBackgroundStackData *data // Run-time data
     
    7679      pmFPAview *view = pmFPAviewAlloc(0);
    7780
     81      //      pmHDU *phu = pmFPAviewThisPHU(view, stack->fpa);
     82      psF32 exptime = 1.0;
     83      exptime = psMetadataLookupF32(NULL, stack->fpa->hdu->header, "EXPTIME");
     84     
    7885      // PART 1:
    7986      // Determine the extent of the model map for this stack
     
    116123      if (tp->y > data->y_max) { data->y_max = tp->y; }
    117124
    118 /*       data->x_min -= data->ra_min; */
    119 /*       data->x_max -= data->ra_min; */
    120 /*       data->y_min -= data->dec_min; */
    121 /*       data->y_max -= data->dec_min; */
    122      
    123      
    124125      psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV);
    125126      psImageBinning *binning = psImageBinningAlloc();
    126       binning->nXruff = 15; // Number of samples
    127       binning->nYruff = 15;
    128       //    binning->nXfine = ceil(data->ra_max - data->ra_min) + 1; // This is the range we're looking at
    129       //    binning->nYfine = ceil(data->dec_max - data->dec_min) + 1;
     127      binning->nXruff = 13; // Number of samples
     128      binning->nYruff = 13;
    130129      binning->nXfine = ceil(data->x_max - data->x_min) + 1;
    131130      binning->nYfine = ceil(data->y_max - data->y_min) + 1;
     
    142141      P_PSIMAGE_SET_ROW0(sizeImage, data->y_min);
    143142      data->modelMap = psImageMapAlloc(sizeImage,binning,stats);
    144 /*       psFree(sizeImage); */
    145 /*       data->modelMap = psImageMapNoImageAlloc( binning,stats); */
    146 /*       P_PSIMAGE_SET_COL0(data->modelMap->map, (data->x_min - binning->nXskip) / binning->nXbin); */
    147 /*       P_PSIMAGE_SET_ROW0(data->modelMap->map, (data->y_min - binning->nYskip) / binning->nYbin); */
    148 
    149       // force col0/row0
    150 /*       data->modelMap->map->col0 = data->modelMap->binning->nXskip; */
    151 /*       data->modelMap->map->row0 = data->modelMap->binning->nYskip; */
    152143     
    153144      // PART 2:
     
    169160
    170161      // This is where an iterative solution loop would likely start.
    171       {
     162      for (int iterator = 0; iterator < 4; iterator++) {
    172163        // Construct the offset information
    173164        printf("Model fit!\n");
     
    298289                psPlaneTransformApply(tp, stack->fpa->toTPA, pix);
    299290               
    300                 model->image->data.F32[y][x] = psImageMapEval(data->modelMap,tp->x,tp->y);
     291                model->image->data.F32[y][x] = exptime * psImageMapEval(data->modelMap,tp->x,tp->y);
    301292                corr->image->data.F32[y][x] = readout->image->data.F32[y][x] + model->image->data.F32[y][x];
    302293               
     
    306297            psFree(fp);
    307298            psFree(tp);
     299
     300            // Copy WCS (from ppStackUpdateHeader)
     301            pmHDU *inHDU = pmHDUFromCell(readout->parent);
     302            model->parent->hdu = pmHDUAlloc(NULL);
     303            corr->parent->hdu = pmHDUAlloc(NULL);
     304            pmHDU *modHDU= pmHDUFromCell(model->parent);
     305            pmHDU *corHDU= pmHDUFromCell(corr->parent);
     306
     307            if (!modHDU || !inHDU) {
     308              psWarning("Unable to find HDU at FPA level to copy wcs!");
     309            }
     310            else {
     311              if (!pmAstromReadWCS(stack_model->fpa,model_cell->parent,inHDU->header,1.0)) {
     312                psErrorClear();
     313                psWarning("Unable to read WCS astrometry from input FPA!");
     314              }
     315              else {
     316                if (!modHDU->header) {
     317                  modHDU->header = psMetadataAlloc();
     318                }
     319                if (!pmAstromWriteWCS(modHDU->header, stack_model->fpa,model_cell->parent, WCS_TOLERANCE)) {
     320                  psErrorClear();
     321                  psWarning("Unable to read WCS astrometry from input FPA!");
     322                }
     323              }
     324              if (!pmAstromReadWCS(stack_corr->fpa,corr_cell->parent,inHDU->header,1.0)) {
     325                psErrorClear();
     326                psWarning("Unable to read WCS astrometry from input FPA!");
     327              }
     328              else {
     329                if (!corHDU->header) {
     330                  corHDU->header = psMetadataAlloc();
     331                }
     332                if (!pmAstromWriteWCS(corHDU->header, stack_corr->fpa,corr_cell->parent, WCS_TOLERANCE)) {
     333                  psErrorClear();
     334                  psWarning("Unable to read WCS astrometry from input FPA!");
     335                }
     336              }
     337            } // End WCS saving.
     338
     339           
    308340          } // Close readout
    309341          printf("    I'm done with that readout\n");
     
    335367      psFree(view);
    336368      psFree(data->modelMap);
     369      psFree(sizeImage);
    337370    }
    338371               
Note: See TracChangeset for help on using the changeset viewer.