IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30618


Ignore:
Timestamp:
Feb 13, 2011, 11:35:11 AM (15 years ago)
Author:
eugene
Message:

remove old deprecated functions related to in-line photometry in ppSim; enable 2D seeing variation in simulated images (SEEING.RAMP); galaxy angle in degrees; galaxy grid fluxes user set

Location:
trunk/ppSim/src
Files:
7 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/Makefile.am

    r28125 r30618  
    4747        ppSimUtils.c              \
    4848        ppSimLoop.c               \
    49         ppSimLoadSpots.c          \
    50         ppSimPhotom.c             \
    51         ppSimPhotomFiles.c        \
    52         ppSimLoadForceSources.c   \
    5349        ppSimMergeReadouts.c      \
    5450        ppSimDetections.c         \
     
    5955        ppSimBadCTE.c             \
    6056        ppSimVersion.c
    61 
    62 # these functions have been broken by the API change in psphot (Jan 2010)
    63 #       ppSimPhotomReadoutFake.c 
    64 #       ppSimPhotomReadoutForce.c
    6557
    6658ppSimSequence_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS)
  • trunk/ppSim/src/ppSimArguments.c

    r29011 r30618  
    4949    psMetadataAddF32(arguments,  PS_LIST_TAIL, "-zp", 0, "Photometric zero point", NAN);
    5050    psMetadataAddF32(arguments,  PS_LIST_TAIL, "-seeing", 0, "Seeing FWHM (arcsec)", NAN);
     51    psMetadataAddF32(arguments,  PS_LIST_TAIL, "-seeing-max", 0, "Seeing FWHM (arcsec) at end of ramp", NAN);
     52    psMetadataAddBool(arguments,  PS_LIST_TAIL, "-seeing-ramp", 0, "Use a seeing ramp", false);
    5153    psMetadataAddF32(arguments,  PS_LIST_TAIL, "-starslum", 0, "Fake star luminosity function slope", NAN);
    5254    psMetadataAddF32(arguments,  PS_LIST_TAIL, "-starsmag", 0, "Brightest magnitude for fake stars", NAN);
     
    130132        // 'seeing' is not required: we can load a psf-model instead; but if not, it is allowed
    131133        ppSimArgToRecipeF32(&status, options, "SEEING", arguments, "-seeing"); // seeing (FWHM in arcsec)
     134        ppSimArgToRecipeF32(&status, options, "SEEING.MAX", arguments, "-seeing-max"); // seeing (FWHM in arcsec)
     135        ppSimArgToRecipeBool(&status, options, "SEEING.RAMP", arguments, "-seeing-ramp"); // seeing (FWHM in arcsec)
    132136
    133137        // 'scale' is not required: we can use the WCS instead; but if not, it is allowed
     
    227231        psMetadataAddF32(options, PS_LIST_TAIL, "PA", 0, "Boresight position angle (radians)",pa * M_PI / 180.0);
    228232
     233        if (psMetadataLookupBool(NULL, arguments, "-seeing-ramp")) {
     234            float seeingMax = psMetadataLookupF32(NULL, arguments, "-seeing-max"); // seeing at ramp end
     235            psMetadataAddF32(options, PS_LIST_TAIL, "SEEING.MAX", 0, "Seeing FWHM (arcsec)", seeingMax);
     236            psMetadataAddBool(options, PS_LIST_TAIL, "SEEING.RAMP", 0, "use seeing ramp", true);
     237        }
     238
    229239        ppSimArgToRecipeF32(&status, options, "ZEROPOINT", arguments, "-zp"); // Zero point
    230240    }
  • trunk/ppSim/src/ppSimCreate.c

    r29125 r30618  
    103103        psMetadataAddF32(recipe, PS_LIST_TAIL, "SEEING", PS_META_REPLACE, "Seeing SIGMA (pixels)", seeing / 2.0 / sqrt(2.0 * log(2.0)) / scale);
    104104
     105        float seeingMax = psMetadataLookupF32(&status, recipe, "SEEING.MAX");
     106        psMetadataAddF32(recipe, PS_LIST_TAIL, "SEEING.MAX", PS_META_REPLACE, "Seeing SIGMA (pixels)", seeingMax / 2.0 / sqrt(2.0 * log(2.0)) / scale);
     107
    105108        // if we have been supplied an input image, but no ra & dec, use the input image values
    106109        if (input) {
     
    132135    bool doPhotom = psMetadataLookupBool(&status, recipe, "PHOTOM"); // Density of fakes
    133136    if (doPhotom) {
    134 
    135         // XXX at the moment, we can perform photometry on the fake sources and the forced
    136         // photometry positions, but not one or the other.  Also, we only support photometry in
    137         // the context of an image previously analysed by psphot.  Add support for:
    138         // * photometry of a pure fake image (requires peak detection and psf creation)
    139         // * photometry of forced source positions without fake image (this might work, it just
    140         // requires not generating any fake features).
    141 
    142         if (!input) {
    143             psError(PS_ERR_UNKNOWN, false, "input image not found; currently required for photometry");
    144             return NULL;
    145         }
    146 
    147         // we need a chip image if we perform photometry (is it necessary to build it if we don't use it?)
    148         pmFPAfile *fakeImage = pmFPAfileDefineChipMosaic(config, output->fpa, "PPSIM.FAKE.CHIP");
    149         if (!fakeImage) {
    150             psError(PS_ERR_IO, false, _("Unable to generate new file from PPSIM.FAKE.CHIP"));
    151             psFree(fpa);
    152             return NULL;
    153         }
    154         if (fakeImage->type != PM_FPA_FILE_IMAGE) {
    155             psError(PS_ERR_IO, true, "PPSIM.FAKE.CHIP is not of type IMAGE");
    156             psFree(fpa);
    157             return NULL;
    158         }
    159 
    160         // we need a chip image if we perform photometry (is it necessary to build it if we don't use it?)
    161         pmFPAfile *forceImage = NULL;
    162         if (input) {
    163             forceImage = pmFPAfileDefineChipMosaic(config, input->fpa, "PPSIM.FORCE.CHIP");
    164             if (!forceImage) {
    165                 psError(PS_ERR_IO, false, _("Unable to generate new file from PPSIM.FORCE.CHIP"));
    166                 psFree(fpa);
    167                 return NULL;
    168             }
    169             if (forceImage->type != PM_FPA_FILE_IMAGE) {
    170                 psError(PS_ERR_IO, true, "PPSIM.FORCE.CHIP is not of type IMAGE");
    171                 psFree(fpa);
    172                 return NULL;
    173             }
    174         }
    175 
    176         // define associated psphot input/output files
    177         if (!ppSimPhotomFiles (config, fakeImage, forceImage)) {
    178             psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot");
    179             psFree(fpa);
    180             return NULL;
    181         }
    182     } else {
    183         // have we supplied a psf model?  this happens in ppSimPhotomFiles if we request a photometry
    184         // analysis.  however, even if we do not, a psf model may be used to generate the fake
    185         // sources.
    186         if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
    187             // tie the psf file to the chipMosaic
    188             pmFPAfileBindFromArgs(&status, output, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
    189             if (!status) {
    190                 psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD");
    191                 psFree(fpa);
    192                 return NULL;
    193             }
    194         }
     137        psError(PS_ERR_UNKNOWN, false, "in-line photometry in ppSim had been deprecated");
     138        return NULL;
     139    }
     140
     141    // have we supplied a psf model?  this happens in ppSimPhotomFiles if we request a photometry
     142    // analysis.  however, even if we do not, a psf model may be used to generate the fake
     143    // sources.
     144    if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
     145        // tie the psf file to the chipMosaic
     146        pmFPAfileBindFromArgs(&status, output, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
     147        if (!status) {
     148            psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD");
     149            psFree(fpa);
     150            return NULL;
     151        }
    195152    }
    196153
     
    257214                }
    258215            }
     216            // XXX this is a hack, but I don't have a better way at the moment: assumes a single cell per chip
     217            if (nx) {
     218                psMetadataAddS32(chip->concepts, PS_LIST_TAIL, "CHIP.XSIZE", PS_META_REPLACE, "", nx);
     219            } else {
     220                nx = psMetadataLookupF32(&status, cell->concepts, "CELL.XSIZE");
     221                psMetadataAddS32(chip->concepts, PS_LIST_TAIL, "CHIP.XSIZE", PS_META_REPLACE, "", nx);
     222            }
     223            if (ny) {
     224                psMetadataAddS32(chip->concepts, PS_LIST_TAIL, "CHIP.YSIZE", PS_META_REPLACE, "", ny);
     225            } else {
     226                ny = psMetadataLookupF32(&status, cell->concepts, "CELL.YSIZE");
     227                psMetadataAddS32(chip->concepts, PS_LIST_TAIL, "CHIP.YSIZE", PS_META_REPLACE, "", ny);
     228            }
    259229        }
    260230    }
  • trunk/ppSim/src/ppSimLoop.c

    r28125 r30618  
    4242    if (type == PPSIM_TYPE_OBJECT) {
    4343        // Load forced-photometry positions (these are placed on fpa->analysis for use in ppSimPhotomReadout)
    44         if (!ppSimLoadSpots (fpa, config)) ESCAPE (PS_ERR_UNKNOWN, "failed to load forced-photometry spots");
     44        // if (!ppSimLoadSpots (fpa, config)) ESCAPE (PS_ERR_UNKNOWN, "failed to load forced-photometry spots");
    4545
    4646        // Load catalogue stars
     
    5858
    5959    pmFPAview *view = pmFPAviewAlloc(0);// View for iterating over FPA
    60 
    61     // XXX if we include the psphot analysis, we will need to activate the correct pmFPAfiles
    62     // at the correct times.  ppSim operates on PPSIM.OUTPUT and PPSIM.SOURCES
    6360
    6461    // load any needed files (eg, input image, PSF)
     
    209206
    210207        // we perform photometry on the readouts of this chip in the output
    211         if (!ppSimPhotom (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem performing photometry");
     208        // if (!ppSimPhotom (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem performing photometry");
    212209
    213210        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
  • trunk/ppSim/src/ppSimMakeGalaxies.c

    r29011 r30618  
    2828    float galaxyThetaMax  = psMetadataLookupF32(&mdok, recipe, "GALAXY.THETA.MAX"); // Density of fakes
    2929    float galaxyThetaMin  = psMetadataLookupF32(&mdok, recipe, "GALAXY.THETA.MIN"); // Density of fakes
     30    galaxyThetaMax *= PS_RAD_DEG;
     31    galaxyThetaMin *= PS_RAD_DEG;
    3032
    3133    float galaxyIndexMin  = psMetadataLookupF32(&mdok, recipe, "GALAXY.INDEX.MIN"); // Density of fakes
     
    9597
    9698        int i = 0;
     99        float refNorm = 1.0;
     100        float ourNorm = 1.0;
    97101
    98102        for (long iy = 0.5*galaxyGridDY; iy < ySize; iy += galaxyGridDY) {
     
    104108                galaxy->y    = iy;
    105109
    106                 galaxy->peak = 1000;
     110                // galaxy->peak = 1000;
     111                galaxy->peak = bright / 100.0;
     112                // fprintf (stderr, "Io: %f\n", bright);
    107113
    108114                // galaxyIndex from user should be for function of this form: exp(-r^(1/n))
     
    111117                float rndValue;
    112118
    113                 rndValue = galaxyGridRandom ? drand48() : i / num;
     119                rndValue = galaxyGridRandom ? drand48() : i / (float) num;
    114120                float index = (galaxyIndexMin  + rndValue * galaxyIndexSlope);
    115121                galaxy->index = 0.5/index; // factor of 0.5 because the Sersic model creates exp(-z^n), not exp(-r^n)
    116122
    117                 rndValue = galaxyGridRandom ? drand48() : i / num;
     123                rndValue = galaxyGridRandom ? drand48() : i / (float) num;
    118124                float scale = (galaxyRmajorMin + rndValue * galaxyRmajorSlope);
    119125
     
    125131                galaxy->Rmaj  = scale;
    126132
    127                 rndValue = galaxyGridRandom ? drand48() : i / num;
     133                rndValue = galaxyGridRandom ? drand48() : i / (float) num;
    128134                galaxy->Rmin  = (galaxyARatioMin + rndValue * galaxyARatioSlope) * galaxy->Rmaj;
    129135
    130                 rndValue = galaxyGridRandom ? drand48() : i / num;
     136                rndValue = galaxyGridRandom ? drand48() : i / (float) num;
    131137                galaxy->theta = (galaxyThetaMin  + rndValue * galaxyThetaSlope);
    132 
    133                 // galaxy->peak *= Io;
     138               
     139                if (i == 0) {
     140                    refNorm = Io*scale*scale;
     141                }
     142                ourNorm = refNorm / (Io*scale*scale);
     143                galaxy->peak *= ourNorm;
    134144
    135145                if (0) {
    136                     fprintf (stderr, "Rmaj: %f, scale: %f, index: %f, bn: %f, Ro: %f, Io: %f\n", galaxy->Rmaj, scale, index, bn, fR, Io);
     146                    fprintf (stderr, "Rmaj: %f, scale: %f, index: %f, bn: %f, Ro: %f, Io: %f, theta: %f\n", galaxy->Rmaj, scale, index, bn, fR, Io, galaxy->theta);
    137147                }
    138148
  • trunk/ppSim/src/ppSimSetPSF.c

    r26900 r30618  
    2323    float theta    = psMetadataLookupF32(&status, recipe, "PSF.THETA"); // Seeing SIGMA (pixels)
    2424
     25    float seeingMax = psMetadataLookupF32(&status, recipe, "SEEING.MAX"); // Seeing SIGMA (pixels)
     26    bool seeingRamp = psMetadataLookupBool(&status, recipe, "SEEING.RAMP"); // Seeing SIGMA (pixels)
     27
    2528    char *psfModelName = psMetadataLookupStr(&status, recipe, "PSF.MODEL"); // Name of PSF model
    2629    if (psfModelName == NULL) {
     
    3942    int xSize = psMetadataLookupS32(NULL, chip->concepts, "CHIP.XSIZE");
    4043    int ySize = psMetadataLookupS32(NULL, chip->concepts, "CHIP.YSIZE");
    41     xSize = 1000;
    42     ySize = 1000;
    4344
    44     // no spatial variation
    45     options->psfTrendMode = PM_TREND_POLY_ORD;
    46     options->psfTrendNx = 0;
    47     options->psfTrendNy = 0;
    48     options->psfFieldNx = xSize;
    49     options->psfFieldNy = ySize;
     45    if (seeingRamp) {
     46        psEllipseAxes axes;
     47        psEllipsePol pol;
     48        psEllipsePol polMax;
    5049
    51     // generate the psf
    52     psf = pmPSFAlloc (options);
     50        // try spatial variation
     51        options->psfTrendMode = PM_TREND_POLY_ORD;
     52        options->psfTrendNx = 1;
     53        options->psfTrendNy = 1;
     54        options->psfFieldNx = xSize;
     55        options->psfFieldNy = ySize;
    5356
    54     psEllipseAxes axes;
    55     psEllipsePol pol;
     57        // generate the psf
     58        psf = pmPSFAlloc (options);
    5659
    57     // supply the semi-major axis (these are SIGMA values in PIXELS)
    58     axes.major = seeing;
    59     axes.minor = aRatio * seeing;
    60     axes.theta = theta * PS_RAD_DEG;
     60        // supply the semi-major axis (these are SIGMA values in PIXELS)
     61        axes.major = seeing;
     62        axes.minor = aRatio * seeing;
     63        axes.theta = theta * PS_RAD_DEG;
    6164
    62     pol = psEllipseAxesToPol (axes);
     65        pol = psEllipseAxesToPol (axes);
    6366   
    64     param = psf->params->data[PM_PAR_E0];
    65     param->poly->coeff[0][0] = pol.e0;
     67        axes.major = seeingMax;
     68        axes.minor = aRatio * seeingMax;
     69        polMax = psEllipseAxesToPol (axes);
    6670
    67     param = psf->params->data[PM_PAR_E1];
    68     param->poly->coeff[0][0] = pol.e1;
     71        param = psf->params->data[PM_PAR_E0];
     72        param->poly->coeff[0][0] = pol.e0;
     73        param->poly->coeff[1][0] = (polMax.e0 - pol.e0) / xSize;
     74        param->poly->coeff[0][1] = (polMax.e0 - pol.e0) / ySize;
    6975
    70     param = psf->params->data[PM_PAR_E2];
    71     param->poly->coeff[0][0] = pol.e2;
     76        param = psf->params->data[PM_PAR_E1];
     77        param->poly->coeff[0][0] = pol.e1;
     78        param->poly->coeff[1][0] = 0.0;
     79        param->poly->coeff[0][1] = 0.0;
    7280
    73     if (!strcasecmp (psfModelName, "PS_MODEL_QGAUSS")) {
    74         param = psf->params->data[PM_PAR_7];
    75         param->poly->coeff[0][0] = 1.0;
    76     }
     81        param = psf->params->data[PM_PAR_E2];
     82        param->poly->coeff[0][0] = pol.e2;
     83        param->poly->coeff[1][0] = 0.0;
     84        param->poly->coeff[0][1] = 0.0;
    7785
    78     if (!strcasecmp (psfModelName, "PS_MODEL_RGAUSS")) {
    79         param = psf->params->data[PM_PAR_7];
    80         param->poly->coeff[0][0] = 1.0;
     86        if (!strcasecmp (psfModelName, "PS_MODEL_QGAUSS")) {
     87            param = psf->params->data[PM_PAR_7];
     88            param->poly->coeff[0][0] = 1.0;
     89            param->poly->coeff[1][0] = 0.0;
     90            param->poly->coeff[0][1] = 0.0;
     91        }
     92
     93        if (!strcasecmp (psfModelName, "PS_MODEL_RGAUSS")) {
     94            param = psf->params->data[PM_PAR_7];
     95            param->poly->coeff[0][0] = 1.0;
     96            param->poly->coeff[1][0] = 0.0;
     97            param->poly->coeff[0][1] = 0.0;
     98        }
     99
     100    } else {
     101        psEllipseAxes axes;
     102        psEllipsePol pol;
     103
     104        // no spatial variation
     105        options->psfTrendMode = PM_TREND_POLY_ORD;
     106        options->psfTrendNx = 0;
     107        options->psfTrendNy = 0;
     108        options->psfFieldNx = xSize;
     109        options->psfFieldNy = ySize;
     110
     111        // generate the psf
     112        psf = pmPSFAlloc (options);
     113
     114        // supply the semi-major axis (these are SIGMA values in PIXELS)
     115        axes.major = seeing;
     116        axes.minor = aRatio * seeing;
     117        axes.theta = theta * PS_RAD_DEG;
     118
     119        pol = psEllipseAxesToPol (axes);
     120   
     121        param = psf->params->data[PM_PAR_E0];
     122        param->poly->coeff[0][0] = pol.e0;
     123
     124        param = psf->params->data[PM_PAR_E1];
     125        param->poly->coeff[0][0] = pol.e1;
     126
     127        param = psf->params->data[PM_PAR_E2];
     128        param->poly->coeff[0][0] = pol.e2;
     129
     130        if (!strcasecmp (psfModelName, "PS_MODEL_QGAUSS")) {
     131            param = psf->params->data[PM_PAR_7];
     132            param->poly->coeff[0][0] = 1.0;
     133        }
     134
     135        if (!strcasecmp (psfModelName, "PS_MODEL_RGAUSS")) {
     136            param = psf->params->data[PM_PAR_7];
     137            param->poly->coeff[0][0] = 1.0;
     138        }
    81139    }
    82140
Note: See TracChangeset for help on using the changeset viewer.