Changeset 17935 for branches/eam_branch_20080511/ppSim/src/ppSimLoadSpots.c
- Timestamp:
- Jun 5, 2008, 3:29:09 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080511/ppSim/src/ppSimLoadSpots.c
r17930 r17935 1 1 # include "ppSim.h" 2 2 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. 7 bool ppSimLoadSpots (pmFPA *fpa, pmConfig *config) { 5 8 6 9 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 7 14 8 15 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe … … 15 22 if (!astroRecipe) { 16 23 psError(PSASTRO_ERR_CONFIG, false, "Can't find recipe %s", PSASTRO_RECIPE); 17 return NULL;24 return false; 18 25 } 19 26 … … 22 29 float scale = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel) 23 30 31 char *catdir = psMetadataLookupStr(NULL, recipe, "FORCED.CATDIR"); 32 char *photcode = psMetadataLookupStr(NULL, recipe, "FORCED.PHOTCODE"); 33 float MAGmax = 100.0; 34 24 35 // Size of FPA 25 36 psRegion *bounds = ppSimFPABounds (fpa); … … 27 38 psFree(bounds); 28 39 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); 31 52 32 // XXX need to use the WCS to define the overlap region33 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);37 53 psArray *refStars = psastroLoadRefstars(config); 38 54 if (!refStars || refStars->n == 0) { 39 55 psError(PS_ERR_UNKNOWN, false, "Unable to find reference stars."); 40 56 psFree(refStars); 41 return NULL;57 return false; 42 58 } 43 59 psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld reference stars", refStars->n); 44 60 45 61 // 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); 51 63 for (long i = 0; i < refStars->n; i++) { 52 64 ppSimStar *spot = ppSimStarAlloc (); … … 62 74 // spot->y = sin(pa) * xi + cos(pa) * eta + y0fpa; 63 75 64 spots->data[ oldSize + i] = star;76 spots->data[i] = spot; 65 77 66 78 psTrace("ppSim", 10, "Adding catalogue star: %.1f,%.1f --> %.2f\n", spot->x, spot->y, ref->Mag); 67 79 } 68 80 69 // XXX these need to be saved on PSPHOT.INPUT.CMF70 81 return true; 71 82 }
Note:
See TracChangeset
for help on using the changeset viewer.
