IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 20, 2008, 3:28:06 PM (18 years ago)
Author:
Paul Price
Message:

Adding penalty for wideness.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_080617/ppSub/test/fake.c

    r18175 r18249  
    77
    88// PSF for images
    9 #define X_AXIS_1 5.0                    // Length of x axis (FWHM) for image 1
    10 #define Y_AXIS_1 3.0                    // Length of y axis (FWHM) for image 1
    11 #define X_AXIS_2 3.0                    // Length of x axis (FWHM) for image 1
    12 #define Y_AXIS_2 5.0                    // Length of y axis (FWHM) for image 1
     9#define X_AXIS_1 3.0                    // Length of x axis (FWHM) for image 1
     10#define Y_AXIS_1 5.0                    // Length of y axis (FWHM) for image 1
     11#define X_AXIS_2 5.0                    // Length of x axis (FWHM) for image 1
     12#define Y_AXIS_2 3.0                    // Length of y axis (FWHM) for image 1
    1313
    1414// Image parameters
     
    2222#define SOURCES_DENSITY 30000.0         // Source density at nominated magnitude (per deg^2)
    2323#define SOURCES_ZP 25.0                 // Magnitude ZP
    24 #define SOURCES_GAUSSIAN 0              // Gaussian sources (boolean)?
     24#define SOURCES_GAUSSIAN 1              // Gaussian sources (boolean)?
    2525
    2626// Noise properties
     
    125125    }
    126126
     127#if 1
     128    psImage *var1 = (psImage*)psBinaryOp(NULL, image1, "+", psScalarAlloc(PS_SQR(NOISE_1), PS_TYPE_F32));
     129    psImage *var2 = (psImage*)psBinaryOp(NULL, image2, "+", psScalarAlloc(PS_SQR(NOISE_2), PS_TYPE_F32));
     130#else
     131    psImage *var1 = psImageAlloc(NUMCOLS, NUMROWS, PS_TYPE_F32);
     132    psImage *var2 = psImageAlloc(NUMCOLS, NUMROWS, PS_TYPE_F32);
     133    psImageInit(var1, PS_SQR(NOISE_1));
     134    psImageInit(var2, PS_SQR(NOISE_2));
     135#endif
     136
    127137    for (int y = 0; y < NUMROWS; y++) {
    128138        for (int x = 0; x < NUMCOLS; x++) {
    129             image1->data.F32[y][x] += psRandomGaussian(rng) * NOISE_1;
    130             image2->data.F32[y][x] += psRandomGaussian(rng) * NOISE_2;
     139            image1->data.F32[y][x] += psRandomGaussian(rng) * sqrtf(var1->data.F32[y][x]);
     140            image2->data.F32[y][x] += psRandomGaussian(rng) * sqrtf(var2->data.F32[y][x]);
    131141        }
    132142    }
    133 
     143#if 1
     144    var1 = (psImage*)psBinaryOp(var1, image1, "+", psScalarAlloc(PS_SQR(NOISE_1), PS_TYPE_F32));
     145    var2 = (psImage*)psBinaryOp(var2, image2, "+", psScalarAlloc(PS_SQR(NOISE_2), PS_TYPE_F32));
     146#else
     147    psImageInit(var1, PS_SQR(NOISE_1));
     148    psImageInit(var2, PS_SQR(NOISE_2));
     149#endif
    134150
    135151    {
     
    144160    }
    145161
    146     psFree(image1);
    147     psFree(image2);
    148 
    149     psFree(rng);
    150 
    151     psImage *noise1 = psImageAlloc(NUMCOLS, NUMROWS, PS_TYPE_F32);
    152     psImage *noise2 = psImageAlloc(NUMCOLS, NUMROWS, PS_TYPE_F32);
    153     psImageInit(noise1, PS_SQR(NOISE_1));
    154     psImageInit(noise2, PS_SQR(NOISE_2));
    155162    {
    156163        psFits *fits = psFitsOpen("variance1.fits", "w");
    157         psFitsWriteImage(fits, NULL, noise1, 0, NULL);
     164        psFitsWriteImage(fits, NULL, var1, 0, NULL);
    158165        psFitsClose(fits);
    159166    }
    160167    {
    161168        psFits *fits = psFitsOpen("variance2.fits", "w");
    162         psFitsWriteImage(fits, NULL, noise2, 0, NULL);
     169        psFitsWriteImage(fits, NULL, var2, 0, NULL);
    163170        psFitsClose(fits);
    164171    }
    165     psFree(noise1);
    166     psFree(noise2);
     172
     173    psFree(image1);
     174    psFree(image2);
     175
     176    psFree(var1);
     177    psFree(var2);
     178
     179    psFree(rng);
    167180
    168181    return PS_EXIT_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.