Changeset 8928
- Timestamp:
- Sep 24, 2006, 3:07:04 PM (20 years ago)
- Location:
- trunk/ppShutter
- Files:
-
- 2 added
- 3 edited
-
src (modified) (1 prop)
-
src/.cvsignore (modified) (1 diff)
-
src/ppShutter.c (modified) (10 diffs)
-
test (added)
-
test/tests.pro (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppShutter/src
- Property svn:ignore
-
old new 2 2 Makefile 3 3 Makefile.in 4 ppMerge5 4 config.h 6 5 config.h.in 7 6 stamp-h1 7 ppShutter
-
- Property svn:ignore
-
trunk/ppShutter/src/.cvsignore
r8901 r8928 2 2 Makefile 3 3 Makefile.in 4 ppMerge5 4 config.h 6 5 config.h.in 7 6 stamp-h1 7 ppShutter -
trunk/ppShutter/src/ppShutter.c
r8901 r8928 5 5 void usage () { 6 6 7 fprintf (stderr, "USAGE: ppShutter (output) ( input) (input) (input) ...\n");7 fprintf (stderr, "USAGE: ppShutter (output) (outscale) (input) (input) (input) ...\n"); 8 8 fprintf (stderr, " minimum number of input images: 5\n"); 9 9 exit (1); … … 19 19 20 20 // minimum number of input images: 5 21 if (argc < 7) usage ();21 if (argc < 8) usage (); 22 22 23 int Ninput = argc - 2;23 int Ninput = argc - 3; 24 24 25 25 // load the input images (for now, load them all into memory) … … 28 28 psArray *images = psArrayAlloc (Ninput); 29 29 for (int i = 0; i < Ninput; i++) { 30 fits = psFitsOpen (argv[i -2], "r");30 fits = psFitsOpen (argv[i+3], "r"); 31 31 files->data[i] = fits; 32 32 … … 37 37 images->data[i] = image; 38 38 } 39 images->n = files->n = headers->n = Ninput; 39 40 40 41 // find the exposures times for each input images … … 43 44 psVector *fluxRef = psVectorAlloc (Ninput, PS_TYPE_F32); 44 45 psVector *normCts = psVectorAlloc (Ninput, PS_TYPE_F32); 46 psVector *normErr = psVectorAlloc (Ninput, PS_TYPE_F32); 45 47 for (int i = 0; i < Ninput; i++) { 46 48 exptime->data.F32[i] = psMetadataLookupF32 (NULL, headers->data[i], "EXPTIME"); 47 49 } 50 exptime->n = fluxRef->n = normCts->n = normErr->n = Ninput; 51 48 52 psVector *index = psVectorSortIndex (NULL, exptime); 49 53 … … 52 56 53 57 // statistics used to measure initial parameters 54 psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN );58 psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); 55 59 56 60 // define the reference region … … 62 66 myStats = psImageStats(myStats, image, NULL, 0); 63 67 fluxRef->data.F32[i] = myStats->sampleMean; 68 fprintf (stderr, "ref flux for image %d: %f\n", i, fluxRef->data.F32[i]); 64 69 } 65 70 … … 79 84 psPlane *coord = samples->data[j]; 80 85 86 fprintf (stderr, "norm cnts for region %d: ", j); 81 87 for (int i = 0; i < Ninput; i++) { 82 88 psImage *image = images->data[index->data.S32[i]]; … … 84 90 region = psRegionForSquare(coord->x, coord->y, 10); 85 91 region = psRegionForImage(image, region); 92 // fprintf (stderr, "%f,%f:%f,%f : ", region.x0, region.y0, region.x1, region.y1); 86 93 87 myStats = psImageStats(myStats, image, NULL, 0); 94 psImage *raster = psImageSubset (image, region); 95 myStats = psImageStats(myStats, raster, NULL, 0); 88 96 normCts->data.F32[i] = myStats->sampleMean / fluxRef->data.F32[i]; 97 normErr->data.F32[i] = myStats->sampleStdev / fluxRef->data.F32[i]; 98 fprintf (stderr, "%f ", normCts->data.F32[i]); 99 // fprintf (stderr, "%f\n", myStats->sampleMean); 100 101 psFree (raster); 89 102 } 103 fprintf (stderr, "\n"); 90 104 91 105 pmShutterCorrPars *guess = pmShutterCorrectionGuess (exptime, normCts); 92 pmShutterCorrPars *params = pmShutterCorrectionFullFit (exptime, normCts, guess);106 pmShutterCorrPars *params = pmShutterCorrectionFullFit (exptime, normCts, normErr, guess); 93 107 94 108 refOffsetSample->data.F32[j] = params->offref; 95 109 } 110 refOffsetSample->n = Nsamples; 96 111 myStats = psVectorStats (myStats, refOffsetSample, NULL, NULL, 0); 97 112 float refOffset = myStats->sampleMean; 113 fprintf (stderr, "refOffset : %f +/- %f\n", myStats->sampleMean, myStats->sampleStdev); 98 114 99 115 // now run through all pixels in the images and measure the shutter parameters for each pixel … … 101 117 psImage *offset = psImageAlloc (refimage->numCols, refimage->numRows, PS_TYPE_F32); 102 118 119 int dotInterval = refimage->numRows / 32; 103 120 for (int ny = 0; ny < refimage->numRows; ny++) { 121 if (ny % dotInterval == 0) fprintf (stderr, "."); 104 122 for (int nx = 0; nx < refimage->numCols; nx++) { 105 123 for (int i = 0; i < Ninput; i++) { 106 124 psImage *image = images->data[index->data.S32[i]]; 107 125 normCts->data.F32[i] = image->data.F32[ny][nx] / fluxRef->data.F32[i]; 126 normErr->data.F32[i] = sqrt(image->data.F32[ny][nx]) / fluxRef->data.F32[i]; 108 127 } 109 pmShutterCorrPars *params = pmShutterCorrectionLinFit (exptime, normCts, refOffset);128 pmShutterCorrPars *params = pmShutterCorrectionLinFit (exptime, normCts, normErr, refOffset); 110 129 pattern->data.F32[ny][nx] = params->scale; 111 130 offset->data.F32[ny][nx] = params->offset;
Note:
See TracChangeset
for help on using the changeset viewer.
