IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:50:52 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/simtest_nebulous_branches
Files:
17 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/simtest_nebulous_branches

  • branches/simtest_nebulous_branches/ppSim

  • branches/simtest_nebulous_branches/ppSim/src/Makefile.am

    r23808 r27840  
    3030        ppSimLoadStars.c          \
    3131        ppSimMakeStars.c          \
     32        ppSimMakeStarGrid.c       \
    3233        ppSimMakeGalaxies.c       \
    3334        ppSimMakeBiassec.c        \
     
    4748        ppSimLoadSpots.c          \
    4849        ppSimPhotom.c             \
    49         ppSimPhotomReadoutFake.c  \
    50         ppSimPhotomReadoutForce.c \
    5150        ppSimPhotomFiles.c        \
    5251        ppSimLoadForceSources.c   \
     
    5958        ppSimBadCTE.c             \
    6059        ppSimVersion.c
     60
     61# these functions have been broken by the API change in psphot (Jan 2010)
     62#       ppSimPhotomReadoutFake.c 
     63#       ppSimPhotomReadoutForce.c
    6164
    6265ppSimSequence_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS)
  • branches/simtest_nebulous_branches/ppSim/src/ppSim.h

    r23836 r27840  
    103103bool ppSimLoadStars (psArray *stars, pmFPA *fpa, pmConfig *config);
    104104bool ppSimMakeStars(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng);
     105bool ppSimMakeStarGrid(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng);
    105106bool ppSimInsertStars (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config);
    106107
  • branches/simtest_nebulous_branches/ppSim/src/ppSimAddNoise.c

    r18011 r27840  
    1616    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
    1717
    18     float gain = psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN"); // CCD gain, e/ADU
     18    // the recipe should set GAIN to NAN, and only modify to override the concept value
     19    float gain = psMetadataLookupF32(&mdok, recipe, "GAIN"); // CCD gain, e/ADU
    1920    if (isnan(gain)) {
    20         psWarning("CELL.GAIN is not set; reverting to recipe value GAIN.");
    21         gain = psMetadataLookupF32(&mdok, recipe, "GAIN");
     21        gain = psMetadataLookupF32(&mdok, cell->concepts, "CELL.GAIN");
    2222        if (!mdok) {
    23             psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find GAIN in recipe.");
    24             return false;
     23            psWarning("CELL.GAIN is not set; assuming gain of 1.0.");
     24            gain = 1.0;
    2525        }
    2626    }
  • branches/simtest_nebulous_branches/ppSim/src/ppSimInsertGalaxies.c

    r18011 r27840  
    7474    int dY = PM_CELL_TO_CHIP (0.0, y0Cell, yParityCell, binning);
    7575
    76     // psMetadataLookupPtr (readout->analysis, "PSPHOT.SOURCES", 0);
    77 
    78     psArray *sources = psArrayAllocEmpty (galaxies->n);
    79 
     76    pmDetections *detections = psMetadataLookupPtr (&mdok, readout->analysis, "PSPHOT.DETECTIONS");
     77    if (!detections) {
     78        detections = pmDetectionsAlloc();
     79        detections->allSources = psArrayAllocEmpty (galaxies->n);
     80        psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_ARRAY | PS_META_REPLACE, "psphot detections", detections);
     81    } else {
     82        psMemIncrRefCounter (detections);
     83    }
     84    psArray *sources = sources = detections->allSources;
    8085
    8186    // add sources to the readout image & weight
     
    181186    }
    182187
    183     // NOTE: readout must be part of the pmFPAfile named "PPSIM.OUTPUT"
    184     // psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, "psphot sources", sources);
     188    // XXX many leaks in here, i think
     189    psFree (detections);
    185190
    186     // XXX many leaks in here, i think
    187191    return true;
    188192}
  • branches/simtest_nebulous_branches/ppSim/src/ppSimInsertStars.c

    r21365 r27840  
    2626    float expTime   = psMetadataLookupF32(NULL, recipe, "EXPTIME"); // Exposure time
    2727    float darkRate  = psMetadataLookupF32(NULL, recipe, "DARK.RATE"); // Dark rate
     28    float nSigmaLim = psMetadataLookupF32(NULL, recipe, "STARS.SIGMA.LIM"); // significance of faintest stars
    2829
    2930    float readnoise = psMetadataLookupF32(NULL, cell->concepts, "CELL.READNOISE");// CCD read noise, e
     
    106107        pmModelSetFlux (model, flux);
    107108
    108         // XXX let the flux limit be a user-defined number of sky sigmas (not just 1.0)
    109         float radius = model->modelRadius (model->params, roughNoise);
     109        float radius = model->modelRadius (model->params, nSigmaLim * roughNoise);
    110110        radius = PS_MAX (radius, 1.0);
    111111
     
    136136        RESET(source->maskView);
    137137        RESET(source->modelFlux);
    138         RESET(source->psfFlux);
     138        RESET(source->psfImage);
    139139        RESET(source->blends);
    140140
     
    145145    fclose (outfile);
    146146
    147     // NOTE: the pmFPAfile "PPSIM.OUTPUT" points at these sources
    148     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "fake sources", sources);
    149     psFree(sources);
     147    pmDetections *detections = pmDetectionsAlloc();
     148    detections->allSources = sources;
     149
     150    // save detections on the readout->analysis
     151    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "fake sources", detections)) {
     152        psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     153        return false;
     154    }
     155    psFree(detections);
    150156
    151157    // XXX many leaks in here, i think
  • branches/simtest_nebulous_branches/ppSim/src/ppSimLoadForceSources.c

    r21365 r27840  
    102102        RESET(source->maskView);
    103103        RESET(source->modelFlux);
    104         RESET(source->psfFlux);
     104        RESET(source->psfImage);
    105105        RESET(source->blends);
    106106
  • branches/simtest_nebulous_branches/ppSim/src/ppSimLoadStars.c

    r23413 r27840  
    3030    psRegion *bounds = ppSimFPABounds (fpa);
    3131    float radius = 0.5 * PS_MAX(bounds->x1 - bounds->x0, bounds->y1 - bounds->y0) * scale;
    32     psFree(bounds);
    3332
    3433    float x0fpa = 0.5*(bounds->x0 + bounds->x1);
    3534    float y0fpa = 0.5*(bounds->y0 + bounds->y1);
     35
     36    psFree(bounds);
    3637
    3738    psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MIN",  PS_DATA_F32 | PS_META_REPLACE, "",
     
    4142    psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MIN", PS_DATA_F32 | PS_META_REPLACE, "", dec0 - radius);
    4243    psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MAX", PS_DATA_F32 | PS_META_REPLACE, "", dec0 + radius);
    43     psArray *refStars = psastroLoadRefstars(config, "PSASTRO.INPUT");
     44    psArray *refStars = psastroLoadRefstars(config, "PPSIM.OUTPUT");
    4445    if (!refStars) {
    4546        psError(PS_ERR_UNKNOWN, false, "Unable to find reference stars.");
  • branches/simtest_nebulous_branches/ppSim/src/ppSimLoop.c

    r24486 r27840  
    3030    ppSimType type = ppSimTypeFromString (typeStr); // Type of image to simulate
    3131    int binning = psMetadataLookupS32(NULL, recipe, "BINNING"); // Binning in x and y
     32
     33    ppSimUpdateConceptsFPA (fpa, config);
     34    if (fpa->hdu) { // XXX only do this if there is no INPUT image
     35        if (!ppSimInitHeader(config, fpa, NULL, NULL)) ESCAPE (PS_ERR_UNKNOWN, "problem setting output header");
     36    }
    3237
    3338    psArray *stars = psArrayAllocEmpty (1);
     
    4348        if (!ppSimMakeStars (stars, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make random stars");
    4449
     50        // Add random stars
     51        if (!ppSimMakeStarGrid (stars, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make random stars");
     52
    4553        // Add random galaxies
    4654        if (!ppSimMakeGalaxies (galaxies, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make random galaxies");
     
    5765        psFree(view);
    5866        return false;
    59     }
    60 
    61     ppSimUpdateConceptsFPA (fpa, config);
    62     if (fpa->hdu) { // XXX only do this if there is no INPUT image
    63         if (!ppSimInitHeader(config, fpa, NULL, NULL)) ESCAPE (PS_ERR_UNKNOWN, "problem setting output header");
    6467    }
    6568
  • branches/simtest_nebulous_branches/ppSim/src/ppSimMakeStars.c

    r18011 r27840  
    6161        if (!status) {
    6262            refMag = brightMag;
    63             refSum = 1;
     63            refSum = starsDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI);
    6464        }
    6565    } else {
  • branches/simtest_nebulous_branches/ppSim/src/ppSimPhotom.c

    r21183 r27840  
    4646            if (! readout->data_exists) { continue; }
    4747
     48// these are broken by the Jan 2010 API changes to psphot
     49#if 0
    4850            // run the actual photometry analysis
    4951            if (!ppSimPhotomReadoutFake (config, view)) {
     
    5658            }
    5759            // ppSimDetectionLimits (config, view);
     60#endif
    5861        }
    5962    }
  • branches/simtest_nebulous_branches/ppSim/src/ppSimPhotomReadout.c

    r21183 r27840  
    66    PS_ASSERT_PTR_NON_NULL (readout, NULL);
    77
    8     psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");
     8    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     9    psAssert (detections, "missing detections?");
     10
     11    psArray *sources = detections->allSources;
    912    return sources;
    1013}
     
    3942# if 0   
    4043    // set the photcode for this image
    41     if (!psphotAddPhotcode (recipe, config, view, "PPSIM.CHIP")) {
     44    if (!psphotAddPhotcodeReadout (recipe, config, view, "PPSIM.CHIP", 0)) {
    4245        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    4346        return false;
     
    7477
    7578    // Generate the mask and weight images, including the user-defined analysis region of interest
    76     psphotSetMaskAndWeight (config, readout, recipe);
     79    psphotSetMaskAndWeight (config, view, recipe);
    7780
    7881    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved in the recipe
     
    8588
    8689    // generate a background model (median, smoothed image)
    87     if (!psphotModelBackground (config, view, "PPSIM.CHIP")) {
     90    if (!psphotModelBackgroundReadoutFileIndex (config, view, "PPSIM.CHIP", 0)) {
    8891        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
    8992    }
    90     if (!psphotSubtractBackground (config, view, "PPSIM.CHIP")) {
     93    if (!psphotSubtractBackgroundReadout (config, view, "PPSIM.CHIP", 0)) {
    9194        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
    9295    }
     
    151154
    152155    // create the exported-metadata and free local data
    153     // XXX this places the sources on readout->analysis as PSPHOT.SOURCES.  modify?
    154     // (or don't supply the sources, and do this with a different function)
    155156    psphotReadoutCleanup(config, readout, recipe, NULL, psf, NULL);
    156157
     
    167168    psAssert (forceReadout, "no forceReadout?");
    168169    pmChipSetDataStatus (forceChip, true);
    169     psMetadataAddArray (forceReadout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE, "forced photometry ", forceSources);
    170     psFree (forceSources);
     170
     171    pmDetections *detectionsForce = pmDetectionsAlloc();
     172    detectionForce->allSources = forceSources;
     173
     174    // save detections on the readout->analysis
     175    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "force sources", detectionsForce)) {
     176        psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     177        return false;
     178    }
     179    psFree(detectionsForce);
    171180
    172181    pmCell    *fakeCell    = pmFPAfileThisCell (config->files, view, "PPSIM.FAKE.SOURCES"); psAssert (fakeCell, "no cell?");
     
    179188    psAssert (fakeReadout, "no fakeReadout?");
    180189    pmChipSetDataStatus (fakeChip, true);
    181     psMetadataAddArray (fakeReadout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE, "fake photometry ", fakeSources);
     190
     191    pmDetections *detectionsFake = pmDetectionsAlloc();
     192    detectionFake->allSources = fakeSources;
     193
     194    // save detections on the readout->analysis
     195    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "fake sources", detectionsFake)) {
     196        psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     197        return false;
     198    }
     199    psFree(detectionsFake);
    182200
    183201    return true;
  • branches/simtest_nebulous_branches/ppSim/src/ppSimPhotomReadoutFake.c

    r21365 r27840  
    11# include "ppSim.h"
    22
     3// XXX this function is currently disabled -- need to update code below to distinguish the fake
     4// and force positions, etc
    35bool ppSimPhotomReadoutFake(pmConfig *config, const pmFPAview *view) {
    46
     
    1113        return false;
    1214    }
    13 
    14 # if 0
    15     // set the photcode for this image
    16     if (!psphotAddPhotcode (recipe, config, view, "PPSIM.FAKE.CHIP")) {
    17         psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    18         return false;
    19     }
    20 # endif
    2115
    2216    // *** in this section, perform the photometry for real + fake sources on PPSIM.FAKE.CHIP ***
     
    3630
    3731    // Generate the mask and variance images, including the user-defined analysis region of interest
    38     psphotSetMaskAndVariance (config, readout, recipe);
     32    psphotSetMaskAndVariance (config, view);
    3933
    4034    // XXX need to define the source pixels
     
    5852    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved in the recipe
    5953    // this function uses PSPHOT.PSF.LOAD as the pmFPAfile
    60     pmPSF *psf = psphotLoadPSF (config, view, recipe);
    61     assert (psf);
     54    psphotLoadPSF (config, view);
    6255
    6356    // remove all sources
     
    6558
    6659    // generate a background model (median, smoothed image)
    67     if (!psphotModelBackground (config, view, "PPSIM.FAKE.CHIP")) {
     60    if (!psphotModelBackgroundReadoutFileIndex (config, view, "PPSIM.FAKE.CHIP", 0)) {
    6861        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
    6962    }
    70     if (!psphotSubtractBackground (config, view, "PPSIM.FAKE.CHIP")) {
     63    if (!psphotSubtractBackgroundReadout (config, view, "PPSIM.FAKE.CHIP", 0, recipe)) {
    7164        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
    7265    }
     
    118111    psAssert (fakeReadout, "no fakeReadout?");
    119112    pmChipSetDataStatus (fakeChip, true);
    120     psMetadataAddArray (fakeReadout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE, "fake photometry ", fakeSources);
     113
     114    pmDetections *detections = pmDetectionsAlloc();
     115    detection->allSources = fakeSources;
     116
     117    psMetadataAddArray (fakeReadout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE, "fake photometry ", detections);
     118    psFree(detections);
    121119
    122120    return true;
  • branches/simtest_nebulous_branches/ppSim/src/ppSimPhotomReadoutForce.c

    r21365 r27840  
    1414# if 0
    1515    // set the photcode for this image
    16     if (!psphotAddPhotcode (recipe, config, view, "PPSIM.FAKE.CHIP")) {
     16    if (!psphotAddPhotcodeReadout (recipe, config, view, "PPSIM.FAKE.CHIP", 0)) {
    1717        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    1818        return false;
     
    3636
    3737    // Generate the mask and variance images, including the user-defined analysis region of interest
    38     psphotSetMaskAndVariance (config, readout, recipe);
     38    psphotSetMaskAndVariance (config, view, recipe);
    3939
    4040    // XXX need to define the source pixels
     
    5858
    5959    // generate a background model (median, smoothed image)
    60     if (!psphotModelBackground (config, view, "PPSIM.FORCE.CHIP")) {
     60    if (!psphotModelBackgroundReadoutFileIndex (config, view, "PPSIM.FORCE.CHIP", 0)) {
    6161        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
    6262    }
    63     if (!psphotSubtractBackground (config, view, "PPSIM.FORCE.CHIP")) {
     63    if (!psphotSubtractBackgroundReadout (config, view, "PPSIM.FORCE.CHIP", 0)) {
    6464        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
    6565    }
     
    9898
    9999    // create the exported-metadata and free local data
    100     // XXX this places the sources on readout->analysis as PSPHOT.SOURCES.  modify?
    101     // (or don't supply the sources, and do this with a different function)
    102100    psphotReadoutCleanup(config, readout, recipe, NULL, psf, NULL);
    103101
     
    111109    psAssert (forceReadout, "no forceReadout?");
    112110    pmChipSetDataStatus (forceChip, true);
    113     psMetadataAddArray (forceReadout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE, "force photometry ", forceSources);
     111
     112    pmDetections *detections = pmDetectionsAlloc();
     113    detection->allSources = forceSources;
     114    psMetadataAddArray (forceReadout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE, "force photometry ", detections);
     115    psFree(detections);
    114116
    115117    return true;
  • branches/simtest_nebulous_branches/ppSim/src/ppSimSetPSF.c

    r18011 r27840  
    2020    // ppSimArguments)
    2121    float seeing   = psMetadataLookupF32(&status, recipe, "SEEING"); // Seeing SIGMA (pixels)
     22    float aRatio   = psMetadataLookupF32(&status, recipe, "PSF.ARATIO"); // Seeing SIGMA (pixels)
     23    float theta    = psMetadataLookupF32(&status, recipe, "PSF.THETA"); // Seeing SIGMA (pixels)
    2224
    2325    char *psfModelName = psMetadataLookupStr(&status, recipe, "PSF.MODEL"); // Name of PSF model
     
    5557    // supply the semi-major axis (these are SIGMA values in PIXELS)
    5658    axes.major = seeing;
    57     axes.minor = seeing;
    58     axes.theta = 0.0;
     59    axes.minor = aRatio * seeing;
     60    axes.theta = theta * PS_RAD_DEG;
    5961
    6062    pol = psEllipseAxesToPol (axes);
  • branches/simtest_nebulous_branches/ppSim/src/ppSimUtils.c

    r24807 r27840  
    270270psArray *ppSimSelectSources (pmConfig *config, const pmFPAview *view, const char *filename) {
    271271
     272    bool status;
     273
    272274    pmReadout *readout = pmFPAfileThisReadout (config->files, view, filename);
    273275    PS_ASSERT_PTR_NON_NULL (readout, NULL);
    274276
    275     psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");
     277    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     278    psAssert (detections, "missing detections?");
     279
     280    psArray *sources = detections->allSources;
    276281    return sources;
    277282}
Note: See TracChangeset for help on using the changeset viewer.