Changeset 4129 for trunk/psphot
- Timestamp:
- Jun 6, 2005, 11:20:45 PM (21 years ago)
- Location:
- trunk/psphot
- Files:
-
- 2 added
- 15 edited
-
. (modified) (1 prop)
-
.cvsignore (added)
-
Makefile (modified) (1 diff)
-
src/apply_psf_model.c (modified) (2 diffs)
-
src/by_SN.c (modified) (2 diffs)
-
src/choose_psf_model.c (modified) (1 diff)
-
src/find_defects.c (added)
-
src/mark_psf_source.c (modified) (1 diff)
-
src/psPolynomials.c (modified) (2 diffs)
-
src/psUtils.c (modified) (1 diff)
-
src/psphot.c (modified) (4 diffs)
-
src/psphot.h (modified) (4 diffs)
-
src/pspsf.c (modified) (4 diffs)
-
src/source_moments.c (modified) (1 diff)
-
src/subtract_galaxies.c (modified) (1 diff)
-
src/subtract_psf_source.c (modified) (2 diffs)
-
src/test_psf_scatter.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot
-
Property svn:ignore
set to
bin
-
Property svn:ignore
set to
-
trunk/psphot/Makefile
r4114 r4129 32 32 $(SRC)/mark_psf_sources.$(ARCH).o \ 33 33 $(SRC)/subtract_psf_sources.$(ARCH).o \ 34 $(SRC)/mark_psf_source.$(ARCH).o \ 35 $(SRC)/subtract_psf_source.$(ARCH).o \ 36 $(SRC)/by_SN.$(ARCH).o \ 34 37 $(SRC)/fit_galaxies.$(ARCH).o \ 35 $(SRC)/subtract_galaxies.$(ARCH).o 38 $(SRC)/subtract_galaxies.$(ARCH).o \ 39 $(SRC)/find_defects.$(ARCH).o 36 40 37 41 psphot: $(BIN)/psphot.$(ARCH) -
trunk/psphot/src/apply_psf_model.c
r4116 r4129 25 25 26 26 float shapeNsigma = psMetadataLookupF32 (&status, config, "PSF_SHAPE_NSIGMA"); 27 float snFaint = psMetadataLookupF32 (&status, config, "FAINT_SN_LIM");27 // float snFaint = psMetadataLookupF32 (&status, config, "FAINT_SN_LIM"); 28 28 29 29 // set the object surface-brightness limit for fitted pixels … … 66 66 Nfit ++; 67 67 68 mark_psf_source (source );68 mark_psf_source (source, shapeNsigma); 69 69 subtract_psf_source (source); 70 70 } -
trunk/psphot/src/by_SN.c
r4115 r4129 1 1 # include "psphot.h" 2 2 3 // sort by SN (descending) 3 4 int by_SN (const void **a, const void **b) 4 5 { 5 psSource *A = * a;6 psSource *B = * b;6 psSource *A = *(psSource **)a; 7 psSource *B = *(psSource **)b; 7 8 8 9 psF32 fA = (A->moments == NULL) ? 0 : A->moments->SN; … … 10 11 11 12 psF32 diff = fA - fB; 12 if (diff <FLT_EPSILON) return (-1);13 if (diff >FLT_EPSILON) return (+1);13 if (diff > FLT_EPSILON) return (-1); 14 if (diff < FLT_EPSILON) return (+1); 14 15 return (0); 15 16 } -
trunk/psphot/src/choose_psf_model.c
r4115 r4129 20 20 psArrayAdd (stars, 200, source); 21 21 } 22 psTrace (".psphot.pspsf", 3, "selected candidate %d PSF objects\n", stars->n); 22 23 23 24 // define model fit pixels -
trunk/psphot/src/mark_psf_source.c
r4116 r4129 14 14 // any object which meets the criterion is marked as 15 15 // PS_SOURCE_BRIGHTSTAR 16 bool mark_psf_source (ps Array *sources)16 bool mark_psf_source (psSource *source, float shapeNsigma) 17 17 { 18 bool status = false;19 18 float dSX, dSY, SX, SY, SN; 20 19 float nSx, nSy; -
trunk/psphot/src/psPolynomials.c
r4116 r4129 233 233 // Build the B and A data structs. 234 234 for (int k = 0; k < x->n; k++) { 235 if ((mask != NULL) && mask-> U8[k]) continue;235 if ((mask != NULL) && mask->data.U8[k]) continue; 236 236 xSums = BuildSums1D(xSums, x->data.F64[k], nTerm); 237 237 … … 325 325 // Build the B and A data structs. 326 326 for (int k = 0; k < x->n; k++) { 327 if ((mask != NULL) && mask->data.U8[ i]) continue;327 if ((mask != NULL) && mask->data.U8[k]) continue; 328 328 Sums = BuildSums2D(Sums, x->data.F64[k], y->data.F64[k], nXterm, nYterm); 329 329 -
trunk/psphot/src/psUtils.c
r4114 r4129 261 261 } 262 262 263 bool psImageInit (psImage *image,...) { 264 265 va_list argp; 266 psU8 vU8; 267 psF32 vF32; 268 psF64 vF64; 269 270 if (image == NULL) return (false); 271 272 va_start (argp, image); 273 274 switch (image->type.type) { 275 case PS_TYPE_U8: 276 vU8 = va_arg (argp, psU32); 277 278 for (int iy = 0; iy < image->numRows; iy++) { 279 for (int ix = 0; ix < image->numCols; ix++) { 280 image->data.U8[iy][ix] = vU8; 281 } 282 } 283 break; 284 285 case PS_TYPE_F32: 286 vF32 = va_arg (argp, psF64); 287 288 for (int iy = 0; iy < image->numRows; iy++) { 289 for (int ix = 0; ix < image->numCols; ix++) { 290 image->data.F32[iy][ix] = vF32; 291 } 292 } 293 return (true); 294 295 case PS_TYPE_F64: 296 vF64 = va_arg (argp, psF64); 297 298 for (int iy = 0; iy < image->numRows; iy++) { 299 for (int ix = 0; ix < image->numCols; ix++) { 300 image->data.F64[iy][ix] = vF64; 301 } 302 } 303 return (true); 304 305 default: 306 psAbort ("psphot.psUtils", "datatype %d not defined in psImageInit\n", image->type); 307 return (false); 308 } 309 return (false); 310 } -
trunk/psphot/src/psphot.c
r4115 r4129 1 1 # include "psphot.h" 2 void dump_image (psImage *image, char *filename); 2 3 3 4 int main (int argc, char **argv) { … … 33 34 psf = choose_psf_model (image, config, sources); 34 35 36 psImage *zap = psImageAlloc (image->numCols, image->numRows, PS_TYPE_F32); 37 psImageInit (zap, 0); 38 find_defects (zap, sources, config, psf); 39 dump_image (zap, argv[2]); 40 exit (0); 41 35 42 // test PSF on all except SATURATE and DEFECT (artifacts) 36 43 apply_psf_model (image, config, sources, psf, sky); … … 44 51 // subtract_galaxies (sources, config); 45 52 46 // write out subtracted image 47 unlink (argv[2]); 48 psFits *fits = psFitsAlloc (argv[2]); 49 psFitsWriteImage (fits, NULL, image, 0, NULL); 50 psFree (fits); 51 53 dump_image (image, argv[2]); 52 54 DumpModelPSF (sources, "sources.dat"); 53 55 exit (0); … … 59 61 exit (2); 60 62 } 63 64 void dump_image (psImage *image, char *filename) { 65 66 unlink (filename); 67 psFits *fits = psFitsAlloc (filename); 68 psFitsWriteImage (fits, NULL, image, 0, NULL); 69 psFree (fits); 70 return; 71 } 72 -
trunk/psphot/src/psphot.h
r4115 r4129 21 21 psF64 psTimerMark (char *name); 22 22 23 bool psImageInit (psImage *image,...); 23 24 void psImageSmooth (psImage *image, float sigma, float Nsigma); 24 25 psRegion *psRegionForImage (psRegion *out, psImage *image, psRegion *in); … … 40 41 psF32 Polynomial2DEval(const psPolynomial2D* myPoly, psF32 x, psF32 y); 41 42 psImage *psBuildSums2D(psImage* sums,psF64 x,psF64 y,psS32 nXterm, psS32 nYterm); 42 psPolynomial1D* VectorFitPolynomial1DOrd_EAM(psPolynomial1D* myPoly, const psVector* x, const psVector* y, const psVector* yErr);43 psPolynomial2D* VectorFitPolynomial2DOrd_EAM(psPolynomial2D* myPoly, const psVector* x, const psVector* y, const psVector* z, const psVector* zErr);43 psPolynomial1D* VectorFitPolynomial1DOrd_EAM(psPolynomial1D* myPoly, psVector* mask, const psVector* x, const psVector* y, const psVector* yErr); 44 psPolynomial2D* VectorFitPolynomial2DOrd_EAM(psPolynomial2D* myPoly, psVector* mask, const psVector* x, const psVector* y, const psVector* z, const psVector* zErr); 44 45 psPolynomial2D* Polynomial2DAlloc(psS32 nXorder, psS32 nYorder, psPolynomialType type); 45 46 void psPolynomial2DDump (psPolynomial2D *poly); 46 psPolynomial2D* RobustFit2D(psPolynomial2D* poly, const psVector* x, const psVector* y, const psVector* z, const psVector* zErr); 47 psPolynomial2D* RobustFit2D_nomask(psPolynomial2D* poly, const psVector* x, const psVector* y, const psVector* z, const psVector* zErr); 48 psPolynomial2D* RobustFit2D(psPolynomial2D* poly, psVector* mask, const psVector* x, const psVector* y, const psVector* z, const psVector* zErr); 47 49 psVector *Polynomial2DEvalVector(const psPolynomial2D *myPoly, const psVector *x,const psVector *y); 48 50 psVector *psBuildSums1D(psVector* sums, psF64 x,psS32 nTerm); … … 58 60 pmPSF_Test *pmPSF_TestModel (psArray *stars, char *modelName); 59 61 60 bool pmPSFFromModels (pmPSF *psf, psArray *models );62 bool pmPSFFromModels (pmPSF *psf, psArray *models, psVector *mask); 61 63 psModel *psModelFromPSF (psModel *model, pmPSF *psf); 62 64 void pmSourceMaskRegion (psSource *source, psRegion *region); … … 75 77 bool fit_galaxies (psImage *image, psMetadata *config, psArray *sources); 76 78 bool subtract_galaxies (psArray *sources, psMetadata *config); 79 80 int by_SN (const void **a, const void **b); 81 bool subtract_psf_source (psSource *source); 82 bool mark_psf_source (psSource *source, float shapeNsigma); 83 bool find_defects (psImage *zapmask, psArray *sources, psMetadata *config, pmPSF *psf); -
trunk/psphot/src/pspsf.c
r4116 r4129 68 68 } 69 69 psLogMsg ("psphot.psftest", 4, "fit flt: %f sec for %d sources\n", psTimerMark ("fit"), sources->n); 70 psTrace ("psphot.psftest", 3, "keeping %d of %d PSF candidates (FLT)\n", Nflt, sources->n); 70 71 DumpModelFits (test->modelFLT, "modelsFLT.dat"); 71 72 72 73 // stage 2: construct a psf (pmPSF) from this collection of model fits 73 74 pmPSFFromModels (test->psf, test->modelFLT, test->mask); 75 76 // count valid sources 77 int Nkeep = 0; 78 for (int i = 0; i < sources->n; i++) { 79 if (test->mask->data.U8[i]) continue; 80 Nkeep++; 81 } 82 psTrace ("psphot.psftest", 3, "keeping %d of %d PSF candidates\n", Nkeep, sources->n); 74 83 75 84 // stage 3: refit with fixed shape parameters … … 96 105 } 97 106 psLogMsg ("psphot.psftest", 4, "fit psf: %f sec for %d sources\n", psTimerMark ("fit"), sources->n); 107 psTrace ("psphot.psftest", 3, "keeping %d of %d PSF candidates (PSF)\n", Npsf, sources->n); 98 108 DumpModelFits (test->modelPSF, "modelsPSF.dat"); 99 109 … … 152 162 bool pmPSFFromModels (pmPSF *psf, psArray *models, psVector *mask) { 153 163 154 int n;155 156 164 // construct the fit vectors from the collection of objects 157 165 // use the mask to ignore missing fits … … 187 195 psf->params->data[i] = RobustFit2D (psf->params->data[i], mask, x, y, z, dz); 188 196 // psPolynomial2DDump (psf->params->data[i]); 197 198 // count valid sources 199 int Nkeep = 0; 200 for (int j = 0; j < mask->n; j++) { 201 if (mask->data.U8[j]) continue; 202 Nkeep++; 203 } 204 psTrace ("psphot.psftest", 3, "keeping %d of %d PSF candidates (PSF param %d)\n", Nkeep, mask->n, i); 205 189 206 } 190 207 return (true); -
trunk/psphot/src/source_moments.c
r4114 r4129 18 18 psRegion *keep = psRegionAlloc (XBORDER, -XBORDER, YBORDER, -YBORDER); 19 19 keep = psRegionForImage (keep, image, keep); 20 peaks = pmPeaksSubset (allpeaks, 100000, keep);21 22 20 // I need to exclude the saturated objects here, but include them again later...? 23 21 peaks = pmPeaksSubset (allpeaks, 100000, keep); -
trunk/psphot/src/subtract_galaxies.c
r4114 r4129 5 5 bool subtract_galaxies (psArray *sources, psMetadata *config) 6 6 { 7 bool status;8 9 7 for (int i = 0; i < sources->n; i++) { 10 8 psSource *source = sources->data[i]; -
trunk/psphot/src/subtract_psf_source.c
r4116 r4129 4 4 // need to control application of this with some thresholding 5 5 6 bool subtract_psf_source s(psSource *source)6 bool subtract_psf_source (psSource *source) 7 7 { 8 8 float sky; 9 psSource *source = sources->data[i];10 9 11 10 // non-stellar sources are ignored … … 15 14 psModel *model = source->modelPSF; 16 15 if (model == NULL) { 17 psLogMsg ("psphot.subtract_psf_source", "missing model for %f, %f\n", source->moments->x, source->moments->y);16 psLogMsg ("psphot.subtract_psf_source", 2, "missing model for %f, %f\n", source->moments->x, source->moments->y); 18 17 return (false); 19 18 } -
trunk/psphot/src/test_psf_scatter.c
r4115 r4129 70 70 snBin ->n = bin; 71 71 72 // XXX these APIs should get changed 72 73 psPolynomial1D *dsxLine = psPolynomial1DAlloc (2, PS_POLYNOMIAL_ORD); 73 psVectorFitPolynomial1D (dsxLine, NULL,snBin, dsxBin, NULL);74 psVectorFitPolynomial1D (dsxLine, snBin, dsxBin, NULL); 74 75 psPolynomial1D *dsyLine = psPolynomial1DAlloc (2, PS_POLYNOMIAL_ORD); 75 psVectorFitPolynomial1D (dsyLine, NULL,snBin, dsyBin, NULL);76 psVectorFitPolynomial1D (dsyLine, snBin, dsyBin, NULL); 76 77 // these should have a slope of 1.0 77 78 psPolynomial1DDump (dsxLine);
Note:
See TracChangeset
for help on using the changeset viewer.
