Changeset 25930
- Timestamp:
- Oct 22, 2009, 4:54:27 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 11 edited
-
ppImage/src/Makefile.am (modified) (1 diff)
-
ppImage/src/ppImage.h (modified) (1 diff)
-
ppImage/src/ppImageDetrendFringe.c (modified) (4 diffs)
-
ppImage/src/ppImageDetrendPattern.c (added)
-
ppImage/src/ppImageDetrendReadout.c (modified) (1 diff)
-
ppImage/src/ppImageLoop.c (modified) (1 diff)
-
ppImage/src/ppImageOptions.c (modified) (1 diff)
-
psModules/src/concepts/pmConcepts.c (modified) (2 diffs)
-
psModules/src/concepts/pmConceptsRead.c (modified) (1 diff)
-
psModules/src/concepts/pmConceptsStandard.c (modified) (2 diffs)
-
psModules/src/concepts/pmConceptsStandard.h (modified) (1 diff)
-
psModules/src/detrend/pmFringeStats.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/Makefile.am
r25299 r25930 41 41 ppImageDetrendFringe.c \ 42 42 ppImageDetrendFree.c \ 43 ppImageDetrendPattern.c \ 43 44 ppImageRebinReadout.c \ 44 45 ppImageMosaic.c \ -
trunk/ppImage/src/ppImage.h
r25875 r25930 159 159 bool ppImageBurntoolMask(pmConfig *config, ppImageOptions *options, pmFPAview *view, pmReadout *mask); 160 160 161 bool ppImageDetrendPatternApply(pmConfig *config, pmChip *chip, const pmFPAview *inputView, const ppImageOptions *options); 162 161 163 // Record which detrend file was used for the detrending 162 164 bool ppImageDetrendRecord( -
trunk/ppImage/src/ppImageDetrendFringe.c
r24911 r25930 84 84 psArray *cells = chip->cells; // Component cells 85 85 psArray *fringes = psArrayAlloc(cells->n); // Fringes, to return 86 int video_cell_zero = 0; 87 86 88 for (int i = 0; i < cells->n; i++) { 87 89 fringes->data[i] = NULL; … … 89 91 pmCell *cell = cells->data[i]; // Cell of interest 90 92 93 psTrace("psModules.detrend",7,"Readouts: Cell %d chip: %ld\n",i,cell->readouts->n); 91 94 // XXX for now, skip the video cells (cell->readouts->n > 1) 92 if (cell->readouts->n > 1) { 93 psWarning ("Skipping Video Cell (%d) for ppImageDetrendFringe.c:getFringes", i); 94 continue; 95 } 96 95 // CZW: This mess creates a fake set of fringe stats by stealing the previous one. 96 // We let the fitting code know that this is all lies by scaling the weights by a crazy amount. 97 98 if ( (cell->readouts->n > 1) ) { 99 psTrace("psModules.detrend",7,"Should be skipping scichip: %d\n",i); 100 psWarning ("Skipping Video Cell (%d) for ppImageDetrendFringe.c:getFringes", i); 101 102 if (i == 0) { 103 video_cell_zero = 1; 104 } 105 else { 106 pmFringeStats *prevFringe = fringes->data[i-1]; 107 pmFringeStats *fringe = pmFringeStatsAlloc(prevFringe->regions); 108 for (int j = 0; j < fringe->regions->nRequested; j++) { 109 fringe->f->data.F32[j] = prevFringe->f->data.F32[j]; 110 fringe->df->data.F32[j] = prevFringe->df->data.F32[j] / 1e6; 111 } 112 fringes->data[i] = fringe; 113 } 114 115 continue; 116 } 117 97 118 fringes->data[i] = psMemIncrRefCounter(psMetadataLookupPtr(NULL, cell->analysis, source)); 98 119 } 99 120 121 if (video_cell_zero == 1) { 122 pmFringeStats *prevFringe = fringes->data[1]; 123 pmFringeStats *fringe = pmFringeStatsAlloc(prevFringe->regions); 124 for (int j = 0; j < fringe->regions->nRequested; j++) { 125 fringe->f->data.F32[j] = NAN; 126 fringe->df->data.F32[j] = 1.0; 127 } 128 fringes->data[0] = fringe; 129 } 130 100 131 return fringes; 101 132 } … … 112 143 psArray *science = NULL; 113 144 if (isResidual) { 114 science = getFringes(scienceChip, "FRINGE.RESIDUALS"); // Fringe residuals on science chip145 science = getFringes(scienceChip, "FRINGE.RESIDUALS"); // Fringe residuals on science chip 115 146 } else { 116 147 science = getFringes(scienceChip, "FRINGE.MEASUREMENTS"); // Fringe measurements on science chip … … 124 155 psArray *references = getFringes(refChip, "FRINGE.MEASUREMENTS"); // Fringe measurements on reference chip 125 156 int numRefs = ((psArray*)references->data[0])->n; // Number of reference fringes 126 psArray *referencesCat = psArrayAlloc(numRefs); // Reference fringes 127 for (int i = 0; i < numRefs; i++) { // Iterate over fringes 128 psArray *refs = psArrayAlloc(references->n); // Array of fringes for each cell 129 for (int j = 0; j < references->n; j++) { // Iterate over cells 130 psArray *ref = references->data[j]; // Array of references for this cell 157 psArray *referencesCat = psArrayAlloc(numRefs); // Reference fringes 158 for (int i = 0; i < numRefs; i++) { // Iterate over fringes 159 psArray *refs = psArrayAlloc(references->n); // Array of fringes for each cell 160 for (int j = 0; j < references->n; j++) { // Iterate over cells 161 psArray *ref = references->data[j]; // Array of references for this cell 162 131 163 refs->data[j] = psMemIncrRefCounter(ref->data[i]); 132 164 } 133 referencesCat->data[i] = pmFringeStatsConcatenate(refs, NULL, NULL);165 referencesCat->data[i] = pmFringeStatsConcatenate(refs, NULL, NULL); 134 166 psFree(refs); 135 167 } -
trunk/ppImage/src/ppImageDetrendReadout.c
r25299 r25930 128 128 } 129 129 130 // Pattern noise correction 131 if (options->doPattern) { 132 if (!pmPatternRow(input, options->patternOrder, options->patternIter, options->patternRej, 133 options->patternThresh, options->patternMean, options->patternStdev, 134 options->maskValue, options->darkMask)) { 135 psFree(detview); 136 return false; 137 } 138 } 130 /* // Pattern noise correction */ 131 /* if (options->doPattern) { */ 132 /* if (!pmPatternRow(input, options->patternOrder, options->patternIter, options->patternRej, */ 133 /* options->patternThresh, options->patternMean, options->patternStdev, */ 134 /* options->maskValue, options->darkMask)) { */ 135 /* psFree(detview); */ 136 /* return false; */ 137 /* } */ 138 /* } */ 139 139 140 140 // Normalization by a single (known) constant -
trunk/ppImage/src/ppImageLoop.c
r25875 r25930 163 163 } 164 164 165 // Apply the pattern noise correction 166 if (options->doPattern) { 167 if (!ppImageDetrendPatternApply(config,chip,view,options)) { 168 ESCAPE("Unable to apply pattern corrections"); 169 } 170 } 171 165 172 // measure various pixel-based statistics for this image 166 173 if (!ppImagePixelStats(config, stats, options, view)) { -
trunk/ppImage/src/ppImageOptions.c
r25324 r25930 249 249 250 250 options->burntoolTrails = psMetadataLookupS32(&status, recipe, "BURNTOOL.TRAILS"); 251 fprintf(stderr,"TRAILS: %d %d %d\n",options->burntoolTrails,psMetadataLookupS32(&status,recipe,"BURNTOOL.TRAILS"),status); 251 psTrace("psModules.detrend", 7, "burntoolTrails: %d BURNTOOL.TRAILS: %d Status: %d\n", 252 options->burntoolTrails,psMetadataLookupS32(&status,recipe,"BURNTOOL.TRAILS"),status); 252 253 if (!status) { 253 254 psWarning("BURNTOOL.TRAILS not found in recipe: setting to default value.\n"); -
trunk/psModules/src/concepts/pmConcepts.c
r25882 r25930 249 249 CONCEPT_REGISTER_FUNCTION(S32, Enum, -1); // For enums: set default to -1 250 250 CONCEPT_REGISTER_FUNCTION(S32, S32, 0); // For values: set default to 0 251 //CONCEPT_REGISTER_FUNCTION(Bool, Bool, NULL); // For values: set default to 0 251 252 252 253 static void conceptRegisterTime(const char *name, /* Name of concept */ \ … … 333 334 conceptRegisterF32("FPA.TELTEMP.EXTRA", "Telescope Temperatures: extra", p_pmConceptParse_TELTEMPS, NULL, NULL, false, PM_FPA_LEVEL_FPA); 334 335 conceptRegisterF32("FPA.PON.TIME", "Power On Time", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA); 335 conceptRegisterS32("FPA.BURNTOOL.APPLIED", "Status of burntool processing", p_pmConceptParse_BTOOLAPP,NULL,NULL,false,PM_FPA_LEVEL_FPA); 336 conceptRegisterS32("FPA.BURNTOOL.APPLIED", "Status of burntool processing", p_pmConceptParse_BTOOLAPP,p_pmConceptFormat_BTOOLAPP,NULL,false,PM_FPA_LEVEL_FPA); 337 // conceptRegisterBool("FPA.BURNTOOL.APPLIED", "Status of burntool processing", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA); 336 338 conceptRegisterF32("FPA.EXPOSURE", "Exposure time (sec)", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA); 337 339 } -
trunk/psModules/src/concepts/pmConceptsRead.c
r25425 r25930 47 47 case PS_DATA_F64: 48 48 return psMetadataItemAllocF64(pattern->name, pattern->comment, psMetadataItemParseF64(concept)); 49 case PS_DATA_BOOL: 50 return psMetadataItemAllocBool(pattern->name, pattern->comment, psMetadataItemParseBool(concept)); 49 51 default: 50 52 psWarning("Concept %s (%s) is not of a standard type (%x)\n", -
trunk/psModules/src/concepts/pmConceptsStandard.c
r25882 r25930 753 753 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Type for %s (%x) is not BOOL\n", 754 754 concept->name, concept->type); 755 return NULL; 755 if (concept->type != PS_DATA_S32) { 756 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Wasn't the type I'd guessed either.\n"); 757 return NULL; 758 } 759 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Looks like an S32 value? (%d)\n", 760 concept->data.S32); 761 762 if (concept->data.S32 == 0) { 763 bt_status = 1; 764 } 765 else if (concept->data.S32 == 1) { 766 bt_status = -2; 767 } 756 768 } 757 769 … … 765 777 return psMetadataItemAllocS32(concept->name, concept->comment, bt_status); 766 778 } 779 psMetadataItem *p_pmConceptFormat_BTOOLAPP(const psMetadataItem *concept, 780 pmConceptSource source, 781 const psMetadata *cameraFormat, 782 const pmFPA *fpa, 783 const pmChip *chip, 784 const pmCell *cell) 785 { 786 assert(concept); 787 788 if (concept->type != PS_DATA_S32) { 789 return NULL; 790 } 791 792 if (concept->data.S32 == 0) { 793 return NULL; 794 } 795 else if (concept->data.S32 == -2) { 796 return psMetadataItemAllocBool(concept->name,concept->comment,true); 797 } 798 else if (concept->data.S32 == 1) { 799 return psMetadataItemAllocBool(concept->name,concept->comment,false); 800 } 801 else { 802 return NULL; 803 } 804 805 } 806 767 807 768 808 // Get the current value of a concept -
trunk/psModules/src/concepts/pmConceptsStandard.h
r25882 r25930 146 146 const pmCell *cell ///< Cell for concept, or NULL 147 147 ); 148 psMetadataItem *p_pmConceptFormat_BTOOLAPP( 149 const psMetadataItem *concept, ///< Concept to format 150 pmConceptSource source, ///< Source for concept 151 const psMetadata *cameraFormat, ///< Camera format definition 152 const pmFPA *fpa, ///< FPA for concept, or NULL 153 const pmChip *chip, ///< Chip for concept, or NULL 154 const pmCell *cell ///< Cell for concept, or NULL 155 ); 148 156 149 157 -
trunk/psModules/src/detrend/pmFringeStats.c
r24912 r25930 11 11 #include "pmFPA.h" 12 12 #include "pmFringeStats.h" 13 14 #include "psPolynomialMD.h" 15 #include "psMinimizePolyFit.h" 16 #include "psVector.h" 17 13 18 14 19 // Future optimisations for speed: … … 331 336 dfPt[i] = 1.0 / medianSd->sampleStdev; 332 337 333 psTrace("psModules.detrend", 7, "[%d:%d,%d:%d]: %f %f \n", (int)region.x0, (int)region.x1,334 (int)region.y0, (int)region.y1, fPt[i], dfPt[i] );338 psTrace("psModules.detrend", 7, "[%d:%d,%d:%d]: %f %f : %s\n", (int)region.x0, (int)region.x1, 339 (int)region.y0, (int)region.y1, fPt[i], dfPt[i], readout->parent->hdu->extname); 335 340 } 336 341 psFree(sky); … … 840 845 } 841 846 } 842 B->data.F64[i] = vector;847 B->data.F64[i] = vector; 843 848 } 844 849 … … 966 971 } 967 972 } 973 968 974 } 969 975 … … 988 994 psTrace("psModules.detrend", 9, "Masking region %d because not finite in fringe %d.\n", j, i); 989 995 } 990 } 991 } 992 996 else if (fabs(fringe->f->data.F32[j]) > 0.1) { 997 mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 1; 998 psTrace("psModules.detrend", 9, "Masking region %d because too large fringe %d.\n", j, i); 999 } 1000 // Mask bad points in the science data as well. 1001 if ((i == 0) && (!isfinite(science->f->data.F32[j]))) { 1002 mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 1; 1003 psTrace("psModules.detrend", 9, "Masking region %d because not finite in science fringe %d.\n", j, i); 1004 } 1005 psTrace("psModules.detrend", 7, "F %f %f %f %d\n", 1006 fringe->f->data.F32[j], science->f->data.F32[j], 1007 1 / science->df->data.F32[j],(int) mask->data.PS_TYPE_VECTOR_MASK_DATA[j]); 1008 } 1009 } 1010 1011 /* // Begin switch from old outlier removal and fitting code. */ 1012 1013 psPolynomial1D *poly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, 1); 1014 1015 pmFringeStats *fringe = fringes->data[0]; 1016 psVector *errors = psVectorAlloc(science->df->n,PS_TYPE_F32); 1017 for (int j = 0; j < errors->n; j++) { 1018 errors->data.F32[j] = 1 / science->df->data.F32[j]; 1019 } 1020 psVectorFitPolynomial1D(poly,mask,0xff,science->f,errors,fringe->f); 1021 1022 for (int i = 0; i <= poly->nX; i++) { 1023 scale->coeff->data.F32[i] = poly->coeff[i]; 1024 psTrace("psModules.detrend",7,"COEFFS: %d %g %g %g\n",i,scale->coeff->data.F32[i],poly->coeff[i],poly->coeffErr[i]); 1025 } 1026 1027 psFree(poly); 1028 // psFree(fringe); 1029 psFree(errors); 1030 1031 psFree(median); 1032 psFree(diff); 1033 return scale; 1034 // End switch from old code. 1035 1036 1037 993 1038 # if (0) 994 1039 // Write fringe data to file for a test … … 1019 1064 } 1020 1065 scale->coeff->data.F32[0] -= median->sampleMedian; 1021 scale->coeff->data.F32[i] = 0.0; 1066 if (i != 0) { 1067 scale->coeff->data.F32[i] = 0.0; 1068 } 1022 1069 } 1023 1070 psFree(median); … … 1051 1098 1052 1099 return scale; 1100 //# endif 1053 1101 } 1054 1102
Note:
See TracChangeset
for help on using the changeset viewer.
