Changeset 30118 for branches/czw_branch/20101203/psModules
- Timestamp:
- Dec 20, 2010, 2:30:45 PM (16 years ago)
- Location:
- branches/czw_branch/20101203
- Files:
-
- 17 edited
-
. (modified) (1 prop)
-
psModules/src/camera/pmFPAFlags.c (modified) (2 diffs)
-
psModules/src/camera/pmFPAFlags.h (modified) (2 diffs)
-
psModules/src/camera/pmFPAfile.c (modified) (1 diff)
-
psModules/src/camera/pmFPAfileIO.c (modified) (8 diffs)
-
psModules/src/concepts/pmConceptsAverage.c (modified) (4 diffs)
-
psModules/src/config/pmConfigDump.c (modified) (1 diff)
-
psModules/src/detrend/pmNonLinear.c (modified) (4 diffs)
-
psModules/src/objects (modified) (1 prop)
-
psModules/src/objects/pmPSF_IO.c (modified) (3 diffs)
-
psModules/src/objects/pmPSFtry.h (modified) (2 diffs)
-
psModules/src/objects/pmPSFtryMakePSF.c (modified) (10 diffs)
-
psModules/src/objects/pmPSFtryModel.c (modified) (2 diffs)
-
psModules/src/objects/pmSource.c (modified) (1 diff)
-
psModules/src/objects/pmSourcePhotometry.c (modified) (2 diffs)
-
psModules/src/objects/pmTrend2D.c (modified) (4 diffs)
-
psModules/src/objects/pmTrend2D.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20101203
- Property svn:mergeinfo changed
-
branches/czw_branch/20101203/psModules/src/camera/pmFPAFlags.c
r15477 r30118 49 49 } 50 50 51 bool pmReadoutSetFileStatus(pmReadout *readout, bool status) 52 { 53 PS_ASSERT_PTR_NON_NULL(readout, false); 54 55 readout->file_exists = status; 56 return true; 57 } 58 59 bool pmFPAviewSetFileStatus (pmFPA *fpa, const pmFPAview *view, bool status) { 60 61 PS_ASSERT_PTR_NON_NULL(fpa, false); 62 PS_ASSERT_PTR_NON_NULL(view, false); 63 64 if (view->chip == -1) { 65 bool set = pmFPASetFileStatus (fpa, status); 66 return set; 67 } 68 69 if (view->chip >= fpa->chips->n) { 70 psError(PS_ERR_IO, true, "Requested chip == %d >= fpa->chips->n == %ld", view->chip, fpa->chips->n); 71 return false; 72 } 73 pmChip *chip = fpa->chips->data[view->chip]; 74 75 if (view->cell == -1) { 76 bool set = pmChipSetFileStatus (chip, status); 77 return set; 78 } 79 80 if (view->cell >= chip->cells->n) { 81 psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %ld", view->cell, chip->cells->n); 82 return false; 83 } 84 pmCell *cell = chip->cells->data[view->cell]; 85 86 if (view->readout == -1) { 87 bool set = pmCellSetFileStatus (cell, status); 88 return set; 89 } 90 91 if (view->readout >= cell->readouts->n) { 92 psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouds->n == %ld", view->readout, cell->readouts->n); 93 return false; 94 } 95 pmReadout *readout = cell->readouts->data[view->readout]; 96 97 bool set = pmReadoutSetFileStatus (readout, status); 98 return set; 99 } 100 51 101 bool pmFPACheckFileStatus(const pmFPA *fpa) 52 102 { … … 125 175 for (int i = 0; i < cell->readouts->n; i++) { 126 176 pmReadout *readout = cell->readouts->data[i]; 127 readout->data_exists = status; 128 } 129 return true; 177 pmReadoutSetDataStatus(readout, status); 178 } 179 return true; 180 } 181 182 bool pmReadoutSetDataStatus (pmReadout *readout, bool status) 183 { 184 PS_ASSERT_PTR_NON_NULL(readout, false); 185 186 readout->data_exists = status; 187 return true; 188 } 189 190 bool pmFPAviewSetDataStatus (pmFPA *fpa, const pmFPAview *view, bool status) { 191 192 PS_ASSERT_PTR_NON_NULL(fpa, false); 193 PS_ASSERT_PTR_NON_NULL(view, false); 194 195 if (view->chip == -1) { 196 bool set = pmFPASetDataStatus (fpa, status); 197 return set; 198 } 199 200 if (view->chip >= fpa->chips->n) { 201 psError(PS_ERR_IO, true, "Requested chip == %d >= fpa->chips->n == %ld", view->chip, fpa->chips->n); 202 return false; 203 } 204 pmChip *chip = fpa->chips->data[view->chip]; 205 206 if (view->cell == -1) { 207 bool set = pmChipSetDataStatus (chip, status); 208 return set; 209 } 210 211 if (view->cell >= chip->cells->n) { 212 psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %ld", view->cell, chip->cells->n); 213 return false; 214 } 215 pmCell *cell = chip->cells->data[view->cell]; 216 217 if (view->readout == -1) { 218 bool set = pmCellSetDataStatus (cell, status); 219 return set; 220 } 221 222 if (view->readout >= cell->readouts->n) { 223 psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouds->n == %ld", view->readout, cell->readouts->n); 224 return false; 225 } 226 pmReadout *readout = cell->readouts->data[view->readout]; 227 228 bool set = pmReadoutSetDataStatus (readout, status); 229 return set; 130 230 } 131 231 -
branches/czw_branch/20101203/psModules/src/camera/pmFPAFlags.h
r13190 r30118 34 34 ); 35 35 36 bool pmReadoutSetFileStatus(pmReadout *readout, bool status); 37 38 bool pmFPAviewSetFileStatus (pmFPA *fpa, const pmFPAview *view, bool status); 39 36 40 // Functions to check the file_exists flags 37 41 … … 65 69 ); 66 70 71 bool pmReadoutSetDataStatus (pmReadout *readout, bool status); 72 73 bool pmFPAviewSetDataStatus (pmFPA *fpa, const pmFPAview *view, bool status); 67 74 68 75 // Functions the check the data_exists flags -
branches/czw_branch/20101203/psModules/src/camera/pmFPAfile.c
r29833 r30118 36 36 return; 37 37 } 38 psTrace ("pmFPAfileFree", 5, "freeing %s % ld\n", file->name,(psU64)file->fits);38 psTrace ("pmFPAfileFree", 5, "freeing %s %p\n", file->name, file->fits); 39 39 psAssert(!fpaFileFreeStrict || file->fits == NULL, "File %s wasn't closed.", file->name); 40 40 -
branches/czw_branch/20101203/psModules/src/camera/pmFPAfileIO.c
r29833 r30118 135 135 PS_ASSERT_PTR_NON_NULL(view, false); 136 136 137 // an internal file should not be sent here (should not be left on config->files)138 PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);139 140 137 // skip the following states 141 138 if (file->state & PM_FPA_STATE_INACTIVE) { … … 143 140 return true; 144 141 } 142 143 // an active internal file should not be sent here (should not be left on config->files) 144 PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false); 145 145 146 if (file->mode != PM_FPA_MODE_READ) { 146 147 psTrace("psModules.camera", 6, "skip read for %s, mode is not READ", file->name); … … 258 259 return true; 259 260 } 261 262 // an active internal file should not be returned to here 263 PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false); 264 260 265 if (file->mode != PM_FPA_MODE_WRITE) { 261 266 psTrace("psModules.camera", 6, "skip create for non-write file %s", file->name); 262 267 return true; 263 268 } 264 265 // an internal file should not be returned to here266 PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);267 269 268 270 // get the current level … … 335 337 } 336 338 339 // an ACTIVE internal file should not be sent here 340 PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false); 341 337 342 if (file->mode != PM_FPA_MODE_WRITE) { 338 343 psTrace("psModules.camera", 6, "skip write for %s, mode is not WRITE", file->name); 339 344 return true; 340 }341 342 // an internal file should not be returned to here343 if (file->mode == PM_FPA_MODE_INTERNAL) {344 psError(PS_ERR_IO, true, "File is mode PM_FPA_MODE_INTERNAL");345 return false;346 345 } 347 346 … … 523 522 PS_ASSERT_PTR_NON_NULL(view, false); 524 523 525 // an internal file should not be sent here (should not be left on config->files)526 PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);527 528 524 // skip the following states 529 525 if (file->state & PM_FPA_STATE_INACTIVE) { … … 531 527 return true; 532 528 } 529 533 530 if (file->state == PM_FPA_STATE_CLOSED) { 534 531 psTrace("psModules.camera", 6, "skip close for %s, files is closed", file->name); 535 532 return true; 536 533 } 534 535 // an active internal file should not be sent here (should not be left on config->files) 536 PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false); 537 537 538 538 // is current level == open level? … … 596 596 PS_ASSERT_PTR_NON_NULL(view, false); 597 597 598 // an internal file should not be sent here (should not be left on config->files)599 PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);600 601 598 if (file->state & PM_FPA_STATE_INACTIVE) { 602 599 psTrace("psModules.camera", 6, "skip free for %s, files is inactive", file->name); 603 600 return true; 604 601 } 602 603 // an active internal file should not be sent here (should not be left on config->files) 604 PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false); 605 605 606 606 // get the current level … … 746 746 } 747 747 748 // these are programming errors748 // an ACTIVE internal file should not be sent here 749 749 PS_ASSERT(file->mode != PM_FPA_MODE_NONE, false); 750 750 PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false); -
branches/czw_branch/20101203/psModules/src/concepts/pmConceptsAverage.c
r29603 r30118 136 136 return average; 137 137 } 138 float medianWithDropouts (psList *sources, char *name) { 139 140 bool status; 141 142 psListIterator *sourcesIter = psListIteratorAlloc(sources, PS_LIST_HEAD, false); // Iterator for sources 143 pmCell *cell = NULL; // Source cell from iteration 144 145 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 146 psVector *values = psVectorAlloc(sources->n, PS_TYPE_F32); 147 int nvalues = 0; 148 while ((cell = psListGetAndIncrement(sourcesIter))) { 149 if (!cell) { 150 continue; 151 } 152 153 float value = psMetadataLookupF32(&status, cell->concepts, name); 154 if (!status) continue; 155 if (!isfinite(value)) continue; 156 157 values->data.F32[nvalues++] = value; 158 } 159 psFree (sourcesIter); 160 if (!nvalues) { 161 psWarning("no valid values found for %s\n", name); 162 psFree(values); 163 psFree(stats); 164 return INFINITY; 165 } 166 if (!(values = psVectorRealloc(values, nvalues))) { 167 psWarning("failed to reallocate values vector for %s\n", name); 168 psFree(stats); 169 return INFINITY; 170 } 171 if (!psVectorStats(stats, values, NULL, NULL, 0)) { 172 psWarning("psVectorStats failed for %s\n", name); 173 psFree(values); 174 psFree(stats); 175 return INFINITY; 176 } 177 178 psF32 median = psStatsGetValue(stats, PS_STAT_SAMPLE_MEDIAN); 179 180 psFree(values); 181 psFree(stats); 182 183 return median; 184 } 138 185 139 186 // Set a variety of concepts in a cell by averaging over several … … 145 192 PS_ASSERT_INT_POSITIVE(sources->n, false); 146 193 147 float saturation = INFINITY; // Saturation level148 194 float bad = -INFINITY; // Bad level 149 195 double time = 0.0; // Time of observation … … 158 204 float exposure = averageWithDropouts (sources, "CELL.EXPOSURE"); 159 205 float darktime = averageWithDropouts (sources, "CELL.DARKTIME"); 206 float saturation = medianWithDropouts(sources, "CELL.SATURATION"); 160 207 161 208 // other concepts are a bit more "special" … … 221 268 } 222 269 223 float cellSaturation = psMetadataLookupF32(NULL, cell->concepts, "CELL.SATURATION");224 if (cellSaturation > 10000) {225 // do not allow invalid values to polute this calculation226 // XXX really need to do this on the basis of the fraction of the cell that contributes..227 // if a cell is completely masked, it should not be included.228 if (cellSaturation < saturation) {229 saturation = cellSaturation;230 }231 }232 270 float cellBad = psMetadataLookupF32(NULL, cell->concepts, "CELL.BAD"); 233 271 if (cellBad > bad) { -
branches/czw_branch/20101203/psModules/src/config/pmConfigDump.c
r27147 r30118 150 150 } 151 151 152 if (!psMetadataConfigWrite(config->user, resolved)) { 152 // check for Metadata compression options: 153 char *compressMode = NULL; 154 bool status = false; 155 if (config->camera) { 156 compressMode = psMetadataLookupStr(&status, config->camera, "METADATA.COMPRESSION"); 157 } 158 159 if (!psMetadataConfigWrite(config->user, resolved, compressMode)) { 153 160 psError(psErrorCodeLast(), false, "Unable to dump configuration to %s", filename); 154 161 psFree(resolved); -
branches/czw_branch/20101203/psModules/src/detrend/pmNonLinear.c
r29833 r30118 332 332 return(0.0); 333 333 } 334 /* if (flux > correction_fluxes->data.F32[bin]) { */335 /* return(0.0); */336 /* } */337 334 338 335 for (int i = 0; i < correction_fluxes->n - 1; i++) { … … 347 344 } 348 345 349 /* PS_BIN_FOR_VALUE(bin,correction_fluxes,flux); */350 /* if ((bin < 0)||(bin > correction_fluxes->n)) { */351 /* return(1.0); */352 /* } */353 354 /* PS_BIN_INTERPOLATE(result,correction_fluxes,correction_factors,bin,flux); */355 346 if (!isfinite(result)) { 356 347 result = 0.0; 357 348 } 358 /* if (result <= 0) { */359 /* result = 1.0; */360 /* } */361 349 return(result); 362 350 } … … 372 360 return(0.0); 373 361 } 374 /* if (flux > correction_fluxes->data.F32[bin]) { */375 /* return(0.0); */376 /* } */377 362 378 363 for (int i = 0; i < correction_fluxes->n - 1; i++) { … … 389 374 } 390 375 391 /* PS_BIN_FOR_VALUE(bin,correction_fluxes,flux); */392 /* if ((bin < 0)||(bin > correction_fluxes->n)) { */393 /* return(1.0); */394 /* } */395 396 /* PS_BIN_INTERPOLATE(result,correction_fluxes,correction_factors,bin,flux); */397 376 if (!isfinite(result)) { 398 377 result = 0.0; 399 378 } 400 /* if (result <= 0) { */401 /* result = 1.0; */402 /* } */403 379 return(result); 404 380 } 405 406 407 -
branches/czw_branch/20101203/psModules/src/objects
-
Property svn:mergeinfo
set to
/branches/eam_branches/ipp-20101103/psModules/src/objects merged eligible /branches/eam_branches/ipp-20101205/psModules/src/objects merged eligible /trunk/psModules/src/objects merged eligible
-
Property svn:mergeinfo
set to
-
branches/czw_branch/20101203/psModules/src/objects/pmPSF_IO.c
r29004 r30118 62 62 #include "pmSourceIO.h" 63 63 64 bool pmPSFmodelReadPSFClump (psMetadata *analysis, psMetadata *header); 65 64 66 bool pmPSFmodelCheckDataStatusForView (const pmFPAview *view, const pmFPAfile *file) 65 67 { … … 851 853 852 854 // read the psf clump data for each region 855 status = false; 853 856 if (roAnalysis) { 854 int nRegions = psMetadataLookupS32 (&status, header, "PSF_CLN"); 855 if (!status) { 856 // read old-style psf clump data 857 858 char regionName[64]; 859 snprintf (regionName, 64, "PSF.CLUMP.REGION.000"); 860 psMetadataAddS32 (roAnalysis, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", 1); 861 862 psMetadata *regionMD = psMetadataLookupPtr (&status, roAnalysis, regionName); 863 if (!regionMD) { 864 regionMD = psMetadataAlloc(); 865 psMetadataAddMetadata (roAnalysis, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD); 866 psFree (regionMD); 867 } 868 869 // psf clump data 870 pmPSFClump psfClump; 871 872 psfClump.X = psMetadataLookupF32 (&status, header, "PSF_CLX" ); assert(status); 873 psfClump.Y = psMetadataLookupF32 (&status, header, "PSF_CLY" ); assert(status); 874 psfClump.dX = psMetadataLookupF32 (&status, header, "PSF_CLDX"); assert(status); 875 psfClump.dY = psMetadataLookupF32 (&status, header, "PSF_CLDY"); assert(status); 876 877 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X); 878 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y); 879 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX); 880 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY); 881 } else { 882 psMetadataAddS32 (roAnalysis, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", nRegions); 883 884 for (int i = 0; i < nRegions; i++) { 885 char key[10]; 886 char regionName[64]; 887 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", i); 888 889 psMetadata *regionMD = psMetadataLookupPtr (&status, roAnalysis, regionName); 890 if (!regionMD) { 891 regionMD = psMetadataAlloc(); 892 psMetadataAddMetadata (roAnalysis, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD); 893 psFree (regionMD); 894 } 895 896 // psf clump data 897 pmPSFClump psfClump; 898 899 snprintf (key, 9, "CLX_%03d", i); 900 psfClump.X = psMetadataLookupF32 (&status, header, key); assert(status); 901 snprintf (key, 9, "CLY_%03d", i); 902 psfClump.Y = psMetadataLookupF32 (&status, header, key); assert(status); 903 snprintf (key, 9, "CLDX_%03d", i); 904 psfClump.dX = psMetadataLookupF32 (&status, header, key); assert(status); 905 snprintf (key, 9, "CLDY_%03d", i); 906 psfClump.dY = psMetadataLookupF32 (&status, header, key); assert(status); 907 908 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X); 909 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y); 910 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX); 911 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY); 912 } 913 } 857 status = pmPSFmodelReadPSFClump (roAnalysis, header); 858 if (!status) { 859 psMetadataAddS32 (roAnalysis, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", 0); 860 } 861 } 862 if (!roAnalysis || !status) { 863 psWarning ("no PSF.CLUMP data available for PSF model"); 914 864 } 915 865 … … 1123 1073 } 1124 1074 1125 // XXX pmPSF to/from Metadata functions were defined for 1.22 and earlier, but were dropped 1075 bool pmPSFmodelReadPSFClump (psMetadata *analysis, psMetadata *header) { 1076 1077 bool status = false;; 1078 1079 int nRegions = psMetadataLookupS32 (&status, header, "PSF_CLN"); 1080 if (!status) { 1081 // read old-style psf clump data 1082 1083 char regionName[64]; 1084 snprintf (regionName, 64, "PSF.CLUMP.REGION.000"); 1085 psMetadata *regionMD = psMetadataLookupPtr (&status, analysis, regionName); 1086 1087 if (!regionMD) { 1088 regionMD = psMetadataAlloc(); 1089 psMetadataAddMetadata (analysis, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD); 1090 psFree (regionMD); 1091 } 1092 1093 // psf clump data 1094 pmPSFClump psfClump; 1095 psfClump.X = psMetadataLookupF32 (&status, header, "PSF_CLX" ); if (!status) return false; 1096 psfClump.Y = psMetadataLookupF32 (&status, header, "PSF_CLY" ); if (!status) return false; 1097 psfClump.dX = psMetadataLookupF32 (&status, header, "PSF_CLDX"); if (!status) return false; 1098 psfClump.dY = psMetadataLookupF32 (&status, header, "PSF_CLDY"); if (!status) return false; 1099 1100 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X); 1101 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y); 1102 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX); 1103 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY); 1104 psMetadataAddS32 (analysis, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", 1); 1105 } else { 1106 for (int i = 0; i < nRegions; i++) { 1107 char key[10]; 1108 char regionName[64]; 1109 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", i); 1110 1111 psMetadata *regionMD = psMetadataLookupPtr (&status, analysis, regionName); 1112 if (!regionMD) { 1113 regionMD = psMetadataAlloc(); 1114 psMetadataAddMetadata (analysis, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD); 1115 psFree (regionMD); 1116 } 1117 1118 // psf clump data 1119 pmPSFClump psfClump; 1120 1121 snprintf (key, 9, "CLX_%03d", i); 1122 psfClump.X = psMetadataLookupF32 (&status, header, key); if (!status) return false; 1123 snprintf (key, 9, "CLY_%03d", i); 1124 psfClump.Y = psMetadataLookupF32 (&status, header, key); if (!status) return false; 1125 snprintf (key, 9, "CLDX_%03d", i); 1126 psfClump.dX = psMetadataLookupF32 (&status, header, key); if (!status) return false; 1127 snprintf (key, 9, "CLDY_%03d", i); 1128 psfClump.dY = psMetadataLookupF32 (&status, header, key); if (!status) return false; 1129 1130 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X); 1131 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y); 1132 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX); 1133 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY); 1134 } 1135 psMetadataAddS32 (analysis, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", nRegions); 1136 } 1137 return true; 1138 } -
branches/czw_branch/20101203/psModules/src/objects/pmPSFtry.h
r25754 r30118 100 100 bool pmPSFtryFitEXT (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal); 101 101 102 bool pmPSFtryMakePSF ( pmPSFtry *psfTry);102 bool pmPSFtryMakePSF (bool *pGoodFit, pmPSFtry *psfTry); 103 103 104 104 bool pmPSFtryFitPSF (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal); … … 123 123 ); 124 124 125 bool pmPSFFitShapeParams ( pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask);125 bool pmPSFFitShapeParams (bool *pGoodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask); 126 126 127 127 float psVectorSystematicError (psVector *residuals, psVector *errors, float clipFraction); -
branches/czw_branch/20101203/psModules/src/objects/pmPSFtryMakePSF.c
r29004 r30118 50 50 Note: some of the array entries may be NULL (failed fits); ignore them. 51 51 *****************************************************************************/ 52 bool pmPSFtryMakePSF ( pmPSFtry *psfTry)52 bool pmPSFtryMakePSF (bool *pGoodFit, pmPSFtry *psfTry) 53 53 { 54 54 PS_ASSERT_PTR_NON_NULL(psfTry, false); … … 74 74 75 75 // fit the shape parameters (SXX, SYY, SXY) as a function of position 76 if (!pmPSFFitShapeParams (p sf, psfTry->sources, x, y, srcMask)) {76 if (!pmPSFFitShapeParams (pGoodFit, psf, psfTry->sources, x, y, srcMask)) { 77 77 psFree(x); 78 78 psFree(y); 79 79 return false; 80 } 81 if (!*pGoodFit) { 82 psWarning ("poor fit to PSF shape parameters for trend order %d, %d, skipping\n", psf->trendNx, psf->trendNy); 83 psFree(x); 84 psFree(y); 85 return true; 80 86 } 81 87 … … 115 121 // the mask is carried from previous steps and updated with this operation 116 122 // the weight is either the flux error or NULL, depending on 'psf->poissonErrorParams' 117 if (!pmTrend2DFit ( trend, srcMask, 0xff, x, y, z, NULL)) {123 if (!pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, z, NULL)) { 118 124 psError(PS_ERR_UNKNOWN, false, "failed to build psf model for parameter %d", i); 119 125 psFree(x); … … 122 128 return false; 123 129 } 130 if (!*pGoodFit) { 131 // if we do not get a good fit (but do not actually hit an error), 132 // tell the calling program to try something else 133 psWarning ("poor fit to PSF parameter %d for trend order %d, %d, skipping\n", i, psf->trendNx, psf->trendNy); 134 psFree(x); 135 psFree(y); 136 psFree(z); 137 return true; 138 } 124 139 if (trend->mode == PM_TREND_MAP) { 125 140 // p_psImagePrint (2, trend->map->map, "param N Before"); // XXX TEST: … … 139 154 140 155 pmModel *modelPSF = pmModelFromPSF (source->modelEXT, psf); 156 if (!modelPSF) { 157 fprintf(f, "modelPSF is NULL\n"); 158 break; 159 } 160 if (!source->modelEXT) { 161 fprintf(f, "source->modelEXT is NULL\n"); 162 break; 163 } 141 164 142 165 fprintf (f, "%f %f : ", source->modelEXT->params->data.F32[PM_PAR_XPOS], source->modelEXT->params->data.F32[PM_PAR_YPOS]); … … 163 186 164 187 // fit the shape parameters using the supplied order (pmPSF->trendNx,trendNy) 165 bool pmPSFFitShapeParams ( pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask) {188 bool pmPSFFitShapeParams (bool *pGoodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask) { 166 189 167 190 // we are doing a robust fit. after each pass, we drop points which are more deviant than … … 219 242 trend = psf->params->data[PM_PAR_E0]; 220 243 trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here 221 status &= pmTrend2DFit (trend, srcMask, 0xff, x, y, e0, NULL); 244 status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e0, NULL); 245 if (!*pGoodFit) { 246 psFree (e0); 247 psFree (e1); 248 psFree (e2); 249 return true; 250 } 222 251 mean = psStatsGetValue (trend->stats, meanOption); 223 252 stdev = psStatsGetValue (trend->stats, stdevOption); … … 228 257 trend = psf->params->data[PM_PAR_E1]; 229 258 trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here 230 status &= pmTrend2DFit (trend, srcMask, 0xff, x, y, e1, NULL); 259 status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e1, NULL); 260 if (!*pGoodFit) { 261 psFree (e0); 262 psFree (e1); 263 psFree (e2); 264 return true; 265 } 231 266 mean = psStatsGetValue (trend->stats, meanOption); 232 267 stdev = psStatsGetValue (trend->stats, stdevOption); … … 237 272 trend = psf->params->data[PM_PAR_E2]; 238 273 trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here 239 status &= pmTrend2DFit (trend, srcMask, 0xff, x, y, e2, NULL); 274 status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e2, NULL); 275 if (!*pGoodFit) { 276 psFree (e0); 277 psFree (e1); 278 psFree (e2); 279 return true; 280 } 240 281 mean = psStatsGetValue (trend->stats, meanOption); 241 282 stdev = psStatsGetValue (trend->stats, stdevOption); … … 246 287 if (!status) { 247 288 psError (PS_ERR_UNKNOWN, true, "failed to fit PSF shape params"); 289 psFree (e0); 290 psFree (e1); 291 psFree (e2); 248 292 return false; 249 293 } -
branches/czw_branch/20101203/psModules/src/objects/pmPSFtryModel.c
r29004 r30118 136 136 137 137 // stage 2: construct a psf (pmPSF) from this collection of model fits, including the 2D variation 138 if (!pmPSFtryMakePSF (psfTry)) { 138 bool goodFit = false; 139 if (!pmPSFtryMakePSF (&goodFit, psfTry)) { 139 140 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources"); 140 141 psFree(psfTry); 141 142 return NULL; 142 143 } 144 if (!goodFit) { 145 psWarning ("poor psf fit for order %d, skipping\n", i); 146 continue; 147 } 143 148 144 149 // stage 3: refit with fixed shape parameters, measure pmPSFtry->metric … … 169 174 } 170 175 psFree (srcMask); 176 177 if (!minPSF) { 178 psError(PS_ERR_UNKNOWN, false, "failed to construct a valid psf model from the sources"); 179 psFree(psfTry); 180 return NULL; 181 } 171 182 172 183 // keep the ones matching the min systematic error: -
branches/czw_branch/20101203/psModules/src/objects/pmSource.c
r29546 r30118 189 189 // pixels. Modifying these pixels (ie, subtracting the model) will affect the pixels seen 190 190 // by all copies. 191 source->pixels = psImageCopyView(NULL, in->pixels);192 source->variance = psImageCopyView(NULL, in->variance);191 source->pixels = in->pixels ? psImageCopyView(NULL, in->pixels) : NULL; 192 source->variance = in->variance ? psImageCopyView(NULL, in->variance) : NULL; 193 193 source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL; 194 194 -
branches/czw_branch/20101203/psModules/src/objects/pmSourcePhotometry.c
r29546 r30118 107 107 // XXX handle negative flux, low-significance 108 108 if (model->dparams->data.F32[PM_PAR_I0] > 0) { 109 SN = model->params->data.F32[PM_PAR_I0] / model->dparams->data.F32[PM_PAR_I0];109 SN = fabs(model->params->data.F32[PM_PAR_I0] / model->dparams->data.F32[PM_PAR_I0]); 110 110 source->errMag = 1.0 / SN; 111 111 } else { … … 331 331 } 332 332 if (apFluxOut) *apFluxOut = apFlux; 333 if (apFluxErr) *apFluxErr = sqrt( apFluxVar);333 if (apFluxErr) *apFluxErr = sqrt(fabs(apFluxVar)); 334 334 335 335 if (apFlux <= 0) { -
branches/czw_branch/20101203/psModules/src/objects/pmTrend2D.c
r25754 r30118 179 179 } 180 180 181 bool pmTrend2DFit( pmTrend2D *trend, psVector *mask, psVectorMaskType maskVal, const psVector *x,181 bool pmTrend2DFit(bool *pGoodFit, pmTrend2D *trend, psVector *mask, psVectorMaskType maskVal, const psVector *x, 182 182 const psVector *y, const psVector *f, const psVector *df) 183 183 { … … 188 188 PS_ASSERT_VECTOR_NON_NULL(f, false); 189 189 190 bool status; 190 bool status = false; 191 *pGoodFit = false; 192 // for the psImageMap fit, it is possible to have valid data but no valid solution for 193 // example, an isolated cell may not be reached from other cells, making the solution 194 // degenerate. psImageMapFit should probably handle this case, but until it does, we allow 195 // it to fail on the result, but not yield an error (pGoodFit = false). 196 // psVectorClipFitPolynomial2D can not fail in this way (really?), so pGoodFit is always 197 // true 198 191 199 switch (trend->mode) { 192 200 case PM_TREND_POLY_ORD: … … 196 204 // of points in the image, and potentially based on the fractional range of the 197 205 // data? 206 *pGoodFit = true; 198 207 break; 199 208 … … 201 210 // XXX supply fraction from trend elements 202 211 // XXX need to add the API which adjusts the scale 203 status = psImageMapClipFit( trend->map, trend->stats, mask, maskVal, x, y, f, df);212 status = psImageMapClipFit(pGoodFit, trend->map, trend->stats, mask, maskVal, x, y, f, df); 204 213 break; 205 214 -
branches/czw_branch/20101203/psModules/src/objects/pmTrend2D.h
r29004 r30118 76 76 ); 77 77 78 bool pmTrend2DFit(pmTrend2D *trend, 78 bool pmTrend2DFit(bool *goodFit, 79 pmTrend2D *trend, 79 80 psVector *mask, // Warning: mask is modified! 80 81 psVectorMaskType maskVal,
Note:
See TracChangeset
for help on using the changeset viewer.
