Changeset 38938
- Timestamp:
- Oct 22, 2015, 5:53:15 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/addstar/src/mkcmf.c (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/src/mkcmf.c
r38920 r38938 25 25 void writeStars_PS1_DEV_0 (FTable *ftable, double *X, double *Y, double *M, int Nstars); 26 26 27 int WriteXSRCtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars );27 int WriteXSRCtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars, float zeroPt, float exptime); 28 28 int WriteXFITtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 29 29 int WriteXRADtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); … … 334 334 gfits_modify (&header, "UTC-OBS", "%s", 1, time); 335 335 } 336 gfits_modify (&header, "ZERO_PT", "%lf", 1, ZERO_POINT); 336 gfits_modify (&header, "ZERO_PT", "%lf", 1, ZERO_POINT); // this is now not used 337 337 gfits_modify (&header, "EXPTIME", "%lf", 1, exptime); 338 338 gfits_modify (&header, "AIRMASS", "%lf", 1, airmass); … … 370 370 gfits_modify (&header, "AST_CDY", "%f", 1, 0.04); 371 371 372 float zeroPt = 25.0 + 0.3*(drand48() - 0.5); 373 372 374 if (!isStack && !isForcedWarp) { 373 375 gfits_modify (&header, "HIERARCH DETREND.MASK", "%s", 1, "detref615.XY33.fits"); … … 377 379 gfits_modify (&header, "HIERARCH DETREND.NONLIN", "%s", 1, "linearity_data.XY33.fits"); 378 380 gfits_modify (&header, "HIERARCH DETREND.VIDEODARK", "%s", 1, "GPC1.VIDEODARK.979.0.XY33.fits"); 379 gfits_modify (&header, "ZPT_OBS", "%f", 1, 25.0);381 gfits_modify (&header, "ZPT_OBS", "%f", 1, zeroPt); 380 382 } 381 383 382 384 if (isStack) { 383 gfits_modify (&header, "HIERARCH FPA.ZP", "%f", 1, 25.0);385 gfits_modify (&header, "HIERARCH FPA.ZP", "%f", 1, zeroPt); 384 386 gfits_modify (&header, "TESS_ID", "%s", 1, tess_id); 385 387 gfits_modify (&header, "SKYCELL", "%s", 1, skycell); 388 gfits_modify (&header, "ZPT_OBS", "%f", 1, zeroPt); 386 389 } 387 390 if (isForcedWarp) { 388 gfits_modify (&header, "HIERARCH FPA.FILTERID", "%s", 1, "r.00000"); 389 gfits_modify (&header, "HIERARCH FPA.ZP", "%f", 1, 25.0);391 gfits_modify (&header, "HIERARCH FPA.FILTERID", "%s", 1, "r.00000"); // does this affect anything? I don't actually think so... 392 gfits_modify (&header, "HIERARCH FPA.ZP", "%f", 1, zeroPt); 390 393 gfits_modify (&header, "TESS_ID", "%s", 1, tess_id); 391 394 gfits_modify (&header, "SKYCELL", "%s", 1, skycell); … … 472 475 gfits_fwrite_table (fits, &ftable); 473 476 474 if (WriteXSRC) WriteXSRCtable (fits, extroot, X, Y, M, Flag, Nstars );477 if (WriteXSRC) WriteXSRCtable (fits, extroot, X, Y, M, Flag, Nstars, zeroPt, exptime); 475 478 if (WriteXFIT) WriteXFITtable (fits, extroot, X, Y, M, Flag, Nstars); 476 479 if (WriteXRAD) WriteXRADtable (fits, extroot, X, Y, M, Flag, Nstars); … … 572 575 fSN = 1.0 / sqrt(flux); 573 576 577 if (ADDNOISE) { 578 X[i] += FX * fSN * rnd_gauss(0.0, 1.0); 579 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0); 580 M[i] += fSN*rnd_gauss(0.0, 1.0); 581 flux = pow (10.0, -0.4*M[i]); 582 fSN = 1.0 / sqrt(flux); 583 } 584 574 585 stars[i].X = X[i]; 575 586 stars[i].Y = Y[i]; 576 587 stars[i].M = M[i]; 577 578 if (ADDNOISE) {579 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0);580 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0);581 stars[i].M += fSN*rnd_gauss(0.0, 1.0);582 }583 588 584 589 stars[i].dX = FX * fSN; … … 616 621 fSN = 1.0 / sqrt(flux); 617 622 623 if (ADDNOISE) { 624 X[i] += FX * fSN * rnd_gauss(0.0, 1.0); 625 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0); 626 M[i] += fSN*rnd_gauss(0.0, 1.0); 627 flux = pow (10.0, -0.4*M[i]); 628 fSN = 1.0 / sqrt(flux); 629 } 630 618 631 stars[i].X = X[i]; 619 632 stars[i].Y = Y[i]; 620 633 stars[i].M = M[i]; 621 622 if (ADDNOISE) {623 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0);624 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0);625 stars[i].M += fSN*rnd_gauss(0.0, 1.0);626 }627 634 628 635 stars[i].dX = FX * fSN; … … 663 670 fSN = 1.0 / sqrt(flux); 664 671 672 if (ADDNOISE) { 673 X[i] += FX * fSN * rnd_gauss(0.0, 1.0); 674 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0); 675 M[i] += fSN*rnd_gauss(0.0, 1.0); 676 flux = pow (10.0, -0.4*M[i]); 677 fSN = 1.0 / sqrt(flux); 678 } 679 665 680 stars[i].X = X[i]; 666 681 stars[i].Y = Y[i]; 667 682 stars[i].M = M[i]; 668 669 if (ADDNOISE) {670 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0);671 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0);672 stars[i].M += fSN*rnd_gauss(0.0, 1.0);673 }674 683 675 684 stars[i].dX = FX * fSN; … … 712 721 fSN = 1.0 / sqrt(flux); 713 722 723 if (ADDNOISE) { 724 X[i] += FX * fSN * rnd_gauss(0.0, 1.0); 725 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0); 726 M[i] += fSN*rnd_gauss(0.0, 1.0); 727 flux = pow (10.0, -0.4*M[i]); 728 fSN = 1.0 / sqrt(flux); 729 } 730 714 731 stars[i].X = X[i]; 715 732 stars[i].Y = Y[i]; 716 733 stars[i].M = M[i]; 717 718 if (ADDNOISE) {719 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0);720 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0);721 stars[i].M += fSN*rnd_gauss(0.0, 1.0);722 }723 734 724 735 // randomly give poor PSFQF values … … 767 778 fSN = 1.0 / sqrt(flux); 768 779 780 if (ADDNOISE) { 781 X[i] += FX * fSN * rnd_gauss(0.0, 1.0); 782 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0); 783 M[i] += fSN*rnd_gauss(0.0, 1.0); 784 flux = pow (10.0, -0.4*M[i]); 785 fSN = 1.0 / sqrt(flux); 786 } 787 769 788 stars[i].X = X[i]; 770 789 stars[i].Y = Y[i]; 771 790 stars[i].M = M[i]; 772 791 stars[i].Map = M[i] - 0.05; 773 774 if (ADDNOISE) {775 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0);776 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0);777 stars[i].M += fSN*rnd_gauss(0.0, 1.0);778 }779 792 780 793 // randomly give poor PSFQF values … … 826 839 fSN = 1.0 / sqrt(flux); 827 840 841 if (ADDNOISE) { 842 X[i] += FX * fSN * rnd_gauss(0.0, 1.0); 843 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0); 844 M[i] += fSN*rnd_gauss(0.0, 1.0); 845 flux = pow (10.0, -0.4*M[i]); 846 fSN = 1.0 / sqrt(flux); 847 } 848 828 849 stars[i].X = X[i]; 829 850 stars[i].Y = Y[i]; … … 837 858 stars[i].apFlux = pow(10.0, -0.4*stars[i].Map); 838 859 stars[i].apFluxErr = stars[i].apFlux * fSN; 839 840 if (ADDNOISE) {841 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0);842 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0);843 stars[i].M += fSN*rnd_gauss(0.0, 1.0);844 }845 860 846 861 // randomly give poor PSFQF values … … 893 908 fSN = 1.0 / sqrt(flux); 894 909 910 if (ADDNOISE) { 911 X[i] += FX * fSN * rnd_gauss(0.0, 1.0); 912 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0); 913 M[i] += fSN*rnd_gauss(0.0, 1.0); 914 flux = pow (10.0, -0.4*M[i]); 915 fSN = 1.0 / sqrt(flux); 916 } 917 895 918 stars[i].detID = i; 896 919 stars[i].X = X[i]; … … 972 995 973 996 stars[i].nFrames = 1; 974 975 if (ADDNOISE) {976 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0);977 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0);978 float Moff = fSN*rnd_gauss(0.0, 1.0);979 stars[i].M += Moff;980 stars[i].Map += Moff;981 stars[i].MapRaw += Moff;982 stars[i].Mcalib += Moff;983 }984 997 } 985 998 … … 1001 1014 flux = pow (10.0, -0.4*M[i]); 1002 1015 fSN = 1.0 / sqrt(flux); 1016 1017 if (ADDNOISE) { 1018 X[i] += FX * fSN * rnd_gauss(0.0, 1.0); 1019 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0); 1020 M[i] += fSN*rnd_gauss(0.0, 1.0); 1021 flux = pow (10.0, -0.4*M[i]); 1022 fSN = 1.0 / sqrt(flux); 1023 } 1003 1024 1004 1025 stars[i].detID = i; … … 1081 1102 1082 1103 stars[i].nFrames = 1; 1083 1084 if (ADDNOISE) {1085 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0);1086 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0);1087 float Moff = fSN*rnd_gauss(0.0, 1.0);1088 stars[i].M += Moff;1089 stars[i].Map += Moff;1090 stars[i].MapRaw += Moff;1091 stars[i].Mcalib += Moff;1092 }1093 1104 } 1094 1105 … … 1118 1129 flux = pow (10.0, -0.4*M[i]); 1119 1130 fSN = 1.0 / sqrt(flux); 1131 1132 if (ADDNOISE) { 1133 X[i] += FX * fSN * rnd_gauss(0.0, 1.0); 1134 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0); 1135 M[i] += fSN*rnd_gauss(0.0, 1.0); 1136 flux = pow (10.0, -0.4*M[i]); 1137 fSN = 1.0 / sqrt(flux); 1138 } 1120 1139 1121 1140 stars[i].detID = i; … … 1221 1240 1222 1241 stars[i].nFrames = 1; 1223 1224 if (ADDNOISE) {1225 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0);1226 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0);1227 float Moff = fSN*rnd_gauss(0.0, 1.0);1228 stars[i].M += Moff;1229 stars[i].Map += Moff;1230 stars[i].MapRaw += Moff;1231 stars[i].Mcalib += Moff;1232 }1233 1242 } 1234 1243 … … 1237 1246 } 1238 1247 1239 int WriteXSRCtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars ) {1248 int WriteXSRCtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars, float zeroPt, float exptime) { 1240 1249 1241 1250 int i, j; … … 1306 1315 float *PROF_FILL ; ALLOCATE (PROF_FILL , float , 9*Nstars); 1307 1316 1317 float magtime = 2.5*log10(exptime); 1318 1308 1319 // assign the storage arrays 1309 1320 for (i = 0; i < Nstars; i++) { … … 1318 1329 F25_ARATIO [i] = 0.9; 1319 1330 F25_THETA [i] = 10.0; 1320 PETRO_MAG [i] = M[i] ;1321 PETRO_MAG_ERR [i] = fSN;1331 PETRO_MAG [i] = M[i] + zeroPt + magtime; 1332 PETRO_MAG_ERR [i] = 1.0 / fSN; 1322 1333 PETRO_RADIUS [i] = 8.0; 1323 1334 if (i == 2) { … … 1528 1539 int WriteXRADtable (FILE *fits, char *extroot, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) { 1529 1540 1530 int i, j ;1541 int i, j, k; 1531 1542 Header header; 1532 1543 FTable ftable; … … 1553 1564 1554 1565 // create intermediate storage arrays 1555 int *IPP_IDET ; ALLOCATE (IPP_IDET , int , Nstars); 1556 float *X_APER ; ALLOCATE (X_APER , float , Nstars); 1557 float *Y_APER ; ALLOCATE (Y_APER , float , Nstars); 1558 float *PSF_FWHM ; ALLOCATE (PSF_FWHM , float , Nstars); 1559 float *APER_FLUX ; ALLOCATE (APER_FLUX , float , Nstars*9); 1560 float *APER_FLUX_ERR ; ALLOCATE (APER_FLUX_ERR , float , Nstars*9); 1561 float *APER_FLUX_STDEV ; ALLOCATE (APER_FLUX_STDEV , float , Nstars*9); 1562 float *APER_FILL ; ALLOCATE (APER_FILL , float , Nstars*9); 1566 int *IPP_IDET ; ALLOCATE (IPP_IDET , int , 3*Nstars); 1567 float *X_APER ; ALLOCATE (X_APER , float , 3*Nstars); 1568 float *Y_APER ; ALLOCATE (Y_APER , float , 3*Nstars); 1569 float *PSF_FWHM ; ALLOCATE (PSF_FWHM , float , 3*Nstars); 1570 float *APER_FLUX ; ALLOCATE (APER_FLUX , float , 3*Nstars*9); 1571 float *APER_FLUX_ERR ; ALLOCATE (APER_FLUX_ERR , float , 3*Nstars*9); 1572 float *APER_FLUX_STDEV ; ALLOCATE (APER_FLUX_STDEV , float , 3*Nstars*9); 1573 float *APER_FILL ; ALLOCATE (APER_FILL , float , 3*Nstars*9); 1574 1575 float psfFWHM[3] = {4.8, 6.0, 8.0}; 1563 1576 1564 1577 // assign the storage arrays … … 1567 1580 // float fSN = 1.0 / sqrt(flux); 1568 1581 1569 IPP_IDET [i] = i; 1570 X_APER [i] = X[i]; 1571 Y_APER [i] = Y[i]; 1572 PSF_FWHM [i] = FX*2.8; 1573 for (j = 0; j < 9; j ++) { 1574 APER_FLUX [j + 9*i] = flux; 1575 APER_FLUX_ERR [j + 9*i] = sqrt(flux); 1576 APER_FLUX_STDEV[j + 9*i] = sqrt(flux); 1577 APER_FILL [j + 9*i] = 0.9; 1582 for (k = 0; k < 3; k++) { 1583 int N = 3*i + k; 1584 IPP_IDET [N] = i; 1585 X_APER [N] = X[i]; 1586 Y_APER [N] = Y[i]; 1587 PSF_FWHM [N] = psfFWHM[k]; 1588 for (j = 0; j < 9; j ++) { 1589 float Flux = flux*(1.0 + 0.02*j - 0.2); 1590 APER_FLUX [j + 9*N] = Flux; 1591 APER_FLUX_ERR [j + 9*N] = sqrt(Flux); 1592 APER_FLUX_STDEV[j + 9*N] = sqrt(Flux*1.1); 1593 APER_FILL [j + 9*N] = 0.9; 1594 } 1578 1595 } 1579 1596 } 1580 1597 1581 1598 // set the table data 1582 gfits_set_bintable_column (&header, &ftable, "IPP_IDET" , IPP_IDET , Nstars);1583 gfits_set_bintable_column (&header, &ftable, "X_APER" , X_APER , Nstars);1584 gfits_set_bintable_column (&header, &ftable, "Y_APER" , Y_APER , Nstars);1585 gfits_set_bintable_column (&header, &ftable, "PSF_FWHM" , PSF_FWHM , Nstars);1586 gfits_set_bintable_column (&header, &ftable, "APER_FLUX" , APER_FLUX , Nstars);1587 gfits_set_bintable_column (&header, &ftable, "APER_FLUX_ERR" , APER_FLUX_ERR , Nstars);1588 gfits_set_bintable_column (&header, &ftable, "APER_FLUX_STDEV" , APER_FLUX_STDEV , Nstars);1589 gfits_set_bintable_column (&header, &ftable, "APER_FILL" , APER_FILL , Nstars);1599 gfits_set_bintable_column (&header, &ftable, "IPP_IDET" , IPP_IDET , 3*Nstars); 1600 gfits_set_bintable_column (&header, &ftable, "X_APER" , X_APER , 3*Nstars); 1601 gfits_set_bintable_column (&header, &ftable, "Y_APER" , Y_APER , 3*Nstars); 1602 gfits_set_bintable_column (&header, &ftable, "PSF_FWHM" , PSF_FWHM , 3*Nstars); 1603 gfits_set_bintable_column (&header, &ftable, "APER_FLUX" , APER_FLUX , 3*Nstars); 1604 gfits_set_bintable_column (&header, &ftable, "APER_FLUX_ERR" , APER_FLUX_ERR , 3*Nstars); 1605 gfits_set_bintable_column (&header, &ftable, "APER_FLUX_STDEV" , APER_FLUX_STDEV , 3*Nstars); 1606 gfits_set_bintable_column (&header, &ftable, "APER_FILL" , APER_FILL , 3*Nstars); 1590 1607 } 1591 1608 /**/
Note:
See TracChangeset
for help on using the changeset viewer.
