IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27665


Ignore:
Timestamp:
Apr 12, 2010, 12:54:19 PM (16 years ago)
Author:
Paul Price
Message:

Explicitly set TRIMSEC when resizing image.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppViz/src/ppVizPSF/ppVizPSFLoop.c

    r26405 r27665  
    7575                psVector *xOffset = NULL, *yOffset = NULL; // Offset from source to true position
    7676
    77                 if (sources || (data->fakeNum > 0 && isfinite(data->fakeMag))) {
    78                   numCols = psf->fieldNx;
    79                   numRows = psf->fieldNy;
    80                   psLogMsg("ppVizPSF", PS_LOG_INFO, "Generating %dx%d image", numCols, numRows);
    81                 }
     77                if (sources || (data->fakeNum > 0 && isfinite(data->fakeMag))) {
     78                    numCols = psf->fieldNx;
     79                    numRows = psf->fieldNy;
     80                    psLogMsg("ppVizPSF", PS_LOG_INFO, "Generating %dx%d image", numCols, numRows);
     81                }
    8282                if (sources) {
    8383                    psMemIncrRefCounter(sources);
    8484                    psLogMsg("ppVizPSF", PS_LOG_INFO, "Using %ld input sources", sources->n);
    8585                }
    86                 if (data->fakeNum > 0 && isfinite(data->fakeMag)) {
    87                   long numOld = 0; // Old number of sources
    88                   long numNew = -1; // New number of sources
    89                   psLogMsg("ppVizPSF", PS_LOG_INFO, "Adding %d fake sources", data->fakeNum);
    90                   if (sources) {
    91                     numOld = sources->n;
    92                     numNew = numOld + data->fakeNum;
    93                     sources = psArrayRealloc(sources, numNew);
    94                     sources->n = numNew;
    95                   } else {
    96                     numNew = data->fakeNum;
    97                     sources = psArrayAlloc(numNew);
    98                   }
     86                if (data->fakeNum > 0 && isfinite(data->fakeMag)) {
     87                    long numOld = 0; // Old number of sources
     88                    long numNew = -1; // New number of sources
     89                    psLogMsg("ppVizPSF", PS_LOG_INFO, "Adding %d fake sources", data->fakeNum);
     90                    if (sources) {
     91                        numOld = sources->n;
     92                        numNew = numOld + data->fakeNum;
     93                        sources = psArrayRealloc(sources, numNew);
     94                        sources->n = numNew;
     95                    } else {
     96                        numNew = data->fakeNum;
     97                        sources = psArrayAlloc(numNew);
     98                    }
    9999
    100                   psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
     100                    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
    101101
    102                   for (int i = numOld; i < numNew; i++) {
    103                     pmSource *source = pmSourceAlloc(); // Fake source
    104                     sources->data[i] = source;
    105                     float xSrc = psRandomUniform(rng) * numCols, ySrc = psRandomUniform(rng) * numRows; // Position of source
     102                    for (int i = numOld; i < numNew; i++) {
     103                        pmSource *source = pmSourceAlloc(); // Fake source
     104                        sources->data[i] = source;
     105                        float xSrc = psRandomUniform(rng) * numCols, ySrc = psRandomUniform(rng) * numRows; // Position of source
    106106
    107                     pmModel *model = pmModelFromPSFforXY(psf, xSrc, ySrc, 1.0); // Model for normalisation
    108                     float fluxNorm = model->modelFlux(model->params);               // Flux for peak=1
    109                     float fluxPeak = powf(10.0, -0.4 * data->fakeMag) / fluxNorm; // Peak flux
    110                     source->peak = pmPeakAlloc(xSrc, ySrc, fluxPeak, PM_PEAK_LONE);
    111                     source->psfMag = data->fakeMag;
    112                     psFree(model);
    113                   }
    114                 }                 
    115                 if (!sources) {
    116                   // Generate fake image with only a single realisation of the PSF
     107                        pmModel *model = pmModelFromPSFforXY(psf, xSrc, ySrc, 1.0); // Model for normalisation
     108                        float fluxNorm = model->modelFlux(model->params);               // Flux for peak=1
     109                        float fluxPeak = powf(10.0, -0.4 * data->fakeMag) / fluxNorm; // Peak flux
     110                        source->peak = pmPeakAlloc(xSrc, ySrc, fluxPeak, PM_PEAK_LONE);
     111                        source->psfMag = data->fakeMag;
     112                        psFree(model);
     113                    }
     114                }
     115                if (!sources) {
     116                    // Generate fake image with only a single realisation of the PSF
    117117                    sources = psArrayAlloc(1);
    118118                    pmSource *source = pmSourceAlloc(); // Fake source
     
    134134                    psLogMsg("ppVizPSF", PS_LOG_INFO, "Generating %dx%d image with single PSF",
    135135                             numCols, numRows);
     136                    psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
     137                    *trimsec = psRegionSet(0, numCols, 0, numRows);
    136138                }
    137139
Note: See TracChangeset for help on using the changeset viewer.