Changeset 15250
- Timestamp:
- Oct 8, 2007, 5:10:05 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c
r15243 r15250 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-10-0 8 18:52:49$5 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-10-09 03:10:05 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 66 66 for (i = 0; i < sources->n; i++) { 67 67 pmSource *source = (pmSource *) sources->data[i]; 68 source->seq = i;68 source->seq = i; 69 69 70 70 // no difference between PSF and non-PSF model … … 166 166 assert (modelType > -1); 167 167 168 psArray *table = psFitsReadTable (fits);169 168 // validate a single row of the table (must match SMP) 170 169 171 // XXX test return values 170 // XXX test return values 172 171 173 172 // XXX we have a memory problem, which is illustrated here: if I allocate the sources array … … 178 177 // return (fooSources); 179 178 180 psArray *sources = psArrayAlloc (table->n); 179 180 // We get the size of the table, and allocate the array of sources first because the table is large and 181 // ephemeral --- when the table gets blown away, whatever is allocated after the table is read. In fact, 182 // it's better to read the table row by row. 183 long numSources = psFitsTableSize(fits); // Number of sources in table 184 psArray *sources = psArrayAlloc(numSources); // Array of sources, to return 181 185 182 186 // convert the table to the pmSource entries 183 187 // XXX need to chooose PSF vs EXT, based on type? 184 for (int i = 0; i < table->n; i++) { 188 for (int i = 0; i < numSources; i++) { 189 psMetadata *row = psFitsReadTableRow(fits, i); // Table row 190 185 191 pmSource *source = pmSourceAlloc (); 186 192 pmModel *model = pmModelAlloc (modelType); … … 191 197 PAR = model->params->data.F32; 192 198 dPAR = model->dparams->data.F32; 193 194 psMetadata *row = table->data[i];195 199 196 200 PAR[PM_PAR_XPOS] = psMetadataLookupF32 (&status, row, "X_PSF"); … … 225 229 226 230 source->mode = psMetadataLookupU16 (&status, row, "FLAGS"); 227 assert (status);231 assert (status); 228 232 229 233 // XXX other values saved but not loaded? … … 232 236 233 237 sources->data[i] = source; 234 } 235 psFree (table); 236 return (sources); 238 psFree(row); 239 } 240 241 return sources; 237 242 }
Note:
See TracChangeset
for help on using the changeset viewer.
