Changeset 41625 for branches/eam_branches/relphot.20210521/src/MosaicOps.c
- Timestamp:
- May 31, 2021, 11:45:18 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/relphot.20210521/src/MosaicOps.c
r41608 r41625 780 780 if (i == -1) return (0.0); 781 781 782 if (mosaic[i].flags & IMAGE_BAD) return (NAN); 782 // if the mosaic cannot be calibrated (too few measurements, skip it) 783 // XXX: if the mosaic is bad (few) but the chips are OK, I can used them. 784 // XXX: if (mosaic[i].flags & ID_IMAGE_PHOTOM_FEW) return (NAN); 783 785 value = mosaic[i].McalPSF; 784 786 return (value); … … 1330 1332 } 1331 1333 1332 // When we rationalize the images/mosaics, we are driving the negative cloud images back1333 // to 0.0. At the same time, we make a guess to the effective impact on all other images,1334 // driven by the coupling of common stars.1335 // XXX this function is no longer used because we force significantly negative clouds to 0.01336 int rationalize_mosaics (Catalog *catalog, int Ncatalog) {1337 1338 double *imageOffset, **starOffset;1339 int **starNcount, *seclist;1340 int **Slist, *NSlist, *NSLIST;1341 int i, j, k, m, nMos, Ns, found;1342 1343 off_t Nimage;1344 Image *image;1345 1346 // set a test value for now1347 float CLOUD_TOLERANCE = 0.025;1348 1349 if (!MOSAIC_ZEROPT) return (FALSE);1350 if (FREEZE_MOSAICS) return (FALSE);1351 1352 image = getimages (&Nimage, NULL);1353 1354 ALLOCATE (imageOffset, double, Nmosaic);1355 ALLOCATE ( Slist, int *, Nmosaic); // array of calibrated star indexes on this mosaic1356 ALLOCATE (NSlist, int, Nmosaic); // number of stars on mosaic1357 ALLOCATE (NSLIST, int, Nmosaic); // number of Slist entries allocated1358 memset (Slist, 0, Nmosaic*sizeof(int *));1359 1360 // find the images / mosaics with negative clouds and save their offset1361 for (i = 0; i < Nmosaic; i++) {1362 1363 NSlist[i] = 0;1364 NSLIST[i] = 100;1365 ALLOCATE (Slist[i], int, NSLIST[i]);1366 1367 imageOffset[i] = 0.0;1368 1369 if (VERBOSE2 && (fabs(mosaic[i].McalPSF) < CLOUD_TOLERANCE)) {1370 fprintf (stderr, "cloud-free: %s : %f\n", image[MosaicToImage[i][0]].name, mosaic[i].McalPSF);1371 }1372 if (VERBOSE2 && (mosaic[i].McalPSF < -CLOUD_TOLERANCE)) {1373 imageOffset[i] = -mosaic[i].McalPSF;1374 // NOTE the negative sign: down below, we are going to add in the negative of McalPSF1375 // to this image, and the propagated mean values for other images1376 fprintf (stderr, "anti-clouds: %s : %f\n", image[MosaicToImage[i][0]].name, mosaic[i].McalPSF);1377 }1378 if (VERBOSE2 && (mosaic[i].McalPSF > CLOUD_TOLERANCE)) {1379 fprintf (stderr, "cloudy : %s : %f\n", image[MosaicToImage[i][0]].name, mosaic[i].McalPSF);1380 }1381 }1382 1383 int Nsecfilt = GetPhotcodeNsecfilt ();1384 ALLOCATE (seclist, int, Nphotcodes);1385 for (Ns = 0; Ns < Nphotcodes; Ns ++) {1386 int thisCode = photcodes[Ns][0].code;1387 seclist[Ns] = GetPhotcodeNsec(thisCode);1388 }1389 1390 // allocate an array for star offsets1391 int Nstars = 0;1392 int NSTARS = 1000;1393 ALLOCATE (starOffset, double *, NSTARS);1394 ALLOCATE (starNcount, int *, NSTARS);1395 memset (starOffset, 0, NSTARS*sizeof(double *));1396 memset (starNcount, 0, NSTARS*sizeof(int *));1397 1398 // find the mean offset for each star1399 for (i = 0; i < Ncatalog; i++) {1400 for (j = 0; j < catalog[i].Naverage; j++) {1401 ALLOCATE (starOffset[Nstars], double, Nphotcodes);1402 ALLOCATE (starNcount[Nstars], int, Nphotcodes);1403 memset (starOffset[Nstars], 0, Nphotcodes*sizeof(double));1404 memset (starNcount[Nstars], 0, Nphotcodes*sizeof(int));1405 1406 m = catalog[i].averageT[j].measureOffset;1407 1408 // determine the mosaic for each measurement1409 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) {1410 1411 // skip unused measurements1412 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue;1413 1414 // skip unused measurements1415 1416 // XXX replace with:1417 // Ns = GetActivePhotcodeIndex (photcode);1418 // if (Ns < 0) continue;1419 1420 int Nsec;1421 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode);1422 found = FALSE;1423 for (Ns = 0; !found && (Ns < Nphotcodes); Ns ++) {1424 if (ecode == photcodes[Ns][0].code) {1425 found = TRUE;1426 break;1427 }1428 }1429 if (!found) continue;1430 Nsec = seclist[Ns];1431 1432 // bad stars for this secfilt1433 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue;1434 1435 // skip REF measurements (not tied to an image)1436 if (getImageEntry (m, i) < 0) continue;1437 1438 // find the source of this measurement (skip unassigned measurements)1439 nMos = MeasureToMosaic[i][m];1440 if (nMos == -1) continue;1441 1442 // XXX how can this not be true?1443 if (mosaic[nMos].photcode != ecode) {1444 fprintf (stderr, "*");1445 }1446 1447 assert (Ns >= 0);1448 assert (Ns < Nphotcodes);1449 1450 // accumulate the offsets from the negative cloud images (others have 0.0 value)1451 starOffset[Nstars][Ns] += imageOffset[nMos];1452 starNcount[Nstars][Ns] ++;1453 1454 // record the mosaic->star reference1455 Slist[nMos][NSlist[nMos]] = Nstars;1456 NSlist[nMos] ++;1457 if (NSlist[nMos] == NSLIST[nMos]) {1458 NSLIST[nMos] += 100;1459 REALLOCATE (Slist[nMos], int, NSLIST[nMos]);1460 }1461 }1462 Nstars ++;1463 if (Nstars == NSTARS) {1464 NSTARS += 1000;1465 REALLOCATE (starOffset, double *, NSTARS);1466 REALLOCATE (starNcount, int *, NSTARS);1467 memset (&starOffset[NSTARS-1000], 0, 1000*sizeof(double *));1468 memset (&starNcount[NSTARS-1000], 0, 1000*sizeof(int *));1469 }1470 }1471 }1472 1473 // find the mean offset of the images without negative clouds1474 for (i = 0; i < Nmosaic; i++) {1475 1476 found = FALSE;1477 for (Ns = 0; !found && (Ns < Nphotcodes); Ns ++) {1478 if (mosaic[i].photcode == photcodes[Ns][0].code) {1479 found = TRUE;1480 break;1481 }1482 }1483 if (!found) {1484 fprintf (stderr, "invalid photcode for mosaic?\n");1485 abort();1486 }1487 1488 // a negative cloud image (cloud: McalPSF > 0; anti-clouds: McalPSF < 0; imageOffset = -McalPSF)1489 if (imageOffset[i] > 0.0) continue;1490 1491 // we need to actually have cross-references to count1492 if (NSlist[i] < 2) continue;1493 1494 float dM = 0.0;1495 for (j = 0; j < NSlist[i]; j++) {1496 k = Slist[i][j];1497 if (starNcount[k][Ns] > 1) {1498 dM += (starOffset[k][Ns] / starNcount[k][Ns]);1499 }1500 }1501 imageOffset[i] = dM / NSlist[i];1502 // fprintf (stderr, "adjust image: %s : (%f %d) : %f\n", image[MosaicToImage[i][0]].name, dM, NSlist[i], imageOffset[i]);1503 }1504 1505 // for (i = 0; i < Nmosaic; i++) {1506 // fprintf (stderr, "correction: %s : %f\n", image[MosaicToImage[i][0]].name, imageOffset[i]);1507 // }1508 1509 // apply all offset values to the mosaics1510 // find the images / mosaics with negative clouds and save their offset1511 for (i = 0; i < Nmosaic; i++) {1512 mosaic[i].McalPSF += imageOffset[i];1513 }1514 1515 for (i = 0; i < Nstars; i++) {1516 free (starOffset[i]);1517 free (starNcount[i]);1518 }1519 free (starOffset);1520 free (starNcount);1521 1522 free (seclist);1523 free (NSlist);1524 free (NSLIST);1525 for (i = 0; i < Nmosaic; i++){1526 free (Slist[i]);1527 }1528 free (Slist);1529 free (imageOffset);1530 return (TRUE);1531 }1532 1533 1334 StatType statsMosaicM (Catalog *catalog) { 1534 1335 OHANA_UNUSED_PARAM(catalog); … … 1547 1348 n = 0; 1548 1349 for (i = 0; i < Nmosaic; i++) { 1549 if (mosaic[i].flags & IMAGE_BAD) continue;1350 if (mosaic[i].flags & (ID_IMAGE_MOSAIC_POOR | ID_IMAGE_PHOTOM_FEW)) continue; 1550 1351 if (mosaic[i].skipCal) continue; 1551 1352 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; … … 1580 1381 n = 0; 1581 1382 for (i = 0; i < Nmosaic; i++) { 1582 if (mosaic[i].flags & IMAGE_BAD) continue;1383 if (mosaic[i].flags & (ID_IMAGE_MOSAIC_POOR | ID_IMAGE_PHOTOM_FEW)) continue; 1583 1384 if (mosaic[i].skipCal) continue; 1584 1385 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; … … 1613 1414 n = 0; 1614 1415 for (i = 0; i < Nmosaic; i++) { 1615 if (mosaic[i].flags & IMAGE_BAD) continue;1416 if (mosaic[i].flags & (ID_IMAGE_MOSAIC_POOR | ID_IMAGE_PHOTOM_FEW)) continue; 1616 1417 if (mosaic[i].skipCal) continue; 1617 1418 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; … … 1663 1464 n = 0; 1664 1465 for (i = 0; i < Nmosaic; i++) { 1665 if (mosaic[i].flags & IMAGE_BAD) continue;1466 if (mosaic[i].flags & (ID_IMAGE_MOSAIC_POOR | ID_IMAGE_PHOTOM_FEW)) continue; 1666 1467 if (mosaic[i].skipCal) continue; 1667 1468 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; … … 1795 1596 c = MosaicToCatalog[i][j]; 1796 1597 1797 if (catalog[c].measureT[m].dbFlags & (ID_MEAS_AREA | ID_MEAS_NOCAL)) continue;1598 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) continue; 1798 1599 1799 1600 // ave = catalog[c].measureT[m].averef;
Note:
See TracChangeset
for help on using the changeset viewer.
