Changeset 4215
- Timestamp:
- Jun 11, 2005, 5:43:47 AM (21 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 1 added
- 8 edited
-
LocalSky.c (added)
-
choose_psf_model.c (modified) (1 diff)
-
find_peaks.c (modified) (2 diffs)
-
image_stats.c (modified) (1 diff)
-
psphot-utils.c (modified) (1 diff)
-
psphot.c (modified) (2 diffs)
-
psphot.h (modified) (1 diff)
-
setup.c (modified) (1 diff)
-
source_moments.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/choose_psf_model.c
r4129 r4215 26 26 float RADIUS = psMetadataLookupF32 (&status, config, "FIT_RADIUS"); 27 27 28 float XBORDER = psMetadataLookupF32 (&status, config, "XBORDER");29 float YBORDER = psMetadataLookupF32 (&status, config, "YBORDER");30 psRegion *keep = psRegionAlloc (XBORDER, -XBORDER, YBORDER, -YBORDER);31 keep = psRegionForImage (keep, image, keep);32 33 28 for (int i = 0; i < stars->n; i++) { 34 29 psSource *source = stars->data[i]; 35 30 pmSourceSetPixelCircle (source, image, RADIUS); 36 pmSourceMaskRegion (source, keep);37 // XXX EAM - this is silly: reconsider how we use the masks38 // XXX - we are needlessly re-defining the pixels here39 31 } 40 32 -
trunk/psphot/src/find_peaks.c
r4189 r4215 1 1 # include "psphot.h" 2 2 3 psArray *find_peaks (psImage *image, psMetadata *config, psStats *sky)3 psArray *find_peaks (psImageData *imdata, psMetadata *config, psStats *sky) 4 4 { 5 5 bool status = false; … … 16 16 NSIGMA = psMetadataLookupF32 (&status, config, "SMOOTH_NSIGMA"); 17 17 18 psImage *image = imdata->image; 18 19 psImage *smooth = psImageCopy (NULL, image, PS_TYPE_F32); 19 20 psImageSmooth (smooth, SIGMA, NSIGMA); -
trunk/psphot/src/image_stats.c
r4115 r4215 1 1 # include "psphot.h" 2 2 3 psStats *image_stats (psImage *image, psMetadata *config)3 psStats *image_stats (psImageData *imdata, psMetadata *config) 4 4 { 5 5 psStats *stats = NULL; 6 6 psStats *sky = NULL; 7 8 psImage *image = imdata->image; 7 9 8 10 // get image stats on a subset of the image (random 1e5 pts) -
trunk/psphot/src/psphot-utils.c
r4114 r4215 160 160 } 161 161 162 // mask the area contained by the region 163 void psImageMaskRegion (psImage *image, psRegion *region, int maskValue) { 164 165 for (int iy = 0; iy < image->numRows; iy++) { 166 for (int ix = 0; ix < image->numCols; ix++) { 167 if (ix + image->col0 < region->x0) continue; 168 if (ix + image->col0 >= region->x1) continue; 169 if (iy + image->row0 < region->y0) continue; 170 if (iy + image->row0 >= region->y1) continue; 171 image->data.U8[iy][ix] |= maskValue; 172 } 173 } 174 } 175 176 // mask the area not contained by the region 177 void psImageKeepRegion (psImage *image, psRegion *region, int maskValue) { 178 179 for (int iy = 0; iy < image->numRows; iy++) { 180 for (int ix = 0; ix < image->numCols; ix++) { 181 if (ix + image->col0 < region->x0) goto maskit; 182 if (ix + image->col0 >= region->x1) goto maskit; 183 if (iy + image->row0 < region->y0) goto maskit; 184 if (iy + image->row0 >= region->y1) goto maskit; 185 continue; 186 maskit: 187 image->data.U8[iy][ix] |= maskValue; 188 } 189 } 190 } 191 162 192 // create a subset of sources for the PS_SOURCE_PSFSTAR entries 163 193 // XXX deprecated -
trunk/psphot/src/psphot.c
r4189 r4215 4 4 int main (int argc, char **argv) { 5 5 6 psMetadata *config = NULL; // user-provided configuration information 7 psMetadata *header = NULL; // input image header 8 psImage *image = NULL; // input image data 9 psImage *noise = NULL; // input image data 10 psImage *mask = NULL; // input image data 11 psArray *sources = NULL; 12 psArray *peaks = NULL; // a list of pmPeaks 13 pmPSF *psf = NULL; 14 psStats *sky = NULL; 6 psMetadata *config = NULL; // user-provided configuration information 7 psImageData *imdata = NULL; 8 psArray *sources = NULL; 9 psArray *peaks = NULL; // a list of pmPeaks 10 pmPSF *psf = NULL; 11 psStats *sky = NULL; 15 12 16 13 psLogArguments (&argc, argv); … … 20 17 // load input data (image and config) 21 18 // create or load mask and noise images 22 setup (&image, &mask, &noise, &header,config);19 imdata = setup (config); 23 20 24 21 // measure image stats for initial guess 25 sky = image_stats (im age, config);22 sky = image_stats (imdata, config); 26 23 27 24 // find the peaks in the image 28 peaks = find_peaks (im age, config, sky);25 peaks = find_peaks (imdata, config, sky); 29 26 30 27 // construct sources and measure basic stats 31 sources = source_moments (im age, config, peaks);28 sources = source_moments (imdata, config, peaks); 32 29 33 30 // source analysis is done in S/N order (brightest first) -
trunk/psphot/src/psphot.h
r4129 r4215 5 5 # include <unistd.h> 6 6 # include <stdlib.h> 7 8 typedef struct { 9 psImage *image; 10 psImage *mask; 11 psImage *noise; 12 psMetadata *header; 13 } psImageData; 7 14 8 15 // data to test a given PSF model type -
trunk/psphot/src/setup.c
r4189 r4215 1 1 # include "psphot.h" 2 2 3 bool setup (psImage **image, psImage **mask, psImage **noise, psMetadata **header, psMetadata **config)3 psImageData *setup (psMetadata *config) 4 4 { 5 int Nfail;6 psFits *file = NULL; // FITS pointer to input image7 5 psRegion region = {0,0,0,0}; // a region representing the entire array 8 6 9 7 psTimerStart ("psphot"); 10 8 11 char *input = p mConfigLookupSTR (&status, *config, *header, "INPUT");12 file = psFitsAlloc (input);9 char *input = psMetadataLookupSTR (&status, config, "INPUT"); 10 psFits *file = psFitsAlloc (input); 13 11 14 *header = psMetadataAlloc (); 15 psMetadataAdd (*header, PS_LIST_HEAD, "COMMENT", PS_META_MULTI, "folder for comment", NULL); 16 psMetadataAdd (*header, PS_LIST_HEAD, "HISTORY", PS_META_MULTI, "folder for history", NULL); 17 *header = psFitsReadHeader (*header, file); 18 *image = psFitsReadImage (*image, file, region, 0); 12 psImageData *imdata = psAlloc(sizeof(psImageData)); 13 psMetadata *header = psMetadataAlloc (); 14 psMetadataAdd (header, PS_LIST_HEAD, "COMMENT", PS_META_MULTI, "folder for comment", NULL); 15 psMetadataAdd (header, PS_LIST_HEAD, "HISTORY", PS_META_MULTI, "folder for history", NULL); 16 header = psFitsReadHeader (header, file); 17 psImage *image = psFitsReadImage (NULL, file, region, 0); 19 18 psFree (file); 20 19 21 20 // grab these values from the approrpiate location (image header if necessary) 22 21 bool status = false; 23 float RDNOISE = pmConfigLookupF32 (&status, *config, *header, "RDNOISE");24 float GAIN = pmConfigLookupF32 (&status, *config, *header, "GAIN");25 psMetadataAdd ( *config, PS_LIST_TAIL, "RDNOISE", PS_META_F32 | PS_META_REPLACE, "read noise value used", RDNOISE);26 psMetadataAdd ( *config, PS_LIST_TAIL, "GAIN", PS_META_F32 | PS_META_REPLACE, "gain value used", GAIN);22 float RDNOISE = pmConfigLookupF32 (&status, config, header, "RDNOISE"); 23 float GAIN = pmConfigLookupF32 (&status, config, header, "GAIN"); 24 psMetadataAdd (config, PS_LIST_TAIL, "RDNOISE", PS_META_F32 | PS_META_REPLACE, "read noise value used", RDNOISE); 25 psMetadataAdd (config, PS_LIST_TAIL, "GAIN", PS_META_F32 | PS_META_REPLACE, "gain value used", GAIN); 27 26 28 // load the noise image if it exists, otherwise build from input 29 char *noiseName = pmConfigLookupSTR (&status, *config, *header, "NOISE"); 27 imdata->image = image; 28 imdata->header = header; 29 30 // load the noise image if it is supplied, otherwise build from input 31 char *noiseName = psMetadataLookupSTR (&status, config, "NOISE"); 30 32 if (status == true) { 31 33 file = psFitsAlloc (noiseName); 32 *noise = psFitsReadImage (*noise, file, region, 0);34 imdata->noise = psFitsReadImage (NULL, file, region, 0); 33 35 psFree (file); 34 36 } else { 35 *value = psScalar (1.0 / GAIN);36 *noise = BinaryOp (NULL, *image, '/', value);37 psScalar *value = psScalarAlloc (1.0 / GAIN, PS_TYPE_F64); 38 imdata->noise = BinaryOp (NULL, imdata->image, '/', value); 37 39 psFree (value); 38 40 39 *value = psScalar (PS_SQR(RDNOISE/GAIN));40 *noise = BinaryOp (*noise, *noise, '+', value);41 psScalar *value = psScalarAlloc (PS_SQR(RDNOISE/GAIN), PS_TYPE_F64); 42 imdata->noise = BinaryOp (imdata->noise, imdata->noise, '+', value); 41 43 psFree (value); 42 44 } 43 45 44 char *maskName = p mConfigLookupSTR (&status, *config, *header, "MASK");46 char *maskName = psMetadataLookupSTR (&status, config, "MASK"); 45 47 if (status == true) { 46 48 file = psFitsAlloc (maskName); 47 *mask = psFitsReadImage (*mask, file, region, 0); 49 imdata->mask = psFitsReadImage (NULL, file, region, 0); 50 // check if U8 & force? 48 51 psFree (file); 49 52 } else { 50 *mask = psImageAlloc (image->numCols, image->numRows, PS_TYPE_U8);53 imdata->mask = psImageAlloc (image->numCols, image->numRows, PS_TYPE_U8); 51 54 } 55 56 float XBORDER = psMetadataLookupF32 (&status, config, "XBORDER"); 57 float YBORDER = psMetadataLookupF32 (&status, config, "YBORDER"); 58 psRegion *keep = psRegionAlloc (XBORDER, -XBORDER, YBORDER, -YBORDER); 59 keep = psRegionForImage (keep, image, keep); 60 psImageKeepRegion (imdata->mask, keep, 0x01); 52 61 53 62 psLogMsg ("psphot", 3, "load data: %f sec\n", psTimerMark ("psphot")); -
trunk/psphot/src/source_moments.c
r4129 r4215 1 1 # include "psphot.h" 2 2 3 psArray *source_moments (psImage *image, psMetadata *config, psArray *allpeaks)3 psArray *source_moments (psImageData *imdata, psMetadata *config, psArray *allpeaks) 4 4 { 5 5 bool status = false; … … 8 8 9 9 psTimerStart ("psphot"); 10 11 // reduce the initial peaks to a subset of the better peaks12 // is this the appropriate place for this culling?13 14 float XBORDER = psMetadataLookupF32 (&status, config, "XBORDER");15 float YBORDER = psMetadataLookupF32 (&status, config, "YBORDER");16 float SATURATE = psMetadataLookupF32 (&status, config, "SATURATE");17 18 psRegion *keep = psRegionAlloc (XBORDER, -XBORDER, YBORDER, -YBORDER);19 keep = psRegionForImage (keep, image, keep);20 // I need to exclude the saturated objects here, but include them again later...?21 peaks = pmPeaksSubset (allpeaks, 100000, keep);22 10 23 11 // determine properties (sky, moments) of initial sources … … 32 20 for (int i = 0; i < peaks->n; i++) { 33 21 // provide the user arguments as metadata? 34 psSource *source = pmSource LocalSky (image, (psPeak *)peaks->data[i], PS_STAT_SAMPLE_MEDIAN, INNER, OUTER);22 psSource *source = pmSourceDefinePixels (imdata, (psPeak *)peaks->data[i], OUTER); 35 23 if (source == NULL) continue; 36 pmSourceMaskRegion (source, keep); 24 25 pmSourceLocalSky_EAM (source, PS_STAT_SAMPLE_MEDIAN, INNER); 37 26 pmSourceMoments (source, RADIUS); 38 27 psArrayAdd (sources, 100, source);
Note:
See TracChangeset
for help on using the changeset viewer.
