| Line 20... |
Line 20... |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
|
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
|
*
|
*
|
* Last modified: 23/06/2011
|
* Last modified: 06/10/2011
|
*
|
*
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
#include "config.h"
|
#include "config.h"
|
| Line 79... |
Line 79... |
*/
|
*/
|
void psf_end(psfstruct *psf, psfitstruct *psfit)
|
void psf_end(psfstruct *psf, psfitstruct *psfit)
|
{
|
{
|
int d, ndim;
|
int d, ndim;
|
|
|
if (psf->pc)
|
|
pc_end(psf->pc);
|
|
|
|
ndim = psf->poly->ndim;
|
ndim = psf->poly->ndim;
|
for (d=0; d<ndim; d++)
|
for (d=0; d<ndim; d++)
|
free(psf->contextname[d]);
|
free(psf->contextname[d]);
|
free(psf->context);
|
free(psf->context);
|
free(psf->contextname);
|
free(psf->contextname);
|
| Line 115... |
Line 112... |
/*
|
/*
|
Read the PSF data from a FITS file.
|
Read the PSF data from a FITS file.
|
*/
|
*/
|
psfstruct *psf_load(char *filename)
|
psfstruct *psf_load(char *filename)
|
{
|
{
|
static objstruct saveobj;
|
|
static obj2struct saveobj2;
|
static obj2struct saveobj2;
|
psfstruct *psf;
|
psfstruct *psf;
|
catstruct *cat;
|
catstruct *cat;
|
tabstruct *tab;
|
tabstruct *tab;
|
keystruct *key;
|
keystruct *key;
|
| Line 162... |
Line 158... |
QMALLOC(psf->context, double *, ndim);
|
QMALLOC(psf->context, double *, ndim);
|
QMALLOC(psf->contexttyp, t_type, ndim);
|
QMALLOC(psf->contexttyp, t_type, ndim);
|
QMALLOC(psf->contextoffset, double, ndim);
|
QMALLOC(psf->contextoffset, double, ndim);
|
QMALLOC(psf->contextscale, double, ndim);
|
QMALLOC(psf->contextscale, double, ndim);
|
|
|
/*-- We will have to use the outobj structs, so we first save their content */
|
/*-- We will have to use the flagobj2 struct, so we first save its content */
|
saveobj = outobj;
|
saveobj2 = flagobj2;
|
saveobj2 = outobj2;
|
/*-- flagobj2 is used as a FLAG array, so we initialize it to 0 */
|
/*-- outobj's are used as FLAG arrays, so we initialize them to 0 */
|
memset(&flagobj2, 0, sizeof(flagobj2));
|
memset(&outobj, 0, sizeof(outobj));
|
|
memset(&outobj2, 0, sizeof(outobj2));
|
|
for (i=0; i<ndim; i++)
|
for (i=0; i<ndim; i++)
|
{
|
{
|
/*---- Polynomial groups */
|
/*---- Polynomial groups */
|
sprintf(gstr, "POLGRP%1d", i+1);
|
sprintf(gstr, "POLGRP%1d", i+1);
|
if (fitsread(head, gstr, &group[i], H_INT,T_LONG) != RETURN_OK)
|
if (fitsread(head, gstr, &group[i], H_INT,T_LONG) != RETURN_OK)
|
| Line 225... |
Line 219... |
goto headerror;
|
goto headerror;
|
}
|
}
|
|
|
psf->poly = poly_init(group, ndim, deg, ngroup);
|
psf->poly = poly_init(group, ndim, deg, ngroup);
|
|
|
/*-- Update the permanent FLAG arrays (that is, perform an "OR" on them) */
|
/*-- Restore previous flagobj2 content */
|
for (ci=(char *)&outobj,co=(char *)&flagobj,i=sizeof(objstruct); i--;)
|
flagobj2 = saveobj2;
|
*(co++) |= *(ci++);
|
|
for (ci=(char *)&outobj2,co=(char *)&flagobj2,i=sizeof(obj2struct); i--;)
|
|
*(co++) |= *(ci++);
|
|
|
|
/*-- Restore previous outobj contents */
|
|
outobj = saveobj;
|
|
outobj2 = saveobj2;
|
|
}
|
}
|
else
|
else
|
{
|
{
|
/*-- This is a simple, constant PSF */
|
/*-- This is a simple, constant PSF */
|
psf->poly = poly_init(group, 0, deg, 0);
|
psf->poly = poly_init(group, 0, deg, 0);
|
| Line 273... |
Line 260... |
|
|
/* Load the PSF mask data */
|
/* Load the PSF mask data */
|
key = read_key(tab, "PSF_MASK");
|
key = read_key(tab, "PSF_MASK");
|
psf->maskcomp = key->ptr;
|
psf->maskcomp = key->ptr;
|
|
|
psf->pc = pc_load(cat);
|
|
|
|
QMALLOC(psf->maskloc, float, psf->masksize[0]*psf->masksize[1]);
|
QMALLOC(psf->maskloc, float, psf->masksize[0]*psf->masksize[1]);
|
|
|
/* But don't touch my arrays!! */
|
/* But don't touch my arrays!! */
|
blank_keys(tab);
|
blank_keys(tab);
|
|
|
| Line 323... |
Line 308... |
/******************************** psf_fit ***********************************/
|
/******************************** psf_fit ***********************************/
|
/* standard PSF fit for one component */
|
/* standard PSF fit for one component */
|
/****************************************************************************/
|
/****************************************************************************/
|
|
|
void psf_fit(psfstruct *psf, picstruct *field, picstruct *wfield,
|
void psf_fit(psfstruct *psf, picstruct *field, picstruct *wfield,
|
objstruct *obj, obj2struct *obj2)
|
obj2struct *obj2)
|
{
|
{
|
checkstruct *check;
|
checkstruct *check;
|
static double x2[PSF_NPSFMAX],y2[PSF_NPSFMAX],xy[PSF_NPSFMAX],
|
static double x2[PSF_NPSFMAX],y2[PSF_NPSFMAX],xy[PSF_NPSFMAX],
|
deltax[PSF_NPSFMAX],
|
deltax[PSF_NPSFMAX],
|
deltay[PSF_NPSFMAX],
|
deltay[PSF_NPSFMAX],
|
| Line 355... |
Line 340... |
niter = 0;
|
niter = 0;
|
npsfmax = prefs.psf_npsfmax;
|
npsfmax = prefs.psf_npsfmax;
|
pixstep = 1.0/psf->pixstep;
|
pixstep = 1.0/psf->pixstep;
|
gain = (field->gain >0.0? field->gain: 1e30);
|
gain = (field->gain >0.0? field->gain: 1e30);
|
backnoise2 = field->backsig*field->backsig;
|
backnoise2 = field->backsig*field->backsig;
|
satlevel = field->satur_level - obj->bkg;
|
satlevel = field->satur_level - obj2->bkg;
|
wthresh = wfield?wfield->weight_thresh:BIG;
|
wthresh = wfield?wfield->weight_thresh:BIG;
|
gainflag = prefs.weightgain_flag;
|
gainflag = prefs.weightgain_flag;
|
psf_fwhm = psf->fwhm*psf->pixstep;
|
psf_fwhm = psf->fwhm*psf->pixstep;
|
|
|
|
|
| Line 373... |
Line 358... |
thepsfit->flux[j] = 0.0;
|
thepsfit->flux[j] = 0.0;
|
thepsfit->fluxerr[j] = 0.0;
|
thepsfit->fluxerr[j] = 0.0;
|
}
|
}
|
|
|
/* Scale data area with object "size" */
|
/* Scale data area with object "size" */
|
ix = (obj->xmax+obj->xmin+1)/2;
|
ix = (obj2->xmax+obj2->xmin+1)/2;
|
iy = (obj->ymax+obj->ymin+1)/2;
|
iy = (obj2->ymax+obj2->ymin+1)/2;
|
width = obj->xmax-obj->xmin+1+psf_fwhm;
|
width = obj2->xmax-obj2->xmin+1+psf_fwhm;
|
if (width < (ival=(int)(psf_fwhm*2)))
|
if (width < (ival=(int)(psf_fwhm*2)))
|
width = ival;
|
width = ival;
|
height = obj->ymax-obj->ymin+1+psf_fwhm;
|
height = obj2->ymax-obj2->ymin+1+psf_fwhm;
|
if (height < (ival=(int)(psf_fwhm*2)))
|
if (height < (ival=(int)(psf_fwhm*2)))
|
height = ival;
|
height = ival;
|
npix = width*height;
|
npix = width*height;
|
radmin2 = PSF_MINSHIFT*PSF_MINSHIFT;
|
radmin2 = PSF_MINSHIFT*PSF_MINSHIFT;
|
radmax2 = npix/2.0;
|
radmax2 = npix/2.0;
|
| Line 397... |
Line 382... |
QMALLOC(datah, PIXTYPE, npix);
|
QMALLOC(datah, PIXTYPE, npix);
|
QMALLOC(data, float, npix);
|
QMALLOC(data, float, npix);
|
QMALLOC(data2, float, npix);
|
QMALLOC(data2, float, npix);
|
QMALLOC(data3, float, npix);
|
QMALLOC(data3, float, npix);
|
QMALLOC(mat, double, npix*PSF_NTOT);
|
QMALLOC(mat, double, npix*PSF_NTOT);
|
if (prefs.check[CHECK_SUBPSFPROTOS] || prefs.check[CHECK_PSFPROTOS]
|
if (prefs.check[CHECK_SUBPSFPROTOS] || prefs.check[CHECK_PSFPROTOS])
|
|| prefs.check[CHECK_SUBPCPROTOS] || prefs.check[CHECK_PCPROTOS]
|
|
|| prefs.check[CHECK_PCOPROTOS])
|
|
{
|
{
|
QMALLOC(checkmask, PIXTYPE, nppix);
|
QMALLOC(checkmask, PIXTYPE, nppix);
|
}
|
}
|
|
|
QMALLOC(psfmasks, float *, npsfmax);
|
QMALLOC(psfmasks, float *, npsfmax);
|
| Line 453... |
Line 436... |
if (wbad>=npix-3)
|
if (wbad>=npix-3)
|
return;
|
return;
|
|
|
/* Weight the data */
|
/* Weight the data */
|
dh = datah;
|
dh = datah;
|
val = obj->dbkg; /* Take into account a local background change */
|
val = obj2->dbkg; /* Take into account a local background change */
|
d = data;
|
d = data;
|
w = weight;
|
w = weight;
|
for (p=npix; p--;)
|
for (p=npix; p--;)
|
*(d++) = (*(dh++)-val)**(w++);
|
*(d++) = (*(dh++)-val)**(w++);
|
|
|
/* Get the local PSF */
|
/* Get the local PSF */
|
psf_build(psf);
|
psf_build(psf, obj2);
|
|
|
npsfflag = 1;
|
npsfflag = 1;
|
r2 = psf_fwhm*psf_fwhm/2.0;
|
r2 = psf_fwhm*psf_fwhm/2.0;
|
fluxb[0] = fluxerrb[0] = deltaxb[0] = deltayb[0] = 0.0;
|
fluxb[0] = fluxerrb[0] = deltaxb[0] = deltayb[0] = 0.0;
|
|
|
| Line 519... |
Line 502... |
deltay[npsf-1] = (double)(ymax - height/2);
|
deltay[npsf-1] = (double)(ymax - height/2);
|
}
|
}
|
else
|
else
|
{
|
{
|
/*---- Only one component to fit: simply use the barycenter as a guess */
|
/*---- Only one component to fit: simply use the barycenter as a guess */
|
deltax[npsf-1] = obj->mx - ix;
|
deltax[npsf-1] = obj2->mx - ix;
|
deltay[npsf-1] = obj->my - iy;
|
deltay[npsf-1] = obj2->my - iy;
|
}
|
}
|
|
|
niter = 0;
|
niter = 0;
|
convflag = 1;
|
convflag = 1;
|
for (i=0; i<PSF_NITER && convflag; i++)
|
for (i=0; i<PSF_NITER && convflag; i++)
|
| Line 615... |
Line 598... |
pix = *(d++);
|
pix = *(d++);
|
pix -= psfmasks[j][p]*flux[j]**w;
|
pix -= psfmasks[j][p]*flux[j]**w;
|
chi2 += pix*pix;
|
chi2 += pix*pix;
|
if (chi2>1E29) chi2=1E28;
|
if (chi2>1E29) chi2=1E28;
|
}
|
}
|
obj2->chi2_psf = obj->sigbkg>0.?
|
obj2->chi2_psf = obj2->sigbkg>0.?
|
chi2/((npix - 3*npsf)*obj->sigbkg*obj->sigbkg):999999;
|
chi2/((npix - 3*npsf)*obj2->sigbkg*obj2->sigbkg):999999;
|
|
|
}
|
}
|
|
|
}*/
|
}*/
|
/* Compute relative chi2 if asked to */
|
/* Compute relative chi2 if asked to */
|
| Line 635... |
Line 618... |
pix -= psfmasks[j][p]**w;
|
pix -= psfmasks[j][p]**w;
|
chi2 += pix*pix;
|
chi2 += pix*pix;
|
if (chi2>1E29) chi2=1E28;
|
if (chi2>1E29) chi2=1E28;
|
}
|
}
|
obj2->chi2_psf = flux[j]>0?
|
obj2->chi2_psf = flux[j]>0?
|
chi2/((npix - 3*npsf)*obj->sigbkg*obj->sigbkg):999999;
|
chi2/((npix - 3*npsf)*obj2->sigbkg*obj2->sigbkg):999999;
|
|
|
}
|
}
|
|
|
}
|
}
|
/* CHECK images */
|
/* CHECK images */
|
| Line 663... |
Line 646... |
thepsfit->y[j] = iy+deltay[j]+1.0;
|
thepsfit->y[j] = iy+deltay[j]+1.0;
|
thepsfit->flux[j] = flux[j];
|
thepsfit->flux[j] = flux[j];
|
thepsfit->fluxerr[j] = fluxerr[j];
|
thepsfit->fluxerr[j] = fluxerr[j];
|
}
|
}
|
|
|
|
|
|
|
|
|
/* Now the morphology stuff */
|
|
if (prefs.pc_flag)
|
|
{
|
|
width = pwidth-1;
|
|
height = pheight-1;
|
|
npix = width*height;
|
|
|
|
/*-- Re-compute weights */
|
|
if (wfield)
|
|
{
|
|
psf_copyobjpix(datah, weighth, width, height, ix,iy, obj2,
|
|
!(field->flags&MEASURE_FIELD));
|
|
for (wh=weighth ,w=weight, p=npix; p--;)
|
|
*(w++) = (pix=*(wh++))<wthresh? sqrt(pix): 0.0;
|
|
}
|
|
else
|
|
{
|
|
psf_copyobjpix(datah, NULL, width, height, ix,iy, obj2,
|
|
!(field->flags&MEASURE_FIELD));
|
|
for (w=weight, dh=datah, p=npix; p--;)
|
|
*(w++) = ((pix = *(dh++))>-BIG && pix<satlevel)?
|
|
1.0/sqrt(backnoise2+(pix>0.0?pix/gain:0.0))
|
|
:0.0;
|
|
}
|
|
|
|
/*-- Weight the data */
|
|
dh = datah;
|
|
d = data;
|
|
w = weight;
|
|
for (p=npix; p--;)
|
|
*(d++) = *(dh++)*(*(w++));
|
|
|
|
pc_fit(psf, data, weight, width, height, ix,iy, dx,dy, npix,
|
|
field->backsig);
|
|
}
|
|
|
|
|
|
for (i=0; i<prefs.psf_npsfmax; i++)
|
for (i=0; i<prefs.psf_npsfmax; i++)
|
{
|
{
|
QFREE(psfmasks[i]);
|
QFREE(psfmasks[i]);
|
QFREE(psfmaskx[i]);
|
QFREE(psfmaskx[i]);
|
QFREE(psfmasky[i]);
|
QFREE(psfmasky[i]);
|
| Line 722... |
Line 665... |
QFREE(weighth);
|
QFREE(weighth);
|
QFREE(weight);
|
QFREE(weight);
|
QFREE(data);
|
QFREE(data);
|
QFREE(mat);
|
QFREE(mat);
|
|
|
if (prefs.check[CHECK_SUBPSFPROTOS] || prefs.check[CHECK_PSFPROTOS]
|
if (prefs.check[CHECK_SUBPSFPROTOS] || prefs.check[CHECK_PSFPROTOS])
|
|| prefs.check[CHECK_SUBPCPROTOS] || prefs.check[CHECK_PCPROTOS]
|
|
|| prefs.check[CHECK_PCOPROTOS])
|
|
{
|
|
QFREE(checkmask);
|
QFREE(checkmask);
|
}
|
|
|
|
return;
|
return;
|
}
|
}
|
|
|
|
|
/****************************** double_psf_fit ******************************/
|
/****************************** double_psf_fit ******************************/
|
/* double fit to make psf detection on one image and photometry on another */
|
/* double fit to make psf detection on one image and photometry on another */
|
/****************************************************************************/
|
/****************************************************************************/
|
|
|
void double_psf_fit(psfstruct *ppsf, picstruct *pfield, picstruct *pwfield,
|
void double_psf_fit(psfstruct *ppsf, picstruct *pfield, picstruct *pwfield,
|
objstruct *obj, obj2struct *obj2,
|
obj2struct *obj2,
|
psfstruct *psf, picstruct *field, picstruct *wfield)
|
psfstruct *psf, picstruct *field, picstruct *wfield)
|
{
|
{
|
static double /* sum[PSF_NPSFMAX]*/ pdeltax[PSF_NPSFMAX],
|
static double /* sum[PSF_NPSFMAX]*/ pdeltax[PSF_NPSFMAX],
|
pdeltay[PSF_NPSFMAX],psol[PSF_NPSFMAX], pcovmat[PSF_NPSFMAX*PSF_NPSFMAX],
|
pdeltay[PSF_NPSFMAX],psol[PSF_NPSFMAX], pcovmat[PSF_NPSFMAX*PSF_NPSFMAX],
|
pvmat[PSF_NPSFMAX*PSF_NPSFMAX], pwmat[PSF_NPSFMAX],pflux[PSF_NPSFMAX],
|
pvmat[PSF_NPSFMAX*PSF_NPSFMAX], pwmat[PSF_NPSFMAX],pflux[PSF_NPSFMAX],
|
| Line 770... |
Line 709... |
ppixstep = 1.0/ppsf->pixstep;
|
ppixstep = 1.0/ppsf->pixstep;
|
pixstep = 1.0/psf->pixstep;
|
pixstep = 1.0/psf->pixstep;
|
gain = (field->gain >0.0? field->gain: 1e30);
|
gain = (field->gain >0.0? field->gain: 1e30);
|
npsfmax=prefs.psf_npsfmax;
|
npsfmax=prefs.psf_npsfmax;
|
pbacknoise2 = pfield->backsig*pfield->backsig;
|
pbacknoise2 = pfield->backsig*pfield->backsig;
|
satlevel = field->satur_level - obj->bkg;
|
satlevel = field->satur_level - obj2->bkg;
|
gainflag = prefs.weightgain_flag;
|
gainflag = prefs.weightgain_flag;
|
psf_fwhm = psf->fwhm*psf->pixstep;
|
psf_fwhm = psf->fwhm*psf->pixstep;
|
ppsf_fwhm = ppsf->fwhm*ppsf->pixstep;
|
ppsf_fwhm = ppsf->fwhm*ppsf->pixstep;
|
pwthresh = pwfield?pwfield->weight_thresh:BIG;
|
pwthresh = pwfield?pwfield->weight_thresh:BIG;
|
|
|
| Line 789... |
Line 728... |
ppsfit->fluxerr[j] = 0.0;
|
ppsfit->fluxerr[j] = 0.0;
|
pdeltax[j]= pdeltay[j]=psol[j]= pwmat[j]=pflux[j]=pfluxerr[j]=0.0;
|
pdeltax[j]= pdeltay[j]=psol[j]= pwmat[j]=pflux[j]=pfluxerr[j]=0.0;
|
|
|
}
|
}
|
|
|
ix = (obj->xmax+obj->xmin+1)/2;
|
ix = (obj2->xmax+obj2->xmin+1)/2;
|
iy = (obj->ymax+obj->ymin+1)/2;
|
iy = (obj2->ymax+obj2->ymin+1)/2;
|
width = obj->xmax-obj->xmin+1+psf_fwhm;
|
width = obj2->xmax-obj2->xmin+1+psf_fwhm;
|
if (width < (ival=(int)(psf_fwhm*2)))
|
if (width < (ival=(int)(psf_fwhm*2)))
|
width = ival;
|
width = ival;
|
height = obj->ymax-obj->ymin+1+psf_fwhm;
|
height = obj2->ymax-obj2->ymin+1+psf_fwhm;
|
if (height < (ival=(int)(psf_fwhm*2)))
|
if (height < (ival=(int)(psf_fwhm*2)))
|
height = ival;
|
height = ival;
|
npix = width*height;
|
npix = width*height;
|
radmin2 = PSF_MINSHIFT*PSF_MINSHIFT;
|
radmin2 = PSF_MINSHIFT*PSF_MINSHIFT;
|
radmax2 = npix/2.0;
|
radmax2 = npix/2.0;
|
psf_fit(psf, field, wfield, obj, obj2);
|
psf_fit(psf, field, wfield, obj2);
|
npsf=thepsfit->npsf;
|
npsf=thepsfit->npsf;
|
|
|
QMALLOC(ppsfmasks,float *,npsfmax);
|
QMALLOC(ppsfmasks,float *,npsfmax);
|
QMALLOC(ppsfmaskx,float *,npsfmax);
|
QMALLOC(ppsfmaskx,float *,npsfmax);
|
QMALLOC(ppsfmasky,float *,npsfmax);
|
QMALLOC(ppsfmasky,float *,npsfmax);
|
| Line 870... |
Line 809... |
|
|
/* Weight the data */
|
/* Weight the data */
|
pdh = pdatah;
|
pdh = pdatah;
|
pd = pdata;
|
pd = pdata;
|
pw = pweight;
|
pw = pweight;
|
val = obj->dbkg;
|
val = obj2->dbkg;
|
for (p=npix; p--;)
|
for (p=npix; p--;)
|
*(pd++) = (*(pdh++)-val)**(pw++);
|
*(pd++) = (*(pdh++)-val)**(pw++);
|
|
|
|
|
/* Get the photmetry PSF */
|
/* Get the photmetry PSF */
|
psf_build(ppsf);
|
psf_build(ppsf, obj2);
|
for (j=1; j<=npsf; j++)
|
for (j=1; j<=npsf; j++)
|
{
|
{
|
if (j>1)
|
if (j>1)
|
{
|
{
|
/*---- Subtract //previously fitted components in photometry image */
|
/*---- Subtract //previously fitted components in photometry image */
|
| Line 945... |
Line 884... |
ppix = *(pd++);
|
ppix = *(pd++);
|
ppix -= ppsfmasks[j][p]*pflux[j]**pw;
|
ppix -= ppsfmasks[j][p]*pflux[j]**pw;
|
chi2 += ppix*ppix;
|
chi2 += ppix*ppix;
|
if (chi2>1E29) chi2=1E28;
|
if (chi2>1E29) chi2=1E28;
|
}
|
}
|
obj2->chi2_psf = obj->sigbkg>0.?
|
obj2->chi2_psf = obj2->sigbkg>0.?
|
chi2/((npix - 3*npsf)*obj->sigbkg*obj->sigbkg):999999;
|
chi2/((npix - 3*npsf)*obj2->sigbkg*obj2->sigbkg):999999;
|
|
|
}
|
}
|
|
|
}
|
}
|
*/
|
*/
|
| Line 966... |
Line 905... |
ppix -= ppsfmasks[j][p]**pw;
|
ppix -= ppsfmasks[j][p]**pw;
|
chi2 += ppix*ppix;
|
chi2 += ppix*ppix;
|
if (chi2>1E29) chi2=1E28;
|
if (chi2>1E29) chi2=1E28;
|
}
|
}
|
obj2->chi2_psf = pflux[j]>0?
|
obj2->chi2_psf = pflux[j]>0?
|
chi2/((npix - 3*npsf)*obj->sigbkg*obj->sigbkg):999999;
|
chi2/((npix - 3*npsf)*obj2->sigbkg*obj2->sigbkg):999999;
|
|
|
}
|
}
|
|
|
}
|
}
|
ppsfit->niter = thepsfit->niter;
|
ppsfit->niter = thepsfit->niter;
|
| Line 1007... |
Line 946... |
QFREE(pweighth);
|
QFREE(pweighth);
|
QFREE(pweight);
|
QFREE(pweight);
|
QFREE(pdata);
|
QFREE(pdata);
|
QFREE(pmat);
|
QFREE(pmat);
|
|
|
if (prefs.check[CHECK_SUBPSFPROTOS] || prefs.check[CHECK_PSFPROTOS]
|
if (prefs.check[CHECK_SUBPSFPROTOS] || prefs.check[CHECK_PSFPROTOS])
|
|| prefs.check[CHECK_SUBPCPROTOS] || prefs.check[CHECK_PCPROTOS]
|
|
|| prefs.check[CHECK_PCOPROTOS])
|
|
{
|
{
|
QFREE(checkmask);
|
QFREE(checkmask);
|
}
|
}
|
return;
|
return;
|
}
|
}
|
| Line 1110... |
Line 1047... |
|
|
/******************************* psf_build **********************************/
|
/******************************* psf_build **********************************/
|
/*
|
/*
|
Build the local PSF (function of "context").
|
Build the local PSF (function of "context").
|
*/
|
*/
|
void psf_build(psfstruct *psf)
|
void psf_build(psfstruct *psf, obj2struct *obj2)
|
{
|
{
|
static double pos[POLY_MAXDIM];
|
static double pos[POLY_MAXDIM];
|
double *basis, fac;
|
double *basis, fac;
|
float *ppc, *pl;
|
float *ppc, *pl;
|
int i,n,p, ndim, npix;
|
int i,n,p, ndim, npix;
|
| Line 1129... |
Line 1066... |
|
|
/* Grab the context vector */
|
/* Grab the context vector */
|
ndim = psf->poly->ndim;
|
ndim = psf->poly->ndim;
|
for (i=0; i<ndim; i++)
|
for (i=0; i<ndim; i++)
|
{
|
{
|
ttypeconv(psf->context[i], &pos[i], psf->contexttyp[i],T_DOUBLE);
|
ttypeconv((char *)obj2 + ((void *)psf->context[i]-(void *)&flagobj2),
|
|
&pos[i], psf->contexttyp[i],T_DOUBLE);
|
pos[i] = (pos[i] - psf->contextoffset[i]) / psf->contextscale[i];
|
pos[i] = (pos[i] - psf->contextoffset[i]) / psf->contextscale[i];
|
}
|
}
|
poly_func(psf->poly, pos);
|
poly_func(psf->poly, pos);
|
|
|
basis = psf->poly->basis;
|
basis = psf->poly->basis;
|
| Line 1156... |
Line 1094... |
|
|
/******************************** psf_fwhm **********************************/
|
/******************************** psf_fwhm **********************************/
|
/*
|
/*
|
Return the local PSF FWHM.
|
Return the local PSF FWHM.
|
*/
|
*/
|
double psf_fwhm(psfstruct *psf)
|
double psf_fwhm(psfstruct *psf, obj2struct *obj2)
|
{
|
{
|
float *pl,
|
float *pl,
|
val, max;
|
val, max;
|
int n,p, npix;
|
int n,p, npix;
|
|
|
if (!psf->build_flag)
|
if (!psf->build_flag)
|
psf_build(psf);
|
psf_build(psf, obj2);
|
|
|
npix = psf->masksize[0]*psf->masksize[1];
|
npix = psf->masksize[0]*psf->masksize[1];
|
max = -BIG;
|
max = -BIG;
|
pl = psf->maskloc;
|
pl = psf->maskloc;
|
for (p=npix; p--;)
|
for (p=npix; p--;)
|