Changeset 41662
- Timestamp:
- Jun 14, 2021, 11:02:20 AM (5 years ago)
- Location:
- trunk/Ohana/src/relphot
- Files:
-
- 5 edited
-
include/relphot.h (modified) (1 diff)
-
src/ImageOps.c (modified) (1 diff)
-
src/MosaicOps.c (modified) (1 diff)
-
src/TGroupOps.c (modified) (1 diff)
-
src/relphot_images.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/include/relphot.h
r41647 r41662 874 874 void ResetAverageActivePhotcodes (SecFilt *secfilt); 875 875 876 876 void rationalize_zeropoints (int Niter); 877 double get_median_zpt_images (short photcode); 878 void set_median_zpt_images (short photcode, double zpt); 879 double get_median_zpt_mosaics (short photcode); 880 void set_median_zpt_mosaics (short photcode, double zpt); 881 double get_median_zpt_tgroups (short photcode); 882 void set_median_zpt_tgroups (short photcode, double zpt); -
trunk/Ohana/src/relphot/src/ImageOps.c
r41647 r41662 951 951 } 952 952 953 // find the median zero point and subtract it (for each active average photcode) 954 void rationalize_zeropoints (int Niter) { 955 956 if (VERBOSE) fprintf (stderr, "rationalize zero points\n"); 957 958 // if we are calculating zero points for tgroups, 959 // rationalize based on the tgroups 960 if (TGROUP_ZEROPT) { 961 for (int ic = 0; ic < Nphotcodes; ic++) { 962 double zpt = get_median_zpt_tgroups (photcodes[ic][0].code); 963 fprintf (stderr, "rationalize zero points by tgroup for %s (%d) : %f\n", photcodes[ic][0].name, photcodes[ic][0].code, zpt); 964 if (isnan(zpt)) continue; 965 set_median_zpt_tgroups (photcodes[ic][0].code, zpt); 966 set_median_zpt_mosaics (photcodes[ic][0].code, zpt); 967 set_median_zpt_images (photcodes[ic][0].code, zpt); 968 } 969 return; 970 } 971 972 // if we are calculating zero points for mosaics, but not tgroups, 973 // rationalize based on the mosaics 974 if (MOSAIC_ZEROPT) { 975 for (int ic = 0; ic < Nphotcodes; ic++) { 976 double zpt = get_median_zpt_mosaics (photcodes[ic][0].code); 977 fprintf (stderr, "rationalize zero points by mosaic for %s (%d) : %f\n", photcodes[ic][0].name, photcodes[ic][0].code, zpt); 978 if (isnan(zpt)) continue; 979 set_median_zpt_tgroups (photcodes[ic][0].code, zpt); 980 set_median_zpt_mosaics (photcodes[ic][0].code, zpt); 981 set_median_zpt_images (photcodes[ic][0].code, zpt); 982 } 983 return; 984 } 985 986 // otherwise, rationalize based on the images 987 for (int ic = 0; ic < Nphotcodes; ic++) { 988 double zpt = get_median_zpt_images (photcodes[ic][0].code); 989 fprintf (stderr, "rationalize zero points by image for %s (%d) : %f\n", photcodes[ic][0].name, photcodes[ic][0].code, zpt); 990 if (isnan(zpt)) continue; 991 set_median_zpt_tgroups (photcodes[ic][0].code, zpt); 992 set_median_zpt_mosaics (photcodes[ic][0].code, zpt); 993 set_median_zpt_images (photcodes[ic][0].code, zpt); 994 } 995 } 996 997 double get_median_zpt_images (short photcode) { 998 999 double *mlist; 1000 1001 ALLOCATE (mlist, double, Nimage); 1002 1003 int N = 0; 1004 for (int i = 0; i < Nimage; i++) { 1005 int mycode = GetPhotcodeEquivCodebyCode (image[i].photcode); 1006 if (mycode != photcode) continue; 1007 if (!(image[i].flags & ID_IMAGE_IMAGE_PHOTCAL)) continue; 1008 mlist[N] = image[i].McalPSF; 1009 N++; 1010 } 1011 1012 if (N == 0) { 1013 free (mlist); 1014 return NAN; 1015 } 1016 1017 StatType stats; 1018 liststats_setmode (&stats, "MEAN"); 1019 1020 liststats (mlist, NULL, NULL, N, &stats); 1021 free (mlist); 1022 1023 return stats.median; 1024 } 1025 1026 void set_median_zpt_images (short photcode, double zpt) { 1027 1028 if (!isfinite(zpt)) return; // do not break the zero points 1029 1030 for (int i = 0; i < Nimage; i++) { 1031 int mycode = GetPhotcodeEquivCodebyCode (image[i].photcode); 1032 if (mycode != photcode) continue; 1033 image[i].McalPSF -= zpt; 1034 image[i].McalAPER -= zpt; 1035 } 1036 1037 return; 1038 } 1039 953 1040 static int setMcal_init_done = FALSE; 954 1041 void plot_setMcal (double *list, int Npts) { -
trunk/Ohana/src/relphot/src/MosaicOps.c
r41647 r41662 1574 1574 } 1575 1575 1576 double get_median_zpt_mosaics (short photcode) { 1577 1578 double *mlist; 1579 1580 if (!MOSAIC_ZEROPT) return NAN; 1581 1582 ALLOCATE (mlist, double, Nmosaic); 1583 1584 int N = 0; 1585 for (int i = 0; i < Nmosaic; i++) { 1586 if (mosaic[i].photcode != photcode) continue; 1587 if (!(mosaic[i].flags & ID_IMAGE_MOSAIC_PHOTCAL)) continue; 1588 mlist[N] = mosaic[i].McalPSF; 1589 N++; 1590 } 1591 1592 if (N == 0) { 1593 free (mlist); 1594 return NAN; 1595 } 1596 1597 StatType stats; 1598 liststats_setmode (&stats, "MEAN"); 1599 1600 liststats (mlist, NULL, NULL, N, &stats); 1601 free (mlist); 1602 1603 return stats.median; 1604 } 1605 1606 void set_median_zpt_mosaics (short photcode, double zpt) { 1607 1608 if (!MOSAIC_ZEROPT) return; 1609 if (!isfinite(zpt)) return; // do not break the zero points 1610 1611 for (int i = 0; i < Nmosaic; i++) { 1612 if (mosaic[i].photcode != photcode) continue; 1613 mosaic[i].McalPSF -= zpt; 1614 mosaic[i].McalAPER -= zpt; 1615 } 1616 1617 return; 1618 } 1619 1576 1620 void plot_mosaic_fields (Catalog *catalog) { 1577 1621 -
trunk/Ohana/src/relphot/src/TGroupOps.c
r41647 r41662 1365 1365 } 1366 1366 1367 double get_median_zpt_tgroups (short photcode) { 1368 1369 double *mlist; 1370 1371 if (!TGROUP_ZEROPT) return NAN; 1372 1373 ALLOCATE (mlist, double, NtgroupTimes); 1374 1375 int N = 0; 1376 for (int i = 0; i < NtgroupTimes; i++) { 1377 TGroup *tgroup = tgroupTimes[i][0].byCode; 1378 for (int j = 0; j < tgroupTimes[i][0].nCode; j++) { 1379 if (tgroup[j].photcode != photcode) continue; 1380 if (!(tgroup[j].flags & ID_IMAGE_TGROUP_PHOTCAL)) continue; 1381 mlist[N] = tgroup[j].McalPSF; 1382 N++; 1383 } 1384 } 1385 1386 if (N == 0) { 1387 free (mlist); 1388 return NAN; 1389 } 1390 1391 StatType stats; 1392 liststats_setmode (&stats, "MEAN"); 1393 1394 liststats (mlist, NULL, NULL, N, &stats); 1395 free (mlist); 1396 1397 return stats.median; 1398 } 1399 1400 void set_median_zpt_tgroups (short photcode, double zpt) { 1401 1402 if (!TGROUP_ZEROPT) return; 1403 if (!isfinite(zpt)) return; // do not break the zero points 1404 1405 for (int i = 0; i < NtgroupTimes; i++) { 1406 TGroup *tgroup = tgroupTimes[i][0].byCode; 1407 for (int j = 0; j < tgroupTimes[i][0].nCode; j++) { 1408 if (tgroup[j].photcode != photcode) continue; 1409 tgroup[j].McalPSF -= zpt; 1410 tgroup[j].McalAPER -= zpt; 1411 } 1412 } 1413 return; 1414 } 1415 1367 1416 void plot_tgroup_fields (Catalog *catalog) { 1368 1417 -
trunk/Ohana/src/relphot/src/relphot_images.c
r41647 r41662 102 102 setMmos (catalog); 103 103 setMgrp (catalog); 104 105 rationalize_zeropoints (i); 104 106 105 107 setMgrid (catalog, Ncatalog);
Note:
See TracChangeset
for help on using the changeset viewer.
