/* FILE: phot_mag.c * PURPOSE: Calculate the stellar magnitude. * AUTHOR: Kenneth J. Mighell (mighell@noao.edu) * LANGUAGE: ANSI C * DATE: 2001JUL03 * COPYRIGHT: (C) 2001 Assoc. of Universities for Research in Astronomy Inc. */ #include "mx.h" #include "qdphot.h" int qdphot5_PhotS_CalcMag_f2 ( qdphot5_ImageS *Image, qdphot5_PhotS *PhotS ){ char mxfunc[] = "qdphot5_PhotS_CalcMag_f2"; int status = -1; double ebkg; double area; double sgnl; double esgnl; double electrons; double ron; double flux; double mg; double emg; double cmg; double mnsnr; double mmag; ebkg = PhotS->ebkg; area = PhotS->area; sgnl = PhotS->sgnl; ron = Image->ron; /* CCD readout noise */ mnsnr = Image->mnsnr; if (sgnl <= 0) goto bye; electrons = sgnl; esgnl = sqrt( electrons /* random error due to photon noise */ + (area*(ron*ron)) /* random error readout noise */ ) + (area*ebkg); /* systmatic error due to sky measurement error */ /* magnitude */ flux = sgnl; mg = 99.999; emg = 99.999; if (flux > 0) { mg = -2.5*log10(flux); emg = 1.0857*(esgnl/sgnl); } /* check magnitude */ flux = mnsnr*esgnl; cmg = 99.999; if (flux > 0) cmg = -2.5*log10(flux); if (mgmg = mg; PhotS->emg = emg; PhotS->cmg = cmg; return( status ); } /* end-of-file */