Changeset 15562 for trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c
- Timestamp:
- Nov 9, 2007, 3:09:20 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c
r15250 r15562 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-1 0-09 03:10:05$5 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-11-10 01:09:20 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 47 47 // XXX how do I generate the source tables which I need to send to PSPS? 48 48 49 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname )49 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname, char *xsrcname) 50 50 { 51 51 … … 57 57 psF32 xPos, yPos; 58 58 psF32 xErr, yErr; 59 60 // if we request XSRC output, add the XSRC name to this header 61 if (xsrcname) { 62 psMetadataAddStr (tableHeader, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname); 63 } 59 64 60 65 // let's write these out in S/N order … … 144 149 return false; 145 150 } 146 147 151 psFree (table); 152 153 if (xsrcname) { 154 pmSourcesWrite_PS1_DEV_1_XSRC (fits, sources, xsrcname); 155 } 156 148 157 return true; 149 158 } … … 165 174 } 166 175 assert (modelType > -1); 176 177 // XXX need to look up the XSRCNAME entries 167 178 168 179 // validate a single row of the table (must match SMP) … … 241 252 return sources; 242 253 } 254 255 bool pmSourcesWrite_PS1_DEV_1_XSRC (psFits *fits, psArray *sources, char *extname) 256 { 257 258 psArray *table; 259 psMetadata *row; 260 int i; 261 psF32 *PAR, *dPAR; 262 psEllipseAxes axes; 263 psF32 xPos, yPos; 264 psF32 xErr, yErr; 265 266 // create a header to hold the output data 267 psMetadata *outhead = psMetadataAlloc (); 268 269 // write the links to the image header 270 psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "xsrc table extension", extname); 271 272 // let's write these out in S/N order 273 sources = psArraySort (sources, pmSourceSortBySN); 274 275 table = psArrayAllocEmpty (sources->n); 276 277 // we write out all sources, regardless of quality. the source flags tell us the state 278 for (i = 0; i < sources->n; i++) { 279 pmSource *source = (pmSource *) sources->data[i]; 280 source->seq = i; 281 282 // skip source if it is not a ext sourc 283 284 // no difference between PSF and non-PSF model 285 // XXX the PSF output should report the value for the psf, not the ext, model 286 pmModel *model = source->modelEXT; 287 if (model == NULL) continue; 288 289 PAR = model->params->data.F32; 290 dPAR = model->dparams->data.F32; 291 xPos = PAR[PM_PAR_XPOS]; 292 yPos = PAR[PM_PAR_YPOS]; 293 xErr = dPAR[PM_PAR_XPOS]; 294 yErr = dPAR[PM_PAR_YPOS]; 295 296 axes = pmPSF_ModelToAxes (PAR, 20.0); 297 298 row = psMetadataAlloc (); 299 // XXX we are not writing out the mode (flags) or the type (psf, ext, etc) 300 psMetadataAdd (row, PS_LIST_TAIL, "IPP_IDET", PS_DATA_U32, "IPP detection identifier index", source->seq); 301 psMetadataAdd (row, PS_LIST_TAIL, "X_EXT", PS_DATA_F32, "PSF x coordinate", xPos); 302 psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT", PS_DATA_F32, "PSF y coordinate", yPos); 303 psMetadataAdd (row, PS_LIST_TAIL, "X_EXT_SIG", PS_DATA_F32, "Sigma in PSF x coordinate", xErr); 304 psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT_SIG", PS_DATA_F32, "Sigma in PSF y coordinate", yErr); 305 psMetadataAdd (row, PS_LIST_TAIL, "EXT_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", PS_MIN (99.0, source->extMag)); 306 // XXX need to calculate psfMag, psfMagErr, extMag, extMagErr... 307 psMetadataAdd (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", PS_MIN (99.0, source->errMag)); 308 309 // XXX these should be major and minor, not 'x' and 'y' 310 psMetadataAdd (row, PS_LIST_TAIL, "EXT_WIDTH_X", PS_DATA_F32, "PSF width in x coordinate", axes.major); 311 psMetadataAdd (row, PS_LIST_TAIL, "EXT_WIDTH_Y", PS_DATA_F32, "PSF width in y coordinate", axes.minor); 312 psMetadataAdd (row, PS_LIST_TAIL, "EXT_THETA", PS_DATA_F32, "PSF orientation angle", axes.theta); 313 314 // other values that I need to report: 315 // R, Mag Petrosian, ..... 316 317 psArrayAdd (table, 100, row); 318 psFree (row); 319 } 320 321 if (table->n == 0) { 322 psFitsWriteBlank (fits, outhead, extname); 323 psFree (table); 324 return true; 325 } 326 327 psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname); 328 if (!psFitsWriteTable (fits, outhead, table, extname)) { 329 psError(PS_ERR_IO, false, "writing ext data %s\n", extname); 330 psFree(table); 331 return false; 332 } 333 psFree (table); 334 335 return true; 336 }
Note:
See TracChangeset
for help on using the changeset viewer.
