-
Notifications
You must be signed in to change notification settings - Fork 1
/
stdotpt.c
executable file
·162 lines (147 loc) · 5.6 KB
/
stdotpt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include <stdio.h>
#include <math.h>
#include "tuneable.h"
#include "estuff_struct.h"
#include "eoff_struct.h"
#include "string.h"
#include "cast_arr.h"
#include "ellipse.h"
#include "outputs.h"
/* dophot subroutine converted to c void function 02-06-2012 */
char* stdotpt_(int* I_ptr, int* ITYPE_ptr, float* STPARR, int* NPARR_ptr, float* APPARR, int* lNAPPLE_ptr, float* PROBG_ptr, int which_model)
{
/* dereference the pointers */
int I = *I_ptr;
int ITYPE = *ITYPE_ptr;
int lNAPPLE = *lNAPPLE_ptr;
float PROBG = *PROBG_ptr;
/* renaming used common block variables */
char** flags = tune16_.flags;
float XFRAC = eoff_.xfrac;
float YFRAC = eoff_.yfrac;
short int* EMSUB = estuff_.emsub;
float* EMERR = estuff_.emerr;
float** EMPAR = estuff_.empar;
/* substace of subroutine begins here */
/* Get image shape and area and calc. Fit magnitude: */
static char OUTSTRING[300];
float AREA, AMAJOR, AMINOR, TILT;
float FMAG;
float APMAG, APERUNC;
float XC, YC;
float t1, t2, t3, t4;
if (ITYPE != 8){
ellipse_(STPARR+4, STPARR+5, STPARR+6,
&AREA, &AMAJOR, &AMINOR, &TILT);
FMAG = AREA*STPARR[1];
if (FMAG <= 0.0f){
FMAG = 99.999f;
}
else{
FMAG = -2.5f*log10f(FMAG);
}
TILT = 57.29578f*TILT;
}
else{
if (STPARR[5] == -1.0f){
FMAG = 99.999f;
}
else{
FMAG = -99.999f;
}
AMAJOR = STPARR[4];
AMINOR = STPARR[6];
TILT = STPARR[5];
// if (STPARR[4] >= STPARR[6]){
// AMAJOR = STPARR[4];
// AMINOR = STPARR[6];
// TILT = 0.0f;
// }
// else{
// AMAJOR = STPARR[6];
// AMINOR = STPARR[4];
// TILT = 90.0f;
// }
}
/* Convert aperture flux to magnitudes: */
if (APPARR[0] <= 0.0f){
APMAG = 99.999f;
}
else{
APMAG = -2.5f*log10f(APPARR[0]);
}
/* If available, get uncertainty in aperture magnitudes: */
APERUNC = 99.999f;
if (lNAPPLE >= 5){
APERUNC = APPARR[4];
}
/* Fix the co-ordinates so that the center of the first pixel is
0.5 and not 1.0 as in the internal representation */
XC = STPARR[2] - 0.5f;
YC = STPARR[3] - 0.5f;
/* process the empirical fit data: */
I = I-1;
if ((int)(EMSUB[I]) != 0){
t1 = EMPAR[I][0];
t2 = EMPAR[I][1]*10000.0f*AREA;
if (t2 <= 0.0f){
t2 = 99.999f;
}
else{
t2 = -2.5*log10f(t2);
}
t3 = EMPAR[I][2] + XFRAC - 0.5f;
t4 = EMPAR[I][3] + YFRAC - 0.5f;
}
else{
t1 = EMPAR[I][0];
t2 = -99.999f;
t3 = EMPAR[I][2];
t4 = EMPAR[I][3];
}
if ((strncmp(flags[0], "PGAUSS", 5) == 0) ||
(strncmp(flags[0], "GAUSS", 5) == 0)) {
sprintf(OUTSTRING," %4d %2d %8.2f %8.2f %8.3f %6.3f %9.2f %9.3f %9.3f %7.2f %10.2E %8.3f %6.3f %9.2f %7.3f %9.2f %8.3f %8.2f %8.2f %6.3f \n",
I+1, ITYPE, XC, YC, FMAG,
APPARR[3], STPARR[0], AMAJOR, AMINOR, TILT, PROBG,
APMAG, APERUNC, APPARR[1], APPARR[2], t1, t2, t3, t4, EMERR[I]);
/* Order is: No., obtype, xpos, ypos, fitmag,
err_fitmag, fitsky, FWHM_major, FWHM_minor, Tilt, probgal,
apmag, err_apmag, apsky, diff_fit_ap */
}
if ((strncmp(flags[0], "PGALTMODEL", 5) == 0) ||
(strncmp(flags[0], "GALTMODEL", 5) == 0)) {
sprintf(OUTSTRING," %4d %2d %8.2f %8.2f %8.3f %6.3f %9.2f %9.3f %9.3f %7.2f %10.3E %10.3E %10.3E %10.3E %2d %10.2E %8.3f %6.3f %9.2f %7.3f %9.2f %8.3f %8.2f %8.2f %6.3f \n",
I+1, ITYPE, XC, YC, FMAG,
APPARR[3], STPARR[0], AMAJOR, AMINOR, TILT,
STPARR[7], STPARR[8], STPARR[9], STPARR[10], which_model, PROBG,
APMAG, APERUNC, APPARR[1], APPARR[2], t1, t2, t3, t4, EMERR[I]);
/* Order is: No., obtype, xpos, ypos, fitmag,
err_fitmag, fitsky, FWHM_major, FWHM_minor, Tilt,
NEWI1, NEWI2, NEWI3, NEWI4, which_model, probgal,
apmag, err_apmag, apsky, diff_fit_ap */
}
if (strncmp(flags[0], "SERSIC", 5) == 0){
sprintf(OUTSTRING," %4d %2d %8.2f %8.2f %8.3f %6.3f %9.2f %9.3f %9.3f %7.2f %6.2f %2d %10.2E %8.3f %6.3f %9.2f %7.3f %9.2f %8.3f %8.2f %8.2f %6.3f \n",
I+1, ITYPE, XC, YC, FMAG,
APPARR[3], STPARR[0], AMAJOR, AMINOR, TILT,
STPARR[7], which_model, PROBG,
APMAG, APERUNC, APPARR[1], APPARR[2], t1, t2, t3, t4, EMERR[I]);
/* Order is: No., obtype, xpos, ypos, fitmag,
err_fitmag, fitsky, FWHM_major, FWHM_minor, Tilt,
sersic index, which_model, probgal,
apmag, err_apmag, apsky, diff_fit_ap */
}
if (strncmp(flags[0], "EXTPGAUSS", 5) == 0){
sprintf(OUTSTRING," %4d %2d %8.2f %8.2f %8.3f %6.3f %9.2f %9.3f %9.3f %7.2f %6.2f %6.2f %2d %10.2E %8.3f %6.3f %9.2f %7.3f %9.2f %8.3f %8.2f %8.2f %6.3f \n",
I+1, ITYPE, XC, YC, FMAG,
APPARR[3], STPARR[0], AMAJOR, AMINOR, TILT,
STPARR[7], STPARR[8], which_model, PROBG,
APMAG, APERUNC, APPARR[1], APPARR[2], t1, t2, t3, t4, EMERR[I]);
/* Order is: No., obtype, xpos, ypos, fitmag,
err_fitmag, fitsky, FWHM_major, FWHM_minor, Tilt,
b4, which_model, probgal,
apmag, err_apmag, apsky, diff_fit_ap */
}
return OUTSTRING;
}