Changeset 18601 for trunk/psModules/src/objects
- Timestamp:
- Jul 17, 2008, 12:38:15 PM (18 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 4 edited
-
pmPSF_IO.c (modified) (15 diffs)
-
pmPSF_IO.h (modified) (2 diffs)
-
pmSourceIO.c (modified) (22 diffs)
-
pmSourceIO.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSF_IO.c
r18600 r18601 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2008-07-17 2 0:43:38$8 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2008-07-17 22:38:15 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "pmFPAview.h" 36 36 #include "pmFPAfile.h" 37 #include "pmFPAfileFitsIO.h" 37 38 38 39 #include "pmPeaks.h" … … 107 108 } 108 109 109 bool pmPSFmodelWriteForView (const pmFPAview *view, pmFPAfile *file, constpmConfig *config)110 bool pmPSFmodelWriteForView (const pmFPAview *view, pmFPAfile *file, pmConfig *config) 110 111 { 111 112 PS_ASSERT_PTR_NON_NULL(view, false); … … 142 143 143 144 // read in all chip-level PSFmodel files for this FPA 144 bool pmPSFmodelWriteFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, constpmConfig *config)145 bool pmPSFmodelWriteFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config) 145 146 { 146 147 PS_ASSERT_PTR_NON_NULL(view, false); … … 164 165 165 166 // read in all cell-level PSFmodel files for this chip 166 bool pmPSFmodelWriteChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, constpmConfig *config)167 bool pmPSFmodelWriteChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config) 167 168 { 168 169 PS_ASSERT_PTR_NON_NULL(view, false); … … 185 186 // - psf table (+header) : FITS Table 186 187 bool pmPSFmodelWrite (psMetadata *analysis, const pmFPAview *view, 187 pmFPAfile *file, constpmConfig *config)188 pmFPAfile *file, pmConfig *config) 188 189 { 189 190 PS_ASSERT_PTR_NON_NULL(view, false); … … 208 209 209 210 // get the current header 210 pmHDU *hdu = pmFPAviewThisHDU (view, file->fpa); 211 pmFPA *fpa = pmFPAfileSuitableFPA(file, view, config, false); // Suitable FPA for writing 212 pmHDU *hdu = psMemIncrRefCounter(pmFPAviewThisHDU(view, fpa)); 213 psFree(fpa); 211 214 if (!hdu) { 212 215 psError(PS_ERR_UNKNOWN, false, "Unable to find HDU"); … … 229 232 if (!menu) { 230 233 psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config"); 234 psFree(hdu); 231 235 return false; 232 236 } … … 236 240 if (!rule) { 237 241 psError(PS_ERR_UNKNOWN, false, "missing entry for PSF.HEAD in EXTNAME.RULES in camera.config"); 242 psFree(hdu); 238 243 return false; 239 244 } … … 245 250 psError(PS_ERR_UNKNOWN, false, "missing entry for PSF.TABLE in EXTNAME.RULES in camera.config"); 246 251 psFree (headName); 252 psFree(hdu); 247 253 return false; 248 254 } … … 255 261 psFree (headName); 256 262 psFree (tableName); 263 psFree(hdu); 257 264 return false; 258 265 } … … 278 285 psFree (headName); 279 286 } 287 psFree(hdu); 280 288 281 289 // select the psf of interest … … 481 489 482 490 // if this file needs to have a PHU written out, write one 483 bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, constpmConfig *config)491 bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config) 484 492 { 485 493 PS_ASSERT_PTR_NON_NULL(view, false); … … 496 504 if (file->fpa->chips->n == 1) return true; 497 505 506 498 507 // find the FPA phu 499 pmHDU *phu = pmFPAviewThisPHU (view, file->fpa); 508 pmFPA *fpa = pmFPAfileSuitableFPA(file, view, config, false); // Suitable FPA for writing 509 pmHDU *phu = psMemIncrRefCounter(pmFPAviewThisPHU(view, fpa)); 510 psFree(fpa); 500 511 501 512 // if there is no PHU, this is a single header+image (extension-less) file. This could be … … 508 519 pmConfigConformHeader (outhead, file->format); 509 520 } 521 psFree(phu); 510 522 511 523 psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true); -
trunk/psModules/src/objects/pmPSF_IO.h
r15000 r18601 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $9 * @date $Date: 200 7-09-24 21:27:58$8 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2008-07-17 22:38:15 $ 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 11 */ … … 17 17 /// @{ 18 18 19 bool pmPSFmodelWriteForView (const pmFPAview *view, pmFPAfile *file, constpmConfig *config);20 bool pmPSFmodelWriteFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, constpmConfig *config);21 bool pmPSFmodelWriteChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, constpmConfig *config);22 bool pmPSFmodelWrite (psMetadata *analysis, const pmFPAview *view, pmFPAfile *file, constpmConfig *config);19 bool pmPSFmodelWriteForView (const pmFPAview *view, pmFPAfile *file, pmConfig *config); 20 bool pmPSFmodelWriteFPA (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config); 21 bool pmPSFmodelWriteChip (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config); 22 bool pmPSFmodelWrite (psMetadata *analysis, const pmFPAview *view, pmFPAfile *file, pmConfig *config); 23 23 24 bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, constpmConfig *config);24 bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config); 25 25 26 26 bool pmPSFmodelReadForView (const pmFPAview *view, pmFPAfile *file, const pmConfig *config); -
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); -
trunk/psModules/src/objects/pmSourceIO.h
r17850 r18601 4 4 * @author EAM, IfA; GLG, MHPCC 5 5 * 6 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $7 * @date $Date: 2008-0 5-29 13:25:38$6 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2008-07-17 22:38:15 $ 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 9 9 * … … 30 30 bool pmSourcesWrite_PS1_DEV_1_XFIT (psFits *fits, psArray *sources, char *extname); 31 31 32 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, constpmConfig *config);32 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config); 33 33 34 34 psArray *pmSourcesReadCMP (char *filename, psMetadata *header); … … 50 50 bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config); 51 51 52 bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file, constpmConfig *config);52 bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file, pmConfig *config); 53 53 bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config); 54 54 bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config);
Note:
See TracChangeset
for help on using the changeset viewer.
