/*
|
/*
|
makeit.c
|
makeit.c
|
|
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
*
|
*
|
* Part of: SExtractor
|
* Part of: SExtractor
|
*
|
*
|
* Author: E.BERTIN, IAP & Leiden observatory
|
* Author: E.BERTIN, IAP & Leiden observatory
|
*
|
*
|
* Contents: main program.
|
* Contents: main program.
|
*
|
*
|
* Last modify: 12/01/2006
|
* Last modify: 12/01/2006
|
*
|
*
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
*/
|
*/
|
|
|
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
#include "config.h"
|
#include "config.h"
|
#endif
|
#endif
|
|
|
#include <math.h>
|
#include <math.h>
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <string.h>
|
#include <string.h>
|
#include <time.h>
|
#include <time.h>
|
|
|
#include "define.h"
|
#include "define.h"
|
#include "globals.h"
|
#include "globals.h"
|
#include "prefs.h"
|
#include "prefs.h"
|
#include "fits/fitscat.h"
|
#include "fits/fitscat.h"
|
#include "assoc.h"
|
#include "assoc.h"
|
#include "back.h"
|
#include "back.h"
|
#include "check.h"
|
#include "check.h"
|
#include "field.h"
|
#include "field.h"
|
#include "filter.h"
|
#include "filter.h"
|
#include "growth.h"
|
#include "growth.h"
|
#include "interpolate.h"
|
#include "interpolate.h"
|
#include "psf.h"
|
#include "psf.h"
|
#include "som.h"
|
#include "som.h"
|
#include "weight.h"
|
#include "weight.h"
|
|
|
/******************************** makeit *************************************/
|
/******************************** makeit *************************************/
|
/*
|
/*
|
Manage the whole stuff.
|
Manage the whole stuff.
|
*/
|
*/
|
void makeit()
|
void makeit()
|
|
|
{
|
{
|
checkstruct *check;
|
checkstruct *check;
|
picstruct *dfield, *field,*pffield[MAXFLAG], *wfield,*dwfield;
|
picstruct *dfield, *field,*pffield[MAXFLAG], *wfield,*dwfield;
|
catstruct *imacat;
|
catstruct *imacat;
|
tabstruct *imatab;
|
tabstruct *imatab;
|
static time_t thetime1, thetime2;
|
static time_t thetime1, thetime2;
|
int i, nok, ntab, next;
|
int i, nok, ntab, next;
|
|
|
/* Initialize globals variables */
|
/* Initialize globals variables */
|
initglob();
|
initglob();
|
|
|
NFPRINTF(OUTPUT, "Setting catalog parameters");
|
NFPRINTF(OUTPUT, "Setting catalog parameters");
|
readcatparams(prefs.param_name);
|
readcatparams(prefs.param_name);
|
useprefs(); /* update things accor. to prefs parameters */
|
useprefs(); /* update things accor. to prefs parameters */
|
|
|
if (prefs.psf_flag)
|
if (prefs.psf_flag)
|
{
|
{
|
NFPRINTF(OUTPUT, "Reading PSF information");
|
NFPRINTF(OUTPUT, "Reading PSF information");
|
thepsf = psf_load(prefs.psf_name[0]);
|
thepsf = psf_load(prefs.psf_name[0]);
|
if (prefs.dpsf_flag)
|
if (prefs.dpsf_flag)
|
ppsf = psf_load(prefs.psf_name[1]);
|
ppsf = psf_load(prefs.psf_name[1]);
|
/*-- Need to check things up because of PSF context parameters */
|
/*-- Need to check things up because of PSF context parameters */
|
updateparamflags();
|
updateparamflags();
|
useprefs();
|
useprefs();
|
}
|
}
|
|
|
if (prefs.filter_flag)
|
if (prefs.filter_flag)
|
{
|
{
|
NFPRINTF(OUTPUT, "Reading detection filter");
|
NFPRINTF(OUTPUT, "Reading detection filter");
|
getfilter(prefs.filter_name); /* get the detection filter */
|
getfilter(prefs.filter_name); /* get the detection filter */
|
}
|
}
|
|
|
if (FLAG(obj2.sprob))
|
if (FLAG(obj2.sprob))
|
{
|
{
|
NFPRINTF(OUTPUT, "Initializing Neural Network");
|
NFPRINTF(OUTPUT, "Initializing Neural Network");
|
neurinit();
|
neurinit();
|
NFPRINTF(OUTPUT, "Reading Neural Network Weights");
|
NFPRINTF(OUTPUT, "Reading Neural Network Weights");
|
getnnw();
|
getnnw();
|
}
|
}
|
|
|
if (prefs.somfit_flag)
|
if (prefs.somfit_flag)
|
{
|
{
|
int margin;
|
int margin;
|
|
|
thesom = som_load(prefs.som_name);
|
thesom = som_load(prefs.som_name);
|
if ((margin=(thesom->inputsize[1]+1)/2) > prefs.cleanmargin)
|
if ((margin=(thesom->inputsize[1]+1)/2) > prefs.cleanmargin)
|
prefs.cleanmargin = margin;
|
prefs.cleanmargin = margin;
|
if (prefs.somfit_vectorsize>thesom->neurdim)
|
if (prefs.somfit_vectorsize>thesom->neurdim)
|
{
|
{
|
prefs.somfit_vectorsize = thesom->neurdim;
|
prefs.somfit_vectorsize = thesom->neurdim;
|
sprintf(gstr,"%d", prefs.somfit_vectorsize);
|
sprintf(gstr,"%d", prefs.somfit_vectorsize);
|
warning("Dimensionality of the SOM-fit vector limited to ", gstr);
|
warning("Dimensionality of the SOM-fit vector limited to ", gstr);
|
}
|
}
|
}
|
}
|
|
|
/* Prepare growth-curve buffer */
|
/* Prepare growth-curve buffer */
|
if (prefs.growth_flag)
|
if (prefs.growth_flag)
|
initgrowth();
|
initgrowth();
|
|
|
/* Compute the number of valid input extensions */
|
/* Compute the number of valid input extensions */
|
if (!(imacat = read_cat(prefs.image_name[0])))
|
if (!(imacat = read_cat(prefs.image_name[0])))
|
error(EXIT_FAILURE, "*Error*: cannot open ", prefs.image_name[0]);
|
error(EXIT_FAILURE, "*Error*: cannot open ", prefs.image_name[0]);
|
close_cat(imacat);
|
close_cat(imacat);
|
imatab = imacat->tab;
|
imatab = imacat->tab;
|
next = 0;
|
next = 0;
|
for (ntab = 0 ; ntab<imacat->ntab; ntab++, imatab = imatab->nexttab)
|
for (ntab = 0 ; ntab<imacat->ntab; ntab++, imatab = imatab->nexttab)
|
{
|
{
|
/*-- Check for the next valid image extension */
|
/*-- Check for the next valid image extension */
|
if ((imatab->naxis < 2)
|
if ((imatab->naxis < 2)
|
|| !strncmp(imatab->xtension, "BINTABLE", 8)
|
|| !strncmp(imatab->xtension, "BINTABLE", 8)
|
|| !strncmp(imatab->xtension, "ASCTABLE", 8))
|
|| !strncmp(imatab->xtension, "ASCTABLE", 8))
|
continue;
|
continue;
|
next++;
|
next++;
|
}
|
}
|
thecat.next = next;
|
thecat.next = next;
|
|
|
/*-- Init the CHECK-images */
|
/*-- Init the CHECK-images */
|
if (prefs.check_flag)
|
if (prefs.check_flag)
|
{
|
{
|
checkenum c;
|
checkenum c;
|
|
|
NFPRINTF(OUTPUT, "Initializing check-image(s)");
|
NFPRINTF(OUTPUT, "Initializing check-image(s)");
|
for (i=0; i<prefs.ncheck_type; i++)
|
for (i=0; i<prefs.ncheck_type; i++)
|
if ((c=prefs.check_type[i]) != CHECK_NONE)
|
if ((c=prefs.check_type[i]) != CHECK_NONE)
|
{
|
{
|
if (prefs.check[c])
|
if (prefs.check[c])
|
error(EXIT_FAILURE,"*Error*: 2 CHECK_IMAGEs cannot have the same ",
|
error(EXIT_FAILURE,"*Error*: 2 CHECK_IMAGEs cannot have the same ",
|
" CHECK_IMAGE_TYPE");
|
" CHECK_IMAGE_TYPE");
|
prefs.check[c] = initcheck(prefs.check_name[i], prefs.check_type[i],
|
prefs.check[c] = initcheck(prefs.check_name[i], prefs.check_type[i],
|
next);
|
next);
|
free(prefs.check_name[i]);
|
free(prefs.check_name[i]);
|
}
|
}
|
}
|
}
|
|
|
NFPRINTF(OUTPUT, "Initializing catalog");
|
NFPRINTF(OUTPUT, "Initializing catalog");
|
initcat();
|
initcat();
|
|
|
|
|
/* Go through all images */
|
/* Go through all images */
|
nok = -1;
|
nok = -1;
|
for (ntab = 0 ; ntab<imacat->ntab; ntab++, imatab = imatab->nexttab)
|
for (ntab = 0 ; ntab<imacat->ntab; ntab++, imatab = imatab->nexttab)
|
{
|
{
|
/*-- Check for the next valid image extension */
|
/*-- Check for the next valid image extension */
|
if ((imatab->naxis < 2)
|
if ((imatab->naxis < 2)
|
|| !strncmp(imatab->xtension, "BINTABLE", 8)
|
|| !strncmp(imatab->xtension, "BINTABLE", 8)
|
|| !strncmp(imatab->xtension, "ASCTABLE", 8))
|
|| !strncmp(imatab->xtension, "ASCTABLE", 8))
|
continue;
|
continue;
|
nok++;
|
nok++;
|
|
|
/*-- Initial time measurement*/
|
/*-- Initial time measurement*/
|
time(&thetime1);
|
time(&thetime1);
|
thecat.currext = nok+1;
|
thecat.currext = nok+1;
|
|
|
dfield = field = wfield = dwfield = NULL;
|
dfield = field = wfield = dwfield = NULL;
|
|
|
if (prefs.dimage_flag)
|
if (prefs.dimage_flag)
|
{
|
{
|
/*---- Init the Detection and Measurement-images */
|
/*---- Init the Detection and Measurement-images */
|
dfield = newfield(prefs.image_name[0], DETECT_FIELD, nok);
|
dfield = newfield(prefs.image_name[0], DETECT_FIELD, nok);
|
field = newfield(prefs.image_name[1], MEASURE_FIELD, nok);
|
field = newfield(prefs.image_name[1], MEASURE_FIELD, nok);
|
if ((field->width!=dfield->width) || (field->height!=dfield->height))
|
if ((field->width!=dfield->width) || (field->height!=dfield->height))
|
error(EXIT_FAILURE, "*Error*: Frames have different sizes","");
|
error(EXIT_FAILURE, "*Error*: Frames have different sizes","");
|
/*---- Prepare interpolation */
|
/*---- Prepare interpolation */
|
if (prefs.dweight_flag && prefs.interp_type[0] == INTERP_ALL)
|
if (prefs.dweight_flag && prefs.interp_type[0] == INTERP_ALL)
|
init_interpolate(dfield, -1, -1);
|
init_interpolate(dfield, -1, -1);
|
if (prefs.interp_type[1] == INTERP_ALL)
|
if (prefs.interp_type[1] == INTERP_ALL)
|
init_interpolate(field, -1, -1);
|
init_interpolate(field, -1, -1);
|
}
|
}
|
else
|
else
|
{
|
{
|
field = newfield(prefs.image_name[0], DETECT_FIELD | MEASURE_FIELD, nok);
|
field = newfield(prefs.image_name[0], DETECT_FIELD | MEASURE_FIELD, nok);
|
/*-- Prepare interpolation */
|
/*-- Prepare interpolation */
|
if ((prefs.dweight_flag || prefs.weight_flag)
|
if ((prefs.dweight_flag || prefs.weight_flag)
|
&& prefs.interp_type[0] == INTERP_ALL)
|
&& prefs.interp_type[0] == INTERP_ALL)
|
init_interpolate(field, -1, -1); /* 0.0 or anything else */
|
init_interpolate(field, -1, -1); /* 0.0 or anything else */
|
}
|
}
|
|
|
/*-- Init the WEIGHT-images */
|
/*-- Init the WEIGHT-images */
|
if (prefs.dweight_flag || prefs.weight_flag)
|
if (prefs.dweight_flag || prefs.weight_flag)
|
{
|
{
|
weightenum wtype;
|
weightenum wtype;
|
PIXTYPE interpthresh;
|
PIXTYPE interpthresh;
|
|
|
if (prefs.nweight_type>1)
|
if (prefs.nweight_type>1)
|
{
|
{
|
/*------ Double-weight-map mode */
|
/*------ Double-weight-map mode */
|
if (prefs.weight_type[1] != WEIGHT_NONE)
|
if (prefs.weight_type[1] != WEIGHT_NONE)
|
{
|
{
|
/*-------- First: the "measurement" weights */
|
/*-------- First: the "measurement" weights */
|
wfield = newweight(prefs.wimage_name[1],field,prefs.weight_type[1],
|
wfield = newweight(prefs.wimage_name[1],field,prefs.weight_type[1],
|
nok);
|
nok);
|
wtype = prefs.weight_type[1];
|
wtype = prefs.weight_type[1];
|
interpthresh = prefs.weight_thresh[1];
|
interpthresh = prefs.weight_thresh[1];
|
/*-------- Convert the interpolation threshold to variance units */
|
/*-------- Convert the interpolation threshold to variance units */
|
weight_to_var(wfield, &interpthresh, 1);
|
weight_to_var(wfield, &interpthresh, 1);
|
wfield->weight_thresh = interpthresh;
|
wfield->weight_thresh = interpthresh;
|
if (prefs.interp_type[1] != INTERP_NONE)
|
if (prefs.interp_type[1] != INTERP_NONE)
|
init_interpolate(wfield,
|
init_interpolate(wfield,
|
prefs.interp_xtimeout[1], prefs.interp_ytimeout[1]);
|
prefs.interp_xtimeout[1], prefs.interp_ytimeout[1]);
|
}
|
}
|
/*------ The "detection" weights */
|
/*------ The "detection" weights */
|
if (prefs.weight_type[0] != WEIGHT_NONE)
|
if (prefs.weight_type[0] != WEIGHT_NONE)
|
{
|
{
|
interpthresh = prefs.weight_thresh[0];
|
interpthresh = prefs.weight_thresh[0];
|
if (prefs.weight_type[0] == WEIGHT_FROMINTERP)
|
if (prefs.weight_type[0] == WEIGHT_FROMINTERP)
|
{
|
{
|
dwfield=newweight(prefs.wimage_name[0],wfield,prefs.weight_type[0],
|
dwfield=newweight(prefs.wimage_name[0],wfield,prefs.weight_type[0],
|
nok);
|
nok);
|
weight_to_var(wfield, &interpthresh, 1);
|
weight_to_var(wfield, &interpthresh, 1);
|
}
|
}
|
else
|
else
|
{
|
{
|
dwfield = newweight(prefs.wimage_name[0], dfield?dfield:field,
|
dwfield = newweight(prefs.wimage_name[0], dfield?dfield:field,
|
prefs.weight_type[0], nok);
|
prefs.weight_type[0], nok);
|
weight_to_var(dwfield, &interpthresh, 1);
|
weight_to_var(dwfield, &interpthresh, 1);
|
}
|
}
|
dwfield->weight_thresh = interpthresh;
|
dwfield->weight_thresh = interpthresh;
|
if (prefs.interp_type[0] != INTERP_NONE)
|
if (prefs.interp_type[0] != INTERP_NONE)
|
init_interpolate(dwfield,
|
init_interpolate(dwfield,
|
prefs.interp_xtimeout[0], prefs.interp_ytimeout[0]);
|
prefs.interp_xtimeout[0], prefs.interp_ytimeout[0]);
|
}
|
}
|
}
|
}
|
else
|
else
|
{
|
{
|
/*------ Single-weight-map mode */
|
/*------ Single-weight-map mode */
|
wfield = newweight(prefs.wimage_name[0], dfield?dfield:field,
|
wfield = newweight(prefs.wimage_name[0], dfield?dfield:field,
|
prefs.weight_type[0], nok);
|
prefs.weight_type[0], nok);
|
wtype = prefs.weight_type[0];
|
wtype = prefs.weight_type[0];
|
interpthresh = prefs.weight_thresh[0];
|
interpthresh = prefs.weight_thresh[0];
|
/*------ Convert the interpolation threshold to variance units */
|
/*------ Convert the interpolation threshold to variance units */
|
weight_to_var(wfield, &interpthresh, 1);
|
weight_to_var(wfield, &interpthresh, 1);
|
wfield->weight_thresh = interpthresh;
|
wfield->weight_thresh = interpthresh;
|
if (prefs.interp_type[0] != INTERP_NONE)
|
if (prefs.interp_type[0] != INTERP_NONE)
|
init_interpolate(wfield,
|
init_interpolate(wfield,
|
prefs.interp_xtimeout[0], prefs.interp_ytimeout[0]);
|
prefs.interp_xtimeout[0], prefs.interp_ytimeout[0]);
|
}
|
}
|
}
|
}
|
|
|
/*-- Init the FLAG-images */
|
/*-- Init the FLAG-images */
|
for (i=0; i<prefs.nimaflag; i++)
|
for (i=0; i<prefs.nimaflag; i++)
|
{
|
{
|
pffield[i] = newfield(prefs.fimage_name[i], FLAG_FIELD, nok);
|
pffield[i] = newfield(prefs.fimage_name[i], FLAG_FIELD, nok);
|
if ((pffield[i]->width!=field->width)
|
if ((pffield[i]->width!=field->width)
|
|| (pffield[i]->height!=field->height))
|
|| (pffield[i]->height!=field->height))
|
error(EXIT_FAILURE,
|
error(EXIT_FAILURE,
|
"*Error*: Incompatible FLAG-map size in ", prefs.fimage_name[i]);
|
"*Error*: Incompatible FLAG-map size in ", prefs.fimage_name[i]);
|
}
|
}
|
|
|
/*-- Compute background maps for `standard' fields */
|
/*-- Compute background maps for `standard' fields */
|
QPRINTF(OUTPUT, dfield? "Measurement image:"
|
QPRINTF(OUTPUT, dfield? "Measurement image:"
|
: "Detection+Measurement image: ");
|
: "Detection+Measurement image: ");
|
makeback(field, wfield);
|
makeback(field, wfield);
|
QPRINTF(OUTPUT, (dfield || (dwfield&&dwfield->flags^INTERP_FIELD))? "(M) "
|
QPRINTF(OUTPUT, (dfield || (dwfield&&dwfield->flags^INTERP_FIELD))? "(M) "
|
"Background: %-10g RMS: %-10g / Threshold: %-10g \n"
|
"Background: %-10g RMS: %-10g / Threshold: %-10g \n"
|
: "(M+D) "
|
: "(M+D) "
|
"Background: %-10g RMS: %-10g / Threshold: %-10g \n",
|
"Background: %-10g RMS: %-10g / Threshold: %-10g \n",
|
field->backmean, field->backsig, (field->flags & DETECT_FIELD)?
|
field->backmean, field->backsig, (field->flags & DETECT_FIELD)?
|
field->dthresh: field->thresh);
|
field->dthresh: field->thresh);
|
if (dfield)
|
if (dfield)
|
{
|
{
|
QPRINTF(OUTPUT, "Detection image: ");
|
QPRINTF(OUTPUT, "Detection image: ");
|
makeback(dfield, dwfield? dwfield
|
makeback(dfield, dwfield? dwfield
|
: (prefs.weight_type[0] == WEIGHT_NONE?NULL:wfield));
|
: (prefs.weight_type[0] == WEIGHT_NONE?NULL:wfield));
|
QPRINTF(OUTPUT, "(D) "
|
QPRINTF(OUTPUT, "(D) "
|
"Background: %-10g RMS: %-10g / Threshold: %-10g \n",
|
"Background: %-10g RMS: %-10g / Threshold: %-10g \n",
|
dfield->backmean, dfield->backsig, dfield->dthresh);
|
dfield->backmean, dfield->backsig, dfield->dthresh);
|
}
|
}
|
else if (dwfield && dwfield->flags^INTERP_FIELD)
|
else if (dwfield && dwfield->flags^INTERP_FIELD)
|
{
|
{
|
makeback(field, dwfield);
|
makeback(field, dwfield);
|
QPRINTF(OUTPUT, "(D) "
|
QPRINTF(OUTPUT, "(D) "
|
"Background: %-10g RMS: %-10g / Threshold: %-10g \n",
|
"Background: %-10g RMS: %-10g / Threshold: %-10g \n",
|
field->backmean, field->backsig, field->dthresh);
|
field->backmean, field->backsig, field->dthresh);
|
}
|
}
|
|
|
/*-- For interpolated weight-maps, copy the background structure */
|
/*-- For interpolated weight-maps, copy the background structure */
|
if (dwfield && dwfield->flags&(INTERP_FIELD|BACKRMS_FIELD))
|
if (dwfield && dwfield->flags&(INTERP_FIELD|BACKRMS_FIELD))
|
copyback(dwfield->reffield, dwfield);
|
copyback(dwfield->reffield, dwfield);
|
if (wfield && wfield->flags&(INTERP_FIELD|BACKRMS_FIELD))
|
if (wfield && wfield->flags&(INTERP_FIELD|BACKRMS_FIELD))
|
copyback(wfield->reffield, wfield);
|
copyback(wfield->reffield, wfield);
|
|
|
/*-- Prepare learn and/or associations */
|
/*-- Prepare learn and/or associations */
|
if (prefs.assoc_flag)
|
if (prefs.assoc_flag)
|
init_assoc(field); /* initialize assoc tasks */
|
init_assoc(field); /* initialize assoc tasks */
|
|
|
/*-- Update the CHECK-images */
|
/*-- Update the CHECK-images */
|
if (prefs.check_flag)
|
if (prefs.check_flag)
|
for (i=0; i<MAXCHECK; i++)
|
for (i=0; i<MAXCHECK; i++)
|
if ((check=prefs.check[i]))
|
if ((check=prefs.check[i]))
|
reinitcheck(field, check);
|
reinitcheck(field, check);
|
|
|
/*-- Initialize PSF contexts and workspace */
|
/*-- Initialize PSF contexts and workspace */
|
if (prefs.psf_flag)
|
if (prefs.psf_flag)
|
{
|
{
|
psf_readcontext(thepsf, field);
|
psf_readcontext(thepsf, field);
|
psf_init(thepsf);
|
psf_init(thepsf);
|
if (prefs.dpsf_flag)
|
if (prefs.dpsf_flag)
|
{
|
{
|
psf_readcontext(thepsf, dfield);
|
psf_readcontext(thepsf, dfield);
|
psf_init(thepsf); /*?*/
|
psf_init(thepsf); /*?*/
|
}
|
}
|
}
|
}
|
|
|
/*-- Copy field structures to static ones (for catalog info) */
|
/*-- Copy field structures to static ones (for catalog info) */
|
if (dfield)
|
if (dfield)
|
{
|
{
|
thefield1 = *field;
|
thefield1 = *field;
|
thefield2 = *dfield;
|
thefield2 = *dfield;
|
}
|
}
|
else
|
else
|
thefield1 = thefield2 = *field;
|
thefield1 = thefield2 = *field;
|
|
|
if (wfield)
|
if (wfield)
|
{
|
{
|
thewfield1 = *wfield;
|
thewfield1 = *wfield;
|
thewfield2 = dwfield? *dwfield: *wfield;
|
thewfield2 = dwfield? *dwfield: *wfield;
|
}
|
}
|
else if (dwfield)
|
else if (dwfield)
|
thewfield2 = *dwfield;
|
thewfield2 = *dwfield;
|
|
|
reinitcat(field);
|
reinitcat(field);
|
|
|
/*-- Start the extraction pipeline */
|
/*-- Start the extraction pipeline */
|
NFPRINTF(OUTPUT, "Scanning image");
|
NFPRINTF(OUTPUT, "Scanning image");
|
scanimage(field, dfield, pffield, prefs.nimaflag, wfield, dwfield);
|
scanimage(field, dfield, pffield, prefs.nimaflag, wfield, dwfield);
|
|
|
/*-- Finish the current CHECK-image processing */
|
/*-- Finish the current CHECK-image processing */
|
if (prefs.check_flag)
|
if (prefs.check_flag)
|
for (i=0; i<MAXCHECK; i++)
|
for (i=0; i<MAXCHECK; i++)
|
if ((check=prefs.check[i]))
|
if ((check=prefs.check[i]))
|
reendcheck(field, check);
|
reendcheck(field, check);
|
|
|
/*-- Final time measurements*/
|
/*-- Final time measurements*/
|
if (time(&thetime2)!=-1)
|
if (time(&thetime2)!=-1)
|
{
|
{
|
if (!strftime(thecat.ext_date, 12, "%d/%m/%Y", localtime(&thetime2)))
|
if (!strftime(thecat.ext_date, 12, "%d/%m/%Y", localtime(&thetime2)))
|
error(EXIT_FAILURE, "*Internal Error*: Date string too long ","");
|
error(EXIT_FAILURE, "*Internal Error*: Date string too long ","");
|
if (!strftime(thecat.ext_time, 10, "%H:%M:%S", localtime(&thetime2)))
|
if (!strftime(thecat.ext_time, 10, "%H:%M:%S", localtime(&thetime2)))
|
error(EXIT_FAILURE, "*Internal Error*: Time/date string too long ","");
|
error(EXIT_FAILURE, "*Internal Error*: Time/date string too long ","");
|
thecat.ext_elapsed = difftime(thetime2, thetime1);
|
thecat.ext_elapsed = difftime(thetime2, thetime1);
|
}
|
}
|
|
|
reendcat();
|
reendcat();
|
|
|
/*-- Close ASSOC routines */
|
/*-- Close ASSOC routines */
|
end_assoc(field);
|
end_assoc(field);
|
|
|
for (i=0; i<prefs.nimaflag; i++)
|
for (i=0; i<prefs.nimaflag; i++)
|
endfield(pffield[i]);
|
endfield(pffield[i]);
|
endfield(field);
|
endfield(field);
|
if (dfield)
|
if (dfield)
|
endfield(dfield);
|
endfield(dfield);
|
if (wfield)
|
if (wfield)
|
endfield(wfield);
|
endfield(wfield);
|
if (dwfield)
|
if (dwfield)
|
endfield(dwfield);
|
endfield(dwfield);
|
|
|
QPRINTF(OUTPUT, "Objects: detected %-8d / sextracted %-8d\n",
|
QPRINTF(OUTPUT, "Objects: detected %-8d / sextracted %-8d \n",
|
thecat.ndetect, thecat.ntotal);
|
thecat.ndetect, thecat.ntotal);
|
}
|
}
|
|
|
if (nok<0)
|
if (nok<0)
|
error(EXIT_FAILURE, "Not enough valid FITS image extensions in ",
|
error(EXIT_FAILURE, "Not enough valid FITS image extensions in ",
|
prefs.image_name[0]);
|
prefs.image_name[0]);
|
free_cat(&imacat, 1);
|
free_cat(&imacat, 1);
|
|
|
NFPRINTF(OUTPUT, "Closing files");
|
NFPRINTF(OUTPUT, "Closing files");
|
|
|
endcat();
|
endcat();
|
|
|
/* End CHECK-image processing */
|
/* End CHECK-image processing */
|
if (prefs.check_flag)
|
if (prefs.check_flag)
|
for (i=0; i<MAXCHECK; i++)
|
for (i=0; i<MAXCHECK; i++)
|
{
|
{
|
if ((check=prefs.check[i]))
|
if ((check=prefs.check[i]))
|
endcheck(check);
|
endcheck(check);
|
prefs.check[i] = NULL;
|
prefs.check[i] = NULL;
|
}
|
}
|
|
|
if (prefs.filter_flag)
|
if (prefs.filter_flag)
|
endfilter();
|
endfilter();
|
|
|
if (prefs.somfit_flag)
|
if (prefs.somfit_flag)
|
som_end(thesom);
|
som_end(thesom);
|
|
|
if (prefs.growth_flag)
|
if (prefs.growth_flag)
|
endgrowth();
|
endgrowth();
|
|
|
if (prefs.psf_flag)
|
if (prefs.psf_flag)
|
psf_end(thepsf,thepsfit); /*?*/
|
psf_end(thepsf,thepsfit); /*?*/
|
|
|
if (prefs.dpsf_flag)
|
if (prefs.dpsf_flag)
|
psf_end(ppsf,ppsfit);
|
psf_end(ppsf,ppsfit);
|
|
|
if (FLAG(obj2.sprob))
|
if (FLAG(obj2.sprob))
|
neurclose();
|
neurclose();
|
|
|
return;
|
return;
|
}
|
}
|
|
|
|
|
/******************************** initglob ***********************************/
|
/******************************** initglob ***********************************/
|
/*
|
/*
|
Initialize a few global variables
|
Initialize a few global variables
|
*/
|
*/
|
void initglob()
|
void initglob()
|
{
|
{
|
int i;
|
int i;
|
|
|
for (i=0; i<37; i++)
|
for (i=0; i<37; i++)
|
{
|
{
|
ctg[i] = cos(i*PI/18);
|
ctg[i] = cos(i*PI/18);
|
stg[i] = sin(i*PI/18);
|
stg[i] = sin(i*PI/18);
|
}
|
}
|
|
|
|
|
return;
|
return;
|
}
|
}
|
|
|
/*
|
/*
|
int matherr(struct exception *x)
|
int matherr(struct exception *x)
|
{
|
{
|
printf("***MATH ERROR***: %d %s %f %f\n",
|
printf("***MATH ERROR***: %d %s %f %f\n",
|
x->type, x->name, x->arg1, x->retval);
|
x->type, x->name, x->arg1, x->retval);
|
return (0);
|
return (0);
|
}
|
}
|
|
|
*/
|
*/
|
|
|