- Timestamp:
- Nov 2, 2015, 7:49:22 AM (11 years ago)
- Location:
- trunk/Ohana/src/addstar/src
- Files:
-
- 2 edited
-
loadgalphot_fit2d.c (modified) (3 diffs)
-
mkcmf.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/src/loadgalphot_fit2d.c
r38743 r39018 183 183 if (!finite(*x) || !finite(*y) || !finite(*z)) continue; 184 184 *zf = 0; 185 double X= 1;185 double Y = 1; 186 186 for (i = ny = 0; ny < fit->nterm; ny++) { 187 double Y = X;187 double X = Y; 188 188 for (nx = 0; nx < fit->nterm - ny; nx++, i++) { 189 *zf += fit->b[i][0]* Y;190 Y = Y * (*y);191 } 192 X = X * (*x);189 *zf += fit->b[i][0]*X; 190 X = X * (*x); 191 } 192 Y = Y * (*y); 193 193 } 194 194 } … … 213 213 maxsigma = fit->ClipNsigma * sigma; 214 214 215 //if (VERBOSE) gprint (GP_ERR, "mean: %g, sigma: %g, maxsigma: %g\n", mean, sigma, maxsigma);215 if (VERBOSE) gprint (GP_ERR, "mean: %g, sigma: %g, maxsigma: %g\n", mean, sigma, maxsigma); 216 216 217 217 /* mask outlier points */ … … 230 230 } 231 231 } 232 // if (VERBOSE) gprint (GP_ERR, "pass: %d, Nmask: %d\n", N, Nmask); 232 if (VERBOSE) { 233 gprint (GP_ERR, "pass: %d, Nmask: %d\n", N, Nmask); 234 } 233 235 } 234 236 -
trunk/Ohana/src/addstar/src/mkcmf.c
r39011 r39018 29 29 int WriteXFITtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 30 30 int WriteXRADtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars, int Nrad); 31 int WriteXGALtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 31 32 int WriteDETFtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 32 33 … … 62 63 int isStack = FALSE; 63 64 int isForcedWarp = FALSE; 65 int isForcedGalaxy = FALSE; 64 66 int isDiff = FALSE; 65 67 int WriteXSRC = FALSE; 66 68 int WriteXFIT = FALSE; 67 69 int WriteXRAD = FALSE; 70 int WriteXGAL = FALSE; 68 71 int WriteDETF = FALSE; 69 72 if ((N = get_argument (argc, argv, "-stack"))) { … … 76 79 WriteXSRC = WriteXFIT = WriteXRAD = TRUE; 77 80 isForcedWarp = TRUE; 81 } 82 if ((N = get_argument (argc, argv, "-forcedgalaxy"))) { 83 remove_argument (N, &argc, argv); 84 WriteXSRC = WriteXFIT = WriteXRAD = TRUE; 85 WriteXGAL = TRUE; 86 isForcedGalaxy = TRUE; 78 87 } 79 88 if ((N = get_argument (argc, argv, "-diff"))) { … … 409 418 gfits_modify (&header, "PHOT_V", "%s", 1, "38100"); 410 419 } 420 if (isForcedGalaxy) { 421 gfits_modify (&header, "HIERARCH FPA.FILTERID", "%s", 1, ""); // does this affect anything? I don't actually think so... 422 gfits_modify (&header, "HIERARCH FPA.ZP", "%f", 1, 25.0); 423 } 411 424 if (isDiff) { 412 425 gfits_modify (&header, "HIERARCH FPA.ZP", "%f", 1, zeroPt); … … 506 519 if (WriteXRAD && isStack) WriteXRADtable (fits, extroot, X, Y, M, Flag, Nstars, 3); 507 520 if (WriteXRAD && isForcedWarp) WriteXRADtable (fits, extroot, X, Y, M, Flag, Nstars, 1); 521 if (WriteXGAL) WriteXGALtable (fits, extroot, X, Y, M, Flag, Nstars); 508 522 509 523 if (WriteDETF) WriteDETFtable (fits, extroot, X, Y, M, Flag, Nstars); … … 1541 1555 } 1542 1556 1557 # define NMODEL 9 1558 static char ModelNames[NMODEL][16] = { 1559 "PS_MODEL_GAUSS", 1560 "PS_MODEL_PGAUSS", 1561 "PS_MODEL_QGAUSS", 1562 "PS_MODEL_PS1V1", 1563 "PS_MODEL_RGAUSS", 1564 "PS_MODEL_SERSIC", 1565 "PS_MODEL_EXP", 1566 "PS_MODEL_DEV", 1567 "PS_MODEL_TRAIL"}; 1568 1543 1569 int WriteXFITtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) { 1544 1570 … … 1677 1703 gfits_set_bintable_column (&header, &ftable, "EXT_THETA_ERR" , EXT_THETA_ERR , Nstars); 1678 1704 gfits_set_bintable_column (&header, &ftable, "EXT_PAR_07" , EXT_PAR_07 , Nstars); 1705 1706 // add model type info in header: 1707 gfits_modify (&header, "MTNUM", "%d", 1, NMODEL); 1708 for (i = 0; i < NMODEL; i++) { 1709 char field[64]; 1710 snprintf (field, 64, "MTNAM%02d", i); 1711 gfits_modify (&header, field, "%s", 1, ModelNames[i]); 1712 snprintf (field, 64, "MTVAL%02d", i); 1713 gfits_modify (&header, field, "%d", 1, i); 1714 } 1715 } 1716 /**/ 1717 1718 gfits_fwrite_Theader (fits, &header); 1719 gfits_fwrite_table (fits, &ftable); 1720 gfits_free_header (&header); 1721 gfits_free_table (&ftable); 1722 1723 return TRUE; 1724 } 1725 1726 # define NXGRID 5 1727 # define NYGRID 5 1728 # define BINSTEP 0.1 1729 1730 int WriteXGALtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) { 1731 1732 int i; 1733 Header header; 1734 FTable ftable; 1735 1736 char extdata[80]; 1737 snprintf (extdata, 80, "%s.xgal", extroot); 1738 1739 /* Example Code to create a bintable */ 1740 { 1741 gfits_create_table_header (&header, "BINTABLE", extdata); 1742 1743 int Nbin = NXGRID * NYGRID; 1744 char fmt[16]; 1745 snprintf (fmt, 16, "%dE", Nbin); 1746 1747 // define the table layout 1748 gfits_define_bintable_column (&header, "J", "IPP_IDET" , "no comment", NULL, 1.0, FT_BZERO_INT32); // unsigned 1749 gfits_define_bintable_column (&header, "J", "MODEL_TYPE" , "no comment", NULL, 1.0, 0.0); 1750 gfits_define_bintable_column (&header, "E", "X_FIT" , "no comment", NULL, 1.0, 0.0); 1751 gfits_define_bintable_column (&header, "E", "Y_FIT" , "no comment", NULL, 1.0, 0.0); 1752 gfits_define_bintable_column (&header, "E", "NPIX" , "no comment", NULL, 1.0, 0.0); 1753 gfits_define_bintable_column (&header, fmt, "GAL_FLUX" , "no comment", NULL, 1.0, 0.0); 1754 gfits_define_bintable_column (&header, fmt, "GAL_FLUX_ERR" , "no comment", NULL, 1.0, 0.0); 1755 gfits_define_bintable_column (&header, fmt, "GAL_CHISQ" , "no comment", NULL, 1.0, 0.0); 1756 gfits_define_bintable_column (&header, "E", "FR_MAJOR_MIN" , "no comment", NULL, 1.0, 0.0); 1757 gfits_define_bintable_column (&header, "E", "FR_MAJOR_MAX" , "no comment", NULL, 1.0, 0.0); 1758 gfits_define_bintable_column (&header, "E", "FR_MAJOR_DEL" , "no comment", NULL, 1.0, 0.0); 1759 gfits_define_bintable_column (&header, "E", "FR_MINOR_MIN" , "no comment", NULL, 1.0, 0.0); 1760 gfits_define_bintable_column (&header, "E", "FR_MINOR_MAX" , "no comment", NULL, 1.0, 0.0); 1761 gfits_define_bintable_column (&header, "E", "FR_MINOR_DEL" , "no comment", NULL, 1.0, 0.0); 1762 1763 // generate the output array that carries the data 1764 gfits_create_table (&header, &ftable); 1765 1766 // create intermediate storage arrays 1767 int *IPP_IDET ; ALLOCATE (IPP_IDET , int , Nstars); 1768 int *MODEL_TYPE ; ALLOCATE (MODEL_TYPE , int , Nstars); 1769 float *X_FIT ; ALLOCATE (X_FIT , float , Nstars); 1770 float *Y_FIT ; ALLOCATE (Y_FIT , float , Nstars); 1771 float *NPIX ; ALLOCATE (NPIX , float , Nstars); 1772 float *GAL_FLUX ; ALLOCATE (GAL_FLUX , float , Nstars*Nbin); 1773 float *GAL_FLUX_ERR ; ALLOCATE (GAL_FLUX_ERR , float , Nstars*Nbin); 1774 float *GAL_CHISQ ; ALLOCATE (GAL_CHISQ , float , Nstars*Nbin); 1775 float *FR_MAJOR_MIN ; ALLOCATE (FR_MAJOR_MIN , float , Nstars); 1776 float *FR_MAJOR_MAX ; ALLOCATE (FR_MAJOR_MAX , float , Nstars); 1777 float *FR_MAJOR_DEL ; ALLOCATE (FR_MAJOR_DEL , float , Nstars); 1778 float *FR_MINOR_MIN ; ALLOCATE (FR_MINOR_MIN , float , Nstars); 1779 float *FR_MINOR_MAX ; ALLOCATE (FR_MINOR_MAX , float , Nstars); 1780 float *FR_MINOR_DEL ; ALLOCATE (FR_MINOR_DEL , float , Nstars); 1781 1782 // assign the storage arrays 1783 for (i = 0; i < Nstars; i++) { 1784 float flux = pow (10.0, -0.4*M[i]); 1785 1786 double ra, dec; 1787 XY_to_RD (&ra, &dec, X[i], Y[i], &coords); 1788 1789 IPP_IDET [i] = i; 1790 MODEL_TYPE [i] = 7; 1791 X_FIT [i] = X[i]; 1792 Y_FIT [i] = Y[i]; 1793 NPIX [i] = 10.0; 1794 FR_MAJOR_MIN [i] = FX*2.7; 1795 FR_MAJOR_DEL [i] = FX*BINSTEP; 1796 FR_MAJOR_MAX [i] = FR_MAJOR_MIN[i] + FR_MAJOR_DEL[i]*(NXGRID - 1); // this is probabaly an error in the real file, careful 1797 FR_MINOR_MIN [i] = FY*2.7; 1798 FR_MINOR_DEL [i] = FY*BINSTEP; 1799 FR_MINOR_MAX [i] = FR_MINOR_MIN[i] + FR_MINOR_DEL[i]*(NYGRID - 1); 1800 1801 int xs = NXGRID / 2; 1802 int ys = NYGRID / 2; 1803 1804 // is it major (fast) * minor (slow) or vice versa? 1805 int Npt = 0; 1806 int ix, iy; 1807 for (ix = -xs; ix <= xs; ix++) { 1808 for (iy = -ys; iy <= ys; iy++) { 1809 float scale = (1.0 + ix*ix + 1.2*iy*iy); // a parabola with min at ix,iy = 0,0 1810 GAL_FLUX [Nbin*i + (ix + xs) + NXGRID*(iy + ys)] = flux / scale; 1811 GAL_FLUX_ERR [Nbin*i + (ix + xs) + NXGRID*(iy + ys)] = sqrt(flux / scale); 1812 GAL_CHISQ [Nbin*i + (ix + xs) + NXGRID*(iy + ys)] = 10.0 * scale; 1813 Npt ++; 1814 } 1815 } 1816 } 1817 1818 // set the table data 1819 gfits_set_bintable_column (&header, &ftable, "IPP_IDET" , IPP_IDET , Nstars); 1820 gfits_set_bintable_column (&header, &ftable, "MODEL_TYPE" , MODEL_TYPE , Nstars); 1821 gfits_set_bintable_column (&header, &ftable, "X_FIT" , X_FIT , Nstars); 1822 gfits_set_bintable_column (&header, &ftable, "Y_FIT" , Y_FIT , Nstars); 1823 gfits_set_bintable_column (&header, &ftable, "NPIX" , NPIX , Nstars); 1824 gfits_set_bintable_column (&header, &ftable, "GAL_FLUX" , GAL_FLUX , Nstars); 1825 gfits_set_bintable_column (&header, &ftable, "GAL_FLUX_ERR" , GAL_FLUX_ERR , Nstars); 1826 gfits_set_bintable_column (&header, &ftable, "GAL_CHISQ" , GAL_CHISQ , Nstars); 1827 gfits_set_bintable_column (&header, &ftable, "FR_MAJOR_MIN" , FR_MAJOR_MIN , Nstars); 1828 gfits_set_bintable_column (&header, &ftable, "FR_MAJOR_MAX" , FR_MAJOR_MAX , Nstars); 1829 gfits_set_bintable_column (&header, &ftable, "FR_MAJOR_DEL" , FR_MAJOR_DEL , Nstars); 1830 gfits_set_bintable_column (&header, &ftable, "FR_MINOR_MIN" , FR_MINOR_MIN , Nstars); 1831 gfits_set_bintable_column (&header, &ftable, "FR_MINOR_MAX" , FR_MINOR_MAX , Nstars); 1832 gfits_set_bintable_column (&header, &ftable, "FR_MINOR_DEL" , FR_MINOR_DEL , Nstars); 1679 1833 } 1680 1834 /**/
Note:
See TracChangeset
for help on using the changeset viewer.
