Changeset 13515 for trunk/ppStack/src/ppStackCamera.c
- Timestamp:
- May 24, 2007, 2:28:58 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppStack/src/ppStackCamera.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStackCamera.c
r13493 r13515 13 13 bool ppStackCamera(pmConfig *config) 14 14 { 15 psString imageName = psMetadataLookupStr(NULL, config->arguments, "IMAGES.LIST"); // Image list filename 16 assert(imageName); 17 psString maskName = psMetadataLookupStr(NULL, config->arguments, "MASKS.LIST"); // Mask list filename 18 assert(maskName); 19 20 psString imageList = psSlurpFilename(imageName); // Contents of image list 21 if (!imageList) { 22 psError(PS_ERR_IO, false, "Unable to read list of image files %s", imageName); 23 return false; 24 } 25 psArray *images = psStringSplitArray(imageList, "\n", false); // The image filenames 26 psFree(imageList); 27 28 psString maskList = psSlurpFilename(maskName); // Contents of mask list 29 if (!maskList) { 30 psError(PS_ERR_IO, false, "Unable to read list of mask files %s", maskName); 31 return false; 32 } 33 psArray *masks = psStringSplitArray(maskList, "\n", false); // The mask filenames 34 psFree(maskList); 35 if (images->n != masks->n) { 36 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 37 "Number input images (%ld) does not match number of input masks (%ld).", 38 images->n, masks->n); 39 psFree(images); 40 psFree(masks); 41 return false; 42 } 43 44 for (int i = 0; i < images->n; i++) { 45 psString image = images->data[i]; // Name of image 46 if (!image || strlen(image) == 0) { 47 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Image name %d is blank.", i); 48 psFree(images); 49 psFree(masks); 50 return false; 51 } 52 psString mask = masks->data[i]; // Name of mask 53 if (!mask || strlen(mask) == 0) { 54 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Mask name %d is blank.", i); 55 psFree(images); 56 psFree(masks); 15 psMetadata *inputs = psMetadataLookupMetadata(NULL, config->arguments, "INPUTS"); // The inputs info 16 psMetadataIterator *iter = psMetadataIteratorAlloc(inputs, PS_LIST_HEAD, NULL); // Iterator 17 psMetadataItem *item; // Item from iteration 18 int i = 0; // Counter 19 while ((item = psMetadataGetAndIncrement(iter))) { 20 if (item->type != PS_DATA_METADATA) { 21 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 22 "Component %s of the input metadata is not of type METADATA", item->name); 23 psFree(iter); 57 24 return false; 58 25 } 59 26 27 psMetadata *input = item->data.md; // The input metadata of interest 28 29 psString image = psMetadataLookupStr(NULL, input, "IMAGE"); // Name of image 30 if (!image || strlen(image) == 0) { 31 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks IMAGE of type STR", item->name); 32 psFree(iter); 33 return false; 34 } 35 36 psString mask = psMetadataLookupStr(NULL, input, "MASK"); // Name of mask 37 if (!mask || strlen(mask) == 0) { 38 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks MASK of type STR", item->name); 39 psFree(iter); 40 return false; 41 } 42 43 float seeing = psMetadataLookupF32(NULL, input, "SEEING"); // Seeing FWHM 44 if (isnan(seeing)) { 45 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks SEEING of type F32", item->name); 46 psFree(iter); 47 return false; 48 } 49 50 float weight = psMetadataLookupF32(NULL, input, "WEIGHT"); // Relative weight 51 if (isnan(weight)) { 52 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks WEIGHT of type F32", item->name); 53 psFree(iter); 54 return false; 55 } 56 57 float scale = psMetadataLookupF32(NULL, input, "SCALE"); // Relative scale 58 if (isnan(scale)) { 59 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks SCALE of type F32", item->name); 60 psFree(iter); 61 return false; 62 } 63 64 // Add the image file 60 65 psArray *imageFiles = psArrayAlloc(1); // Array of filenames for this FPA 61 66 imageFiles->data[0] = psMemIncrRefCounter(image); … … 68 73 if (!imageFile || !found) { 69 74 psError(PS_ERR_UNKNOWN, false, "Unable to define file from image %d (%s)", i, image); 70 psFree(images);71 psFree(masks);72 75 return false; 73 76 } 74 77 if (imageFile->type != PM_FPA_FILE_IMAGE) { 75 78 psError(PS_ERR_IO, true, "PPSTACK.INPUT is not of type IMAGE"); 76 psFree(images);77 psFree(masks);78 79 return false; 79 80 } 80 81 82 // Add the mask file 81 83 psArray *maskFiles = psArrayAlloc(1); // Array of filenames for this FPA 82 84 maskFiles->data[0] = psMemIncrRefCounter(mask); … … 90 92 if (!maskFile || !found) { 91 93 psError(PS_ERR_UNKNOWN, false, "Unable to define file from mask %d (%s)", i, mask); 92 psFree(images);93 psFree(masks);94 94 return false; 95 95 } 96 96 if (maskFile->type != PM_FPA_FILE_MASK) { 97 97 psError(PS_ERR_IO, true, "PPSTACK.INPUT.MASK is not of type MASK"); 98 psFree(images);99 psFree(masks);100 98 return false; 101 99 } 100 101 psMetadataAddF32(imageFile->fpa->analysis, PS_LIST_TAIL, "PPSTACK.SEEING", 0, 102 "Seeing for image", seeing); 103 psMetadataAddF32(imageFile->fpa->analysis, PS_LIST_TAIL, "PPSTACK.WEIGHT", 0, 104 "Relative weight for image", weight); 105 psMetadataAddF32(imageFile->fpa->analysis, PS_LIST_TAIL, "PPSTACK.SCALE", 0, 106 "Relative scale for image", scale); 107 108 i++; 102 109 } 110 psFree(iter); 103 111 psMetadataRemoveKey(config->arguments, "IMAGE.FILENAMES"); 104 112 psMetadataRemoveKey(config->arguments, "MASK.FILENAMES"); 105 113 106 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INPUTS.NUM", 0, "Number of input files", images->n); 107 108 psFree(images); 109 psFree(masks); 114 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INPUTS.NUM", 0, "Number of input files", i); 110 115 111 116 // Output image
Note:
See TracChangeset
for help on using the changeset viewer.
