Newer
Older
* Functions related to catalogue output.
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Emmanuel Bertin
committed
* Copyright: (C) 1993-2013 Emmanuel Bertin -- IAP/CNRS/UPMC
*
* License: GNU General Public License
*
* SExtractor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* SExtractor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 12/09/2013
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "define.h"
#include "globals.h"
#include "prefs.h"
#include "fits/fitscat.h"
#include "param.h"
#include "sexhead.h"
#include "sexhead1.h"
#include "sexheadsc.h"
#include "xml.h"
catstruct *fitscat;
tabstruct *objtab = NULL;
FILE *ascfile;
char *buf;
int catopen_flag = 0;
/******************************* readcatparams *******************************/
/*
Read the catalog config file
*/
void readcatparams(char *filename)
{
keystruct *key;
FILE *infile;
char str[MAXCHAR], *keyword, *sstr;
int i, size;
/* Prepare the OBJECTS tables*/
objtab = new_tab("OBJECTS");
if ((infile = fopen(filename,"r")) == NULL)
error(EXIT_FAILURE, "*ERROR*: can't read ", filename);
/* Scan the catalog config file*/
thecat.nparam = 0;
while (fgets(str, MAXCHAR, infile))
{
sstr = str + strspn(str," \t");
if (*sstr!=(char)'#' && *sstr!=(char)'\n')
{
keyword = strtok(sstr, " \t{[(\n\r");
if (keyword &&
(i = findkey(keyword,(char *)objkey,sizeof(keystruct)))!=RETURN_ERROR)
{
key = objkey+i;
add_key(key, objtab, 0);
*((char *)key->ptr) = (char)'\1';
thecat.nparam++;
if (key->naxis)
{
for (i=0; i<key->naxis; i++)
key->naxisn[i] = 1;
size=t_size[key->ttype];
for (i=0; (sstr = strtok(NULL, " \t,;.)]}\r")) && *sstr!=(char)'#'
&& *sstr!=(char)'\n'; i++)
{
if (i>=key->naxis)
error(EXIT_FAILURE, "*Error*: too many dimensions for keyword ",
keyword);
if (!(size*=(key->naxisn[i]=atoi(sstr))))
error(EXIT_FAILURE, "*Error*: wrong array syntax for keyword ",
keyword);
}
key->nbytes = size;
}
}
else
warning(keyword, " catalog parameter unknown");
}
}
fclose(infile);
/* Now we copy the flags to the proper structures */
flagobj = outobj;
flagobj2 = outobj2;
/* Differentiate between outobj and outobj2 vectors */
memset(&outobj2, 0, sizeof(outobj2));
updateparamflags();
return;
}
/******************************* alloccatparams ******************************/
/*
Allocate memory for parameter arrays
*/
void alloccatparams(void)
{
keystruct *key;
int i;
/* Go back to multi-dimensional arrays for memory allocation */
if (thecat.nparam)
for (i=objtab->nkey, key=objtab->key; i--; key = key->nextkey)
if (key->naxis)
{
/*------ Only outobj2 vectors are dynamic */
if (!*((char **)key->ptr))
{
QMALLOC(*((char **)key->ptr), char, key->nbytes);
key->ptr = *((char **)key->ptr);
key->allocflag = 1;
}
}
return;
}
/*************************** changecatparamarrays ****************************/
/*
Change parameter array dimensions
*/
void changecatparamarrays(char *keyword, int *axisn, int naxis)
{
keystruct *key;
int d,i, size;
if (thecat.nparam)
for (i=objtab->nkey, key=objtab->key; i--; key = key->nextkey)
if (key->naxis && !strcmp(keyword, key->name))
{
size = t_size[key->ttype];
if (key->naxis != naxis)
key->naxis = naxis;
for (d=0; d<naxis; d++)
size *= (key->naxisn[d]=axisn[d]);
key->nbytes = size;
break;
}
return;
}
/***************************** updateparamflags ******************************/
/*
Update parameter flags according to their mutual dependencies.
*/
void updateparamflags()
{
int i;
/*----------------------------- Model-fitting -----------------------------*/
prefs.pattern_flag |= FLAG(obj2.prof_disk_patternvector)
| FLAG(obj2.prof_disk_patternmodvector)
| FLAG(obj2.prof_disk_patternargvector)
| FLAG(obj2.prof_disk_patternspiral);
FLAG(obj2.prof_disk_scale) |= prefs.pattern_flag;
FLAG(obj2.prof_concentration) |= FLAG(obj2.prof_concentrationerr);
FLAG(obj2.fluxcorerr_prof) |= FLAG(obj2.magcorerr_prof);
FLAG(obj2.fluxcor_prof) |= FLAG(obj2.magcor_prof)
| FLAG(obj2.fluxcorerr_prof);
FLAG(obj2.poserraw_prof) |= FLAG(obj2.poserrbw_prof);
FLAG(obj2.poserrcxxw_prof) |= FLAG(obj2.poserrcyyw_prof)
| FLAG(obj2.poserrcxyw_prof);
FLAG(obj2.poserrthetas_prof) |= FLAG(obj2.poserrtheta1950_prof)
| FLAG(obj2.poserrtheta2000_prof);
Loading
Loading full blame…