Changeset 14208
- Timestamp:
- Jul 13, 2007, 5:20:44 PM (19 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 2 edited
-
pmSourceIO.c (modified) (7 diffs)
-
pmSourceIO.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceIO.c
r14134 r14208 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-07-1 1 03:09:23$5 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-07-14 03:20:44 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 243 243 char *headname; 244 244 pmHDU *hdu; 245 pmHDU *phu;246 245 psMetadata *updates; 247 246 psMetadata *outhead; … … 294 293 295 294 case PM_FPA_FILE_CMF: 296 // write a PHU? (only if input image is MEF)297 295 // write a header? (only if this is the first readout for cell) 298 296 // note that the file->header is set to track the last hdu->header written … … 301 299 // get the current header 302 300 hdu = pmFPAviewThisHDU (view, file->fpa); 303 304 // if file does not yet have a PHU, attempt to write one to disk305 // we only need a PHU if chips->n > 1 and file->fileLevel == FPA306 // otherwise, the chip header fills the PHU location307 // XXX this code could be placed in a 'pmSource_CMF_WritePHU' function and called308 // from pmFPAfileIO.c.309 if ((file->fileLevel == PM_FPA_LEVEL_FPA) && (file->fpa->chips->n > 1) && !file->phu) {310 311 // find the FPA phu312 phu = pmFPAviewThisPHU (view, file->fpa);313 314 // if there is no PHU, this is a single header+image (extension-less) file315 // if there is a PHU, write it out as a 'blank'316 outhead = psMetadataAlloc();317 if (phu) {318 psMetadataCopy (outhead, phu->header);319 } else {320 pmConfigConformHeader (outhead, file->format);321 322 psMetadata *fileData = psMetadataLookupMetadata(NULL, file->format, "FILE"); // File information323 const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.NAME");324 if (fpaNameHdr && strlen(fpaNameHdr) > 0) {325 const char *fpaName = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.NAME");326 psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName);327 }328 329 #if 0330 // We need to get some FPA-level concepts in there331 // This is a hack, not very pretty. But then, so is writing the FPA in this manner without332 // using the pmFPAMosaic functions....333 334 psMetadata *headers = psMetadataLookupMetadata(NULL, file->fpa->camera,335 BLANK_HEADERS); // Header names336 if (!headers) {337 psError(PS_ERR_UNEXPECTED_NULL, false,338 "Unable to find %s metadata within camera configuration", BLANK_HEADERS);339 psFree(outhead);340 return false;341 }342 343 {344 const char *mjdName = psMetadataLookupStr(NULL, headers, "FPA.TIME"); // Header name345 if (!mjdName || strlen(mjdName) == 0) {346 psError(PS_ERR_UNEXPECTED_NULL, false,347 "Unable to find FPA.TIME in %s within camera configuration.", BLANK_HEADERS);348 psFree(outhead);349 return false;350 }351 psTime *time = psMetadataLookupTime(NULL, file->fpa->concepts,352 "FPA.TIME"); // Time of observation353 double mjd = psTimeToMJD(time); // The MJD of observation354 psMetadataAddF64(outhead, PS_LIST_TAIL, mjdName, PS_META_REPLACE,355 "Time of observation", mjd);356 }357 358 {359 const char *expName = psMetadataLookupStr(NULL, headers, "FPA.EXPOSURE"); // Header name360 if (!expName || strlen(expName) == 0) {361 psError(PS_ERR_UNEXPECTED_NULL, false,362 "Unable to find FPA.EXPOSURE in %s within camera configuration.",363 BLANK_HEADERS);364 psFree(outhead);365 return false;366 }367 float exptime = psMetadataLookupF32(NULL, file->fpa->concepts,368 "FPA.EXPOSURE"); // Exposure time369 psMetadataAddF32(outhead, PS_LIST_TAIL, expName, PS_META_REPLACE,370 "Exposure time (sec)", exptime);371 }372 373 {374 const char *amName = psMetadataLookupStr(NULL, headers, "FPA.AIRMASS"); // Header name375 if (!amName || strlen(amName) == 0) {376 psError(PS_ERR_UNEXPECTED_NULL, false,377 "Unable to find FPA.AIRMASS in %s within camera configuration.",378 BLANK_HEADERS);379 psFree(outhead);380 return false;381 }382 float airmass = psMetadataLookupF32(NULL, file->fpa->concepts, "FPA.AIRMASS"); // Airmass383 psMetadataAddF32(outhead, PS_LIST_TAIL, amName, PS_META_REPLACE,384 "Observation airmass", airmass);385 }386 #endif387 388 }389 390 // if we have mosaic-level astrometry information, add it here:391 updates = psMetadataLookupPtr (&status, file->fpa->analysis, "PSASTRO.HEADER");392 if (updates) {393 psMetadataCopy (outhead, updates);394 }395 396 psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);397 psFitsWriteBlank (file->fits, outhead, "");398 file->phu = true;399 psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type);400 psFree (outhead);401 }402 301 403 302 // define the EXTNAME values for the different data segments: … … 430 329 } 431 330 432 // write out the IMAGE header segment 331 // write out the IMAGE header segment (only for the first readout of the cell) 433 332 { 434 333 // this header block is new, write it to disk … … 437 336 psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTDATA", PS_META_REPLACE, "name of table extension", dataname); 438 337 psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", "IMAGE"); 439 if (!file-> phu) {338 if (!file->wrote_phu) { 440 339 // this hdu->header acts as the PHU: set EXTEND to be true 441 340 psMetadataAddBool (hdu->header, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true); 341 file->wrote_phu = true; 442 342 } 443 343 … … 512 412 // a MEF CMF file has: PHU, CELL-HEAD, TABLE, CELL-HEAD, TABLE, TABLE, TABLE... 513 413 414 // if this file needs to have a PHU written out, write one 415 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config) { 416 417 bool status; 418 419 // not needed if already written 420 if (file->wrote_phu) return true; 421 422 // not needed if not FPA 423 // XXX this prevents us from defining a SPLIT/MEF CMF file... 424 if (file->fileLevel != PM_FPA_LEVEL_FPA) return true; 425 426 // not needed if only one chip 427 if (file->fpa->chips->n == 1) return true; 428 429 // find the FPA phu 430 pmHDU *phu = pmFPAviewThisPHU (view, file->fpa); 431 432 // if there is no PHU, this is a single header+image (extension-less) file. This could be 433 // the case for an input SPLIT set of files being written out as a MEF. if there is a PHU, 434 // write it out as a 'blank' 435 psMetadata *outhead = psMetadataAlloc(); 436 if (phu) { 437 psMetadataCopy (outhead, phu->header); 438 } else { 439 pmConfigConformHeader (outhead, file->format); 440 441 psMetadata *fileData = psMetadataLookupMetadata(NULL, file->format, "FILE"); // File information 442 const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.NAME"); 443 if (fpaNameHdr && strlen(fpaNameHdr) > 0) { 444 const char *fpaName = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.NAME"); 445 psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName); 446 } 447 } 448 449 // if we have mosaic-level astrometry information, add it here: 450 psMetadata *updates = psMetadataLookupPtr (&status, file->fpa->analysis, "PSASTRO.HEADER"); 451 if (updates) { 452 psMetadataCopy (outhead, updates); 453 } 454 455 psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true); 456 psFitsWriteBlank (file->fits, outhead, ""); 457 file->wrote_phu = true; 458 459 psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type); 460 psFree (outhead); 461 462 return true; 463 } 464 514 465 // Given a FITS file pointer, read the table of object data 515 466 // XXX add in error handling -
trunk/psModules/src/objects/pmSourceIO.h
r13192 r14208 4 4 * @author EAM, IfA; GLG, MHPCC 5 5 * 6 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 5-03 20:04:31$6 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-07-14 03:20:44 $ 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 9 9 * … … 26 26 bool pmSourcesWrite_SMPDATA (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 27 27 bool pmSourcesWrite_PS1_DEV_0 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 28 29 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, const pmConfig *config); 28 30 29 31 psArray *pmSourcesReadCMP (char *filename, psMetadata *header);
Note:
See TracChangeset
for help on using the changeset viewer.
