Changeset 17901
- Timestamp:
- Jun 4, 2008, 1:52:32 PM (18 years ago)
- Location:
- branches/eam_branch_20080511/ppSim/src
- Files:
-
- 9 edited
-
ppSim.h (modified) (1 diff)
-
ppSimArguments.c (modified) (4 diffs)
-
ppSimDetections.c (modified) (1 diff)
-
ppSimLoadForceSources.c (modified) (1 diff)
-
ppSimLoop.c (modified) (3 diffs)
-
ppSimPhotom.c (modified) (1 diff)
-
ppSimPhotomFiles.c (modified) (3 diffs)
-
ppSimPhotomReadout.c (modified) (6 diffs)
-
ppSimUtils.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080511/ppSim/src/ppSim.h
r17818 r17901 169 169 ); 170 170 171 bool ppSimArgToRecipeBool(bool *status, 172 psMetadata *options, // Target to which to add value 173 const char *recipeName, // Name for value in the recipe 174 psMetadata *arguments, // Command-line arguments 175 const char *argName // Argument name in the command-line arguments 176 ); 177 171 178 ppSimType ppSimTypeFromString (char *typeStr); 172 179 char *ppSimTypeToString (ppSimType type); -
branches/eam_branch_20080511/ppSim/src/ppSimArguments.c
r17705 r17901 29 29 30 30 psMetadata *arguments = psMetadataAlloc(); // Command-line arguments 31 psMetadataAddStr(arguments, PS_LIST_TAIL, "-format", 0, "Camera format name", NULL); 32 psMetadataAddStr(arguments, PS_LIST_TAIL, "-type", 0, "Exposure type (BIAS|DARK|FLAT|OBJECT)", NULL); 33 psMetadataAddStr(arguments, PS_LIST_TAIL, "-filter", 0, "Filter name", NULL); 34 psMetadataAddF32(arguments, PS_LIST_TAIL, "-exptime", 0, "Exposure time (s)", NAN); 35 psMetadataAddF32(arguments, PS_LIST_TAIL, "-biaslevel", 0, "Bias level (e)", NAN); 36 psMetadataAddF32(arguments, PS_LIST_TAIL, "-biasrange", 0, "Bias range (e)", NAN); 37 psMetadataAddF32(arguments, PS_LIST_TAIL, "-darkrate", 0, "Dark rate (e/s)", NAN); 38 psMetadataAddF32(arguments, PS_LIST_TAIL, "-flatsigma", 0, "Flat sigma", NAN); 39 psMetadataAddF32(arguments, PS_LIST_TAIL, "-flatrate", 0, "Flat rate (e/s)", NAN); 40 psMetadataAddF32(arguments, PS_LIST_TAIL, "-shuttertime", 0, "Shutter time (s)", NAN); 41 psMetadataAddF32(arguments, PS_LIST_TAIL, "-skyrate", 0, "Sky rate (e/s)", NAN); 42 psMetadataAddF32(arguments, PS_LIST_TAIL, "-skymags", 0, "Sky brightness in mags / square arcsec", NAN); 43 psMetadataAddF32(arguments, PS_LIST_TAIL, "-ra", 0, "RA (degrees)", NAN); 44 psMetadataAddF32(arguments, PS_LIST_TAIL, "-dec", 0, "Dec (degrees)", NAN); 45 psMetadataAddF32(arguments, PS_LIST_TAIL, "-pa", 0, "Position angle (degrees)", NAN); 46 psMetadataAddF32(arguments, PS_LIST_TAIL, "-scale", 0, "Plate scale (arcsec/pixel)", NAN); 47 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp", 0, "Photometric zero point", NAN); 48 psMetadataAddF32(arguments, PS_LIST_TAIL, "-seeing", 0, "Seeing FWHM (arcsec)", NAN); 49 psMetadataAddF32(arguments, PS_LIST_TAIL, "-starslum", 0, "Fake star luminosity function slope", NAN); 50 psMetadataAddF32(arguments, PS_LIST_TAIL, "-starsmag", 0, "Brightest magnitude for fake stars", NAN); 51 psMetadataAddF32(arguments, PS_LIST_TAIL, "-starsdensity", 0, "Density of fake stars at magnitude", NAN); 52 psMetadataAddStr(arguments, PS_LIST_TAIL, "-psfclass", 0, "Type of PSF model", NULL); 53 psMetadataAddStr(arguments, PS_LIST_TAIL, "-galmodel", 0, "Type of Galaxy model", NULL); 54 psMetadataAddS32(arguments, PS_LIST_TAIL, "-bin", 0, "Binning in x and y", 1); 31 psMetadataAddStr(arguments, PS_LIST_TAIL, "-format", 0, "Camera format name", NULL); 32 psMetadataAddStr(arguments, PS_LIST_TAIL, "-type", 0, "Exposure type (BIAS|DARK|FLAT|OBJECT)", NULL); 33 psMetadataAddStr(arguments, PS_LIST_TAIL, "-filter", 0, "Filter name", NULL); 34 psMetadataAddF32(arguments, PS_LIST_TAIL, "-exptime", 0, "Exposure time (s)", NAN); 35 psMetadataAddF32(arguments, PS_LIST_TAIL, "-biaslevel", 0, "Bias level (e)", NAN); 36 psMetadataAddF32(arguments, PS_LIST_TAIL, "-biasrange", 0, "Bias range (e)", NAN); 37 psMetadataAddF32(arguments, PS_LIST_TAIL, "-darkrate", 0, "Dark rate (e/s)", NAN); 38 psMetadataAddF32(arguments, PS_LIST_TAIL, "-flatsigma", 0, "Flat sigma", NAN); 39 psMetadataAddF32(arguments, PS_LIST_TAIL, "-flatrate", 0, "Flat rate (e/s)", NAN); 40 psMetadataAddF32(arguments, PS_LIST_TAIL, "-shuttertime", 0, "Shutter time (s)", NAN); 41 psMetadataAddF32(arguments, PS_LIST_TAIL, "-skyrate", 0, "Sky rate (e/s)", NAN); 42 psMetadataAddF32(arguments, PS_LIST_TAIL, "-skymags", 0, "Sky brightness in mags / square arcsec", NAN); 43 psMetadataAddF32(arguments, PS_LIST_TAIL, "-ra", 0, "RA (degrees)", NAN); 44 psMetadataAddF32(arguments, PS_LIST_TAIL, "-dec", 0, "Dec (degrees)", NAN); 45 psMetadataAddF32(arguments, PS_LIST_TAIL, "-pa", 0, "Position angle (degrees)", NAN); 46 psMetadataAddF32(arguments, PS_LIST_TAIL, "-scale", 0, "Plate scale (arcsec/pixel)", NAN); 47 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp", 0, "Photometric zero point", NAN); 48 psMetadataAddF32(arguments, PS_LIST_TAIL, "-seeing", 0, "Seeing FWHM (arcsec)", NAN); 49 psMetadataAddF32(arguments, PS_LIST_TAIL, "-starslum", 0, "Fake star luminosity function slope", NAN); 50 psMetadataAddF32(arguments, PS_LIST_TAIL, "-starsmag", 0, "Brightest magnitude for fake stars", NAN); 51 psMetadataAddF32(arguments, PS_LIST_TAIL, "-starsdensity", 0, "Density of fake stars at magnitude", NAN); 52 psMetadataAddStr(arguments, PS_LIST_TAIL, "-psfclass", 0, "Type of PSF model", NULL); 53 psMetadataAddStr(arguments, PS_LIST_TAIL, "-galmodel", 0, "Type of Galaxy model", NULL); 54 psMetadataAddS32(arguments, PS_LIST_TAIL, "-bin", 0, "Binning in x and y", 1); 55 psMetadataAddBool(arguments, PS_LIST_TAIL, "+photom", 0, "Perform photometry on fake sources", 1); 55 56 56 57 if (psArgumentGet (argc, argv, "-h")) { usage(argv[0], arguments, config); } … … 59 60 60 61 pmConfigFileSetsMD (config->arguments, &argc, argv, "PSPHOT.PSF", "-psf", "-psflist"); 61 if (psErrorCodeLast () != PS_ERR_NONE) { psAbort ("problem with PSPHOT.PSF option"); } 62 if (psErrorCodeLast () != PS_ERR_NONE) { psAbort ("problem with -psf or -psflist option"); } 63 64 pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT.SOURCES", "-cmf", "-cmflist"); 65 if (psErrorCodeLast () != PS_ERR_NONE) { psAbort ("problem with -cmf or -cmflist option"); } 62 66 63 67 // Only one of -camera and -file is needed or allowed. The -camera option would have been … … 103 107 ppSimArgToRecipeF32(&status, options, "STARS.MAG", arguments, "-starsmag"); 104 108 ppSimArgToRecipeF32(&status, options, "STARS.DENSITY", arguments, "-starsdensity"); 109 ppSimArgToRecipeBool(&status, options, "PHOTOM", arguments, "+photom"); 105 110 106 111 // if we are loading the input image (not creating it), then we can skip the remaining arguments … … 168 173 169 174 // these values all get moved from arguments to RECIPE:OPTIONS 170 ppSimArgToRecipeF32(&status, options, "BIAS.LEVEL", arguments, "-biaslevel");171 ppSimArgToRecipeF32(&status, options, "BIAS.RANGE", arguments, "-biasrange");172 ppSimArgToRecipeF32(&status, options, "DARK.RATE", arguments, "-darkrate");173 ppSimArgToRecipeF32(&status, options, "FLAT.SIGMA", arguments, "-flatsigma");174 ppSimArgToRecipeF32(&status, options, "FLAT.RATE", arguments, "-flatrate");175 ppSimArgToRecipeF32(&status, options, "SHUTTER.TIME", arguments, "-shuttertime");176 ppSimArgToRecipeF32(&status, options, "SKY.RATE", arguments, "-skyrate");177 ppSimArgToRecipeS32(&status, options, "BINNING", arguments, "-bin");175 ppSimArgToRecipeF32(&status, options, "BIAS.LEVEL", arguments, "-biaslevel"); 176 ppSimArgToRecipeF32(&status, options, "BIAS.RANGE", arguments, "-biasrange"); 177 ppSimArgToRecipeF32(&status, options, "DARK.RATE", arguments, "-darkrate"); 178 ppSimArgToRecipeF32(&status, options, "FLAT.SIGMA", arguments, "-flatsigma"); 179 ppSimArgToRecipeF32(&status, options, "FLAT.RATE", arguments, "-flatrate"); 180 ppSimArgToRecipeF32(&status, options, "SHUTTER.TIME", arguments, "-shuttertime"); 181 ppSimArgToRecipeF32(&status, options, "SKY.RATE", arguments, "-skyrate"); 182 ppSimArgToRecipeS32(&status, options, "BINNING", arguments, "-bin"); 178 183 179 184 if (type == PPSIM_TYPE_OBJECT) { -
branches/eam_branch_20080511/ppSim/src/ppSimDetections.c
r17818 r17901 2 2 3 3 bool ppSimDetections (psImage *significance, psMetadata *recipe, psArray *sources) { 4 psAssert (sources, "programming error: ppSimDetections passed NULL sources"); 4 5 5 bool status;6 bool status; 6 7 7 // for each source, measure the significance of the peak at the given coordinate8 // where does this get stored?8 // for each source, measure the significance of the peak at the given coordinate 9 // where does this get stored? 9 10 10 // XXX need to get the effective Area from the PSF sigma11 float SIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "SIGMA_SMOOTH");12 psAssert (status, "SIGMA_SMOOTH missing: call psphotSignificanceImage first");13 float effArea = 4.0*M_PI*PS_SQR(SIGMA_SMTH);11 // XXX need to get the effective Area from the PSF sigma 12 float SIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "SIGMA_SMOOTH"); 13 psAssert (status, "SIGMA_SMOOTH missing: call psphotSignificanceImage first"); 14 float effArea = 4.0*M_PI*PS_SQR(SIGMA_SMTH); 14 15 15 int row0 = significance->row0;16 int col0 = significance->col0;16 int row0 = significance->row0; 17 int col0 = significance->col0; 17 18 18 for (int i = 0; i < sources->n; i++) {19 for (int i = 0; i < sources->n; i++) { 19 20 20 pmSource *source = sources->data[i];21 pmPeak *peak = source->peak;22 psAssert (peak, "peak is not defined for the source");21 pmSource *source = sources->data[i]; 22 pmPeak *peak = source->peak; 23 psAssert (peak, "peak is not defined for the source"); 23 24 24 peak->value = significance->data.F32[peak->y-row0][peak->x-col0];25 peak->SN = sqrt(peak->value*effArea);25 peak->value = significance->data.F32[peak->y-row0][peak->x-col0]; 26 peak->SN = sqrt(peak->value*effArea); 26 27 27 }28 return true;28 } 29 return true; 29 30 } -
branches/eam_branch_20080511/ppSim/src/ppSimLoadForceSources.c
r17818 r17901 2 2 3 3 psArray *ppSimLoadForceSources(pmConfig *config, const pmFPAview *view) { 4 5 psArray *result = psArrayAlloc(0); 6 return result; 4 7 5 8 # if (0) -
branches/eam_branch_20080511/ppSim/src/ppSimLoop.c
r17848 r17901 56 56 57 57 ppSimUpdateConceptsFPA (fpa, config); 58 if (fpa->hdu) { // XXX only do this if there is no INPUT image 59 if (!ppSimInitHeader(config, fpa, NULL, NULL)) ESCAPE (PS_ERR_UNKNOWN, "problem setting output header"); 60 } 58 61 59 62 pmChip *chip; // Chip from FPA … … 179 182 } 180 183 184 // XXX why no UpdateConceptsChip?? 185 181 186 if (chip->hdu) { 182 187 // XXX only do this if there is no INPUT image … … 193 198 return false; 194 199 } 195 196 200 } 197 201 198 202 psFree(stars); 199 203 psFree(galaxies); 200 201 if (fpa->hdu) {202 // XXX only do this if there is no INPUT image203 if (!ppSimInitHeader(config, fpa, NULL, NULL)) ESCAPE (PS_ERR_UNKNOWN, "problem setting output header");204 }205 204 206 205 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { -
branches/eam_branch_20080511/ppSim/src/ppSimPhotom.c
r17849 r17901 25 25 } 26 26 27 // we make a new copy of the output chip to keep psphot from modifying the output image 28 // XXX is this needed for ppSim? only if we want to write out the image with and without subtracted sources 29 pmChip *oldChip = pmFPAviewThisChip (view, input->src); 30 pmChip *newChip = pmFPAviewThisChip (view, input->fpa); 31 pmChipCopy (newChip, oldChip); 27 // XXX If we want to be able to write out both the positive and residual images, we will 28 // need to define an additional pmFPAfile container, and then make a copy as is done for 29 // PPIMAGE.CHIP -> PSPHOT.INPUT in ppImage. At the moment, PPSIM.CHIP will write out the 30 // mosaicked image with the sources subtracted. 31 32 // XXX if input -> PSPHOT.INPUT, which is tied to PPSIM.CHIP with pmFPAfileDefineFromFile, 33 // then the following code creates the chip copy: 34 // pmChip *oldChip = pmFPAviewThisChip (view, input->src); 35 // pmChip *newChip = pmFPAviewThisChip (view, input->fpa); 36 // pmChipCopy (newChip, oldChip); 32 37 33 38 // iterate over the cells and readout for this chip -
branches/eam_branch_20080511/ppSim/src/ppSimPhotomFiles.c
r17818 r17901 44 44 pmFPAfile *output = pmFPAfileDefineFromFile (config, input, 1, 1, "PSPHOT.BACKSUB"); 45 45 if (!output) { 46 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT. ");46 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKSUB"); 47 47 return false; 48 48 } … … 51 51 52 52 // the input sources are required for sensible measurements of the fake or force sources 53 pmFPAfile DefineFromArgs (&status, config, "PPSIM.REAL.SOURCES", "INPUT.SOURCES");54 if (! status) {55 psError(PS_ERR_UNKNOWN, false, " Failed to build FPA from PPSIM.REAL.SOURCES");53 pmFPAfile *cmffile = pmFPAfileDefineFromArgs (&status, config, "PPSIM.REAL.SOURCES", "INPUT.SOURCES"); 54 if (!cmffile) { 55 psError(PS_ERR_UNKNOWN, false, "input sources not found; required for photometry (or error with PPSIM.REAL.SOURCES filerule)"); 56 56 return false; 57 57 } … … 60 60 pmFPAfile *outsources = pmFPAfileDefineOutputFromFile (config, input, "PPSIM.FAKE.SOURCES"); 61 61 if (!outsources) { 62 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for P SPHOT.OUTPUT");62 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PPSIM.FAKE.SOURCES"); 63 63 return false; 64 64 } 65 65 outsources->save = true; 66 66 67 pmFPAfileBindFromArgs(&status, input, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF"); 68 if (!status) { 67 // we bind the psffile to the chip-mosaicked image so we have a reference to the image 68 pmFPAfile *psffile = pmFPAfileBindFromArgs(&status, input, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF"); 69 if (!psffile) { 69 70 psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.PSF.LOAD"); 70 return status;71 return false; 71 72 } 72 73 -
branches/eam_branch_20080511/ppSim/src/ppSimPhotomReadout.c
r17851 r17901 1 1 # include "ppSim.h" 2 3 psArray *ppSimSelectSources (pmConfig *config, const pmFPAview *view, const char *filename) { 4 5 pmReadout *readout = pmFPAfileThisReadout (config->files, view, filename); 6 PS_ASSERT_PTR_NON_NULL (readout, NULL); 7 8 psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES"); 9 return sources; 10 } 11 12 bool ppSimDefinePixels (psArray *sources, pmReadout *readout, psMetadata *recipe) { 13 14 bool status; 15 16 float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS"); 17 if (!status) return NULL; 18 19 for (int i = 0; i < sources->n; i++) { 20 pmSource *source = sources->data[i]; 21 22 // allocate image, weight, mask arrays for each peak (square of radius OUTER) 23 pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER); 24 } 25 return true; 26 } 2 27 3 28 bool ppSimPhotomReadout(pmConfig *config, const pmFPAview *view) { … … 13 38 14 39 // set the photcode for this image 15 if (!psphotAddPhotcode (recipe, config, view )) {40 if (!psphotAddPhotcode (recipe, config, view, "PPSIM.CHIP")) { 16 41 psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 17 42 return false; … … 23 48 PS_ASSERT_PTR_NON_NULL (readout, false); 24 49 25 pmReadout *realSourceReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.REAL.SOURCES"); 26 PS_ASSERT_PTR_NON_NULL (realSourceReadout, false); 50 // the previously measured real sources are loaded into the PPSIM.REAL.SOURCES pmFPAfile 51 psArray *realSources = ppSimSelectSources (config, view, "PPSIM.REAL.SOURCES"); 52 PS_ASSERT_PTR_NON_NULL (realSources, false); 53 54 // the newly injected fake sources are saved on the PPSIM.OUTPUT pmFPAfile 55 psArray *injectedSources = ppSimSelectSources (config, view, "PPSIM.OUTPUT"); 56 PS_ASSERT_PTR_NON_NULL (injectedSources, false); 57 58 // XXX need to define the source pixels 59 ppSimDefinePixels (realSources, readout, recipe); 60 ppSimDefinePixels (injectedSources, readout, recipe); 61 62 // make a copy of the fake-source parameters so these can be saved independently from the 63 // measured fake-source parameters 64 psArray *fakeSources = psArrayAlloc (injectedSources->n); 65 for (int i = 0; i < injectedSources->n; i++) { 66 fakeSources->data[i] = pmSourceCopy (injectedSources->data[i]); 67 } 68 69 // load the forced source lists 70 psArray *forceSources = ppSimLoadForceSources (config, view); 71 psAssert (forceSources, "failed to load force photometry sources"); 27 72 28 73 // Generate the mask and weight images, including the user-defined analysis region of interest … … 33 78 pmPSF *psf = psphotLoadPSF (config, view, recipe); 34 79 assert (psf); 35 36 // load the source lists37 // PPSIM.REAL.SOURCES carries the pmSource objects (from psphot analysis or loaded externally)38 psArray *realSources = psMetadataLookupPtr (NULL, realSourceReadout->analysis, "PSPHOT.SOURCES");39 psArray *forceSources = ppSimLoadForceSources (config, view);40 41 // XXX make a copy of the fake-source parameters so these can be saved independently42 // from the measured fake-source parameters43 psArray *injectedSources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");44 psArray *fakeSources = psArrayAlloc (injectedSources->n);45 for (int i = 0; i < injectedSources->n; i++) {46 fakeSources->data[i] = pmSourceCopy (injectedSources->data[i]);47 }48 80 49 81 // remove all sources … … 97 129 // XXX for the fake sources, these must be identically zero 98 130 // XXX for the force sources, need the apresid to put the mags on the correct system 99 if (!psphotApResid (readout, forceSources, recipe, psf)) { 100 psLogMsg ("psphot", 3, "failed on psphotApResid"); 101 return psphotReadoutCleanup (config, readout, recipe, NULL, psf, NULL); 131 if (0) { 132 if (!psphotApResid (readout, forceSources, recipe, psf)) { 133 psLogMsg ("psphot", 3, "failed on psphotApResid"); 134 return psphotReadoutCleanup (config, readout, recipe, NULL, psf, NULL); 135 } 102 136 } 103 137 … … 119 153 // add forceSources to the readout (real and fake already there) 120 154 // these are outputs: we need to generate the fpa structure 121 // psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PPSIM.FAKE.SOURCES", PS_DATA_ARRAY, "fake photometry ", fakeSources); 155 156 pmReadout *fakeReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.FAKE.SOURCES"); 157 psMetadataAdd (fakeReadout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "fake photometry ", fakeSources); 158 122 159 // psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PPSIM.FORCE.SOURCES", PS_DATA_ARRAY, "forced photometry ", forceSources); 123 160 psFree (forceSources); -
branches/eam_branch_20080511/ppSim/src/ppSimUtils.c
r17672 r17901 212 212 213 213 // Get a value from the command-line arguments and add it to recipe options 214 bool ppSimArgToRecipeBool(bool *status, 215 psMetadata *options, // Target to which to add value 216 const char *recipeName, // Name for value in the recipe 217 psMetadata *arguments, // Command-line arguments 218 const char *argName // Argument name in the command-line arguments 219 ) 220 { 221 bool myStatus; 222 bool value = psMetadataLookupS32(&myStatus, arguments, argName); // Value of interest 223 if (status) { *status = myStatus; } 224 225 psMetadataAddBool(options, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL, value); 226 return value; 227 } 228 229 // Get a value from the command-line arguments and add it to recipe options 214 230 char *ppSimArgToRecipeStr(bool *status, 215 231 psMetadata *options, // Target to which to add value
Note:
See TracChangeset
for help on using the changeset viewer.
