IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 12, 2009, 1:03:29 PM (17 years ago)
Author:
Paul Price
Message:

Adding more debugging output. Think I've solved the problem of the poor photometry: the background being added in to the fake images produces the bad photometry. Without it, the photometry s.d. goes from 0.08 mag to 0.02 mag. Want to replace it with the proper psphot background model (not done yet). These files are currently in an intermediate state.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_20090108/ppStack/src/ppStackSources.c

    r21094 r21106  
    99//#define TESTING                         // Enable debugging output
    1010
     11// Size of fake image; set by hand because it's trouble to get it from other places
     12#define FAKE_COLS 4861
     13#define FAKE_ROWS 4913
     14
     15
     16
     17#define MIN_MAG -16                     // Minimum magnitude to consider
    1118
    1219float ppStackSourcesTransparency(const psArray *sourceLists, const pmFPAview *view, const pmConfig *config)
     
    5966        pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i); // File of interest
    6067        pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest
     68
     69#if 1
     70        // Excise bright sources that might be saturated
     71        psArray *sources = sourceLists->data[i]; // Sources for image
     72        for (int j = 0; j < sources->n; j++) {
     73            pmSource *source = sources->data[j]; // Source of interest
     74            if (source && source->psfMag < MIN_MAG) {
     75                psFree(source);
     76                sources->data[j] = NULL;
     77            }
     78        }
     79#endif
     80
     81
     82#if 1
     83        pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout
     84        pmPSF *psf = psMetadataLookupPtr(NULL, config->arguments, "PSF.TARGET"); // PSF for fake image
     85        pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i], NULL, NULL, psf, 5, 0, false, true);
     86        psString name = NULL;
     87        psStringAppend(&name, "start_%03d.fits", i);
     88        psFits *fits = psFitsOpen(name, "w");
     89        psFree(name);
     90        psFitsWriteImage(fits, NULL, fake->image, 0, NULL);
     91        psFitsClose(fits);
     92        psFree(fake);
     93#endif
     94
    6195
    6296        float exptime = psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE"); // Exposure time
     
    105139        FILE *outMatches = fopen("source_match.dat", "w"); // Output matches
    106140        psVector *mag = psVectorAlloc(num, PS_TYPE_F32); // Magnitudes for each star
     141        psVector *magErr = psVectorAlloc(num, PS_TYPE_F32); // Errors for each star
    107142        for (int i = 0; i < matches->n; i++) {
    108143            pmSourceMatch *match = matches->data[i]; // Match of interest
    109144            psVectorInit(mag, NAN);
     145            psVectorInit(magErr, NAN);
    110146            for (int j = 0; j < match->num; j++) {
    111147                if (match->mask->data.PS_TYPE_MASK_DATA[j]) {
     
    114150                int index = match->image->data.U32[j]; // Image index
    115151                mag->data.F32[index] = match->mag->data.F32[j] - zp->data.F32[index] - trans->data.F32[index];
     152                magErr->data.F32[index] = match->magErr->data.F32[j];
    116153            }
    117154            for (int j = 0; j < num; j++) {
    118                 fprintf(outMatches, "%f ", mag->data.F32[j]);
     155                fprintf(outMatches, "%f (%f) ", mag->data.F32[j], magErr->data.F32[j]);
    119156            }
    120157            fprintf(outMatches, "\n");
    121158        }
    122159        psFree(mag);
     160        psFree(magErr);
    123161        fclose(outMatches);
    124162    }
     
    146184                continue;
    147185            }
     186
     187#if 1
     188            float x = source->modelPSF->params->data.F32[PM_PAR_XPOS],
     189                y = source->modelPSF->params->data.F32[PM_PAR_YPOS]; // Coordinates of source
     190            if (x > 2187 && x < 2191 && y > 2280 && y < 2284) {
     191                fprintf(stderr, "Image %d source: (%f,%f) %f --> %f\n",
     192                        i, x, y, source->psfMag, source->psfMag + magCorr);
     193            }
     194#endif
     195
    148196            source->psfMag += magCorr;
    149197        }
     198
     199#if 1
     200// Size of fake image; set by hand because it's trouble to get it from other places
     201        pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout
     202        pmPSF *psf = psMetadataLookupPtr(NULL, config->arguments, "PSF.TARGET"); // PSF for fake image
     203        pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sources, NULL, NULL, psf, 5, 0, false, true);
     204        psString name = NULL;
     205        psStringAppend(&name, "corrected_%03d.fits", i);
     206        psFits *fits = psFitsOpen(name, "w");
     207        psFree(name);
     208        psFitsWriteImage(fits, NULL, fake->image, 0, NULL);
     209        psFitsClose(fits);
     210        psFree(fake);
     211#endif
     212
    150213    }
    151214    psFree(trans);
     
    162225        psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej,
    163226                                               transThresh, starRej, starSys);
     227        for (int i = 0; i < num; i++) {
     228            fprintf(stderr, "Transparency of image %d: %f\n", i, trans->data.F32[i]);
     229        }
    164230        psFree(trans);
    165231    }
Note: See TracChangeset for help on using the changeset viewer.