Changeset 18011 for trunk/ppSim/src/ppSimLoadSpots.c
- Timestamp:
- Jun 8, 2008, 4:03:31 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppSim/src/ppSimLoadSpots.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/ppSimLoadSpots.c
r17628 r18011 1 # include "ppSim.h"1 # include "ppSim.h" 2 2 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. 3 7 bool ppSimLoadSpots (pmFPA *fpa, pmConfig *config) { 4 8 5 bool mdok; 6 assert (stars); 9 bool status; 7 10 8 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSIM_RECIPE); // Recipe9 11 10 bool forcedPhot = psMetadataLookupBool(&mdok, recipe, "FORCED.PHOT"); // Density of fakes 11 if (!forcedPhot) return true; 12 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe 12 13 13 // Read catalogue stars using psastro 14 // XXX probably need to modify this... 14 bool forcedPhot = psMetadataLookupBool(&status, recipe, "FORCED.PHOT"); // Density of fakes 15 if (!forcedPhot) { 16 psArray *spots = psArrayAllocEmpty (1); 17 psMetadataAddArray (fpa->analysis, PS_LIST_TAIL, "FORCED.SPOTS", PS_META_REPLACE, "forced photometry positions", spots); 18 psFree (spots); // free the extra (local) reference; a copy remains on fpa->analysis 19 return true; 20 } 21 22 // We read the catalogue stars using psastroLoadRefstars 15 23 psMetadata *astroRecipe = psMetadataLookupPtr(NULL, config->recipes, PSASTRO_RECIPE); 16 24 if (!astroRecipe) { 17 25 psError(PSASTRO_ERR_CONFIG, false, "Can't find recipe %s", PSASTRO_RECIPE); 18 return NULL;26 return false; 19 27 } 28 29 float ra0 = psMetadataLookupF32(NULL, recipe, "RA"); // Boresight RA (radians) 30 float dec0 = psMetadataLookupF32(NULL, recipe, "DEC"); // Boresight Dec (radians) 31 float scale = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel) 32 33 if (isnan(ra0) || isnan(dec0)) { 34 psError(PS_ERR_UNKNOWN, false, "image boresite coords not defined."); 35 return false; 36 } 37 38 char *catdir = psMetadataLookupStr(NULL, recipe, "FORCED.CATDIR"); 20 39 21 40 // Size of FPA … … 24 43 psFree(bounds); 25 44 26 float x0fpa = 0.5*(bounds->x0 + bounds->x1); 27 float y0fpa = 0.5*(bounds->y0 + bounds->y1); 45 // modify the PSASTRO recipe to use the values desired for FORCED.PHOT. we can use a view on 46 // the PSASTRO recipe because we are not calling psastro elsewhere in this program. XXX need to 47 // use the WCS to define the overlap region 48 psMetadataAddStr(astroRecipe, PS_LIST_TAIL, "DVO.CATDIR", PS_META_REPLACE, "", catdir); 49 psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "RA_MIN", PS_META_REPLACE, "", ra0 - radius); 50 psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "RA_MAX", PS_META_REPLACE, "", ra0 + radius); 51 psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "DEC_MIN", PS_META_REPLACE, "", dec0 - radius); 52 psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "DEC_MAX", PS_META_REPLACE, "", dec0 + radius); 53 54 // tell psastroLoadRefstars to ignore photcode and maglim 55 psMetadataAddStr(astroRecipe, PS_LIST_TAIL, "DVO.GETSTAR.PHOTCODE", PS_META_REPLACE, "", "NONE"); 56 psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "DVO.GETSTAR.MAG.MAX", PS_META_REPLACE, "", NAN); 28 57 29 // XXX need to use the WCS to define the overlap region 30 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MIN", PS_DATA_F32 | PS_META_REPLACE, "", ra0 - radius); 31 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MAX", PS_DATA_F32 | PS_META_REPLACE, "", ra0 + radius); 32 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MIN", PS_DATA_F32 | PS_META_REPLACE, "", dec0 - radius); 33 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MAX", PS_DATA_F32 | PS_META_REPLACE, "", dec0 + radius); 34 psArray *refStars = psastroLoadRefstars(config); 35 if (!refStars || refStars->n == 0) { 58 // load refstars from the catalog 59 psArray *spots = psastroLoadRefstars(config); 60 if (!spots || spots->n == 0) { 36 61 psError(PS_ERR_UNKNOWN, false, "Unable to find reference stars."); 37 psFree( refStars);38 return NULL;62 psFree(spots); 63 return false; 39 64 } 40 psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld reference stars", refStars->n);65 psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld reference stars", spots->n); 41 66 42 // convert the pmAstromObj sources to the storage format used by the CMF files 67 psMetadataAddArray (fpa->analysis, PS_LIST_TAIL, "FORCED.SPOTS", PS_META_REPLACE, "forced photometry positions", spots); 68 psFree (spots); // free the extra (local) reference; a copy remains on fpa->analysis 43 69 44 long oldSize = stars->n;45 stars = psArrayRealloc (stars, refStars->n);46 47 // Conversion loop48 for (long i = 0; i < refStars->n; i++) {49 ppSimStar *star = ppSimStarAlloc ();50 51 pmAstromObj *ref = refStars->data[i]; // Reference star52 star->ra = ref->sky->r; // RA of star53 star->dec = ref->sky->d; // Dec of star54 star->mag = ref->Mag; // Magnitude of star55 56 // Apply rotation, make FPA center of boresite57 // convert the ra,dec to x,y using examples in psastro.58 // star->x = cos(pa) * xi - sin(pa) * eta + x0fpa;59 // star->y = sin(pa) * xi + cos(pa) * eta + y0fpa;60 61 stars->data[oldSize + i] = star;62 63 psTrace("ppSim", 10, "Adding catalogue star: %.1f,%.1f --> %.2f\n", star->x, star->y, star->flux);64 }65 66 // XXX these need to be saved on PSPHOT.INPUT.CMF67 70 return true; 68 71 }
Note:
See TracChangeset
for help on using the changeset viewer.
