Changeset 30618
- Timestamp:
- Feb 13, 2011, 11:35:11 AM (15 years ago)
- Location:
- trunk/ppSim/src
- Files:
-
- 7 deleted
- 6 edited
-
Makefile.am (modified) (2 diffs)
-
ppSimArguments.c (modified) (3 diffs)
-
ppSimCreate.c (modified) (3 diffs)
-
ppSimLoadForceSources.c (deleted)
-
ppSimLoadSpots.c (deleted)
-
ppSimLoop.c (modified) (3 diffs)
-
ppSimMakeGalaxies.c (modified) (5 diffs)
-
ppSimPhotom.c (deleted)
-
ppSimPhotomFiles.c (deleted)
-
ppSimPhotomReadout.c (deleted)
-
ppSimPhotomReadoutFake.c (deleted)
-
ppSimPhotomReadoutForce.c (deleted)
-
ppSimSetPSF.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/Makefile.am
r28125 r30618 47 47 ppSimUtils.c \ 48 48 ppSimLoop.c \ 49 ppSimLoadSpots.c \50 ppSimPhotom.c \51 ppSimPhotomFiles.c \52 ppSimLoadForceSources.c \53 49 ppSimMergeReadouts.c \ 54 50 ppSimDetections.c \ … … 59 55 ppSimBadCTE.c \ 60 56 ppSimVersion.c 61 62 # these functions have been broken by the API change in psphot (Jan 2010)63 # ppSimPhotomReadoutFake.c64 # ppSimPhotomReadoutForce.c65 57 66 58 ppSimSequence_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS) -
trunk/ppSim/src/ppSimArguments.c
r29011 r30618 49 49 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp", 0, "Photometric zero point", NAN); 50 50 psMetadataAddF32(arguments, PS_LIST_TAIL, "-seeing", 0, "Seeing FWHM (arcsec)", NAN); 51 psMetadataAddF32(arguments, PS_LIST_TAIL, "-seeing-max", 0, "Seeing FWHM (arcsec) at end of ramp", NAN); 52 psMetadataAddBool(arguments, PS_LIST_TAIL, "-seeing-ramp", 0, "Use a seeing ramp", false); 51 53 psMetadataAddF32(arguments, PS_LIST_TAIL, "-starslum", 0, "Fake star luminosity function slope", NAN); 52 54 psMetadataAddF32(arguments, PS_LIST_TAIL, "-starsmag", 0, "Brightest magnitude for fake stars", NAN); … … 130 132 // 'seeing' is not required: we can load a psf-model instead; but if not, it is allowed 131 133 ppSimArgToRecipeF32(&status, options, "SEEING", arguments, "-seeing"); // seeing (FWHM in arcsec) 134 ppSimArgToRecipeF32(&status, options, "SEEING.MAX", arguments, "-seeing-max"); // seeing (FWHM in arcsec) 135 ppSimArgToRecipeBool(&status, options, "SEEING.RAMP", arguments, "-seeing-ramp"); // seeing (FWHM in arcsec) 132 136 133 137 // 'scale' is not required: we can use the WCS instead; but if not, it is allowed … … 227 231 psMetadataAddF32(options, PS_LIST_TAIL, "PA", 0, "Boresight position angle (radians)",pa * M_PI / 180.0); 228 232 233 if (psMetadataLookupBool(NULL, arguments, "-seeing-ramp")) { 234 float seeingMax = psMetadataLookupF32(NULL, arguments, "-seeing-max"); // seeing at ramp end 235 psMetadataAddF32(options, PS_LIST_TAIL, "SEEING.MAX", 0, "Seeing FWHM (arcsec)", seeingMax); 236 psMetadataAddBool(options, PS_LIST_TAIL, "SEEING.RAMP", 0, "use seeing ramp", true); 237 } 238 229 239 ppSimArgToRecipeF32(&status, options, "ZEROPOINT", arguments, "-zp"); // Zero point 230 240 } -
trunk/ppSim/src/ppSimCreate.c
r29125 r30618 103 103 psMetadataAddF32(recipe, PS_LIST_TAIL, "SEEING", PS_META_REPLACE, "Seeing SIGMA (pixels)", seeing / 2.0 / sqrt(2.0 * log(2.0)) / scale); 104 104 105 float seeingMax = psMetadataLookupF32(&status, recipe, "SEEING.MAX"); 106 psMetadataAddF32(recipe, PS_LIST_TAIL, "SEEING.MAX", PS_META_REPLACE, "Seeing SIGMA (pixels)", seeingMax / 2.0 / sqrt(2.0 * log(2.0)) / scale); 107 105 108 // if we have been supplied an input image, but no ra & dec, use the input image values 106 109 if (input) { … … 132 135 bool doPhotom = psMetadataLookupBool(&status, recipe, "PHOTOM"); // Density of fakes 133 136 if (doPhotom) { 134 135 // XXX at the moment, we can perform photometry on the fake sources and the forced 136 // photometry positions, but not one or the other. Also, we only support photometry in 137 // the context of an image previously analysed by psphot. Add support for: 138 // * photometry of a pure fake image (requires peak detection and psf creation) 139 // * photometry of forced source positions without fake image (this might work, it just 140 // requires not generating any fake features). 141 142 if (!input) { 143 psError(PS_ERR_UNKNOWN, false, "input image not found; currently required for photometry"); 144 return NULL; 145 } 146 147 // we need a chip image if we perform photometry (is it necessary to build it if we don't use it?) 148 pmFPAfile *fakeImage = pmFPAfileDefineChipMosaic(config, output->fpa, "PPSIM.FAKE.CHIP"); 149 if (!fakeImage) { 150 psError(PS_ERR_IO, false, _("Unable to generate new file from PPSIM.FAKE.CHIP")); 151 psFree(fpa); 152 return NULL; 153 } 154 if (fakeImage->type != PM_FPA_FILE_IMAGE) { 155 psError(PS_ERR_IO, true, "PPSIM.FAKE.CHIP is not of type IMAGE"); 156 psFree(fpa); 157 return NULL; 158 } 159 160 // we need a chip image if we perform photometry (is it necessary to build it if we don't use it?) 161 pmFPAfile *forceImage = NULL; 162 if (input) { 163 forceImage = pmFPAfileDefineChipMosaic(config, input->fpa, "PPSIM.FORCE.CHIP"); 164 if (!forceImage) { 165 psError(PS_ERR_IO, false, _("Unable to generate new file from PPSIM.FORCE.CHIP")); 166 psFree(fpa); 167 return NULL; 168 } 169 if (forceImage->type != PM_FPA_FILE_IMAGE) { 170 psError(PS_ERR_IO, true, "PPSIM.FORCE.CHIP is not of type IMAGE"); 171 psFree(fpa); 172 return NULL; 173 } 174 } 175 176 // define associated psphot input/output files 177 if (!ppSimPhotomFiles (config, fakeImage, forceImage)) { 178 psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot"); 179 psFree(fpa); 180 return NULL; 181 } 182 } else { 183 // have we supplied a psf model? this happens in ppSimPhotomFiles if we request a photometry 184 // analysis. however, even if we do not, a psf model may be used to generate the fake 185 // sources. 186 if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) { 187 // tie the psf file to the chipMosaic 188 pmFPAfileBindFromArgs(&status, output, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF"); 189 if (!status) { 190 psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD"); 191 psFree(fpa); 192 return NULL; 193 } 194 } 137 psError(PS_ERR_UNKNOWN, false, "in-line photometry in ppSim had been deprecated"); 138 return NULL; 139 } 140 141 // have we supplied a psf model? this happens in ppSimPhotomFiles if we request a photometry 142 // analysis. however, even if we do not, a psf model may be used to generate the fake 143 // sources. 144 if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) { 145 // tie the psf file to the chipMosaic 146 pmFPAfileBindFromArgs(&status, output, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF"); 147 if (!status) { 148 psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD"); 149 psFree(fpa); 150 return NULL; 151 } 195 152 } 196 153 … … 257 214 } 258 215 } 216 // XXX this is a hack, but I don't have a better way at the moment: assumes a single cell per chip 217 if (nx) { 218 psMetadataAddS32(chip->concepts, PS_LIST_TAIL, "CHIP.XSIZE", PS_META_REPLACE, "", nx); 219 } else { 220 nx = psMetadataLookupF32(&status, cell->concepts, "CELL.XSIZE"); 221 psMetadataAddS32(chip->concepts, PS_LIST_TAIL, "CHIP.XSIZE", PS_META_REPLACE, "", nx); 222 } 223 if (ny) { 224 psMetadataAddS32(chip->concepts, PS_LIST_TAIL, "CHIP.YSIZE", PS_META_REPLACE, "", ny); 225 } else { 226 ny = psMetadataLookupF32(&status, cell->concepts, "CELL.YSIZE"); 227 psMetadataAddS32(chip->concepts, PS_LIST_TAIL, "CHIP.YSIZE", PS_META_REPLACE, "", ny); 228 } 259 229 } 260 230 } -
trunk/ppSim/src/ppSimLoop.c
r28125 r30618 42 42 if (type == PPSIM_TYPE_OBJECT) { 43 43 // Load forced-photometry positions (these are placed on fpa->analysis for use in ppSimPhotomReadout) 44 if (!ppSimLoadSpots (fpa, config)) ESCAPE (PS_ERR_UNKNOWN, "failed to load forced-photometry spots");44 // if (!ppSimLoadSpots (fpa, config)) ESCAPE (PS_ERR_UNKNOWN, "failed to load forced-photometry spots"); 45 45 46 46 // Load catalogue stars … … 58 58 59 59 pmFPAview *view = pmFPAviewAlloc(0);// View for iterating over FPA 60 61 // XXX if we include the psphot analysis, we will need to activate the correct pmFPAfiles62 // at the correct times. ppSim operates on PPSIM.OUTPUT and PPSIM.SOURCES63 60 64 61 // load any needed files (eg, input image, PSF) … … 209 206 210 207 // we perform photometry on the readouts of this chip in the output 211 if (!ppSimPhotom (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem performing photometry");208 // if (!ppSimPhotom (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem performing photometry"); 212 209 213 210 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { -
trunk/ppSim/src/ppSimMakeGalaxies.c
r29011 r30618 28 28 float galaxyThetaMax = psMetadataLookupF32(&mdok, recipe, "GALAXY.THETA.MAX"); // Density of fakes 29 29 float galaxyThetaMin = psMetadataLookupF32(&mdok, recipe, "GALAXY.THETA.MIN"); // Density of fakes 30 galaxyThetaMax *= PS_RAD_DEG; 31 galaxyThetaMin *= PS_RAD_DEG; 30 32 31 33 float galaxyIndexMin = psMetadataLookupF32(&mdok, recipe, "GALAXY.INDEX.MIN"); // Density of fakes … … 95 97 96 98 int i = 0; 99 float refNorm = 1.0; 100 float ourNorm = 1.0; 97 101 98 102 for (long iy = 0.5*galaxyGridDY; iy < ySize; iy += galaxyGridDY) { … … 104 108 galaxy->y = iy; 105 109 106 galaxy->peak = 1000; 110 // galaxy->peak = 1000; 111 galaxy->peak = bright / 100.0; 112 // fprintf (stderr, "Io: %f\n", bright); 107 113 108 114 // galaxyIndex from user should be for function of this form: exp(-r^(1/n)) … … 111 117 float rndValue; 112 118 113 rndValue = galaxyGridRandom ? drand48() : i / num;119 rndValue = galaxyGridRandom ? drand48() : i / (float) num; 114 120 float index = (galaxyIndexMin + rndValue * galaxyIndexSlope); 115 121 galaxy->index = 0.5/index; // factor of 0.5 because the Sersic model creates exp(-z^n), not exp(-r^n) 116 122 117 rndValue = galaxyGridRandom ? drand48() : i / num;123 rndValue = galaxyGridRandom ? drand48() : i / (float) num; 118 124 float scale = (galaxyRmajorMin + rndValue * galaxyRmajorSlope); 119 125 … … 125 131 galaxy->Rmaj = scale; 126 132 127 rndValue = galaxyGridRandom ? drand48() : i / num;133 rndValue = galaxyGridRandom ? drand48() : i / (float) num; 128 134 galaxy->Rmin = (galaxyARatioMin + rndValue * galaxyARatioSlope) * galaxy->Rmaj; 129 135 130 rndValue = galaxyGridRandom ? drand48() : i / num;136 rndValue = galaxyGridRandom ? drand48() : i / (float) num; 131 137 galaxy->theta = (galaxyThetaMin + rndValue * galaxyThetaSlope); 132 133 // galaxy->peak *= Io; 138 139 if (i == 0) { 140 refNorm = Io*scale*scale; 141 } 142 ourNorm = refNorm / (Io*scale*scale); 143 galaxy->peak *= ourNorm; 134 144 135 145 if (0) { 136 fprintf (stderr, "Rmaj: %f, scale: %f, index: %f, bn: %f, Ro: %f, Io: %f \n", galaxy->Rmaj, scale, index, bn, fR, Io);146 fprintf (stderr, "Rmaj: %f, scale: %f, index: %f, bn: %f, Ro: %f, Io: %f, theta: %f\n", galaxy->Rmaj, scale, index, bn, fR, Io, galaxy->theta); 137 147 } 138 148 -
trunk/ppSim/src/ppSimSetPSF.c
r26900 r30618 23 23 float theta = psMetadataLookupF32(&status, recipe, "PSF.THETA"); // Seeing SIGMA (pixels) 24 24 25 float seeingMax = psMetadataLookupF32(&status, recipe, "SEEING.MAX"); // Seeing SIGMA (pixels) 26 bool seeingRamp = psMetadataLookupBool(&status, recipe, "SEEING.RAMP"); // Seeing SIGMA (pixels) 27 25 28 char *psfModelName = psMetadataLookupStr(&status, recipe, "PSF.MODEL"); // Name of PSF model 26 29 if (psfModelName == NULL) { … … 39 42 int xSize = psMetadataLookupS32(NULL, chip->concepts, "CHIP.XSIZE"); 40 43 int ySize = psMetadataLookupS32(NULL, chip->concepts, "CHIP.YSIZE"); 41 xSize = 1000;42 ySize = 1000;43 44 44 // no spatial variation 45 options->psfTrendMode = PM_TREND_POLY_ORD; 46 options->psfTrendNx = 0; 47 options->psfTrendNy = 0; 48 options->psfFieldNx = xSize; 49 options->psfFieldNy = ySize; 45 if (seeingRamp) { 46 psEllipseAxes axes; 47 psEllipsePol pol; 48 psEllipsePol polMax; 50 49 51 // generate the psf 52 psf = pmPSFAlloc (options); 50 // try spatial variation 51 options->psfTrendMode = PM_TREND_POLY_ORD; 52 options->psfTrendNx = 1; 53 options->psfTrendNy = 1; 54 options->psfFieldNx = xSize; 55 options->psfFieldNy = ySize; 53 56 54 psEllipseAxes axes; 55 psEllipsePol pol;57 // generate the psf 58 psf = pmPSFAlloc (options); 56 59 57 // supply the semi-major axis (these are SIGMA values in PIXELS)58 axes.major = seeing;59 axes.minor = aRatio * seeing;60 axes.theta = theta * PS_RAD_DEG;60 // supply the semi-major axis (these are SIGMA values in PIXELS) 61 axes.major = seeing; 62 axes.minor = aRatio * seeing; 63 axes.theta = theta * PS_RAD_DEG; 61 64 62 pol = psEllipseAxesToPol (axes);65 pol = psEllipseAxesToPol (axes); 63 66 64 param = psf->params->data[PM_PAR_E0]; 65 param->poly->coeff[0][0] = pol.e0; 67 axes.major = seeingMax; 68 axes.minor = aRatio * seeingMax; 69 polMax = psEllipseAxesToPol (axes); 66 70 67 param = psf->params->data[PM_PAR_E1]; 68 param->poly->coeff[0][0] = pol.e1; 71 param = psf->params->data[PM_PAR_E0]; 72 param->poly->coeff[0][0] = pol.e0; 73 param->poly->coeff[1][0] = (polMax.e0 - pol.e0) / xSize; 74 param->poly->coeff[0][1] = (polMax.e0 - pol.e0) / ySize; 69 75 70 param = psf->params->data[PM_PAR_E2]; 71 param->poly->coeff[0][0] = pol.e2; 76 param = psf->params->data[PM_PAR_E1]; 77 param->poly->coeff[0][0] = pol.e1; 78 param->poly->coeff[1][0] = 0.0; 79 param->poly->coeff[0][1] = 0.0; 72 80 73 if (!strcasecmp (psfModelName, "PS_MODEL_QGAUSS")) { 74 param = psf->params->data[PM_PAR_7];75 param->poly->coeff[0][0] = 1.0;76 } 81 param = psf->params->data[PM_PAR_E2]; 82 param->poly->coeff[0][0] = pol.e2; 83 param->poly->coeff[1][0] = 0.0; 84 param->poly->coeff[0][1] = 0.0; 77 85 78 if (!strcasecmp (psfModelName, "PS_MODEL_RGAUSS")) { 79 param = psf->params->data[PM_PAR_7]; 80 param->poly->coeff[0][0] = 1.0; 86 if (!strcasecmp (psfModelName, "PS_MODEL_QGAUSS")) { 87 param = psf->params->data[PM_PAR_7]; 88 param->poly->coeff[0][0] = 1.0; 89 param->poly->coeff[1][0] = 0.0; 90 param->poly->coeff[0][1] = 0.0; 91 } 92 93 if (!strcasecmp (psfModelName, "PS_MODEL_RGAUSS")) { 94 param = psf->params->data[PM_PAR_7]; 95 param->poly->coeff[0][0] = 1.0; 96 param->poly->coeff[1][0] = 0.0; 97 param->poly->coeff[0][1] = 0.0; 98 } 99 100 } else { 101 psEllipseAxes axes; 102 psEllipsePol pol; 103 104 // no spatial variation 105 options->psfTrendMode = PM_TREND_POLY_ORD; 106 options->psfTrendNx = 0; 107 options->psfTrendNy = 0; 108 options->psfFieldNx = xSize; 109 options->psfFieldNy = ySize; 110 111 // generate the psf 112 psf = pmPSFAlloc (options); 113 114 // supply the semi-major axis (these are SIGMA values in PIXELS) 115 axes.major = seeing; 116 axes.minor = aRatio * seeing; 117 axes.theta = theta * PS_RAD_DEG; 118 119 pol = psEllipseAxesToPol (axes); 120 121 param = psf->params->data[PM_PAR_E0]; 122 param->poly->coeff[0][0] = pol.e0; 123 124 param = psf->params->data[PM_PAR_E1]; 125 param->poly->coeff[0][0] = pol.e1; 126 127 param = psf->params->data[PM_PAR_E2]; 128 param->poly->coeff[0][0] = pol.e2; 129 130 if (!strcasecmp (psfModelName, "PS_MODEL_QGAUSS")) { 131 param = psf->params->data[PM_PAR_7]; 132 param->poly->coeff[0][0] = 1.0; 133 } 134 135 if (!strcasecmp (psfModelName, "PS_MODEL_RGAUSS")) { 136 param = psf->params->data[PM_PAR_7]; 137 param->poly->coeff[0][0] = 1.0; 138 } 81 139 } 82 140
Note:
See TracChangeset
for help on using the changeset viewer.
