Changeset 4215 for trunk/psphot/src/setup.c
- Timestamp:
- Jun 11, 2005, 5:43:47 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/setup.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
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"));
Note:
See TracChangeset
for help on using the changeset viewer.
