Changeset 18601 for trunk/psModules/src/objects/pmSourceIO.c
- Timestamp:
- Jul 17, 2008, 12:38:15 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSourceIO.c (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceIO.c
r18599 r18601 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.6 2$ $Name: not supported by cvs2svn $6 * @date $Date: 2008-07-17 2 0:43:23$5 * @version $Revision: 1.63 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2008-07-17 22:38:15 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 #include "pmFPAview.h" 29 29 #include "pmFPAfile.h" 30 #include "pmFPAfileFitsIO.h" 30 31 #include "pmConcepts.h" 31 32 … … 108 109 109 110 // Given a FITS file pointer, write the table of object data 110 bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file, constpmConfig *config)111 bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file, pmConfig *config) 111 112 { 112 113 PS_ASSERT_PTR_NON_NULL(view, false); … … 114 115 PS_ASSERT_PTR_NON_NULL(file->fpa, false); 115 116 116 pmFPA *fpa = file->fpa;117 pmFPA *fpa = pmFPAfileSuitableFPA(file, view, config, false); // Suitable FPA for writing 117 118 118 119 if (view->chip == -1) { 119 120 if (!pmFPAWriteObjects (fpa, view, file, config)) { 120 121 psError(PS_ERR_IO, false, "Failed to write objects from fpa"); 121 return false; 122 } 122 psFree(fpa); 123 return false; 124 } 125 psFree(fpa); 123 126 return true; 124 127 } … … 126 129 if (view->chip >= fpa->chips->n) { 127 130 psError(PS_ERR_UNKNOWN, false, "Writing chip == %d (>= chips->n == %ld)", view->chip, fpa->chips->n); 131 psFree(fpa); 128 132 return false; 129 133 } … … 133 137 if (!pmChipWriteObjects (chip, view, file, config)) { 134 138 psError(PS_ERR_IO, false, "Failed to write objects from chip"); 135 return false; 136 } 139 psFree(fpa); 140 return false; 141 } 142 psFree(fpa); 137 143 return true; 138 144 } … … 141 147 psError(PS_ERR_UNKNOWN, false, "Writing cell == %d (>= cells->n == %ld)", 142 148 view->cell, chip->cells->n); 149 psFree(fpa); 143 150 return false; 144 151 } … … 148 155 if (!pmCellWriteObjects (cell, view, file, config)) { 149 156 psError(PS_ERR_IO, false, "Failed to write objects from cell"); 150 return false; 151 } 152 157 psFree(fpa); 158 return false; 159 } 160 psFree(fpa); 153 161 return true; 154 162 } … … 157 165 psError(PS_ERR_UNKNOWN, false, "Writing readout == %d (>= readouts->n == %ld)", 158 166 view->readout, cell->readouts->n); 167 psFree(fpa); 159 168 return false; 160 169 } … … 163 172 if (!pmReadoutWriteObjects (readout, view, file, config)) { 164 173 psError(PS_ERR_IO, false, "Failed to write objects from readout %d", view->readout); 165 return false; 166 } 167 174 psFree(fpa); 175 return false; 176 } 177 178 psFree(fpa); 168 179 return true; 169 180 } … … 244 255 PS_ASSERT_PTR_NON_NULL(view, false); 245 256 PS_ASSERT_PTR_NON_NULL(file, false); 246 PS_ASSERT_PTR_NON_NULL(file->fpa, false); 257 258 pmCell *cell = readout->parent; 259 PS_ASSERT_PTR_NON_NULL(cell, false); 260 pmChip *chip = cell->parent; 261 PS_ASSERT_PTR_NON_NULL(chip, false); 262 pmFPA *fpa = chip->parent; 263 PS_ASSERT_PTR_NON_NULL(fpa, false); 247 264 248 265 bool status; … … 281 298 case PM_FPA_FILE_CMP: 282 299 // a SPLIT format : only one header and object table per file 283 hdu = pmFPAviewThisHDU (view, f ile->fpa);300 hdu = pmFPAviewThisHDU (view, fpa); 284 301 if (!hdu) { 285 302 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU to write sources."); … … 317 334 318 335 // get the current header 319 hdu = pmFPAviewThisHDU (view, f ile->fpa);336 hdu = pmFPAviewThisHDU (view, fpa); 320 337 if (!hdu) { 321 338 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU to write sources."); … … 486 503 487 504 // if this file needs to have a PHU written out, write one 488 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, constpmConfig *config)505 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config) 489 506 { 490 507 PS_ASSERT_PTR_NON_NULL(view, false); … … 503 520 if (file->fpa->chips->n == 1) return true; 504 521 522 505 523 // find the FPA phu 506 pmHDU *phu = pmFPAviewThisPHU (view, file->fpa); 524 pmFPA *fpa = pmFPAfileSuitableFPA(file, view, config, false); // Suitable FPA for writing 525 pmHDU *phu = psMemIncrRefCounter(pmFPAviewThisPHU(view, fpa)); 507 526 508 527 // if there is no PHU, this is a single header+image (extension-less) file. This could be … … 513 532 psMetadataCopy (outhead, phu->header); 514 533 } 534 psFree(phu); 515 535 516 536 pmConfigConformHeader (outhead, file->format); … … 521 541 // XXX why are these not correctly inserted by pmConfigConformHeader?? 522 542 523 psMetadata *headers = psMetadataLookupMetadata(NULL, file->fpa->camera, BLANK_HEADERS); // Header names 543 // Because these concepts are not part of the "RULE" in the camera format, pmConfigConformHeader only adds 544 // what is required by the "RULE". 545 // Though we can configure Ohana to look at particular header keywords, it doesn't like having the 546 // important values in "HIERARCH FPA.TIME", etc, as is done for skycells, so we stoop to its level, 547 // putting in additional header keywords that it can understand. 548 549 psMetadata *headers = psMetadataLookupMetadata(NULL, fpa->camera, BLANK_HEADERS); // Header names 524 550 if (!headers) { 525 551 psError(PS_ERR_UNEXPECTED_NULL, false, 526 552 "Unable to find %s metadata within camera configuration", BLANK_HEADERS); 527 553 psFree(outhead); 554 psFree(fpa); 528 555 return false; 529 556 } … … 535 562 "Unable to find FPA.TIME in %s within camera configuration.", BLANK_HEADERS); 536 563 psFree(outhead); 537 return false; 538 } 539 psTime *time = psMetadataLookupTime(NULL, file->fpa->concepts, "FPA.TIME"); // Time of observation 564 psFree(fpa); 565 return false; 566 } 567 psTime *time = psMetadataLookupTime(NULL, fpa->concepts, "FPA.TIME"); // Time of observation 540 568 double mjd = psTimeToMJD(time); // The MJD of observation 541 569 psMetadataAddF64(outhead, PS_LIST_TAIL, mjdName, PS_META_REPLACE, … … 550 578 BLANK_HEADERS); 551 579 psFree(outhead); 552 return false;553 }554 float exptime = psMetadataLookupF32(NULL, file->fpa->concepts,555 "FPA.EXPOSURE"); // Exposure time580 psFree(fpa); 581 return false; 582 } 583 float exptime = psMetadataLookupF32(NULL, fpa->concepts, "FPA.EXPOSURE"); // Exposure time 556 584 psMetadataAddF32(outhead, PS_LIST_TAIL, expName, PS_META_REPLACE, 557 585 "Exposure time (sec)", exptime); … … 565 593 BLANK_HEADERS); 566 594 psFree(outhead); 567 return false; 568 } 569 float airmass = psMetadataLookupF32(NULL, file->fpa->concepts, "FPA.AIRMASS"); // Airmass 595 psFree(fpa); 596 return false; 597 } 598 float airmass = psMetadataLookupF32(NULL, fpa->concepts, "FPA.AIRMASS"); // Airmass 570 599 psMetadataAddF32(outhead, PS_LIST_TAIL, amName, PS_META_REPLACE, 571 600 "Observation airmass", airmass); … … 575 604 const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.OBS"); 576 605 if (fpaNameHdr && strlen(fpaNameHdr) > 0) { 577 const char *fpaName = psMetadataLookupStr(NULL, f ile->fpa->concepts, "FPA.OBS");606 const char *fpaName = psMetadataLookupStr(NULL, fpa->concepts, "FPA.OBS"); 578 607 psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, 579 608 "FPA observation identifier", fpaName); … … 581 610 582 611 // if we have mosaic-level astrometry information, add it here: 583 psMetadata *updates = psMetadataLookupPtr (&status, f ile->fpa->analysis, "PSASTRO.HEADER");612 psMetadata *updates = psMetadataLookupPtr (&status, fpa->analysis, "PSASTRO.HEADER"); 584 613 if (updates) { 585 614 psMetadataCopy (outhead, updates); 586 615 } 616 psFree(fpa); 587 617 588 618 psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
Note:
See TracChangeset
for help on using the changeset viewer.
