Changeset 23719 for branches/pap/ppSub
- Timestamp:
- Apr 6, 2009, 6:52:51 PM (17 years ago)
- Location:
- branches/pap/ppSub/src
- Files:
-
- 1 added
- 21 edited
-
. (modified) (1 prop)
-
Makefile.am (modified) (1 diff)
-
ppSub.c (modified) (1 diff)
-
ppSub.h (modified) (5 diffs)
-
ppSubArguments.c (modified) (3 diffs)
-
ppSubBackground.c (modified) (4 diffs)
-
ppSubCamera.c (modified) (10 diffs)
-
ppSubData.c (modified) (4 diffs)
-
ppSubDefineOutput.c (modified) (2 diffs)
-
ppSubErrorCodes.c.in (modified) (2 diffs)
-
ppSubErrorCodes.h.in (modified) (3 diffs)
-
ppSubFiles.c (modified) (10 diffs)
-
ppSubLoop.c (modified) (9 diffs)
-
ppSubMakePSF.c (modified) (7 diffs)
-
ppSubMatchPSFs.c (modified) (2 diffs)
-
ppSubReadoutInverse.c (added)
-
ppSubReadoutJpeg.c (modified) (1 diff)
-
ppSubReadoutPhotometry.c (modified) (6 diffs)
-
ppSubReadoutStats.c (modified) (2 diffs)
-
ppSubReadoutSubtract.c (modified) (4 diffs)
-
ppSubReadoutUpdate.c (modified) (1 diff)
-
ppSubSetMasks.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/ppSub/src
- Property svn:ignore
-
old new 10 10 stamp-h1 11 11 ppSubKernel 12 ppSubErrorCodes.h 13 ppSubErrorCodes.c
-
- Property svn:ignore
-
branches/pap/ppSub/src/Makefile.am
r23704 r23719 13 13 ppSub_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PPSUB_LIBS) 14 14 15 ppSub_SOURCES = \ 16 ppSub.c \ 17 ppSubArguments.c \ 18 ppSubVersion.c \ 19 ppSubBackground.c \ 20 ppSubCamera.c \ 21 ppSubData.c \ 22 ppSubLoop.c \ 23 ppSubReadout.c \ 24 ppSubDefineOutput.c \ 25 ppSubExtras.c \ 26 ppSubMakePSF.c \ 27 ppSubMatchPSFs.c \ 28 ppSubReadoutPhotometry.c \ 29 ppSubReadoutSubtract.c \ 30 ppSubReadoutUpdate.c \ 31 ppSubSetMasks.c \ 32 ppSubReadoutRenorm.c \ 15 ppSub_SOURCES = \ 16 ppSub.c \ 17 ppSubArguments.c \ 18 ppSubVersion.c \ 19 ppSubBackground.c \ 20 ppSubCamera.c \ 21 ppSubData.c \ 22 ppSubErrorCodes.c \ 23 ppSubFiles.c \ 24 ppSubLoop.c \ 25 ppSubDefineOutput.c \ 26 ppSubExtras.c \ 27 ppSubMakePSF.c \ 28 ppSubMatchPSFs.c \ 29 ppSubReadoutInverse.c \ 30 ppSubReadoutJpeg.c \ 31 ppSubReadoutPhotometry.c \ 32 ppSubReadoutStats.c \ 33 ppSubReadoutSubtract.c \ 34 ppSubSetMasks.c \ 35 ppSubReadoutRenorm.c \ 33 36 ppSubVarianceFactors.c 34 37 -
branches/pap/ppSub/src/ppSub.c
r23704 r23719 51 51 ppSubData *data = ppSubDataAlloc(); // Processing data 52 52 53 if (!ppSubArguments Setup(argc, argv, config, data)) {53 if (!ppSubArguments(argc, argv, config, data)) { 54 54 psErrorStackPrint(stderr, "Error reading arguments.\n"); 55 55 exitValue = PS_EXIT_CONFIG_ERROR; -
branches/pap/ppSub/src/ppSub.h
r23711 r23719 14 14 #define PP_SUB_H 15 15 16 #include <stdio.h> 16 17 #include <pslib.h> 17 18 #include <psmodules.h> 19 20 #include "ppSubErrorCodes.h" 18 21 19 22 /// @addtogroup ppSub … … 28 31 PPSUB_FILES_SUB = 0x04, // Subtracted files (output) 29 32 PPSUB_FILES_INV = 0x08, // Inverse subtracted files (output) 30 PPSUB_FILES_P HOT = 0x10, // psphot photometry files33 PPSUB_FILES_PSF = 0x10, // PSF files (output) 31 34 PPSUB_FILES_PHOT_SUB = 0x20, // Subtraction photometry files (output) 32 35 PPSUB_FILES_PHOT_INV = 0x40, // Inverse subtraction photometry files (output) 36 PPSUB_FILES_PHOT = 0x80, // General photometry files (internal) 33 37 PPSUB_FILES_ALL = 0xFF, // All files 34 38 } ppSubFiles; … … 39 43 bool photometry; // Perform photometry? 40 44 bool inverse; // Output inverse subtraction as well? 41 const char *statsFile; // Statistics file 45 psString stamps; // Stamps file 46 pmPSF *psf; // Point Spread Function 47 FILE *statsFile; // Statistics file 42 48 psMetadata *stats; // Statistics 43 49 } ppSubData; … … 47 53 48 54 /// Setup the arguments parsing 49 bool ppSubArgumentsSetup(int argc, char *argv[], ///< Command-line arguments 50 pmConfig *config ///< Configuration 51 ); 52 53 /// Parse the arguments 54 bool ppSubArgumentsParse(pmConfig *config ///< Configuration 55 bool ppSubArguments(int argc, char *argv[], ///< Command-line arguments 56 pmConfig *config, ///< Configuration 57 ppSubData *data ///< Processing data 55 58 ); 56 59 57 60 /// Parse the camera input 58 bool ppSubCamera(pmConfig *config ///< Configuration 61 bool ppSubCamera(pmConfig *config, ///< Configuration 62 ppSubData *data ///< Processing data 59 63 ); 60 64 61 65 /// Loop over the FPA hierarchy 62 bool ppSubLoop(pmConfig *config ///< Configuration 66 bool ppSubLoop(pmConfig *config, ///< Configuration 67 ppSubData *data ///< Processing data 63 68 ); 64 69 65 70 /// Perform PSF-matched image subtraction on the readout 66 71 bool ppSubReadout(pmConfig *config, ///< Configuration 67 ppSubData *data, ///< Processing data 68 const pmFPAview *view ///< View of readout to subtract 72 ppSubData *data ///< Processing data 69 73 ); 70 74 71 75 /// Generate (if needed) and set or update the masks for input and reference images 72 bool ppSubSetMasks(pmConfig *config, ///< Configuration 73 const pmFPAview *view ///< View of active readout 76 bool ppSubSetMasks(pmConfig *config ///< Configuration 74 77 ); 75 78 76 79 /// Generate the PSF-matching kernel and convolve the images as needed. Most of this function involves 77 80 /// looking up the parameters in the recipe and supplying them to the function pmSubtractionMatch() 78 bool ppSubMatchPSFs(pmConfig *config, ///< Configuration 79 ppSubData *data, ///< Processing data 80 const pmFPAview *view ///< View of active readout 81 bool ppSubMatchPSFs(pmConfig *config, ///< Configuration 82 ppSubData *data ///< Processing data 81 83 ); 82 84 83 85 /// Generate the output readout and pass the kernel info to the header 84 bool ppSubDefineOutput( pmConfig *config, ///< Configuration85 const pmFPAview *view ///< View of active readout86 bool ppSubDefineOutput(const char *name,///< Name of output to define 87 pmConfig *config ///< Configuration 86 88 ); 87 89 88 90 /// Photometry stage 1: measure the PSF from the minuend image 89 bool ppSubMakePSF(pmConfig *config, ///< Configuration 90 ppSubData *data, ///< Processing data 91 const pmFPAview *view ///< View of active readout 91 bool ppSubMakePSF(pmConfig *config, ///< Configuration 92 ppSubData *data ///< Processing data 92 93 ); 93 94 94 95 /// Perform the actual image subtraction, update output concepts 95 bool ppSubReadoutSubtract(pmConfig *config, ///< Configuration 96 const pmFPAview *view ///< View of active readout 96 bool ppSubReadoutSubtract(pmConfig *config ///< Configuration 97 97 ); 98 98 99 99 100 100 /// Photometry stage 2: find and measure sources on the subtracted image 101 bool ppSubReadoutPhotometry( pmConfig *config, ///< Configuration102 p pSubData *data, ///< Processing data103 const pmFPAview *view ///< View of active readout101 bool ppSubReadoutPhotometry(const char *name, ///< Name of file to photometer 102 pmConfig *config, ///< Configuration 103 ppSubData *data ///< Processing data 104 104 ); 105 105 106 106 /// Renormalize, update headers and generate JPEGs 107 107 bool ppSubReadoutUpdate(pmConfig *config, ///< Configuration 108 ppSubData *data, ///< Processing data 109 const pmFPAview *view ///< View of active readout 108 ppSubData *data ///< Processing data 110 109 ); 111 110 112 111 /// Higher-order background subtraction 113 bool ppSubBackground(pmConfig *config, ///< Configuration 114 const pmFPAview *view ///< View to readout 112 bool ppSubBackground(pmConfig *config ///< Configuration 115 113 ); 116 114 … … 129 127 ); 130 128 129 130 /// Activate or deactivate files 131 void ppSubFilesActivate(pmConfig *config, // Configuration 132 ppSubFiles files, // File to activate/deactivate 133 bool state // Activation state 134 ); 135 136 /// Generate a view suitable for a readout 137 /// 138 /// Assumes we're working with skycells 139 pmFPAview *ppSubViewReadout(void); 140 141 /// Iterate down the FPA hierarchy, opening files 142 bool ppSubFilesIterateDown(pmConfig *config, // Configuration 143 ppSubFiles files // Files to open 144 ); 145 146 /// Iterate up the FPA hierarchy, closing files 147 bool ppSubFilesIterateUp(pmConfig *config, // Configuration 148 ppSubFiles files // Files to open 149 ); 150 151 /// Collect statistics 152 bool ppSubReadoutStats(pmConfig *config,// Configuration 153 ppSubData *data // Processing data 154 ); 155 156 /// Generate JPEG images 157 bool ppSubReadoutJpeg(pmConfig *config // Configuration 158 ); 159 160 /// Generate inverse subtraction 161 bool ppSubReadoutInverse(pmConfig *config // Configuration 162 ); 163 164 131 165 // Copy every instance of a single keyword from one metadata to another 132 166 bool psMetadataCopySingle(psMetadata *target, psMetadata *source, const char *name); -
branches/pap/ppSub/src/ppSubArguments.c
r23704 r23719 39 39 psLibFinalize(); 40 40 exit(PS_EXIT_CONFIG_ERROR); 41 }42 43 // Get a float-point value from the command-line or recipe, and add it to the arguments44 #define VALUE_ARG_RECIPE_FLOAT(ARGNAME, RECIPENAME, TYPE) { \45 ps##TYPE value = psMetadataLookup##TYPE(NULL, config->arguments, ARGNAME); \46 if (isnan(value)) { \47 bool mdok; \48 value = psMetadataLookup##TYPE(&mdok, recipe, RECIPENAME); \49 if (!mdok) { \50 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \51 RECIPENAME, PPSUB_RECIPE); \52 goto ERROR; \53 } \54 } \55 psMetadataAdd##TYPE(recipe, PS_LIST_TAIL, RECIPENAME, PS_META_REPLACE, NULL, value); \56 }57 58 // Get an integer value from the command-line or recipe, and add it to the arguments59 #define VALUE_ARG_RECIPE_INT(ARGNAME, RECIPENAME, TYPE, UNSET) { \60 ps##TYPE value = psMetadataLookup##TYPE(NULL, config->arguments, ARGNAME); \61 if (value == UNSET) { \62 bool mdok; \63 value = psMetadataLookup##TYPE(&mdok, recipe, RECIPENAME); \64 if (!mdok) { \65 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \66 RECIPENAME, PPSUB_RECIPE); \67 goto ERROR; \68 } \69 } \70 psMetadataAdd##TYPE(recipe, PS_LIST_TAIL, RECIPENAME, PS_META_REPLACE, NULL, value); \71 }72 73 /**74 * Get a string value from the command-line and add it to the target75 */76 static bool valueArgStr(psMetadata *arguments, // Command-line arguments77 const char *argName, // Argument name in the command-line arguments78 const char *mdName, // Name for value in the metadata79 psMetadata *target // Target metadata to which to add value80 )81 {82 psString value = psMetadataLookupStr(NULL, arguments, argName); // Value of interest83 if (value && strlen(value) > 0) {84 return psMetadataAddStr(target, PS_LIST_TAIL, mdName, PS_META_REPLACE, NULL, value);85 }86 return false;87 }88 89 /**90 * Get a string value from the command-line or recipe and add it to the target91 */92 static bool valueArgRecipeStr(psMetadata *arguments, // Command-line arguments93 psMetadata *recipe, // Recipe94 const char *argName, // Argument name in the command-line arguments95 const char *mdName, // Name for value in the metadata and recipe96 psMetadata *target // Target metadata to which to add value97 )98 {99 bool mdok; // Status of MD lookup100 psString value = psMetadataLookupStr(&mdok, arguments, argName); // Value of interest101 if (!value) {102 value = psMetadataLookupStr(&mdok, recipe, mdName);103 if (!value) {104 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s",105 mdName, PPSUB_RECIPE);106 return false;107 }108 }109 return psMetadataAddStr(target, PS_LIST_TAIL, mdName, PS_META_REPLACE, NULL, value);110 }111 112 /**113 * Get a vector from the command-line or recipe, and add it to the target114 */115 static bool vectorArgRecipe(psMetadata *arguments, // Command-line arguments116 const char *argName, // Argument name in the command-line arguments117 const psMetadata *recipe, // Recipe118 const char *recipeName, // Name for value in the recipe119 psMetadata *target, // Target to which to add value120 psElemType type // Type for vector121 )122 {123 psVector *vector; // Vector124 psString string = psMetadataLookupStr(NULL, arguments, argName); // String from arguments125 if (string) {126 psArray *array = psStringSplitArray(string, ", ", false); // Array of strings127 vector = psVectorAlloc(array->n, type);128 for (int i = 0; i < array->n; i++) {129 const char *subString = array->data[i]; // String with a value130 char *end; // Ptr to end of string parsed131 132 switch (type) {133 case PS_TYPE_F32:134 vector->data.F32[i] = strtof(subString, &end);135 break;136 case PS_TYPE_S32: {137 long value = strtol(subString, &end, 10);138 if (value > PS_MAX_S32 || value < PS_MIN_S32) {139 psError(PS_ERR_BAD_PARAMETER_VALUE, true,140 "%s list includes value beyond S32 representation: %s",141 argName, string);142 psFree(vector);143 return false;144 }145 vector->data.S32[i] = value;146 break;147 }148 default:149 psAbort("Unsupported type: %x\n", type);150 }151 if (end == subString) {152 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to decipher %s list: %s",153 argName, string);154 psFree(vector);155 return false;156 }157 }158 psFree(array);159 } else {160 vector = psMetadataLookupPtr(NULL, recipe, recipeName);161 if (!psMemCheckVector(vector) || vector->type.type != type) {162 psError(PS_ERR_BAD_PARAMETER_TYPE, false, "%s in recipe %s is not a vector of type F32.",163 recipeName, PPSUB_RECIPE);164 return false;165 }166 psMemIncrRefCounter(vector);167 }168 169 psMetadataAddVector(target, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL, vector);170 psFree(vector); // Drop reference171 172 return true;173 41 } 174 42 … … 255 123 } 256 124 257 data->stamps = psMe tadataLookupStr(NULL, arguments, "-stamps");125 data->stamps = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-stamps")); 258 126 259 127 const char *statsName = psMetadataLookupStr(NULL, arguments, "-stats"); // Filename for statistics … … 281 149 } 282 150 283 return true;284 }285 286 287 288 151 psTrace("ppSub", 1, "Done reading command-line arguments\n"); 289 152 -
branches/pap/ppSub/src/ppSubBackground.c
r23287 r23719 22 22 #include "ppSub.h" 23 23 24 bool ppSubBackground(pmConfig *config , const pmFPAview *view)24 bool ppSubBackground(pmConfig *config) 25 25 { 26 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view");28 27 29 28 bool mdok; // Status of metadata lookups … … 36 35 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask 37 36 37 pmFPAview *view = ppSubViewReadout(); // View to readout 38 38 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); // Output image 39 39 pmReadout *modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL"); // Background model … … 44 44 if (!psphotModelBackground(config, view, "PPSUB.OUTPUT")) { 45 45 psError(PS_ERR_UNKNOWN, false, "Unable to model background"); 46 psFree(view); 46 47 return false; 47 48 } … … 50 51 if (!modelRO) { 51 52 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background model"); 53 psFree(view); 52 54 return false; 53 55 } 54 56 } 57 psFree(view); 58 55 59 psImageBinning *binning = psMetadataLookupPtr(&mdok, modelRO->analysis, 56 60 "PSPHOT.BACKGROUND.BINNING"); // Binning for model -
branches/pap/ppSub/src/ppSubCamera.c
r23711 r23719 134 134 135 135 136 bool ppSubCamera(pmConfig *config )136 bool ppSubCamera(pmConfig *config, ppSubData *data) 137 137 { 138 138 psAssert(config, "Require configuration"); … … 147 147 pmFPAfile *inVar = defineInputFile(config, input, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE", 148 148 PM_FPA_FILE_VARIANCE); 149 defineInputFile(config, input, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF);149 defineInputFile(config, NULL, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF); 150 150 151 151 // Reference image … … 158 158 pmFPAfile *refVar = defineInputFile(config, ref, "PPSUB.REF.VARIANCE", "REF.VARIANCE", 159 159 PM_FPA_FILE_VARIANCE); 160 defineInputFile(config, ref, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF); 160 defineInputFile(config, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF); 161 162 163 // Convolved input image 164 pmFPAfile *inConvImage = defineOutputFile(config, input, true, "PPSUB.INPUT.CONV", PM_FPA_FILE_IMAGE); 165 pmFPAfile *inConvMask = defineOutputFile(config, inConvImage, false, "PPSUB.INPUT.CONV.MASK", 166 PM_FPA_FILE_MASK); 167 if (!inConvImage || !inConvMask) { 168 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 169 return false; 170 } 171 if (inVar) { 172 pmFPAfile *inConvVar = defineOutputFile(config, inConvImage, false, "PPSUB.INPUT.CONV.VARIANCE", 173 PM_FPA_FILE_VARIANCE); 174 if (!inConvVar) { 175 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 176 return false; 177 } 178 } 179 180 // Convolved ref image 181 pmFPAfile *refConvImage = defineOutputFile(config, input, true, "PPSUB.REF.CONV", PM_FPA_FILE_IMAGE); 182 pmFPAfile *refConvMask = defineOutputFile(config, refConvImage, false, "PPSUB.REF.CONV.MASK", 183 PM_FPA_FILE_MASK); 184 if (!refConvImage || !refConvMask) { 185 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 186 return false; 187 } 188 if (refVar) { 189 pmFPAfile *refConvVar = defineOutputFile(config, refConvImage, false, "PPSUB.REF.CONV.VARIANCE", 190 PM_FPA_FILE_VARIANCE); 191 if (!refConvVar) { 192 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 193 return false; 194 } 195 } 161 196 162 197 … … 172 207 173 208 // Output image 174 pmFPAfile *output = defineOutputFile(config, in put, true, "PPSUB.OUTPUT", PM_FPA_FILE_IMAGE);209 pmFPAfile *output = defineOutputFile(config, inConvImage, true, "PPSUB.OUTPUT", PM_FPA_FILE_IMAGE); 175 210 pmFPAfile *outMask = defineOutputFile(config, output, false, "PPSUB.OUTPUT.MASK", PM_FPA_FILE_MASK); 176 211 if (!output || !outMask) { … … 190 225 } 191 226 227 pmFPAfile *inverse = NULL; // Inverse output image 192 228 if (data->inverse) { 193 229 // Inverse output image 194 pmFPAfile *inverse = defineOutputFile(config, input, true, "PPSUB.INV", PM_FPA_FILE_IMAGE);230 inverse = defineOutputFile(config, output, true, "PPSUB.INVERSE", PM_FPA_FILE_IMAGE); 195 231 pmFPAfile *invMask = defineOutputFile(config, inverse, false, "PPSUB.INVERSE.MASK", 196 232 PM_FPA_FILE_MASK); 197 if (!inv || !invMask) {233 if (!inverse || !invMask) { 198 234 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 199 235 return false; … … 212 248 } 213 249 214 // Convolved input image215 pmFPAfile *inConvImage = defineOutputFile(config, input, true, "PPSUB.INPUT.CONV", PM_FPA_FILE_IMAGE);216 pmFPAfile *inConvMask = defineOutputFile(config, inConvImage, false, "PPSUB.INPUT.CONV.MASK",217 PM_FPA_FILE_MASK);218 if (!inConvImage || !inConvMask) {219 psError(PS_ERR_UNKNOWN, false, "Unable to define output files");220 return false;221 }222 if (inVar) {223 pmFPAfile *inConvVar = defineOutputFile(config, inConvImage, false, "PPSUB.INPUT.CONV.VARIANCE",224 PM_FPA_FILE_VARIANCE);225 if (!inConvVar) {226 psError(PS_ERR_UNKNOWN, false, "Unable to define output files");227 return false;228 }229 }230 231 // Convolved ref image232 pmFPAfile *refConvImage = defineOutputFile(config, input, true, "PPSUB.REF.CONV", PM_FPA_FILE_IMAGE);233 pmFPAfile *refConvMask = defineOutputFile(config, refConvImage, false, "PPSUB.REF.CONV.MASK",234 PM_FPA_FILE_MASK);235 if (!refConvImage || !refConvMask) {236 psError(PS_ERR_UNKNOWN, false, "Unable to define output files");237 return false;238 }239 if (refVar) {240 pmFPAfile *refConvVar = defineOutputFile(config, refConvImage, false, "PPSUB.REF.CONV.VARIANCE",241 PM_FPA_FILE_VARIANCE);242 if (!refConvVar) {243 psError(PS_ERR_UNKNOWN, false, "Unable to define output files");244 return false;245 }246 }247 248 250 249 251 // Output JPEGs … … 276 278 } 277 279 278 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim279 if (!recipe) {280 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSUB_RECIPE);281 return false;282 }283 284 280 // psPhot input 285 281 if (data->photometry) { 286 282 psphotModelClassInit(); // load implementation-specific models 287 283 288 // Internal-ish file for getting the PSF from the minuend289 pmFPAfile *psf = pmFPAfileDefineOutputFromFile(config, output, "PSPHOT.PSF.LOAD");290 if (!psf) {291 psError(PS_ERR_IO, false, "Failed to build FPA from PSPHOT.PSF.LOAD");292 return false;293 }294 if (psf->type != PM_FPA_FILE_PSF) {295 psError(PS_ERR_IO, true, "PSPHOT.PSF.LOAD is not of type PSF");296 return false;297 }298 pmFPAfileActivate(config->files, false, "PSPHOT.PSF.LOAD");299 300 284 pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT"); 301 285 if (!psphot) { … … 307 291 return false; 308 292 } 293 pmFPAfileActivate(config->files, false, "PSPHOT.INPUT"); 294 295 // Internal-ish file for getting the PSF from the minuend 296 pmFPAfile *psf = pmFPAfileDefineOutputFromFile(config, psphot, "PSPHOT.PSF.LOAD"); 297 if (!psf) { 298 psError(PS_ERR_IO, false, "Failed to build FPA from PSPHOT.PSF.LOAD"); 299 return false; 300 } 301 if (psf->type != PM_FPA_FILE_PSF) { 302 psError(PS_ERR_IO, true, "PSPHOT.PSF.LOAD is not of type PSF"); 303 return false; 304 } 305 pmFPAfileActivate(config->files, false, "PSPHOT.PSF.LOAD"); 309 306 310 307 if (!psphotDefineFiles(config, psphot)) { … … 326 323 327 324 if (data->inverse) { 328 pmFPAfile *invSources = defineOutputFile(config, inverse, false, "PPSUB. OUTPUT.SOURCES",325 pmFPAfile *invSources = defineOutputFile(config, inverse, false, "PPSUB.INVERSE.SOURCES", 329 326 PM_FPA_FILE_CMF); 330 327 if (!invSources) { … … 332 329 return false; 333 330 } 334 }335 invSources->save = true;331 invSources->save = true; 332 } 336 333 } 337 334 -
branches/pap/ppSub/src/ppSubData.c
r23704 r23719 9 9 10 10 #include "ppSub.h" 11 12 13 // Image files to activate/deactivate14 static const char *imageFiles[] = { "PPSUB.OUTPUT", "PPSUB.OUTPUT.MASK", "PPSUB.OUTPUT.VARIANCE",15 "PPSUB.OUTPUT.KERNELS", "PPSUB.OUTPUT.JPEG1", "PPSUB.OUTPUT.JPEG2",16 "PPSUB.INPUT.CONV", "PPSUB.INPUT.CONV.MASK", "PPSUB.INPUT.CONV.VARIANCE",17 "PPSUB.REF.CONV", "PPSUB.REF.CONV.MASK", "PPSUB.REF.CONV.VARIANCE",18 NULL };19 20 11 21 12 … … 32 23 fclose(data->statsFile); 33 24 } 25 psFree(data->stamps); 26 psFree(data->psf); 27 psFree(data->statsFile); 34 28 psFree(data->stats); 35 29 return; … … 44 38 data->photometry = false; 45 39 data->inverse = false; 40 data->stamps = NULL; 41 data->psf = NULL; 46 42 data->statsFile = NULL; 47 43 data->stats = psMetadataAlloc(); 48 44 psMetadataAddS32(data->stats, PS_LIST_TAIL, "QUALITY", 0, "Data quality", 0); 49 45 50 return options;46 return data; 51 47 } 52 48 … … 62 58 } 63 59 64 if (files & PPSUB_FILES_IMAGE) { 65 for (int i = 0; imageFiles[i]; i++) { 66 pmFPAfileActivate(config->files, imageFiles[i], false); 67 } 68 } 69 if (files & PPSUB_FILES_PHOT) { 70 psphotFilesActivate(config, false); 71 } 60 ppSubFilesActivate(config, files, false); 72 61 73 62 psErrorClear(); -
branches/pap/ppSub/src/ppSubDefineOutput.c
r23711 r23719 21 21 #include "ppSub.h" 22 22 23 bool ppSubDefineOutput(const char *name, pmConfig *config , const ppSubData *data, const pmFPAview *view)23 bool ppSubDefineOutput(const char *name, pmConfig *config) 24 24 { 25 25 psAssert(name, "Require name"); 26 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view");28 27 28 pmFPAview *view = ppSubViewReadout(); // View to readout 29 29 pmCell *outCell = pmFPAfileThisCell(config->files, view, name); // Output cell 30 30 pmFPA *outFPA = outCell->parent->parent; // Output FPA … … 45 45 pmReadout *inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input readout 46 46 pmReadout *refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference readout 47 psFree(view); 47 48 48 49 // Add kernel descrption to header. -
branches/pap/ppSub/src/ppSubErrorCodes.c.in
r23704 r23719 1 /** @file p swarpErrorCodes.c.in1 /** @file ppSubErrorCodes.c.in 2 2 * 3 3 * @brief 4 4 * 5 * @ingroup p swarp5 * @ingroup ppSub 6 6 * 7 7 * @author IfA … … 12 12 13 13 #include "pslib.h" 14 #include "p swarpErrorCodes.h"14 #include "ppSubErrorCodes.h" 15 15 16 16 /* 17 17 * The line 18 { P SWARP_ERR_$X{ErrorCode}, "$X{ErrorDescription}"},18 { PPSUB_ERR_$X{ErrorCode}, "$X{ErrorDescription}"}, 19 19 * (without the Xs) 20 20 * will be replaced by values from errorCodes.dat 21 21 */ 22 void p swarpErrorRegister(void)22 void ppSubErrorRegister(void) 23 23 { 24 24 static psErrorDescription errors[] = { 25 { P SWARP_ERR_BASE, "First value we use; lower values belong to psLib" },26 { P SWARP_ERR_${ErrorCode}, "${ErrorDescription}"},25 { PPSUB_ERR_BASE, "First value we use; lower values belong to psLib" }, 26 { PPSUB_ERR_${ErrorCode}, "${ErrorDescription}"}, 27 27 }; 28 static int nerror = P SWARP_ERR_NERROR - PSWARP_ERR_BASE; ///< number of values in enum28 static int nerror = PPSUB_ERR_NERROR - PPSUB_ERR_BASE; ///< number of values in enum 29 29 30 30 for (int i = 0; i < nerror; i++) { -
branches/pap/ppSub/src/ppSubErrorCodes.h.in
r23704 r23719 1 /** @file p swarpErrorCodes.h.in1 /** @file ppSubErrorCodes.h.in 2 2 * 3 3 * @brief 4 4 * 5 * @ingroup p swarp5 * @ingroup ppSub 6 6 * 7 7 * @author IfA … … 11 11 */ 12 12 13 #if !defined(P SWARP_ERROR_CODES_H)14 #define P SWARP_ERROR_CODES_H13 #if !defined(PPSUB_ERROR_CODES_H) 14 #define PPSUB_ERROR_CODES_H 15 15 /* 16 16 * The line 17 * P SWARP_ERR_$X{ErrorCode},17 * PPSUB_ERR_$X{ErrorCode}, 18 18 * (without the X) 19 19 * … … 21 21 */ 22 22 typedef enum { 23 P SWARP_ERR_BASE = 14000,24 P SWARP_ERR_${ErrorCode},25 P SWARP_ERR_NERROR26 } p swarpErrorCode;23 PPSUB_ERR_BASE = 14000, 24 PPSUB_ERR_${ErrorCode}, 25 PPSUB_ERR_NERROR 26 } ppSubErrorCode; 27 27 28 void p swarpErrorRegister(void);28 void ppSubErrorRegister(void); 29 29 30 30 #endif -
branches/pap/ppSub/src/ppSubFiles.c
r23711 r23719 12 12 13 13 // Input files 14 static const char *inputFiles[] = { "PPSUB. OUTPUT", "PPSUB.OUTPUT.MASK", "PPSUB.OUTPUT.VARIANCE",15 "PPSUB. OUTPUT.KERNELS", "PPSUB.OUTPUT.JPEG1", "PPSUB.OUTPUT.JPEG2",16 NULL };14 static const char *inputFiles[] = { "PPSUB.INPUT", "PPSUB.INPUT.MASK", "PPSUB.INPUT.VARIANCE", 15 "PPSUB.INPUT.SOURCES", "PPSUB.REF", "PPSUB.REF.MASK", 16 "PPSUB.REF.VARIANCE", "PPSUB.REF.SOURCES", NULL }; 17 17 18 18 // Convolved files … … 23 23 // Subtraction files 24 24 static const char *subFiles[] = { "PPSUB.OUTPUT", "PPSUB.OUTPUT.MASK", "PPSUB.OUTPUT.VARIANCE", 25 "PPSUB.OUTPUT. KERNELS", "PPSUB.OUTPUT.JPEG1", "PPSUB.OUTPUT.JPEG2",25 "PPSUB.OUTPUT.JPEG1", "PPSUB.OUTPUT.JPEG2", 26 26 NULL }; 27 27 … … 30 30 31 31 // Inverse subtraction files 32 static const char *invFiles[] = { "PPSUB.OUTINV", "PPSUB.OUTINV.MASK", "PPSUB.OUTINV.VARIANCE", 33 "PPSUB.OUTINV.KERNELS", "PPSUB.OUTINV.JPEG1", "PPSUB.OUTINV.JPEG2", 34 NULL }; 32 static const char *invFiles[] = { "PPSUB.INVERSE", "PPSUB.INVERSE.MASK", "PPSUB.INVERSE.VARIANCE", NULL }; 35 33 36 34 // Inverse subtraction photometry 37 static const char *subPhotFiles[] = { "PPSUB.OUTINV.SOURCES", NULL }; 35 static const char *invPhotFiles[] = { "PPSUB.INVERSE.SOURCES", NULL }; 36 37 // PSF files 38 static const char *psfFiles[] = { "PSPHOT.PSF.SAVE", NULL }; 38 39 39 40 // Calculation (may be either input or output) files … … 47 48 ) 48 49 { 49 for (int i = 0; imageFiles[i]; i++) {50 pmFPAfileActivate(config->files, files[i], state);50 for (int i = 0; files[i]; i++) { 51 pmFPAfileActivate(config->files, state, files[i]); 51 52 } 52 53 return; … … 62 63 ) 63 64 { 64 for (int i = 0; imageFiles[i]; i++) {65 for (int i = 0; files[i]; i++) { 65 66 pmFPAfile *file = pmFPAfileSelectSingle(config->files, files[i], 0); 66 67 if (file && file->save == save) { 67 pmFPAfileActivate(config->files, files[i], state);68 pmFPAfileActivate(config->files, state, files[i]); 68 69 } 69 70 } … … 76 77 77 78 if (files & PPSUB_FILES_INPUT) { 78 filesActivate( inputFiles, state);79 filesActivate(config, inputFiles, state); 79 80 filesActivateSave(config, calcFiles, false, state); 80 81 } … … 95 96 filesActivate(config, invPhotFiles, state); 96 97 } 98 if (files & PPSUB_FILES_PSF) { 99 filesActivate(config, psfFiles, state); 100 } 97 101 if (files & PPSUB_FILES_PHOT) { 98 psphotFilesActivate(config, false);102 psphotFilesActivate(config, state); 99 103 } 100 104 … … 110 114 } 111 115 112 bool ppSubFilesIterateDown(pmConfig *config )116 bool ppSubFilesIterateDown(pmConfig *config, ppSubFiles files) 113 117 { 114 118 psAssert(config, "Require configuration"); 119 120 ppSubFilesActivate(config, PPSUB_FILES_ALL, false); 121 ppSubFilesActivate(config, files, true); 115 122 116 123 pmFPAview *view = pmFPAviewAlloc(0);// View to FPA top … … 139 146 } 140 147 148 ppSubFilesActivate(config, PPSUB_FILES_ALL, false); 149 141 150 return true; 142 151 } 143 152 144 bool ppSubFilesIterateUp(pmConfig *config )153 bool ppSubFilesIterateUp(pmConfig *config, ppSubFiles files) 145 154 { 146 155 psAssert(config, "Require configuration"); 156 157 ppSubFilesActivate(config, PPSUB_FILES_ALL, false); 158 ppSubFilesActivate(config, files, true); 147 159 148 160 pmFPAview *view = ppSubViewReadout(); // View to readout … … 171 183 } 172 184 185 ppSubFilesActivate(config, PPSUB_FILES_ALL, false); 186 173 187 return true; 174 188 } -
branches/pap/ppSub/src/ppSubLoop.c
r23711 r23719 17 17 #include <pslib.h> 18 18 #include <psmodules.h> 19 #include <ppStats.h>20 19 21 20 #include "ppSub.h" … … 70 69 } 71 70 72 if (!ppSubDefineOutput("PPSUB.OUTPUT", config , data, view)) {71 if (!ppSubDefineOutput("PPSUB.OUTPUT", config)) { 73 72 psError(PS_ERR_UNKNOWN, false, "Unable to define output."); 74 73 return false; 75 74 } 76 75 77 if (!data->quality && !ppSubMakePSF( "PPSUB.OUTPUT", "PPSUB.INVERSE", config, data, view)) {76 if (!data->quality && !ppSubMakePSF(config, data)) { 78 77 psError(PS_ERR_UNKNOWN, false, "Unable to generate PSF."); 79 78 return false; 80 79 } 81 80 82 if (!ppSubReadoutSubtract( "PPSUB.OUTPUT", config, view)) {81 if (!ppSubReadoutSubtract(config)) { 83 82 psError(PS_ERR_UNKNOWN, false, "Unable to subtract images."); 84 83 return false; … … 86 85 87 86 // Close convolved files 88 if (!ppSubFilesIterateUp(config, PPSUB_FILES_ CONV)) {87 if (!ppSubFilesIterateUp(config, PPSUB_FILES_PSF | PPSUB_FILES_CONV)) { 89 88 psError(PPSUB_ERR_IO, false, "Unable to close input files."); 90 89 return false; … … 92 91 93 92 // Higher order background subtraction using psphot 94 if (!ppSubBackground(config , view)) {93 if (!ppSubBackground(config)) { 95 94 psError(PS_ERR_UNKNOWN, false, "Unable to subtract background."); 96 95 return false; 97 96 } 98 97 99 if (!data->quality && ppSubReadoutPhotometry("PPSUB.OUTPUT", PPSUB_FILES_PHOT_SUB, config, data, view)) { 98 if (!ppSubFilesIterateDown(config, PPSUB_FILES_PHOT_SUB)) { 99 psError(PPSUB_ERR_IO, false, "Unable to set up photometry files."); 100 return false; 101 } 102 103 if (!data->quality && !ppSubReadoutPhotometry("PPSUB.OUTPUT", config, data)) { 100 104 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry."); 101 105 return false; 102 106 } 103 107 108 if (!ppSubFilesIterateUp(config, PPSUB_FILES_PHOT_SUB)) { 109 psError(PPSUB_ERR_IO, false, "Unable to set up photometry files."); 110 return false; 111 } 112 104 113 // Perform statistics on the cell 105 if (!ppSubReadoutStats(config, data , view)) {114 if (!ppSubReadoutStats(config, data)) { 106 115 psError(PS_ERR_UNKNOWN, false, "Unable to collect statistics"); 107 116 return false; 108 117 } 109 118 110 if (!ppSubReadoutJpeg( "PPSUB.OUTPUT", config, data, view)) {119 if (!ppSubReadoutJpeg(config)) { 111 120 psError(PS_ERR_UNKNOWN, false, "Unable to update."); 112 121 return false; … … 120 129 } 121 130 122 if (data->inverse && !ppSubDefineOutput("PPSUB.INVERSE", config , data, view)) {131 if (data->inverse && !ppSubDefineOutput("PPSUB.INVERSE", config)) { 123 132 psError(PS_ERR_UNKNOWN, false, "Unable to define inverse."); 124 133 return false; 125 134 } 126 135 127 if (!ppSubReadoutInverse( "PPSUB.INVERSE", "PPSUB.OUTPUT", config, view)) {136 if (!ppSubReadoutInverse(config)) { 128 137 psError(PS_ERR_UNKNOWN, false, "Unable to invert images."); 129 138 return false; … … 136 145 } 137 146 138 if (!data->quality && data->!ppSubReadoutPhotometry("PPSUB.INVERSE", PPSUB_FILES_PHOT_INV, 139 config, data, view)) { 147 if (!ppSubFilesIterateDown(config, PPSUB_FILES_PHOT_INV)) { 148 psError(PPSUB_ERR_IO, false, "Unable to set up inverse files."); 149 return false; 150 } 151 152 if (!data->quality && !ppSubReadoutPhotometry("PPSUB.INVERSE", config, data)) { 140 153 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry."); 141 154 return false; … … 143 156 144 157 // Close inverse subtraction files 145 if (!ppSubFilesIterateUp(config, PPSUB_FILES_INV )) {158 if (!ppSubFilesIterateUp(config, PPSUB_FILES_INV | PPSUB_FILES_PHOT_INV)) { 146 159 psError(PPSUB_ERR_IO, false, "Unable to close subtraction files."); 147 160 return false; … … 155 168 } 156 169 157 psFree(view); 158 159 psString dump_file = psMetadataLookupStr(&mdok, config->arguments, "-dumpconfig"); 170 psString dump_file = psMetadataLookupStr(NULL, config->arguments, "-dumpconfig"); 160 171 if (dump_file) { 161 172 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file … … 164 175 165 176 return true; 166 167 ERROR:168 return false;169 177 } -
branches/pap/ppSub/src/ppSubMakePSF.c
r23688 r23719 22 22 #include "ppSub.h" 23 23 24 bool ppSubMakePSF(pmConfig *config, ppSubData *data , const pmFPAview *view)24 bool ppSubMakePSF(pmConfig *config, ppSubData *data) 25 25 { 26 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view"); 27 28 if (!data->photometry) { 29 return true; 30 } 28 31 29 32 psTimerStart("PPSUB_PHOT"); … … 44 47 pmReadout *minuend = NULL; // Image that will be positive following subtraction 45 48 pmFPAfile *minuendFile = NULL; // File for minuend image 49 pmFPAview *view = ppSubViewReadout(); // View to readout 46 50 if (reverse) { 47 51 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); … … 53 57 54 58 #if 1 59 pmFPAfile *photFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.INPUT"); // Photometry file 60 #if 0 61 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer 55 62 pmReadout *template = minuend; 56 pmFPAfile *photFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.INPUT"); // Photometry file57 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer58 63 if (!photRO) { 59 64 pmCell *cell = pmFPAviewThisCell(view, photFile->fpa); // Cell to photometer … … 74 79 } 75 80 #else 81 if (!pmFPACopy(photFile->fpa, minuendFile->fpa)) { 82 psError(PS_ERR_UNKNOWN, false, "Unable to copy FPA for photometry"); 83 psFree(view); 84 return false; 85 } 86 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer 87 if (psMetadataLookup(photRO->analysis, "PSPHOT.SOURCES")) { 88 psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES"); 89 } 90 #endif 91 92 93 #else 76 94 // Supply the minuend pmFPAfile to psphot as PSPHOT.INPUT: 77 95 psMetadataAddPtr(config->files, PS_LIST_TAIL, "PSPHOT.INPUT", PS_DATA_UNKNOWN | PS_META_REPLACE, … … 87 105 psErrorStackPrint(stderr, "Unable to determine PSF"); 88 106 psWarning("Unable to determine PSF --- suspect bad data quality."); 89 ppSubDataQuality(config, data, PSPHOT_ERR_PSF, PPSUB_FILES_PHOT); 107 ppSubDataQuality(config, data, PSPHOT_ERR_PSF, PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV); 108 psFree(view); 90 109 return true; 91 110 } … … 93 112 // Record the FWHM in the output header 94 113 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); // Output readout 114 psFree(view); 95 115 pmHDU *hdu = pmHDUFromCell(outRO->parent); // HDU with header 96 116 psMetadataItemSupplement(hdu->header, psphotRecipe, "FWHM_MAJ"); … … 100 120 psMetadataRemoveKey(photRO->analysis, "PSPHOT.HEADER"); 101 121 122 data->psf = psMemIncrRefCounter(psMetadataLookupPtr(NULL, photRO->parent->parent->analysis, 123 "PSPHOT.PSF")); 124 102 125 return true; 103 126 } -
branches/pap/ppSub/src/ppSubMatchPSFs.c
r23688 r23719 22 22 #include "ppSub.h" 23 23 24 bool ppSubMatchPSFs(pmConfig *config, ppSubData *data , const pmFPAview *view)24 bool ppSubMatchPSFs(pmConfig *config, ppSubData *data) 25 25 { 26 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view");28 27 29 28 // Look up recipe values 30 29 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim 31 30 psAssert(recipe, "We checked this earlier, so it should be here."); 31 32 pmFPAview *view = ppSubViewReadout(); // View to readout 32 33 33 34 // Input images … … 52 53 pmReadout *kernelRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT.KERNELS"); // RO with kernel 53 54 55 psFree(view); 56 54 57 // Sources in image, used for stamps: these must be loaded from previous analysis stages 55 psArray *inSources = psMetadataLookupPtr(&mdok, inRO->analysis, "PSPHOT.SOURCES"); // Input source list 56 psArray *refSources = psMetadataLookupPtr(&mdok, refRO->analysis, "PSPHOT.SOURCES"); // Ref source list 58 pmReadout *inSourceRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.SOURCES"); 59 pmReadout *refSourceRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.SOURCES"); 60 psArray *inSources = psMetadataLookupPtr(&mdok, inSourceRO->analysis, "PSPHOT.SOURCES"); // Source list 61 psArray *refSources = psMetadataLookupPtr(&mdok, refSourceRO->analysis, "PSPHOT.SOURCES"); // Source list 57 62 58 63 psArray *sources = NULL; // Merged list of sources -
branches/pap/ppSub/src/ppSubReadoutJpeg.c
r23711 r23719 9 9 #include "ppSub.h" 10 10 11 bool ppSubReadoutJpeg(pmConfig *config , ppSubData *data, const pmFPAview *view)11 bool ppSubReadoutJpeg(pmConfig *config) 12 12 { 13 13 psAssert(config, "Require configuration"); 14 psAssert(view, "Require view");15 14 16 bool mdok = false; // Status of MD lookup 15 pmFPAview *view = ppSubViewReadout(); // View to readout 16 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); // Readout to jpeg 17 17 18 18 // Look up recipe values 19 psMetadata *recipe = psMetadataLookupMetadata( &mdok, config->recipes, PPSUB_RECIPE); // Recipe for ppSim19 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim 20 20 psAssert(recipe, "We checked this earlier, so it should be here."); 21 21 22 22 // Generate binned JPEGs 23 { 24 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels 23 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels 25 24 26 int bin1 = psMetadataLookupS32(NULL, recipe, "BIN1"); // First binning level27 int bin2 = psMetadataLookupS32(NULL, recipe, "BIN2"); // Second binning level25 int bin1 = psMetadataLookupS32(NULL, recipe, "BIN1"); // First binning level 26 int bin2 = psMetadataLookupS32(NULL, recipe, "BIN2"); // Second binning level 28 27 29 // Target cells 30 pmCell *cell1 = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.JPEG1"); // Rebinned cell once 31 pmCell *cell2 = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.JPEG2"); // Rebinned cell twice 28 // Target cells 29 pmCell *cell1 = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.JPEG1"); // Rebinned cell once 30 pmCell *cell2 = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.JPEG2"); // Rebinned cell twice 31 psFree(view); 32 32 33 pmReadout *ro1 = pmReadoutAlloc(cell1), *ro2 = pmReadoutAlloc(cell2); // Binned readouts 34 if (!pmReadoutRebin(ro1, outRO, maskBad, bin1, bin1)) { 35 psError(PS_ERR_UNKNOWN, false, "Unable to bin output (1st binning)"); 36 psFree(ro1); 37 psFree(ro2); 38 return false; 39 } 40 if (!pmReadoutRebin(ro2, ro1, 0, bin2, bin2)) { 41 psError(PS_ERR_UNKNOWN, false, "Unable to bin output (2nd binning)"); 42 psFree(ro1); 43 psFree(ro2); 44 return false; 45 } 33 pmReadout *ro1 = pmReadoutAlloc(cell1), *ro2 = pmReadoutAlloc(cell2); // Binned readouts 34 if (!pmReadoutRebin(ro1, outRO, maskBad, bin1, bin1)) { 35 psError(PS_ERR_UNKNOWN, false, "Unable to bin output (1st binning)"); 46 36 psFree(ro1); 47 37 psFree(ro2); 38 return false; 48 39 } 40 if (!pmReadoutRebin(ro2, ro1, 0, bin2, bin2)) { 41 psError(PS_ERR_UNKNOWN, false, "Unable to bin output (2nd binning)"); 42 psFree(ro1); 43 psFree(ro2); 44 return false; 45 } 46 psFree(ro1); 47 psFree(ro2); 49 48 50 49 return true; -
branches/pap/ppSub/src/ppSubReadoutPhotometry.c
r23688 r23719 22 22 #include "ppSub.h" 23 23 24 bool ppSubReadoutPhotometry (pmConfig *config, ppSubData *data, const pmFPAview *view)24 bool ppSubReadoutPhotometry(const char *name, pmConfig *config, ppSubData *data) 25 25 { 26 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view"); 27 28 if (!data->photometry) { 29 return false; 30 } 28 31 29 32 // Look up recipe values … … 39 42 // The PSF (measured in ppSubMakePSF) is stored on the chip->analysis of PSPHOT.INPUT 40 43 // In order to use an incoming PSF, it must be stored on the chip->analysis of PSPHOT.PSF.LOAD 44 pmFPAview *view = ppSubViewReadout(); // View to readout 41 45 pmChip *psfInputChip = pmFPAfileThisChip(config->files, view, "PSPHOT.INPUT"); // Chip with PSF 42 46 psAssert (psfInputChip, "should have been generated for ppSubMakePSF"); … … 47 51 psErrorStackPrint(stderr, "No PSF available"); 48 52 psWarning("No PSF available --- suspect bad data quality."); 49 ppSubDataQuality(config, data, psErrorCodeLast(), PPSUB_FILES_PHOT );53 ppSubDataQuality(config, data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV); 50 54 return true; 51 55 } … … 58 62 // around the pointers so PSPHOT.INPUT corresponds to the output image; previously, it was 59 63 // equivalent to the minuend image. 60 pmFPAfile *outputFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.OUTPUT"); // Output file 61 pmReadout *outRO = pmFPAviewThisReadout(view, outputFile->fpa); // Readout with the sources 64 pmReadout *inRO = pmFPAfileThisReadout(config->files, view, name); // Readout with image and sources 62 65 63 // XXX possibly rename this to PPSUB.RESID?64 66 pmFPAfile *photFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.INPUT"); // Photometry file 65 67 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer … … 68 70 photRO = pmReadoutAlloc(cell); // Output readout: subtraction 69 71 } 70 photRO->image = psImageCopy(photRO->image, outRO->image, PS_TYPE_F32);71 if ( outRO->variance) {72 photRO->variance = psImageCopy(photRO->variance, outRO->variance, PS_TYPE_F32);72 photRO->image = psImageCopy(photRO->image, inRO->image, PS_TYPE_F32); 73 if (inRO->variance) { 74 photRO->variance = psImageCopy(photRO->variance, inRO->variance, PS_TYPE_F32); 73 75 } else { 74 76 psFree(photRO->variance); 75 77 photRO->variance = NULL; 76 78 } 77 if ( outRO->mask) {78 photRO->mask = psImageCopy(photRO->mask, outRO->mask, PS_TYPE_IMAGE_MASK);79 if (inRO->mask) { 80 photRO->mask = psImageCopy(photRO->mask, inRO->mask, PS_TYPE_IMAGE_MASK); 79 81 } else { 80 82 psFree(photRO->mask); 81 83 photRO->mask = NULL; 82 84 } 85 psMetadataAddPtr(photRO->parent->parent->analysis, PS_LIST_TAIL, "PSPHOT.PSF", 86 PS_META_REPLACE | PS_DATA_UNKNOWN, "Point-spread function", data->psf); 87 88 psFree(photRO->analysis); 89 photRO->analysis = psMetadataAlloc(); 83 90 84 91 if (!psphotReadoutMinimal(config, view)) { … … 87 94 psErrorStackPrint(stderr, "Unable to perform photometry on image"); 88 95 psWarning("Unable to perform photometry on image --- suspect bad data quality."); 89 ppSubDataQuality(config, data, psErrorCodeLast(), PPSUB_FILES_PHOT );96 ppSubDataQuality(config, data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV); 90 97 } 91 98 92 photRO->data_exists = true; 93 photRO->parent->data_exists = true; 94 photRO->parent->parent->data_exists = true; 99 if (!data->quality && !psMetadataCopySingle(inRO->analysis, photRO->analysis, "PSPHOT.SOURCES")) { 100 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to copy PSPHOT.SOURCES"); 101 return false; 102 } 95 103 96 104 if (data->stats) { 97 105 psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources 98 psMetadataAddS32(data->stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected", 99 sources ? sources->n : 0); 100 psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_PHOT", 0, "Time to do photometry", 101 psTimerClear("PPSUB_PHOT")); 106 bool mdok; 107 int numSources = psMetadataLookupS32(&mdok, data->stats, "NUM_SOURCES"); // Number of sources 108 numSources += sources ? sources->n : 0; 109 psMetadataAddS32(data->stats, PS_LIST_TAIL, "NUM_SOURCES", PS_META_REPLACE, 110 "Total number of sources detected", numSources); 111 float newTime = psTimerClear("PPSUB_PHOT"); // Time for photometry 112 float oldTime = psMetadataLookupF32(&mdok, data->stats, "TIME_PHOT"); // Previous time for photometry 113 psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_PHOT", PS_META_REPLACE, "Time to do photometry", 114 isfinite(oldTime) ? oldTime + newTime : newTime); 102 115 } 103 116 -
branches/pap/ppSub/src/ppSubReadoutStats.c
r23711 r23719 1 #ifdef HAVE_CONFIG_H 2 #include <config.h> 3 #endif 1 4 2 bool ppSubReadoutStats(pmConfig *config, ppSubData *data, const pmFPAview *view) 5 #include <pslib.h> 6 #include <psmodules.h> 7 #include <ppStats.h> 8 9 #include "ppSub.h" 10 11 12 bool ppSubReadoutStats(pmConfig *config, ppSubData *data) 3 13 { 4 14 psAssert(config, "Require configuration"); 5 15 psAssert(data, "Require data"); 6 psAssert(view, "Require view");7 16 8 17 if (!data->statsFile) { … … 14 23 if (!output) { 15 24 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find file PPSUB.OUTPUT.\n"); 16 goto ERROR;25 return false; 17 26 } 18 27 psImageMaskType maskValue = pmConfigMaskGet("MASK.VALUE", config); 28 pmFPAview *view = ppSubViewReadout(); // View to readout 19 29 ppStatsFPA(data->stats, output->fpa, view, maskValue, config); 30 31 pmReadout *outRO = pmFPAviewThisReadout(view, output->fpa); // Readout of interest 32 psFree(view); 20 33 21 34 // Statistics on the matching -
branches/pap/ppSub/src/ppSubReadoutSubtract.c
r23642 r23719 23 23 #define WCS_TOLERANCE 0.001 // Tolerance for WCS 24 24 25 bool ppSubReadoutSubtract(pmConfig *config , const pmFPAview *view)25 bool ppSubReadoutSubtract(pmConfig *config) 26 26 { 27 27 psAssert(config, "Require configuration"); 28 psAssert(view, "Require view");29 30 28 31 29 // Look up recipe values … … 35 33 36 34 bool reverse = psMetadataLookupBool(&mdok, config->arguments, "REVERSE"); // Reverse sense of subtraction? 35 36 pmFPAview *view = ppSubViewReadout(); // View to readout 37 37 38 38 // Subtraction is: minuend - subtrahend … … 91 91 psError(PS_ERR_UNKNOWN, false, "Unable to copy concepts from input to output."); 92 92 psFree(outRO); 93 psFree(view); 93 94 return false; 94 95 } … … 99 100 pmHDU *outHDU = outFPA->hdu; // Output HDU 100 101 pmChip *outChip = pmFPAfileThisChip(config->files, view, "PPSUB.OUTPUT"); // Output chip 102 psFree(view); 101 103 if (!outHDU || !inHDU) { 102 104 psError(PS_ERR_UNKNOWN, false, "Unable to find HDU at FPA level to copy astrometry."); -
branches/pap/ppSub/src/ppSubReadoutUpdate.c
r23711 r23719 20 20 21 21 #include "ppSub.h" 22 23 bool ppSubReadoutUpdate(pmConfig *config, ppSubData *data, const pmFPAview *view)24 {25 psAssert(config, "Require configuration");26 psAssert(view, "Require view");27 28 bool mdok = false; // Status of MD lookup29 30 // Look up recipe values31 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSUB_RECIPE); // Recipe for ppSim32 psAssert(recipe, "We checked this earlier, so it should be here.");33 34 // Generate binned JPEGs35 {36 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels37 38 int bin1 = psMetadataLookupS32(NULL, recipe, "BIN1"); // First binning level39 int bin2 = psMetadataLookupS32(NULL, recipe, "BIN2"); // Second binning level40 41 // Target cells42 pmCell *cell1 = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.JPEG1"); // Rebinned cell once43 pmCell *cell2 = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.JPEG2"); // Rebinned cell twice44 45 pmReadout *ro1 = pmReadoutAlloc(cell1), *ro2 = pmReadoutAlloc(cell2); // Binned readouts46 if (!pmReadoutRebin(ro1, outRO, maskBad, bin1, bin1)) {47 psError(PS_ERR_UNKNOWN, false, "Unable to bin output (1st binning)");48 psFree(ro1);49 psFree(ro2);50 return false;51 }52 if (!pmReadoutRebin(ro2, ro1, 0, bin2, bin2)) {53 psError(PS_ERR_UNKNOWN, false, "Unable to bin output (2nd binning)");54 psFree(ro1);55 psFree(ro2);56 return false;57 }58 psFree(ro1);59 psFree(ro2);60 }61 62 return true;63 } -
branches/pap/ppSub/src/ppSubSetMasks.c
r23535 r23719 22 22 #include "ppSub.h" 23 23 24 bool ppSubSetMasks(pmConfig *config , const pmFPAview *view)24 bool ppSubSetMasks(pmConfig *config) 25 25 { 26 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view");28 27 29 28 psImageMaskType maskValue, markValue; // Mask values … … 50 49 psAssert(lowValue, "LOW or BAD must be non-zero"); 51 50 52 // input images 51 // Input images 52 pmFPAview *view = ppSubViewReadout(); // View to readout 53 53 pmReadout *inRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT"); // Input readout 54 54 pmReadout *refRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF"); // Reference readout
Note:
See TracChangeset
for help on using the changeset viewer.
