- Timestamp:
- Mar 8, 2006, 5:14:23 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/objects/pmSourceIO_CMF.c
r6545 r6556 1 # include "pmSource.h" 1 /** @file pmSourceIO.c 2 * 3 * @author EAM, IfA 4 * 5 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-03-09 03:14:23 $ 7 * 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 9 * 10 */ 11 12 #include <stdio.h> 13 #include <math.h> 14 #include <string.h> 15 #include "pslib.h" 16 #include "psEllipse.h" 17 #include "pmHDU.h" 18 #include "pmFPA.h" 19 #include "pmPeaks.h" 20 #include "pmMoments.h" 21 #include "pmGrowthCurve.h" 22 #include "pmModel.h" 23 #include "pmPSF.h" 24 #include "pmSource.h" 25 #include "pmModelGroup.h" 26 #include "pmSourceIO.h" 2 27 3 28 // elixir-style FITS table output (header + table in 1st extension) … … 12 37 int i, type; 13 38 psF32 *PAR, *dPAR; 14 float dmag,lsky;39 float lsky; 15 40 bool status; 41 EllipseShape shape; 42 EllipseAxes axes; 16 43 17 44 // find config information for output header … … 23 50 for (i = 0; i < sources->n; i++) { 24 51 pmSource *source = (pmSource *) sources->data[i]; 25 pmModel *model = pm ModelSelect(source);52 pmModel *model = pmSourceSelectModel (source); 26 53 if (model == NULL) 27 54 continue; … … 30 57 dPAR = model->dparams->data.F32; 31 58 32 dmag = dPAR[1] / PAR[1];33 59 type = pmSourceDophotType (source); 34 60 lsky = (PAR[0] < 1.0) ? 0.0 : log10(PAR[0]); 61 62 shape.sx = PAR[4]; 63 shape.sy = PAR[5]; 64 shape.sxy = PAR[6]; 65 axes = EllipseShapeToAxes (shape); 35 66 36 67 row = psMetadataAlloc (); 37 68 psMetadataAdd (row, PS_LIST_TAIL, "X_PIX", PS_DATA_F32, "", PAR[2]); 38 69 psMetadataAdd (row, PS_LIST_TAIL, "Y_PIX", PS_DATA_F32, "", PAR[3]); 39 psMetadataAdd (row, PS_LIST_TAIL, "MAG_RAW", PS_DATA_F32, "", source->fitMag + ZERO_POINT);40 psMetadataAdd (row, PS_LIST_TAIL, "MAG_ ERR", PS_DATA_F32, "", (int)(1000*dmag));41 psMetadataAdd (row, PS_LIST_TAIL, "MAG_ GAL", PS_DATA_F32, "", 32.0);42 psMetadataAdd (row, PS_LIST_TAIL, "MAG_ AP", PS_DATA_F32, "", source->apMag + ZERO_POINT);70 psMetadataAdd (row, PS_LIST_TAIL, "MAG_RAW", PS_DATA_F32, "", PS_MIN (99.0, source->psfMag + ZERO_POINT)); 71 psMetadataAdd (row, PS_LIST_TAIL, "MAG_GAL", PS_DATA_F32, "", PS_MIN (99.0, source->extMag + ZERO_POINT)); 72 psMetadataAdd (row, PS_LIST_TAIL, "MAG_AP", PS_DATA_F32, "", PS_MIN (99.0, source->apMag + ZERO_POINT)); 73 psMetadataAdd (row, PS_LIST_TAIL, "MAG_ERR", PS_DATA_F32, "", PS_MIN (999, 1000*source->errMag)); 43 74 psMetadataAdd (row, PS_LIST_TAIL, "LOG_SKY", PS_DATA_F32, "", lsky); 44 psMetadataAdd (row, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32, "", type);45 psMetadataAdd (row, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32, "", PAR[4]);46 psMetadataAdd (row, PS_LIST_TAIL, "THETA", PS_DATA_F32, "", PAR[5]);47 psMetadataAdd (row, PS_LIST_TAIL, "DOPHOT", PS_DATA_ STRING, "", "0");75 psMetadataAdd (row, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32, "", axes.major); 76 psMetadataAdd (row, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32, "", axes.minor); 77 psMetadataAdd (row, PS_LIST_TAIL, "THETA", PS_DATA_F32, "", axes.theta); 78 psMetadataAdd (row, PS_LIST_TAIL, "DOPHOT", PS_DATA_U8, "", type); 48 79 psMetadataAdd (row, PS_LIST_TAIL, "DUMMY", PS_DATA_STRING, "", "123"); 49 80 … … 62 93 63 94 // read in a readout from the fits file 64 psArray *pm ReadoutReadCMF (psFits *fits, psMetadata *header)95 psArray *pmSourcesReadCMF (psFits *fits, psMetadata *header) 65 96 { 66 97 67 98 bool status; 99 psF32 *PAR, *dPAR; 100 EllipseShape shape; 101 EllipseAxes axes; 102 float lsky; 103 104 // define PSF model type 105 int modelType = pmModelSetType ("PS_MODEL_GAUSS"); 106 107 char *PSF_NAME = psMetadataLookupStr (&status, header, "PSF_NAME"); 108 if (PSF_NAME != NULL) { 109 modelType = pmModelSetType (PSF_NAME); 110 } 68 111 69 112 // find config information for output header 70 113 float ZERO_POINT = psMetadataLookupF32 (&status, header, "ZERO_PT"); 114 if (!status) 115 ZERO_POINT = 25.0; 71 116 72 117 psArray *table = psFitsReadTable (fits); … … 76 121 77 122 // convert the table to the pmSource entries 123 // XXX need to chooose PSF vs EXT, based on type? 78 124 for (int i = 0; i < table->n; i++) { 79 pmStar *source = pmSourceAlloc (); 125 pmSource *source = pmSourceAlloc (); 126 pmModel *model = pmModelAlloc (modelType); 127 source->modelPSF = model; 128 129 PAR = model->params->data.F32; 130 dPAR = model->dparams->data.F32; 80 131 81 132 psMetadata *row = table->data[i]; 82 133 83 source->x = psMetadataLookupF32 (&status, row, "X_PIX"); 84 source->y = psMetadataLookupF32 (&status, row, "Y_PIX"); 85 source->fitMag = psMetadataLookupF32 (&status, row, "MAG_RAW") - ZERO_POINT; 86 source->galMag = psMetadataLookupF32 (&status, row, "MAG_GAL") - ZERO_POINT; 134 lsky = psMetadataLookupF32 (&status, row, "LOG_SKY"); 135 PAR[0] = pow(lsky, 10.0); 136 PAR[2] = psMetadataLookupF32 (&status, row, "X_PIX"); 137 PAR[3] = psMetadataLookupF32 (&status, row, "Y_PIX"); 138 axes.major = psMetadataLookupF32 (&status, row, "FWHM_X"); 139 axes.minor = psMetadataLookupF32 (&status, row, "FWHM_Y"); 140 axes.theta = psMetadataLookupF32 (&status, row, "THETA"); 141 142 shape = EllipseAxesToShape (axes); 143 144 PAR[4] = shape.sx; 145 PAR[5] = shape.sy; 146 PAR[6] = shape.sxy; 147 148 source->psfMag = psMetadataLookupF32 (&status, row, "MAG_RAW") - ZERO_POINT; 149 source->extMag = psMetadataLookupF32 (&status, row, "MAG_GAL") - ZERO_POINT; 150 source->errMag = psMetadataLookupF32 (&status, row, "MAG_ERR"); 87 151 source->apMag = psMetadataLookupF32 (&status, row, "MAG_AP") - ZERO_POINT; 88 source->dMag = psMetadataLookupF32 (&status, row, "MAG_ERR");89 source->sky = psMetadataLookupF32 (&status, row, "LOG_SKY");90 source->sx = psMetadataLookupF32 (&status, row, "FWHM_X");91 source->sy = psMetadataLookupF32 (&status, row, "FWHM_Y");92 source->theta = psMetadataLookupF32 (&status, row, "THETA");93 152 94 153 sources->data[i] = source;
Note:
See TracChangeset
for help on using the changeset viewer.
