IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 5, 2008, 3:29:09 AM (18 years ago)
Author:
eugene
Message:

added forced photometry code; compiles, not tested

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080511/ppSim/src/ppSimLoadSpots.c

    r17930 r17935  
    11# include "ppSim.h"
    22
    3 // need to specify an alternative CATDIR for the force positions
    4 bool ppSimLoadSpots (psArray *spots, pmFPA *fpa, pmConfig *config) {
     3// Load the relevant forced-photometry positions for this field.  This function does not determine
     4// the pixel coordinates, merely the celestial coordinates for sources in the general vicinity.  The
     5// sources are saved on the fpa->analysis metadata as FORCED.SPOTS.  We always create an entry; it
     6// will be empty if no sources were selected or forced photometry is not desired.
     7bool ppSimLoadSpots (pmFPA *fpa, pmConfig *config) {
    58
    69    bool status;
     10
     11    psArray *spots = psArrayAllocEmpty (1);
     12    psMetadataAddPtr (fpa->analysis, PS_LIST_TAIL, "FORCED.SPOTS", PS_META_REPLACE, "forced photometry positions", spots);
     13    psFree (spots); // free the extra (local) reference; a copy remains on fpa->analysis
    714
    815    psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe
     
    1522    if (!astroRecipe) {
    1623        psError(PSASTRO_ERR_CONFIG, false, "Can't find recipe %s", PSASTRO_RECIPE);
    17         return NULL;
     24        return false;
    1825    }
    1926
     
    2229    float scale   = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)
    2330
     31    char *catdir = psMetadataLookupStr(NULL, recipe, "FORCED.CATDIR");
     32    char *photcode = psMetadataLookupStr(NULL, recipe, "FORCED.PHOTCODE");
     33    float MAGmax = 100.0;
     34
    2435    // Size of FPA
    2536    psRegion *bounds = ppSimFPABounds (fpa);
     
    2738    psFree(bounds);
    2839
    29     float x0fpa = 0.5*(bounds->x0 + bounds->x1);
    30     float y0fpa = 0.5*(bounds->y0 + bounds->y1);
     40    // modify the PSASTRO recipe to use the values desired for FORCED.PHOT.  we can use a view on
     41    // the PSASTRO recipe because we are not calling psastro elsewhere in this program.  XXX need to
     42    // use the WCS to define the overlap region
     43    psMetadataAddStr(astroRecipe, PS_LIST_TAIL, "DVO.CATDIR",  PS_META_REPLACE, "", catdir);
     44    psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "RA_MIN",  PS_META_REPLACE, "", ra0 - radius);
     45    psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "RA_MAX",  PS_META_REPLACE, "", ra0 + radius);
     46    psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "DEC_MIN", PS_META_REPLACE, "", dec0 - radius);
     47    psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "DEC_MAX", PS_META_REPLACE, "", dec0 + radius);
     48   
     49    // XXX these two values are somewhat bogus: can we have psastroLoadRefstars optionally ignore photcode and MAGmax?
     50    psMetadataAddStr(astroRecipe, PS_LIST_TAIL, "DVO.GETSTAR.PHOTCODE",  PS_META_REPLACE, "", photcode);
     51    psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "DVO.GETSTAR.MAG.MAX",  PS_META_REPLACE, "", MAGmax);
    3152
    32     // XXX need to use the WCS to define the overlap region
    33     psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MIN",  PS_DATA_F32 | PS_META_REPLACE, "", ra0 - radius);
    34     psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MAX",  PS_DATA_F32 | PS_META_REPLACE, "", ra0 + radius);
    35     psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MIN", PS_DATA_F32 | PS_META_REPLACE, "", dec0 - radius);
    36     psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MAX", PS_DATA_F32 | PS_META_REPLACE, "", dec0 + radius);
    3753    psArray *refStars = psastroLoadRefstars(config);
    3854    if (!refStars || refStars->n == 0) {
    3955        psError(PS_ERR_UNKNOWN, false, "Unable to find reference stars.");
    4056        psFree(refStars);
    41         return NULL;
     57        return false;
    4258    }
    4359    psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld reference stars", refStars->n);
    4460
    4561    // convert the pmAstromObj sources to the storage format used by the CMF files
    46 
    47     long oldSize = spots->n;
    48     spots = psArrayRealloc (spots, oldSize + refStars->n);
    49 
    50     // Conversion loop
     62    psArrayRealloc (spots, refStars->n);
    5163    for (long i = 0; i < refStars->n; i++) {
    5264        ppSimStar *spot = ppSimStarAlloc ();
     
    6274        // spot->y = sin(pa) * xi + cos(pa) * eta + y0fpa;
    6375
    64         spots->data[oldSize + i] = star;
     76        spots->data[i] = spot;
    6577
    6678        psTrace("ppSim", 10, "Adding catalogue star: %.1f,%.1f --> %.2f\n", spot->x, spot->y, ref->Mag);
    6779    }
    6880
    69     // XXX these need to be saved on PSPHOT.INPUT.CMF
    7081    return true;
    7182}
Note: See TracChangeset for help on using the changeset viewer.