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
|
include <mach.h>
include "../lib/noise.h"
# APCOPMAGS -- Procedure to compute the magnitudes from the aperture sums,
# areas and sky values.
procedure apcopmags (sums, areas, mags, magerrs, naperts, sky, sigma, nsky,
zmag, noise, padu)
double sums[ARB] # aperture sums
double areas[ARB] # aperture areas
real mags[ARB] # output magnitudes
real magerrs[ARB] # errors in the magnitudes
int naperts # number of apertures
real sky # sky value
real sigma # sigma of the sky values
int nsky # number of sky pixels
real zmag # sky value, sigma and zero point magnitudes
int noise # noise model
real padu # photons per adu
int i
real err1, err2, err3, err
begin
# Compute the magnitudes and errors
do i = 1, naperts {
mags[i] = sums[i] - areas[i] * sky
if (mags[i] <= 0.0)
mags[i] = INDEFR
else {
if (IS_INDEFR(sigma))
err1 = 0.0
else
err1 = areas[i] * sigma ** 2
switch (noise) {
case AP_NCONSTANT:
err2 = 0.0
case AP_NPOISSON:
err2 = mags[i] / padu
default:
err2 = 0.0
}
if (nsky <= 0)
err3 = 0.0
else if (IS_INDEFR(sigma))
err3 = 0.0
else
err3 = sigma ** 2 * areas[i] ** 2 / nsky
err = err1 + err2 + err3
if (err <= 0.0)
magerrs[i] = 0.0
else {
magerrs[i] = 1.0857 * sqrt (err) / mags[i]
}
mags[i] = zmag - 2.5 * log10 (mags[i])
}
}
end
# APCONMAGS -- Procedure to compute the magnitudes from the aperture sums,
# areas and sky values.
procedure apconmags (sums, areas, mags, magerrs, naperts, sky, sigma, nsky,
zmag, noise, padu, readnoise)
double sums[ARB] # aperture sums
double areas[ARB] # aperture areas
real mags[ARB] # output magnitudes
real magerrs[ARB] # errors in the magnitudes
int naperts # number of apertures
real sky # sky value
real readnoise # readout noise in electrons
real sigma # sigma of the sky values
int nsky # number of sky pixels
real zmag # sky value, sigma and zero point magnitudes
int noise # noise model
real padu # photons per adu
int i
real err1, err2, err3, err
begin
# Compute the magnitudes and errors
do i = 1, naperts {
mags[i] = areas[i] * sky - sums[i]
if (mags[i] <= 0.0)
mags[i] = INDEFR
else {
if (IS_INDEFR(readnoise))
err1 = 0.0
else
err1 = areas[i] * (readnoise / padu) ** 2
switch (noise) {
case AP_NCONSTANT:
err2 = 0.0
case AP_NPOISSON:
err2 = abs (sums[i]) / padu
default:
err2 = 0.0
}
if (nsky <= 0)
err3 = 0.0
else if (IS_INDEFR(sigma))
err3 = 0.0
else
err3 = sigma ** 2 * areas[i] ** 2 / nsky
err = err1 + err2 + err3
if (err <= 0.0)
magerrs[i] = 0.0
else {
magerrs[i] = 1.0857 * sqrt (err) / abs (sums[i])
}
mags[i] = zmag - 2.5 * log10 (mags[i])
}
}
end
|