- Timestamp:
- Sep 13, 2012, 9:54:08 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/ppTranslate/src/ppMopsWrite.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppTranslate/src/ppMopsWrite.c
r34438 r34439 45 45 if (detections->data[d] != NULL) { 46 46 if (det == NULL) { 47 det = detections->data[d];48 } 49 if (isfinite( detections->data[d]->seeing)) {50 validSeeingCount += 1;47 det = detections->data[d]; 48 } 49 if (isfinite(((ppMopsDetections*) detections->data[d])->seeing)) { 50 validSeeingCount += 1; 51 51 } 52 52 } … … 54 54 if (det != NULL) { 55 55 //Get the SEEING median 56 seeingValues = psVectorAlloc(validSeeingCount, PS_TYPE_F32);57 psVectorInit( validSeeingCount, NAN);56 psVector* seeingValues = psVectorAlloc(validSeeingCount, PS_TYPE_F32); 57 psVectorInit(seeingValues, NAN); 58 58 validSeeingCount = 0; 59 59 for (int d = 0; d < detections->n; d++) { 60 if ( (detections->data[d] != NULL) && (isfinite( detections->data[d]->seeing)) ){61 seeingValues->data.F32[validSeeingCount++] = detections->data[d]->seeing;60 if ( (detections->data[d] != NULL) && (isfinite(((ppMopsDetections*) detections->data[d])->seeing)) ){ 61 seeingValues->data.F32[validSeeingCount++] = ((ppMopsDetections*) detections->data[d])->seeing; 62 62 } 63 63 } … … 133 133 // Write data of version 2 (see ICD) 134 134 psMetadataAdd (row, PS_LIST_TAIL, "IPP_IDET", PS_DATA_U32, "IPP detection identifier index", 135 NAN);135 NAN); 136 136 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX", PS_DATA_F32, "PSF fit instrumental magnitude", 137 NAN);137 NAN); 138 138 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental magnitude", 139 NAN);139 NAN); 140 140 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG", PS_DATA_F32, "magnitude in standard aperture", 141 NAN);141 NAN); 142 142 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RAW", PS_DATA_F32, "magnitude in real aperture", 143 NAN);143 NAN); 144 144 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS", PS_DATA_F32, "radius used for aperture mags", 145 NAN);145 NAN); 146 146 psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX", PS_DATA_F32, "instrumental flux in standard aperture", 147 NAN);147 NAN); 148 148 psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX_SIG", PS_DATA_F32, "aperture flux error", 149 NAN);149 NAN); 150 150 psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude", 151 NAN);151 NAN); 152 152 psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG", PS_DATA_F32, "PSF Magnitude using supplied calibration", 153 NAN);153 NAN); 154 154 psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG_SIG", PS_DATA_F32, "measured scatter of zero point calibration", 155 NAN);155 NAN); 156 156 psMetadataAdd (row, PS_LIST_TAIL, "SKY", PS_DATA_F32, "Sky level", 157 NAN);157 NAN); 158 158 psMetadataAdd (row, PS_LIST_TAIL, "SKY_SIGMA", PS_DATA_F32, "Sigma of sky level", 159 NAN);159 NAN); 160 160 psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF_PERFECT", PS_DATA_F32, "PSF coverage/quality factor (poor)", 161 NAN);161 NAN); 162 162 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_R1", PS_DATA_F32, "first radial moment", 163 NAN);163 NAN); 164 164 psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_RH", PS_DATA_F32, "half radial moment", 165 NAN);165 NAN); 166 166 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX", PS_DATA_F32, "Kron Flux (in 2.5 R1)", 167 NAN);167 NAN); 168 168 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_ERR", PS_DATA_F32, "Kron Flux Error", 169 NAN);170 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER", PS_DATA_F32, "Kron Flux (in 1.0 R1)", 171 NAN);169 NAN); 170 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER", PS_DATA_F32, "Kron Flux (in 1.0 R1)", 171 NAN); 172 172 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_OUTER", PS_DATA_F32, "Kron Flux (in 4.0 R1)", 173 NAN);173 NAN); 174 174 psMetadataAdd (row, PS_LIST_TAIL, "DIFF_R_P", PS_DATA_F32, "distance to positive match source", 175 NAN);175 NAN); 176 176 psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_P", PS_DATA_F32, "signal-to-noise of pos match src", 177 NAN);177 NAN); 178 178 psMetadataAdd (row, PS_LIST_TAIL, "DIFF_R_M", PS_DATA_F32, "distance to negative match source", 179 NAN);179 NAN); 180 180 psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_M", PS_DATA_F32, "signal-to-noise of neg match src", 181 NAN);181 NAN); 182 182 psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2", PS_DATA_U32, "psphot analysis flags (group 2)", 183 0);184 psMetadataAdd (row, PS_LIST_TAIL, "N_FRAMES", PS_DATA_U16, "Number of frames overlapping source center", 185 0);186 psMetadataAdd (row, PS_LIST_TAIL, "PADDING", PS_DATA_S16, "padding", 187 0);183 0); 184 psMetadataAdd (row, PS_LIST_TAIL, "N_FRAMES", PS_DATA_U16, "Number of frames overlapping source center", 185 0); 186 psMetadataAdd (row, PS_LIST_TAIL, "PADDING", PS_DATA_S16, "padding", 187 0); 188 188 if (args->version == 3) { 189 // TODO: Write data of version 3 (see ICD)189 // TODO: Write data of version 3 (see ICD) 190 190 } 191 191 } … … 200 200 } else { 201 201 202 #define addColumn(_outName, _inName, _convertTo32) \202 #define addColumn(_outName, _inName, _convertTo32) \ 203 203 if (!addOutputColumn(table, detections, total, _outName, _inName, _convertTo32)) { \ 204 204 psError(PS_ERR_UNKNOWN, false, "Failed to add column %s", _outName); \ 205 return false; \205 return false; \ 206 206 } 207 207 … … 219 219 addColumn("EXT_SIGNIFICANCE", "EXT_NSIGMA", 0); 220 220 addColumn("PSF_MAJOR", NULL, 0); 221 addColumn("PSF_MINOR", NULL, 0); 222 addColumn("PSF_THETA", NULL, 0); 223 addColumn("PSF_QUALITY", "PSF_QF", 0); 224 addColumn("PSF_NPIX", NULL, 1); 221 addColumn("PSF_MINOR", NULL, 0); 222 addColumn("PSF_THETA", NULL, 0); 223 addColumn("PSF_QUALITY", "PSF_QF", 0); 224 addColumn("PSF_NPIX", NULL, 1); 225 225 addColumn("MOMENTS_XX", NULL, 0); 226 226 addColumn("MOMENTS_XY", NULL, 0); … … 308 308 ppMopsDetections *det = detections->data[i]; 309 309 if (!det || det->num == 0) { 310 // no detections survived for this input311 continue;310 // no detections survived for this input 311 continue; 312 312 } 313 313 psVector *in = NULL; 314 314 in = psMetadataLookupVector(NULL, det->table, inColumnName); 315 315 if (!in) { 316 psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is true)", inColumnName);317 return false;316 psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is true)", inColumnName); 317 return false; 318 318 } 319 319 if (in->type.type != PS_TYPE_S64 && in->type.type != PS_TYPE_U64) { 320 psError(PS_ERR_PROGRAMMING, true, "input column to convert is not S64 or U64: %s %d",321 inColumnName, in->type.type);322 return false;320 psError(PS_ERR_PROGRAMMING, true, "input column to convert is not S64 or U64: %s %d", 321 inColumnName, in->type.type); 322 return false; 323 323 } 324 324 if (out == NULL) { 325 // First time through set up the output vector and the copy parameters326 if (in->type.type == PS_TYPE_S64) {327 out = psVectorAlloc(outputSize, PS_TYPE_S32);328 } else {329 out = psVectorAlloc(outputSize, PS_TYPE_U32);330 }325 // First time through set up the output vector and the copy parameters 326 if (in->type.type == PS_TYPE_S64) { 327 out = psVectorAlloc(outputSize, PS_TYPE_S32); 328 } else { 329 out = psVectorAlloc(outputSize, PS_TYPE_U32); 330 } 331 331 } 332 332 for (long d=0; d < det->num; d++) { 333 if (in->type.type == PS_TYPE_S64) {334 out->data.S32[next++] = in->data.S64[d];335 } else {336 out->data.U32[next++] = in->data.U64[d];337 }333 if (in->type.type == PS_TYPE_S64) { 334 out->data.S32[next++] = in->data.S64[d]; 335 } else { 336 out->data.U32[next++] = in->data.U64[d]; 337 } 338 338 } 339 339 } … … 344 344 ppMopsDetections *det = detections->data[i]; 345 345 if (!det || det->num == 0) { 346 // no detections survived for this input347 continue;346 // no detections survived for this input 347 continue; 348 348 } 349 349 psVector *in = NULL; 350 350 in = psMetadataLookupVector(NULL, det->table, inColumnName); 351 351 if (!in) { 352 psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is false)", inColumnName);353 out = psVectorAlloc(outputSize, PS_TYPE_F32);354 psVectorInit(out, NAN);355 psMetadataAddVector(table, PS_LIST_TAIL, outColumnName, 0, NULL, out);356 return false;352 psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is false)", inColumnName); 353 out = psVectorAlloc(outputSize, PS_TYPE_F32); 354 psVectorInit(out, NAN); 355 psMetadataAddVector(table, PS_LIST_TAIL, outColumnName, 0, NULL, out); 356 return false; 357 357 } 358 358 if (out == NULL) { 359 // First time through set up the output vector and the copy parameters360 out = psVectorAlloc(outputSize, in->type.type);361 next = (void *) out->data.U8;362 switch (in->type.type) {363 case PS_TYPE_S8:364 elementSize = sizeof(psS8);365 break;366 case PS_TYPE_U8:367 elementSize = sizeof(psU8);368 break;369 case PS_TYPE_S16:370 elementSize = sizeof(psS16);371 break;372 case PS_TYPE_U16:373 elementSize = sizeof(psU16);374 break;375 case PS_TYPE_S32:376 elementSize = sizeof(psS32);377 break;378 case PS_TYPE_U32:379 elementSize = sizeof(psU32);380 break;381 case PS_TYPE_S64:382 elementSize = sizeof(psS64);383 break;384 case PS_TYPE_U64:385 elementSize = sizeof(psU64);386 break;387 case PS_TYPE_F32:388 elementSize = sizeof(psF32);389 break;390 case PS_TYPE_F64:391 elementSize = sizeof(psF64);392 break;393 default:394 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unknown vector type %d", in->type.type);395 return false;396 }397 } 398 // We are doing nasty things here so we can use memcpy. 359 // First time through set up the output vector and the copy parameters 360 out = psVectorAlloc(outputSize, in->type.type); 361 next = (void *) out->data.U8; 362 switch (in->type.type) { 363 case PS_TYPE_S8: 364 elementSize = sizeof(psS8); 365 break; 366 case PS_TYPE_U8: 367 elementSize = sizeof(psU8); 368 break; 369 case PS_TYPE_S16: 370 elementSize = sizeof(psS16); 371 break; 372 case PS_TYPE_U16: 373 elementSize = sizeof(psU16); 374 break; 375 case PS_TYPE_S32: 376 elementSize = sizeof(psS32); 377 break; 378 case PS_TYPE_U32: 379 elementSize = sizeof(psU32); 380 break; 381 case PS_TYPE_S64: 382 elementSize = sizeof(psS64); 383 break; 384 case PS_TYPE_U64: 385 elementSize = sizeof(psU64); 386 break; 387 case PS_TYPE_F32: 388 elementSize = sizeof(psF32); 389 break; 390 case PS_TYPE_F64: 391 elementSize = sizeof(psF64); 392 break; 393 default: 394 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unknown vector type %d", in->type.type); 395 return false; 396 } 397 } 398 // We are doing nasty things here so we can use memcpy. 399 399 // It would be safer to do a proper loop over the elements. 400 400 long toCopy = det->num * elementSize;
Note:
See TracChangeset
for help on using the changeset viewer.
