Changeset 41434 for trunk/psastro/src/psastroLoadCrosstalk.c
- Timestamp:
- Nov 13, 2020, 2:48:11 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroLoadCrosstalk.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroLoadCrosstalk.c
r41430 r41434 53 53 pmFPAview *viewMask = pmFPAviewAlloc (0); 54 54 55 float zeropt, exptime, MAX_MAG, SPIKE_MAX_MAG;55 float zeropt, exptime, MAX_MAG, INSTR_MAX_MAG, SPIKE_MAX_MAG; 56 56 57 57 psLogMsg ("psastro", PS_LOG_INFO, "determine crosstalk positions"); … … 99 99 } 100 100 101 MAX_MAG = psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_CROSSTALK_MAG_MAX");101 INSTR_MAX_MAG = psMetadataLookupF32 (&status, recipe, "REFSTAR_MASK_CROSSTALK_MAG_MAX"); 102 102 // recipe values are given in instrumental magnitudes 103 103 // use the zero point and exposure time to convert to apparent mags: M_ap = M_inst + C_0 + 2.5*log(exptime) 104 104 float MagOffset = zeropt + 2.5*log10(exptime); 105 MAX_MAG +=MagOffset;105 MAX_MAG = INSTR_MAX_MAG + MagOffset; 106 106 107 107 // Get the spike maximum, as well … … 141 141 } 142 142 143 // Get the array of reference stars we're concerned with. 144 psArray *refstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.REFSTARS"); 145 if (refstars == NULL) { return(true); } 146 147 // Check each reference star 148 for (int i = 0; i < refstars->n; i++) { 149 // This is the source of the ct. 150 pmAstromObj *ref = refstars->data[i]; 151 152 if (ref->Mag > MAX_MAG) { 143 // To check for the presence of crosstalk we first make use the actual detections on this image. 144 // That way we can include things like movers creating crosstalk features. 145 psArray *calstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.CALSTARS"); 146 if (calstars == NULL) { continue; } 147 148 for (int i = 0; i < calstars->n; i++) { 149 pmAstromObj *cal = calstars->data[i]; 150 151 if (cal->Mag > INSTR_MAX_MAG) { 153 152 continue; 154 153 } … … 156 155 // Identify which cell holds the star 157 156 pmChip *CTsourceChip = refChip; 158 pmCell *CTsourceCell = pmCellInChip(refChip, ref->chip->x,ref->chip->y);157 pmCell *CTsourceCell = pmCellInChip(refChip,cal->chip->x,cal->chip->y); 159 158 160 159 if (!CTsourceCell) { … … 162 161 } 163 162 164 psTrace ("psastro.crosstalk",2,"REF: %d %f (%f %f) %f %f :: %f %f\n", 165 i,ref->Mag, ref->sky->r,ref->sky->d, ref->FP->x,ref->FP->y, ref->chip->x,ref->chip->y); 166 163 psTrace ("psastro.crosstalk",2,"DETEC: %d %f :: %f %f\n", 164 i,cal->Mag, cal->chip->x,cal->chip->y); 167 165 168 166 const char *cellName = psMetadataLookupStr(NULL,CTsourceCell->concepts, "CELL.NAME"); … … 176 174 float x_t_chip,y_t_chip; 177 175 // int faint_ct = 0; NOTE: not currently used 178 pmCellCoordsForChip(&x_cell,&y_cell,CTsourceCell, ref->chip->x,ref->chip->y);176 pmCellCoordsForChip(&x_cell,&y_cell,CTsourceCell,cal->chip->x,cal->chip->y); 179 177 180 178 x_t_cell = x_cell; … … 245 243 psStringAppend(&targetCellName,"xy%d%d",Ut,Vt); 246 244 247 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f [%s %s]",245 psTrace ("psastro.crosstalk",2,"CTsource from DETEC @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f [%s %s]", 248 246 X,Y,U,V,x_cell,y_cell,Xt,Yt,Ut,Vt,x_t_cell,y_t_cell, 249 247 targetChipName,targetCellName); 250 248 249 251 250 pmCell *CTtargetCell = getCellByName (CTsourceChip,targetCellName); 252 251 if (!CTtargetCell) continue; … … 254 253 pmChipCoordsForCell(&x_t_chip,&y_t_chip,CTtargetCell,x_t_cell,y_t_cell); 255 254 256 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f ChipLoc: (%f,%f)",255 psTrace ("psastro.crosstalk",2,"CTsource from DETEC @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f ChipLoc: (%f,%f)", 257 256 X,Y,U,V,x_cell,y_cell,Xt,Yt,Ut,Vt,x_t_cell,y_t_cell,x_t_chip,y_t_chip); 258 257 … … 272 271 pmAstromObj *crosstalk = pmAstromObjAlloc(); 273 272 273 crosstalk->Mag = cal->Mag; 274 crosstalk->chip->x = x_t_chip; 275 crosstalk->chip->y = y_t_chip; 276 277 psArray *crosstalks = psMetadataLookupPtr (&status, targetReadout->analysis, "PSASTRO.CROSSTALKS"); 278 if (crosstalks == NULL) { 279 crosstalks = psArrayAllocEmpty(100); 280 if (!psMetadataAdd(targetReadout->analysis,PS_LIST_TAIL,"PSASTRO.CROSSTALKS", PS_DATA_ARRAY, "crosstalk locations", crosstalks)) { 281 psError(PSASTRO_ERR_CONFIG, false, "failure to add crosstalks to readout"); 282 goto escape; 283 } 284 psFree(crosstalks); 285 } 286 psArrayAdd(crosstalks,100,crosstalk); 287 288 psFree(targetChipName); 289 psFree(targetCellName); 290 psFree(crosstalk); 291 } 292 293 294 // We also want to use the refstars to check for crosstalk. In particular, the detections 295 // do not do well for bright stars, and saturated detections will underestimate the size of the crostalk 296 // Get the array of reference stars we're concerned with. 297 psArray *refstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.REFSTARS"); 298 if (refstars == NULL) { return(true); } 299 300 // Check each reference star 301 for (int i = 0; i < refstars->n; i++) { 302 // This is the source of the ct. 303 pmAstromObj *ref = refstars->data[i]; 304 305 if (ref->Mag > MAX_MAG) { 306 continue; 307 } 308 309 // Identify which cell holds the star 310 pmChip *CTsourceChip = refChip; 311 pmCell *CTsourceCell = pmCellInChip(refChip,ref->chip->x,ref->chip->y); 312 313 if (!CTsourceCell) { 314 continue; 315 } 316 317 psTrace ("psastro.crosstalk",2,"REF: %d %f (%f %f) %f %f :: %f %f\n", 318 i,ref->Mag, ref->sky->r,ref->sky->d, ref->FP->x,ref->FP->y, ref->chip->x,ref->chip->y); 319 320 const char *cellName = psMetadataLookupStr(NULL,CTsourceCell->concepts, "CELL.NAME"); 321 int U = cellName[2] - '0'; 322 int V = cellName[3] - '0'; 323 324 int Xt = X,Yt = Y,Ut = U,Vt = V; 325 float x_cell,y_cell; 326 float x_t_cell,y_t_cell; 327 328 float x_t_chip,y_t_chip; 329 // int faint_ct = 0; NOTE: not currently used 330 pmCellCoordsForChip(&x_cell,&y_cell,CTsourceCell,ref->chip->x,ref->chip->y); 331 332 x_t_cell = x_cell; 333 y_t_cell = y_cell; 334 335 // 2020-10-21 TdB: Here is the list of known cross talks from the bright star analysis: 336 // The relationships work using OTA"XY"XY"UV" 337 // Inter-chip 338 // OTA2yXY3v => OTA3yXY3v 339 // OTA4yXY3v <= OTA5yXY3v 340 // Intra-chip 341 // OTA2yXY5v <=> OTA2yXY6v 342 // OTA5yXY5v <=> OTA5yXY6v 343 // One way fainter 344 // OTA2yXY7v => OTA3yXY2v 345 // OTA5yXY7v => OTA4yXY2v 346 // Determine if this combination of chip and cell produces a crosstalk artifact 347 if ((X == 2)&&(! ((U == 3)||(U == 5)||(U == 6)||(U == 7)))) { 348 psTrace ("psastro.crosstalk",2,"Cell (%d%d) on chip (%d%d) not a known crosstalk source.",U,V,X,Y); 349 psTrace ("psastro.crosstalk",2,"t1: %d t2: %d", 350 (X == 2), 351 (! ((U == 3)||(U == 5)||(U == 6)||(U == 7)))); 352 continue; 353 } 354 if ((X == 5)&&(! ((U == 3)||(U == 5)||(U == 6)||(U == 7)))) { 355 psTrace ("psastro.crosstalk",2,"Cell (%d%d) on chip (%d%d) not a known crosstalk source.",U,V,X,Y); 356 continue; 357 } 358 359 // Calculate destination positions 360 if (X == 2) { 361 if (U == 3) { 362 Xt = 3; 363 } 364 if (U == 5) { 365 Ut = 6; 366 } 367 if (U == 6) { 368 Ut = 5; 369 } 370 if (U == 7) { 371 Xt = 3; 372 Ut = 2; 373 // faint_ct = 1; NOTE: not currently used 374 } 375 } 376 if (X == 5) { 377 if (U == 3) { 378 Xt = 4; 379 } 380 if (U == 5) { 381 Ut = 6; 382 } 383 if (U == 6) { 384 Ut = 5; 385 } 386 if (U == 7) { 387 Xt = 4; 388 Ut = 2; 389 // faint_ct = 1; NOTE: not currently used 390 } 391 } 392 393 // Convert target cell coordinates to target chip coordinates 394 psString targetChipName = NULL; 395 psStringAppend(&targetChipName,"XY%d%d",Xt,Yt); 396 psString targetCellName = NULL; 397 psStringAppend(&targetCellName,"xy%d%d",Ut,Vt); 398 399 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f [%s %s]", 400 X,Y,U,V,x_cell,y_cell,Xt,Yt,Ut,Vt,x_t_cell,y_t_cell, 401 targetChipName,targetCellName); 402 403 pmCell *CTtargetCell = getCellByName (CTsourceChip,targetCellName); 404 if (!CTtargetCell) continue; 405 406 pmChipCoordsForCell(&x_t_chip,&y_t_chip,CTtargetCell,x_t_cell,y_t_cell); 407 408 psTrace ("psastro.crosstalk",2,"CTsource @ OTA%d%dxy%d%d@%f,%f CTtarget OTA%d%dxy%d%d@%f,%f ChipLoc: (%f,%f)", 409 X,Y,U,V,x_cell,y_cell,Xt,Yt,Ut,Vt,x_t_cell,y_t_cell,x_t_chip,y_t_chip); 410 411 // Hunt down the readout for the target, and save the chip position and magnitude of source star. 412 pmChip *targetChip = getChipByName(fpa,targetChipName); 413 if (!targetChip) continue; 414 if (!targetChip->cells) continue; 415 if (!targetChip->cells->n) continue; 416 417 pmCell *targetCell = targetChip->cells->data[0]; 418 if (!targetCell) continue; 419 if (!targetCell->readouts) continue; 420 if (!targetCell->readouts->n) continue; 421 pmReadout *targetReadout = targetCell->readouts->data[0]; 422 if (!targetReadout) continue; 423 424 pmAstromObj *crosstalk = pmAstromObjAlloc(); 425 274 426 crosstalk->Mag = ref->Mag - MagOffset; 275 427 crosstalk->chip->x = x_t_chip; 428 crosstalk->chip->y = y_t_chip; 276 429 crosstalk->chip->y = y_t_chip; 277 430
Note:
See TracChangeset
for help on using the changeset viewer.
