Changeset 6859
- Timestamp:
- Apr 14, 2006, 11:43:59 AM (20 years ago)
- Location:
- branches/rel10_ifa/psModules/src
- Files:
-
- 4 added
- 3 deleted
- 24 edited
-
astrom/Makefile.am (modified) (2 diffs)
-
astrom/pmFPA.c (modified) (4 diffs)
-
astrom/pmFPA.h (modified) (2 diffs)
-
astrom/pmFPA_JPEG.c (added)
-
astrom/pmFPA_JPEG.h (added)
-
astrom/pmFPAfile.c (modified) (8 diffs)
-
astrom/pmFPAfile.h (modified) (2 diffs)
-
objects/Makefile.am (modified) (2 diffs)
-
objects/pmFPAviewObjectsIO.h (deleted)
-
objects/pmFPAviewReadObjects.c (deleted)
-
objects/pmFPAviewWriteObjects.c (deleted)
-
objects/pmPSF.c (modified) (2 diffs)
-
objects/pmPSF.h (modified) (2 diffs)
-
objects/pmPSF_IO.c (added)
-
objects/pmPSF_IO.h (added)
-
objects/pmSource.c (modified) (2 diffs)
-
objects/pmSource.h (modified) (2 diffs)
-
objects/pmSourceIO.c (modified) (3 diffs)
-
objects/pmSourceIO.h (modified) (2 diffs)
-
objects/pmSourceIO_CMF.c (modified) (3 diffs)
-
objects/pmSourceIO_CMP.c (modified) (2 diffs)
-
objects/pmSourceIO_OBJ.c (modified) (2 diffs)
-
objects/pmSourceIO_RAW.c (modified) (6 diffs)
-
objects/pmSourceIO_SX.c (modified) (2 diffs)
-
objects/pmSourcePhotometry.c (modified) (5 diffs)
-
objects/pmSourcePhotometry.h (modified) (2 diffs)
-
pslib/psAdditionals.c (modified) (2 diffs)
-
pslib/psAdditionals.h (modified) (1 diff)
-
pslib/psImageUnbin.c (modified) (4 diffs)
-
pslib/psImageUnbin.h (modified) (1 diff)
-
psmodules.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/astrom/Makefile.am
r6720 r6859 18 18 pmConceptsWrite.c \ 19 19 pmConceptsStandard.c \ 20 pmFPA_JPEG.c \ 20 21 pmFPAview.c \ 21 22 pmFPAfile.c … … 41 42 pmConceptsWrite.h \ 42 43 pmConceptsStandard.h \ 44 pmFPA_JPEG.h \ 43 45 pmFPAview.h \ 44 46 pmFPAfile.h -
branches/rel10_ifa/psModules/src/astrom/pmFPA.c
r6854 r6859 12 12 * XXX: Should we implement non-linear cell->chip transforms? 13 13 * 14 * @version $Revision: 1.1.4. 7$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-04-14 03:09:32$14 * @version $Revision: 1.1.4.8 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-04-14 21:43:59 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 512 512 513 513 /***************************************************************************** 514 XXX EAM : I've added the 'exclusive' option. if true all other chips are de-selected 515 XXX EAM : a negative value is valid and, in combinations with exclusive, de-selects all chips 514 516 *****************************************************************************/ 515 bool pmFPASelectChip( 516 pmFPA *fpa, 517 int chipNum) 517 bool pmFPASelectChip(pmFPA *fpa, int chipNum, bool exclusive) 518 518 { 519 519 PS_ASSERT_PTR_NON_NULL(fpa, false); … … 533 533 setCellsProcess(tmpChip, true); 534 534 } else { 535 tmpChip->process = false; 536 setCellsProcess(tmpChip, false); 537 } 538 539 } 540 541 return true; 542 } 543 544 bool pmChipSelectCell(pmChip *chip, 545 int cellNum 546 ) 535 if (exclusive) { 536 tmpChip->process = false; 537 setCellsProcess(tmpChip, false); 538 } 539 } 540 541 } 542 543 return true; 544 } 545 546 /***************************************************************************** 547 XXX EAM : I've added the 'exclusive' option. if true all other chips are de-selected 548 XXX EAM : a negative value is valid and, in combinations with exclusive, de-selects all cells 549 XXX this function should probably be re-defined to merge with 'setCellsProcess' 550 *****************************************************************************/ 551 bool pmChipSelectCell(pmChip *chip, int cellNum, bool exclusive) 547 552 { 548 553 assert(chip); … … 558 563 continue; 559 564 } 560 cell->process = (i == cellNum); 561 } 562 565 if (i == cellNum) { 566 cell->process = true; 567 } else { 568 if (exclusive) { 569 cell->process = false; 570 } 571 } 572 } 563 573 return true; 564 574 } -
branches/rel10_ifa/psModules/src/astrom/pmFPA.h
r6854 r6859 7 7 * @author GLG, MHPCC 8 8 * 9 * @version $Revision: 1.1.4. 7$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-04-14 03:09:32$9 * @version $Revision: 1.1.4.8 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-04-14 21:43:59 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 244 244 bool pmFPASelectChip( 245 245 pmFPA *fpa, 246 int chipNum 246 int chipNum, 247 bool exclusive 247 248 ); 248 249 249 250 bool pmChipSelectCell(pmChip *chip, 250 int cellNum 251 int cellNum, 252 bool exclusive 251 253 ); 252 254 -
branches/rel10_ifa/psModules/src/astrom/pmFPAfile.c
r6850 r6859 11 11 #include "pmFPARead.h" 12 12 #include "pmFPAWrite.h" 13 #include "pmFPAviewObjectsIO.h" 13 #include "pmPeaks.h" 14 #include "pmMoments.h" 15 #include "pmModel.h" 16 #include "pmSource.h" 17 #include "pmSourceIO.h" 18 #include "pmGrowthCurve.h" 19 #include "pmPSF.h" 20 #include "pmPSF_IO.h" 21 #include "pmFPA_JPEG.h" 14 22 15 23 static void pmFPAfileFree (pmFPAfile *file) … … 173 181 if (!strcasecmp (type, "IMAGE")) { 174 182 file->type = PM_FPA_FILE_IMAGE; 183 } 184 if (!strcasecmp (type, "PSF")) { 185 file->type = PM_FPA_FILE_PSF; 186 } 187 if (!strcasecmp (type, "JPEG")) { 188 file->type = PM_FPA_FILE_JPEG; 175 189 } 176 190 } … … 294 308 case PM_FPA_FILE_CMP: 295 309 case PM_FPA_FILE_RAW: 310 case PM_FPA_FILE_PSF: 311 case PM_FPA_FILE_JPEG: 296 312 psTrace ("pmFPAfile", 5, "not opening %s (type: %d)\n", file->filename, file->type); 297 313 break; … … 339 355 break; 340 356 357 case PM_FPA_FILE_PSF: 358 pmFPAviewReadPSFmodel (view, file); 359 psTrace ("pmFPAfile", 5, "reading %s (type: %d)\n", file->filename, file->type); 360 break; 361 362 case PM_FPA_FILE_JPEG: 363 break; 364 341 365 default: 342 366 fprintf (stderr, "warning: type mismatch\n"); … … 378 402 break; 379 403 404 case PM_FPA_FILE_PSF: 405 pmFPAviewWritePSFmodel (view, file); 406 psTrace ("pmFPAfile", 5, "wrote PSF %s (fpa: %p)\n", file->filename, file->fpa); 407 break; 408 409 case PM_FPA_FILE_JPEG: 410 pmFPAviewWriteJPEG (view, file); 411 psTrace ("pmFPAfile", 5, "wrote PSF %s (fpa: %p)\n", file->filename, file->fpa); 412 break; 413 380 414 default: 381 415 fprintf (stderr, "warning: type mismatch\n"); … … 414 448 case PM_FPA_FILE_CMP: 415 449 case PM_FPA_FILE_CMF: 450 case PM_FPA_FILE_PSF: 451 case PM_FPA_FILE_JPEG: 416 452 break; 417 453 … … 453 489 case PM_FPA_FILE_OBJ: 454 490 case PM_FPA_FILE_CMP: 491 case PM_FPA_FILE_PSF: 492 case PM_FPA_FILE_JPEG: 455 493 break; 456 494 … … 775 813 // load the given filerule (from config->camera) and associate it with the fpa 776 814 // the output file is just a view to the file on config->files 815 // XXX the filenames placed on config->files should include the seq number 777 816 file = pmFPAfileDefine (config->files, config->camera, fpa, filename); 778 817 if (!file) { -
branches/rel10_ifa/psModules/src/astrom/pmFPAfile.h
r6847 r6859 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1.1.2.1 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-04-1 3 06:17:28$9 * @version $Revision: 1.1.2.12 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-04-14 21:43:59 $ 11 11 * 12 12 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii … … 34 34 PM_FPA_FILE_RAW, 35 35 PM_FPA_FILE_IMAGE, 36 PM_FPA_FILE_PSF, 37 PM_FPA_FILE_JPEG, 36 38 } pmFPAfileType; 37 39 -
branches/rel10_ifa/psModules/src/objects/Makefile.am
r6848 r6859 20 20 pmSourceIO_RAW.c \ 21 21 pmPSF.c \ 22 pmPSF_IO.c \ 22 23 pmPSFtry.c \ 23 pmGrowthCurve.c \ 24 pmFPAviewReadObjects.c \ 25 pmFPAviewWriteObjects.c 24 pmGrowthCurve.c 26 25 27 26 EXTRA_DIST = \ … … 44 43 pmSourceIO.h \ 45 44 pmPSF.h \ 45 pmPSF_IO.h \ 46 46 pmPSFtry.h \ 47 pmGrowthCurve.h \ 48 pmFPAviewObjectsIO.h 47 pmGrowthCurve.h -
branches/rel10_ifa/psModules/src/objects/pmPSF.c
r6848 r6859 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.4.4. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-04-1 3 06:18:46$8 * @version $Revision: 1.4.4.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-04-14 21:43:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 309 309 return false; 310 310 } 311 312 psMetadata *pmPSFtoMD (psMetadata *metadata, pmPSF *psf)313 {314 315 if (metadata == NULL) {316 metadata = psMetadataAlloc ();317 }318 319 char *modelName = pmModelGetType (psf->type);320 psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_MODEL_NAME", PS_DATA_STRING, "PSF model name", modelName);321 322 psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_POISSON_ERRORS", PS_DATA_BOOL, "Poisson errors for fits", psf->poissonErrors);323 324 int nPar = pmModelParameterCount (psf->type) ;325 psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_MODEL_NPAR", PS_DATA_S32, "PSF model parameter count", nPar);326 327 for (int i = 0; i < nPar - 4; i++) {328 psPolynomial2D *poly = psf->params->data[i];329 psPolynomial2DtoMD (metadata, poly, "PSF_PAR%02d", i);330 }331 psPolynomial4DtoMD (metadata, psf->ApTrend, "APTREND");332 333 psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_AP_RESID", PS_DATA_F32, "aperture residual", psf->ApResid);334 psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_dAP_RESID", PS_DATA_F32, "aperture residual scatter", psf->dApResid);335 psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_SKY_BIAS", PS_DATA_F32, "sky bias level", psf->skyBias);336 337 psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_CHISQ", PS_DATA_F32, "chi-square for fit", psf->chisq);338 psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_NSTARS", PS_DATA_S32, "number of stars used to measure PSF", psf->nPSFstars);339 340 return metadata;341 }342 343 pmPSF *pmPSFfromMD (psMetadata *metadata)344 {345 346 bool status;347 char keyword[80];348 349 char *modelName = psMetadataLookupPtr (&status, metadata, "PSF_MODEL_NAME");350 pmModelType type = pmModelSetType (modelName);351 352 bool poissonErrors = psMetadataLookupPtr (&status, metadata, "PSF_POISSON_ERRORS");353 if (!status)354 poissonErrors = true;355 356 pmPSF *psf = pmPSFAlloc (type, poissonErrors);357 358 int nPar = psMetadataLookupS32 (&status, metadata, "PSF_MODEL_NPAR");359 if (nPar != pmModelParameterCount (psf->type))360 psAbort ("read PSF" , "mismatch model par count");361 362 for (int i = 0; i < nPar - 4; i++) {363 sprintf (keyword, "PSF_PAR%02d", i);364 psMetadata *folder = psMetadataLookupPtr (&status, metadata, keyword);365 psPolynomial2D *poly = psPolynomial2DfromMD (folder);366 psFree (psf->params->data[i]);367 psf->params->data[i] = poly;368 }369 sprintf (keyword, "APTREND");370 psMetadata *folder = psMetadataLookupPtr (&status, metadata, keyword);371 psPolynomial4D *poly = psPolynomial4DfromMD (folder);372 psFree (psf->ApTrend);373 psf->ApTrend = poly;374 375 psf->ApResid = psMetadataLookupF32 (&status, metadata, "PSF_AP_RESID");376 psf->dApResid = psMetadataLookupF32 (&status, metadata, "PSF_dAP_RESID");377 psf->skyBias = psMetadataLookupF32 (&status, metadata, "PSF_SKY_BIAS");378 379 psf->chisq = psMetadataLookupF32 (&status, metadata, "PSF_CHISQ");380 psf->nPSFstars = psMetadataLookupS32 (&status, metadata, "PSF_NSTARS");381 382 psFree (metadata);383 return (psf);384 } -
branches/rel10_ifa/psModules/src/objects/pmPSF.h
r6848 r6859 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.1.22. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-04-1 3 06:18:46$8 * @version $Revision: 1.1.22.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-04-14 21:43:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 103 103 104 104 bool pmPSF_MaskApTrend (pmPSF *psf, pmPSF_ApTrendOptions option); 105 psMetadata *pmPSFtoMD (psMetadata *metadata, pmPSF *psf);106 pmPSF *pmPSFfromMD (psMetadata *metadata);107 105 108 106 # endif -
branches/rel10_ifa/psModules/src/objects/pmSource.c
r6556 r6859 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.1.2. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-0 3-09 03:14:23$8 * @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-04-14 21:43:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 57 57 tmp->mode = PM_SOURCE_MODE_DEFAULT; 58 58 psMemSetDeallocator(tmp, (psFreeFunc) sourceFree); 59 60 tmp->psfMag = 32.0; 61 tmp->extMag = 32.0; 62 tmp->errMag = 32.0; 63 tmp->apMag = 32.0; 64 tmp->pixWeight = 0.0; 59 65 60 66 psTrace(__func__, 3, "---- %s() end ----\n", __func__); -
branches/rel10_ifa/psModules/src/objects/pmSource.h
r6556 r6859 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.1.2. 2$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-0 3-09 03:14:23$5 * @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-14 21:43:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 85 85 float errMag; 86 86 float apMag; 87 float pixWeight; // model-weighted coverage of valid pixels 87 88 psRegion region; // area on image covered by selected pixels 88 89 } -
branches/rel10_ifa/psModules/src/objects/pmSourceIO.c
r6712 r6859 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.1.2. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-0 3-28 02:14:56$5 * @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-14 21:43:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 14 14 #include <string.h> 15 15 #include "pslib.h" 16 #include "psAdditionals.h" 16 17 #include "pmHDU.h" 17 18 #include "pmFPA.h" 19 #include "pmFPAview.h" 20 #include "pmFPAfile.h" 21 18 22 #include "pmPeaks.h" 19 23 #include "pmMoments.h" … … 53 57 } 54 58 59 // Given a FITS file pointer, read the table of object data 60 bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file) 61 { 62 63 pmFPA *fpa = file->fpa; 64 65 if (view->chip == -1) { 66 pmFPAWriteObjects (fpa, view, file); 67 return true; 68 } 69 70 if (view->chip >= fpa->chips->n) { 71 return false; 72 } 73 pmChip *chip = fpa->chips->data[view->chip]; 74 75 if (view->cell == -1) { 76 pmChipWriteObjects (chip, view, file); 77 return true; 78 } 79 80 if (view->cell >= chip->cells->n) { 81 return false; 82 } 83 pmCell *cell = chip->cells->data[view->cell]; 84 85 if (view->readout == -1) { 86 pmCellWriteObjects (cell, view, file); 87 return true; 88 } 89 90 if (view->readout >= cell->readouts->n) { 91 return false; 92 } 93 pmReadout *readout = cell->readouts->data[view->readout]; 94 95 pmReadoutWriteObjects (readout, view, file); 96 return true; 97 } 98 99 // read in all chip-level Objects files for this FPA 100 bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file) 101 { 102 103 for (int i = 0; i < fpa->chips->n; i++) { 104 105 pmChip *chip = fpa->chips->data[i]; 106 pmChipWriteObjects (chip, view, file); 107 } 108 return true; 109 } 110 111 // read in all cell-level Objects files for this chip 112 bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file) 113 { 114 115 for (int i = 0; i < chip->cells->n; i++) { 116 117 pmCell *cell = chip->cells->data[i]; 118 pmCellWriteObjects (cell, view, file); 119 } 120 return true; 121 } 122 123 // read in all readout-level Objects files for this cell 124 bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file) 125 { 126 127 for (int i = 0; i < cell->readouts->n; i++) { 128 129 pmReadout *readout = cell->readouts->data[i]; 130 pmReadoutWriteObjects (readout, view, file); 131 } 132 return true; 133 } 134 135 // read in all readout-level Objects files for this cell 136 bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file) 137 { 138 139 bool status; 140 char *filename; 141 char *dataname; 142 char *headname; 143 pmHDU *hdu; 144 pmHDU *phu; 145 psMetadata *updates; 146 psMetadata *outhead; 147 148 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 149 150 switch (file->type) { 151 case PM_FPA_FILE_RAW: 152 filename = pmFPAfileNameFromRule (file->filerule, file, view); 153 pmSourcesWriteRAW (sources, filename); 154 psFree (filename); 155 break; 156 157 case PM_FPA_FILE_OBJ: 158 filename = pmFPAfileNameFromRule (file->filerule, file, view); 159 pmSourcesWriteOBJ (sources, filename); 160 psFree (filename); 161 break; 162 163 case PM_FPA_FILE_SX: 164 filename = pmFPAfileNameFromRule (file->filerule, file, view); 165 pmSourcesWriteSX (sources, filename); 166 psFree (filename); 167 break; 168 169 case PM_FPA_FILE_CMP: 170 // a SPLIT format : only one header and object table per file 171 hdu = pmFPAviewThisHDU (view, file->fpa); 172 filename = pmFPAfileNameFromRule (file->filerule, file, view); 173 174 // copy the header to an output header, add the output header data 175 outhead = psMetadataCopy (NULL, hdu->header); 176 177 // check/fix first line (must be SIMPLE = F) 178 psMetadataItem *item = psMetadataGet (outhead, PS_LIST_HEAD); 179 if (strcmp (item->name, "SIMPLE") && strcmp (item->name, "XTENSION")) { 180 psErrorStackPrint(stderr, "invalid header: first line is neither SIMPLE nor XTENSION\n"); 181 exit(EXIT_FAILURE); 182 } 183 if (!strcmp (item->name, "XTENSION")) { 184 psMetadataRemoveIndex (outhead, PS_LIST_HEAD); 185 } 186 psMetadataAddBool (outhead, PS_LIST_HEAD, "SIMPLE", PS_META_REPLACE, "CMP file, not simple", false); 187 188 // copy over the entries saved in the 189 updates = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.HEADER"); 190 psMetadataCopy (outhead, updates); 191 192 pmSourcesWriteCMP (sources, filename, outhead); 193 psFree (outhead); 194 psFree (filename); 195 break; 196 197 case PM_FPA_FILE_CMF: 198 // write a PHU? 199 // write a header? 200 // write the data 201 202 // get the current header 203 hdu = pmFPAviewThisHDU (view, file->fpa); 204 205 // if file does not yet have a PHU, write it to disk 206 if (file->phu == NULL) { 207 // get the corresponding phu 208 phu = pmFPAviewThisPHU (view, file->fpa); 209 210 // CMF always has extensions 211 outhead = psMetadataCopy (NULL, phu->header); 212 psMetadataAdd (outhead, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true); 213 psFitsWriteHeaderNotImage (file->fits, outhead); 214 file->phu = phu->header; 215 psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type); 216 psFree (outhead); 217 } 218 219 // this this header block is new, write it to disk, 220 if (hdu->header != file->header) { 221 // determine name for header extension 222 headname = pmFPAfileNameFromRule (file->extxtra, file, view); 223 outhead = psMetadataCopy (NULL, hdu->header); 224 psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "extension name", headname); 225 psFitsWriteHeaderNotImage (file->fits, outhead); 226 psTrace ("pmFPAfile", 5, "wrote ext head %s (type: %d)\n", file->filename, file->type); 227 file->header = hdu->header; 228 psFree (outhead); 229 psFree (headname); 230 } 231 232 // write this table to disk 233 dataname = pmFPAfileNameFromRule (file->extrule, file, view); 234 updates = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.HEADER"); 235 pmSourcesWriteCMF (file->fits, sources, updates, dataname); 236 psTrace ("pmFPAfile", 5, "wrote ext data %s (type: %d)\n", file->filename, file->type); 237 psFree (dataname); 238 break; 239 240 default: 241 fprintf (stderr, "warning: type mismatch\n"); 242 break; 243 } 244 return true; 245 } 246 // a MEF CMF file has: PHU, CELL-HEAD, TABLE, CELL-HEAD, TABLE, TABLE, TABLE... 247 248 // Given a FITS file pointer, read the table of object data 249 bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file) 250 { 251 pmFPA *fpa = file->fpa; 252 253 if (view->chip == -1) { 254 pmFPAReadObjects (fpa, view, file); 255 return true; 256 } 257 258 if (view->chip >= fpa->chips->n) { 259 return false; 260 } 261 pmChip *chip = fpa->chips->data[view->chip]; 262 263 if (view->cell == -1) { 264 pmChipReadObjects (chip, view, file); 265 return true; 266 } 267 268 if (view->cell >= chip->cells->n) { 269 return false; 270 } 271 pmCell *cell = chip->cells->data[view->cell]; 272 273 if (view->readout == -1) { 274 pmCellReadObjects (cell, view, file); 275 return true; 276 } 277 278 if (view->readout >= cell->readouts->n) { 279 return false; 280 } 281 pmReadout *readout = cell->readouts->data[view->readout]; 282 283 pmReadoutReadObjects (readout, view, file); 284 return true; 285 } 286 287 // read in all chip-level Objects files for this FPA 288 bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file) 289 { 290 291 for (int i = 0; i < fpa->chips->n; i++) { 292 293 pmChip *chip = fpa->chips->data[i]; 294 pmChipReadObjects (chip, view, file); 295 } 296 return true; 297 } 298 299 // read in all cell-level Objects files for this chip 300 bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file) 301 { 302 303 for (int i = 0; i < chip->cells->n; i++) { 304 305 pmCell *cell = chip->cells->data[i]; 306 pmCellReadObjects (cell, view, file); 307 } 308 return true; 309 } 310 311 // read in all readout-level Objects files for this cell 312 bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file) 313 { 314 315 for (int i = 0; i < cell->readouts->n; i++) { 316 317 pmReadout *readout = cell->readouts->data[i]; 318 pmReadoutReadObjects (readout, view, file); 319 } 320 return true; 321 } 322 323 // read in all readout-level Objects files for this cell 324 bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file) 325 { 326 327 bool status; 328 psArray *sources; 329 pmHDU *hdu; 330 331 switch (file->type) { 332 case PM_FPA_FILE_OBJ: 333 fprintf (stderr, "warning: OBJ is not supported as an input object format\n"); 334 break; 335 336 case PM_FPA_FILE_SX: 337 fprintf (stderr, "warning: SX is not supported as an input object format\n"); 338 break; 339 340 case PM_FPA_FILE_CMP: 341 // a SPLIT format : only one header and object table per file 342 343 // read in header, if not yet loaded 344 hdu = pmFPAviewThisHDU (view, file->fpa); 345 346 char *filename = pmFPAfileNameFromRule (file->filerule, file, view); 347 file->fits = psFitsOpen (filename, "r"); 348 hdu->header = psFitsReadHeader (NULL, file->fits); 349 psFitsClose (file->fits); 350 sources = pmSourcesReadCMP (filename, hdu->header); 351 psFree (filename); 352 break; 353 354 case PM_FPA_FILE_CMF: 355 // read in header, if not yet loaded 356 hdu = pmFPAviewThisHDU (view, file->fpa); 357 if (hdu->header == NULL) { 358 char *headname = pmFPAfileNameFromRule (file->extxtra, file, view); 359 psFitsMoveExtName (file->fits, headname); 360 hdu->header = psFitsReadHeader (NULL, file->fits); 361 psFree (headname); 362 } 363 364 char *dataname = pmFPAfileNameFromRule (file->extrule, file, view); 365 psFitsMoveExtName (file->fits, dataname); 366 sources = pmSourcesReadCMF (file->fits, hdu->header); 367 psFree (dataname); 368 break; 369 370 default: 371 fprintf (stderr, "warning: type mismatch\n"); 372 break; 373 } 374 status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources); 375 return true; 376 } 377 378 -
branches/rel10_ifa/psModules/src/objects/pmSourceIO.h
r6712 r6859 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.1.2. 2$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-0 3-28 02:14:56$5 * @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-14 21:43:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 30 30 bool pmPeaksWriteText (psArray *peaks, char *filename); 31 31 32 bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file); 33 bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file); 34 bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file); 35 bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file); 36 bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file); 37 38 bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file); 39 bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file); 40 bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file); 41 bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file); 42 bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file); 43 32 44 # endif /* PM_SOURCE_IO_H */ -
branches/rel10_ifa/psModules/src/objects/pmSourceIO_CMF.c
r6726 r6859 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.1.2. 5$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-0 3-29 20:55:42$5 * @version $Revision: 1.1.2.6 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-14 21:43:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 17 17 #include "pmHDU.h" 18 18 #include "pmFPA.h" 19 #include "pmFPAview.h" 20 #include "pmFPAfile.h" 21 19 22 #include "pmPeaks.h" 20 23 #include "pmMoments.h" … … 76 79 psMetadataAdd (row, PS_LIST_TAIL, "THETA", PS_DATA_F32, "", axes.theta); 77 80 psMetadataAdd (row, PS_LIST_TAIL, "DOPHOT", PS_DATA_U8, "", type); 78 psMetadataAdd (row, PS_LIST_TAIL, "DUMMY", PS_DATA_STRING, "", "123"); 81 psMetadataAdd (row, PS_LIST_TAIL, "WEIGHT", PS_DATA_U8, "", PS_MIN (255, PS_MAX(0, 255*source->pixWeight))); 82 psMetadataAdd (row, PS_LIST_TAIL, "DUMMY", PS_DATA_STRING, "", "12"); 79 83 80 84 psArrayAdd (table, 100, row); -
branches/rel10_ifa/psModules/src/objects/pmSourceIO_CMP.c
r6726 r6859 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.1.2. 4$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-0 3-29 20:55:42$5 * @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-14 21:43:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include "pmHDU.h" 19 19 #include "pmFPA.h" 20 #include "pmFPAview.h" 21 #include "pmFPAfile.h" 22 20 23 #include "pmPeaks.h" 21 24 #include "pmMoments.h" -
branches/rel10_ifa/psModules/src/objects/pmSourceIO_OBJ.c
r6565 r6859 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.1.2. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-0 3-09 04:25:03$5 * @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-14 21:43:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include "pmHDU.h" 19 19 #include "pmFPA.h" 20 #include "pmFPAview.h" 21 #include "pmFPAfile.h" 22 20 23 #include "pmPeaks.h" 21 24 #include "pmMoments.h" -
branches/rel10_ifa/psModules/src/objects/pmSourceIO_RAW.c
r6848 r6859 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.1.2. 4$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-04-1 3 06:18:46$5 * @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-14 21:43:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include "pmHDU.h" 19 19 #include "pmFPA.h" 20 #include "pmFPAview.h" 21 #include "pmFPAfile.h" 22 20 23 #include "pmPeaks.h" 21 24 #include "pmMoments.h" … … 91 94 fprintf (f, "%9.6f ", dPAR[j]); 92 95 } 93 fprintf (f, ": %8.4f %2d %#5x %7.3f %7.3f %7.1f %7.2f %4 d %2d\n",96 fprintf (f, ": %8.4f %2d %#5x %7.3f %7.3f %7.1f %7.2f %4.2f %4d %2d\n", 94 97 source[0].apMag, source[0].type, source[0].mode, 95 98 log10(model[0].chisq/model[0].nDOF), … … 97 100 source[0].moments->SN, 98 101 model[0].radiusTMP, 102 source[0].pixWeight, 99 103 model[0].nDOF, 100 104 model[0].nIter); … … 147 151 fprintf (f, "%9.6f ", dPAR[j]); 148 152 } 149 fprintf (f, ": %7.4f %2d %#5x %7.3f %7.3f %7.1f %7.2f %4 d %2d\n",153 fprintf (f, ": %7.4f %2d %#5x %7.3f %7.3f %7.1f %7.2f %4.2f %4d %2d\n", 150 154 source->apMag, 151 155 source[0].type, source[0].mode, … … 154 158 source[0].moments->SN, 155 159 model[0].radiusTMP, 160 source[0].pixWeight, 156 161 model[0].nDOF, 157 162 model[0].nIter); -
branches/rel10_ifa/psModules/src/objects/pmSourceIO_SX.c
r6726 r6859 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.1.2. 4$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-0 3-29 20:55:42$5 * @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-14 21:43:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include "pmHDU.h" 19 19 #include "pmFPA.h" 20 #include "pmFPAview.h" 21 #include "pmFPAfile.h" 22 20 23 #include "pmPeaks.h" 21 24 #include "pmMoments.h" -
branches/rel10_ifa/psModules/src/objects/pmSourcePhotometry.c
r6751 r6859 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.1.2. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-04- 01 02:47:20$5 * @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-14 21:43:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 25 25 #include "pmSourcePhotometry.h" 26 26 27 # define DO_SKY 0 28 27 29 static float AP_MIN_SN = 0.0; 28 30 … … 105 107 status = pmSourcePhotometryModel (&source->extMag, source->modelEXT); 106 108 109 // measure the weight of included pixels 110 status = pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->mask); 111 107 112 // measure object aperture photometry 108 113 if (SN > AP_MIN_SN) { … … 169 174 } 170 175 171 # define DO_SKY 0172 176 // return source aperture magnitude 173 177 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask) … … 202 206 } 203 207 204 # if (0) 205 // XXX split into ap, psf, ext mags? 206 bool pmSourcePhotometry (float *fitMag, float *apMag, pmModel *model, psImage *image, psImage *mask) 207 { 208 209 float obsSum = 0; 210 float fitSum = 0; 211 float sky = model->params->data.F32[0]; 212 213 *fitMag = 99.0; 214 *obsMag = 99.0; 215 216 // measure fitMag 217 pmModelFlux modelFluxFunc = pmModelFlux_GetFunction (model->type); 218 fitSum = modelFluxFunc (model->params); 219 if (fitSum <= 0) 220 return false; 221 if (!isfinite(fitSum)) 222 return false; 223 *fitMag = -2.5*log10(fitSum); 224 225 // measure apMag 226 for (int ix = 0; ix < image->numCols; ix++) { 227 for (int iy = 0; iy < image->numRows; iy++) { 228 if (mask->data.U8[iy][ix]) 229 continue; 230 obsSum += image->data.F32[iy][ix] - sky; 231 } 232 } 233 if (obsSum <= 0) 234 return false; 235 *obsMag = -2.5*log10(obsSum); 236 208 // return source aperture magnitude 209 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask) 210 { 211 float modelSum = 0; 212 float validSum = 0; 213 float sky = 0; 214 float value; 215 216 int Xo, Yo, dP; 217 int dX, DX, NX; 218 int dY, DY, NY; 219 220 *pixWeight = 0.0; 221 222 if (model == NULL) 223 return false; 224 225 // we only care about the value of the object model, not the local sky 226 if (DO_SKY) { 227 sky = model->params->data.F32[0]; 228 } else { 229 sky = 0; 230 } 231 232 // the model function returns the source flux at a position 233 pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type); 234 psVector *coord = psVectorAlloc(2, PS_TYPE_F32); 235 psVector *params = model->params; 236 237 Xo = params->data.F32[2]; 238 Yo = params->data.F32[3]; 239 240 dX = Xo - image->col0; 241 dP = image->numCols - dX; 242 DX = PS_MAX(dX, dP); 243 NX = image->numCols; 244 245 dY = Yo - image->row0; 246 dP = image->numRows - dY; 247 DY = PS_MAX(dY, dP); 248 NY = image->numRows; 249 250 // measure modelSum and validSum 251 // XXX this does not work for sources near the edge: we need to measure for 252 // a full square region 253 for (int ix = -DX; ix < DX + 1; ix++) { 254 int mx = ix + dX; 255 for (int iy = -DY; iy < DY + 1; iy++) { 256 int my = iy + dY; 257 258 coord->data.F32[0] = (psF32) (ix + Xo); 259 coord->data.F32[1] = (psF32) (iy + Yo); 260 261 // for the full model, add all points 262 value = modelFunc (NULL, params, coord) - sky; 263 modelSum += value; 264 265 // include count only the unmasked pixels within the image area 266 if (mx < 0) 267 continue; 268 if (my < 0) 269 continue; 270 if (mx >= NX) 271 continue; 272 if (my >= NY) 273 continue; 274 if (mask->data.U8[my][mx]) 275 continue; 276 277 validSum += value; 278 } 279 } 280 if (validSum <= 0) 281 return false; 282 283 *pixWeight = validSum / modelSum; 237 284 return (true); 238 285 } 239 # endif240 286 241 287 float pmSourceCrossProduct (pmSource *Mi, pmSource *Mj) -
branches/rel10_ifa/psModules/src/objects/pmSourcePhotometry.h
r6751 r6859 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.1.2. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-04- 01 02:47:20$5 * @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-04-14 21:43:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 40 40 float pmSourceCrossProduct (pmSource *Mi, pmSource *Mj); 41 41 float pmSourceCrossWeight (pmSource *Mi, pmSource *Mj); 42 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask); 42 43 43 44 # endif /* PM_SOURCE_PHOTOMETRY_H */ -
branches/rel10_ifa/psModules/src/pslib/psAdditionals.c
r6725 r6859 143 143 { 144 144 psList *values = psListAlloc(NULL); // The list of values to return 145 if (string == NULL) 146 return values; // NULL string is not an error, just an empty list 147 145 148 unsigned int length = strlen(string); // The length of the string 146 149 unsigned int numSplitters = strlen(splitters); // Number of characters that might split … … 176 179 } 177 180 181 psArray *psStringSplitArray (const char *string, const char *splitters) 182 { 183 184 psList *list = psStringSplit (string, splitters); 185 psArray *array = psListToArray (list); 186 psFree (list); 187 return array; 188 } 189 178 190 #ifndef whitespace 179 191 #define whitespace(c) (((c) == ' ') || ((c) == '\t')) -
branches/rel10_ifa/psModules/src/pslib/psAdditionals.h
r6848 r6859 30 30 ); 31 31 32 // Split string on given characters 33 psArray *psStringSplitArray(const char *string, // String to split 34 const char *splitters // Characters on which to split 35 ); 36 32 37 // strip whitespace from head and tail of string 33 38 int psStringStrip (char *string); -
branches/rel10_ifa/psModules/src/pslib/psImageUnbin.c
r6826 r6859 179 179 } 180 180 181 doublepsImageClippedStats (psImage *image, psImage *mask, psU8 maskValue, double fmin, double fmax)181 psStats *psImageClippedStats (psImage *image, psImage *mask, psU8 maskValue, double fmin, double fmax) 182 182 { 183 183 double value; … … 185 185 int ny = image->numRows; 186 186 187 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_QUARTILE); 187 188 if (nx*ny <= 0) 188 return 0.0;189 return stats; 189 190 190 191 int Nsubset = PS_MIN (MAX_SAMPLE_PIXELS, nx*ny); … … 203 204 int iy = pixel / nx; 204 205 205 if (mask ->data.U8[iy][ix] & maskValue)206 if (mask && mask->data.U8[iy][ix] & maskValue) 206 207 continue; 207 208 … … 226 227 value = value / npts; 227 228 229 stats->robustMedian = value; 230 stats->robustUQ = values->data.F32[imax]; 231 stats->robustLQ = values->data.F32[imin]; 232 233 psFree (values); 234 return stats; 228 235 // XXX correct for selection bias?? 229 230 psFree (values);231 return value;232 236 } 233 237 -
branches/rel10_ifa/psModules/src/pslib/psImageUnbin.h
r6826 r6859 11 11 12 12 // my temporary image stats function; seems to be much faster than psLib??? 13 doublepsImageClippedStats (psImage *image, psImage *mask, psU8 maskValue, double fmin, double fmax);13 psStats *psImageClippedStats (psImage *image, psImage *mask, psU8 maskValue, double fmin, double fmax); 14 14 15 15 // my temporary sort which is based on N.R.; seems to be faster than psLib sort??? -
branches/rel10_ifa/psModules/src/psmodules.h
r6848 r6859 35 35 #include <pmFPARead.h> 36 36 #include <pmFPAWrite.h> 37 #include <pmFPA_JPEG.h> 38 37 39 #include <pmReadout.h> 38 40 // #include <pmChipMosaic.h> … … 66 68 # include <pmGrowthCurve.h> 67 69 # include <pmPSF.h> 70 # include <pmPSF_IO.h> 68 71 # include <pmPSFtry.h> 69 72 # include <pmModelGroup.h> 70 73 # include <pmSourcePhotometry.h> 71 # include <pmFPAviewObjectsIO.h>72 74 73 75 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
