Changeset 21488
- Timestamp:
- Feb 15, 2009, 9:54:28 AM (17 years ago)
- Location:
- branches/eam_branch_20090208/psModules/src/objects
- Files:
-
- 2 edited
-
pmSourceIO.c (modified) (5 diffs)
-
pmSourceIO_CMF_PS1_V1.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20090208/psModules/src/objects/pmSourceIO.c
r21448 r21488 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.69.12. 1$ $Name: not supported by cvs2svn $6 * @date $Date: 2009-02-1 2 04:42:05$5 * @version $Revision: 1.69.12.2 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-15 19:54:12 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 493 493 status = pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname); 494 494 } 495 if (!strcmp (exttype, " CMF_PS1_V1")) {495 if (!strcmp (exttype, "PS1_V1")) { 496 496 status = pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname); 497 497 } … … 503 503 status = pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe); 504 504 } 505 if (!strcmp (exttype, " CMF_PS1_V1")) {505 if (!strcmp (exttype, "PS1_V1")) { 506 506 status = pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe); 507 507 } … … 514 514 status = pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname); 515 515 } 516 if (!strcmp (exttype, " CMF_PS1_V1")) {516 if (!strcmp (exttype, "PS1_V1")) { 517 517 status = pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname); 518 518 } … … 938 938 sources = pmSourcesRead_PS1_DEV_1 (file->fits, hdu->header); 939 939 } 940 if (!strcmp (exttype, "PS1_ CAL_0")) {941 sources = pmSourcesRead_ PS1_CAL_0(file->fits, hdu->header);940 if (!strcmp (exttype, "PS1_V1")) { 941 sources = pmSourcesRead_CMF_PS1_V1 (file->fits, hdu->header); 942 942 } 943 943 } -
branches/eam_branch_20090208/psModules/src/objects/pmSourceIO_CMF_PS1_V1.c
r21448 r21488 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $6 * @date $Date: 2009-02-1 2 04:42:37$5 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-15 19:54:28 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 } 76 76 77 // let's write these out in S/N order 78 sources = psArraySort (sources, pmSourceSortBySN); 77 // if the sequence is defined, write these in seq order; otherwise 78 // write them in S/N order: 79 if (sources->n > 0) { 80 pmSource *source = (pmSource *) sources->data[0]; 81 if (source->seq == -1) { 82 // let's write these out in S/N order 83 sources = psArraySort (sources, pmSourceSortBySN); 84 } else { 85 sources = psArraySort (sources, pmSourceSortBySeq); 86 } 87 } 79 88 80 89 table = psArrayAllocEmpty (sources->n); 81 90 82 91 // we write out PSF-fits for all sources, regardless of quality. the source flags tell us the state 92 // by the time we call this function, all values should be assigned. let's use asserts to be sure in some cases. 83 93 for (i = 0; i < sources->n; i++) { 84 94 pmSource *source = (pmSource *) sources->data[i]; 95 96 // If source->seq is -1, source was generated in this analysis. If source->seq is 97 // not -1, source was read from elsewhere: in the latter case, preserve the source 98 // ID. source.seq is used instead of source.id since the latter is a const 99 // generated on Alloc, and would thus be wrong for read in sources. 85 100 if (source->seq == -1) { 86 source->seq = i;101 source->seq = i; 87 102 } 88 103 … … 95 110 xPos = PAR[PM_PAR_XPOS]; 96 111 yPos = PAR[PM_PAR_YPOS]; 97 xErr = dPAR[PM_PAR_XPOS]; 98 yErr = dPAR[PM_PAR_YPOS]; 112 if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) { 113 xErr = dPAR[PM_PAR_XPOS]; 114 yErr = dPAR[PM_PAR_YPOS]; 115 } else { 116 // in linear-fit mode, there is no error on the centroid 117 xErr = source->peak->dx; 118 yErr = source->peak->dy; 119 } 99 120 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) { 100 121 axes = pmPSF_ModelToAxes (PAR, 20.0); … … 134 155 135 156 row = psMetadataAlloc (); 136 // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)137 157 psMetadataAdd (row, PS_LIST_TAIL, "IPP_IDET", PS_DATA_U32, "IPP detection identifier index", source->seq); 138 158 psMetadataAdd (row, PS_LIST_TAIL, "X_PSF", PS_DATA_F32, "PSF x coordinate", xPos); … … 146 166 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfMag); 147 167 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", errMag); 148 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG _STANDARD",PS_DATA_F32, "magnitude in standard aperture", source->apMag);168 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG", PS_DATA_F32, "magnitude in standard aperture", source->apMag); 149 169 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS", PS_DATA_F32, "radius used for aperture mags", apRadius); 150 170 psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude", peakMag); … … 170 190 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_YY", PS_DATA_F32, "second moments (Y*Y)", source->moments->Myy); 171 191 192 psMetadataAdd (row, PS_LIST_TAIL, "FLAGS", PS_DATA_U32, "psphot analysis flags", source->mode); 193 172 194 // XXX not sure how to get this : need to load Nimages with weight? 173 195 psMetadataAdd (row, PS_LIST_TAIL, "N_FRAMES", PS_DATA_U16, "Number of frames overlapping source center", nImageOverlap); 174 psMetadataAdd (row, PS_LIST_TAIL, " FLAGS", PS_DATA_U16, "psphot analysis flags", source->mode);196 psMetadataAdd (row, PS_LIST_TAIL, "PADDING", PS_DATA_S16, "padding", 0); 175 197 176 198 psArrayAdd (table, 100, row); … … 227 249 psArray *sources = psArrayAlloc(numSources); // Array of sources, to return 228 250 229 // convert the table to the pmSource entries 251 // convert the table to the pmSource entriesa 230 252 for (int i = 0; i < numSources; i++) { 231 253 psMetadata *row = psFitsReadTableRow(fits, i); // Table row … … 245 267 dPAR[PM_PAR_XPOS] = psMetadataLookupF32 (&status, row, "X_PSF_SIG"); 246 268 dPAR[PM_PAR_YPOS] = psMetadataLookupF32 (&status, row, "Y_PSF_SIG"); 247 axes.major = psMetadataLookupF32 (&status, row, "PSF_ WIDTH_X");248 axes.minor = psMetadataLookupF32 (&status, row, "PSF_ WIDTH_Y");269 axes.major = psMetadataLookupF32 (&status, row, "PSF_MAJOR"); 270 axes.minor = psMetadataLookupF32 (&status, row, "PSF_MINOR"); 249 271 axes.theta = psMetadataLookupF32 (&status, row, "PSF_THETA"); 250 272 251 273 PAR[PM_PAR_SKY] = psMetadataLookupF32 (&status, row, "SKY"); 252 274 dPAR[PM_PAR_SKY] = psMetadataLookupF32 (&status, row, "SKY_SIGMA"); 253 source->sky = PAR[PM_PAR_SKY];254 source->skyErr = dPAR[PM_PAR_SKY];275 source->sky = PAR[PM_PAR_SKY]; 276 source->skyErr = dPAR[PM_PAR_SKY]; 255 277 256 278 // XXX use these to determine PAR[PM_PAR_I0]? 257 279 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 258 280 source->errMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 281 source->apMag = psMetadataLookupF32 (&status, row, "AP_MAG"); 259 282 260 283 // XXX this scaling is incorrect: does not include the 2 \pi AREA factor … … 264 287 pmPSF_AxesToModel (PAR, axes); 265 288 266 float lflux = psMetadataLookupF32 (&status, row, "PEAK_FLUX_AS_MAG"); 267 float flux = (isfinite(lflux)) ? pow(10.0, -0.4*lflux) : NAN; 268 source->peak = pmPeakAlloc(PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], flux, PM_PEAK_LONE); 269 source->peak->flux = flux; 289 float peakMag = psMetadataLookupF32 (&status, row, "PEAK_FLUX_AS_MAG"); 290 float peakFlux = (isfinite(peakMag)) ? pow(10.0, -0.4*peakMag) : NAN; 291 292 // recreate the peak to match (xPos, yPos) +/- (xErr, yErr) 293 source->peak = pmPeakAlloc(PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], peakFlux, PM_PEAK_LONE); 294 source->peak->flux = peakFlux; 295 source->peak->dx = dPAR[PM_PAR_XPOS]; 296 source->peak->dy = dPAR[PM_PAR_YPOS]; 270 297 271 298 source->pixWeight = psMetadataLookupF32 (&status, row, "PSF_QF"); 272 273 // note that some older versions used PSF_PROBABILITY: this was not well defined.274 model->chisq = psMetadataLookupF32 (&status, row, "PSF_CHISQ");275 299 source->crNsigma = psMetadataLookupF32 (&status, row, "CR_NSIGMA"); 276 300 source->extNsigma = psMetadataLookupF32 (&status, row, "EXT_NSIGMA"); 277 301 278 source->mode = psMetadataLookupU16 (&status, row, "FLAGS"); 302 // note that some older versions used PSF_PROBABILITY: this was not well defined. 303 model->chisq = psMetadataLookupF32 (&status, row, "PSF_CHISQ"); 304 model->nDOF = psMetadataLookupS32 (&status, row, "PSF_NDOF"); 305 model->nPix = psMetadataLookupS32 (&status, row, "PSF_NPIX"); 306 model->radiusFit = psMetadataLookupS32 (&status, row, "AP_MAG_RADIUS"); 307 308 source->moments = pmMomentsAlloc (); 309 source->moments->Mxx = psMetadataLookupF32 (&status, row, "MOMENTS_XX"); 310 source->moments->Mxy = psMetadataLookupF32 (&status, row, "MOMENTS_XY"); 311 source->moments->Myy = psMetadataLookupF32 (&status, row, "MOMENTS_YY"); 312 313 source->mode = psMetadataLookupU32 (&status, row, "FLAGS"); 279 314 assert (status); 280 315
Note:
See TracChangeset
for help on using the changeset viewer.
