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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
include <pkg/dttext.h>
include "starlist.h"
# ST_DTINIT -- Write the header to the database.
procedure st_dtinit (dt, st, starlist, sseed, lseed)
pointer dt # pointer to output database
pointer st # pointer to structure
char starlist[ARB] # name of output text file
long sseed # spatial function seed
long lseed # luminsosity function seed
begin
call dtptime (dt)
call dtput (dt, "# begin\t%s\n")
call pargstr (starlist)
# Write out the spatial density function parameters.
call dtput (dt, "#\tspatial\t\t%s\n")
switch (ST_SPATIAL(st)) {
case ST_UNIFORM:
call pargstr ("uniform")
case ST_HUBBLE:
call pargstr ("hubble")
call dtput (dt, "#\txcenter\t\t%g\n")
call pargr (ST_XC(st))
call dtput (dt, "#\tycenter\t\t%g\n")
call pargr (ST_YC(st))
call dtput (dt, "#\tcoreradius\t%g\n")
call pargr (ST_CORE(st))
call dtput (dt, "#\tbaseline\t%g\n")
call pargr (ST_BASE(st))
case ST_SPFILE:
call pargstr (ST_SFILE(st))
call dtput (dt, "#\txcenter\t\t%g\n")
call pargr (ST_XC(st))
call dtput (dt, "#\tycenter\t\t%g\n")
call pargr (ST_YC(st))
}
call dtput (dt, "#\txmin\t\t%g\n")
call pargr (ST_XMIN(st))
call dtput (dt, "#\txmax\t\t%g\n")
call pargr (ST_XMAX(st))
call dtput (dt, "#\tymin\t\t%g\n")
call pargr (ST_YMIN(st))
call dtput (dt, "#\tymax\t\t%g\n")
call pargr (ST_YMAX(st))
# Write out the luminsosity function parameters.
call dtput (dt, "#\tluminosity\t%s\n")
switch (ST_LUMINOSITY(st)) {
case ST_UNIFORM:
call pargstr ("uniform")
case ST_POWLAW:
call pargstr ("powlaw")
call dtput (dt, "#\tpower\t\t%g\n")
call pargr (ST_POWER(st))
case ST_SALPETER:
call pargstr ("salpeter")
call dtput (dt, "#\tmzero\t\t%g\n")
call pargr (ST_MZERO(st))
case ST_BANDS:
call pargstr ("bands")
call dtput (dt, "#\tmzero\t\t%g\n")
call pargr (ST_MZERO(st))
call dtput (dt, "#\talpha\t\t%g\n")
call pargr (ST_ALPHA(st))
call dtput (dt, "#\tbeta\t\t%g\n")
call pargr (ST_BETA(st))
call dtput (dt, "#\tdelta\t\t%g\n")
call pargr (ST_DELTA(st))
call dtput (dt, "#\tmstar\t\t%g\n")
call pargr (ST_MSTAR(st))
case ST_LFFILE:
call pargstr (ST_LFILE(st))
}
call dtput (dt, "#\tminmag\t\t%g\n")
call pargr (ST_MINMAG(st))
call dtput (dt, "#\tmaxmag\t\t%g\n")
call pargr (ST_MAXMAG(st))
# Save the spatial density function fitting parameters.
call dtput (dt, "#\tnssample\t%d\n")
call pargi (ST_NSSAMPLE(st))
call dtput (dt, "#\tsorder\t\t%d\n")
call pargi (ST_SORDER(st))
call dtput (dt, "#\tsseed\t\t%d\n")
call pargl (sseed)
# Save the luminosity function fitting parameters.
call dtput (dt, "#\tnlsample\t%d\n")
call pargi (ST_NLSAMPLE(st))
call dtput (dt, "#\tlorder\t\t%d\n")
call pargi (ST_LORDER(st))
call dtput (dt, "#\tlseed\t\t%d\n")
call pargl (lseed)
# Save the number of stars.
call dtput (dt, "#\tnstars\t\t%d\n")
call pargi (ST_NSTARS(st))
end
# ST_DTGINIT -- Write the GALLIST header to the database.
procedure st_dtginit (dt, st, galaxies, sseed, lseed)
pointer dt # pointer to database
pointer st # pointer to starlist structure
char galaxies[ARB] # name of output text file
long sseed # spatial function seed
long lseed # luminsosity function seed
begin
call dtptime (dt)
call dtput (dt, "# begin\t%s\n")
call pargstr (galaxies)
# Save the spatial distribution function parameters.
call dtput (dt, "#\tspatial\t\t%s\n")
switch (ST_SPATIAL(st)) {
case ST_UNIFORM:
call pargstr ("uniform")
case ST_HUBBLE:
call pargstr ("hubble")
call dtput (dt, "#\txcenter\t\t%g\n")
call pargr (ST_XC(st))
call dtput (dt, "#\tycenter\t\t%g\n")
call pargr (ST_YC(st))
call dtput (dt, "#\tcoreradius\t%g\n")
call pargr (ST_CORE(st))
call dtput (dt, "#\tbaseline\t%g\n")
call pargr (ST_BASE(st))
case ST_SPFILE:
call pargstr (ST_SFILE(st))
call dtput (dt, "#\txcenter\t\t%g\n")
call pargr (ST_XC(st))
call dtput (dt, "#\tycenter\t\t%g\n")
call pargr (ST_YC(st))
}
call dtput (dt, "#\txmin\t\t%g\n")
call pargr (ST_XMIN(st))
call dtput (dt, "#\txmax\t\t%g\n")
call pargr (ST_XMAX(st))
call dtput (dt, "#\tymin\t\t%g\n")
call pargr (ST_YMIN(st))
call dtput (dt, "#\tymax\t\t%g\n")
call pargr (ST_YMAX(st))
# Save the luminsosity function parameters.
call dtput (dt, "#\tluminosity\t%s\n")
switch (ST_LUMINOSITY(st)) {
case ST_UNIFORM:
call pargstr ("uniform")
case ST_POWLAW:
call pargstr ("powlaw")
call dtput (dt, "#\tpower\t\t%g\n")
call pargr (ST_POWER(st))
case ST_SCHECTER:
call pargstr ("shechter")
call dtput (dt, "#\tmzero\t\t%g\n")
call pargr (ST_MZERO(st))
call dtput (dt, "#\talpha\t\t%g\n")
call pargr (ST_ALPHA(st))
call dtput (dt, "#\tmstar\t\t%g\n")
call pargr (ST_MSTAR(st))
case ST_LFFILE:
call pargstr (ST_LFILE(st))
}
call dtput (dt, "#\tminmag\t\t%g\n")
call pargr (ST_MINMAG(st))
call dtput (dt, "#\tmaxmag\t\t%g\n")
call pargr (ST_MAXMAG(st))
call dtput (dt, "#\teradius\t\t%g\n")
call pargr (ST_ERADIUS(st))
call dtput (dt, "#\tsradius\t\t%g\n")
call pargr (ST_SRADIUS(st))
call dtput (dt, "#\tegalmix\t\t%g\n")
call pargr (ST_EGALMIX(st))
call dtput (dt, "#\tar\t\t%g\n")
call pargr (ST_AR(st))
call dtput (dt, "#\tabsorption\t%g\n")
call pargr (ST_ABSORPTION(st))
call dtput (dt, "#\tz\t\t%g\n")
call pargr (ST_Z(st))
# Save the spatial distribution fitting parameters.
call dtput (dt, "#\tnssample\t%d\n")
call pargi (ST_NSSAMPLE(st))
call dtput (dt, "#\tsorder\t\t%d\n")
call pargi (ST_SORDER(st))
call dtput (dt, "#\tsseed\t\t%d\n")
call pargl (sseed)
# Save the spatial function fitting parameters.
call dtput (dt, "#\tnlsample\t%d\n")
call pargi (ST_NLSAMPLE(st))
call dtput (dt, "#\tlorder\t\t%d\n")
call pargi (ST_LORDER(st))
call dtput (dt, "#\tlseed\t\t%d\n")
call pargl (lseed)
# Save the number of stars.
call dtput (dt, "#\tngals\t\t%d\n")
call pargi (ST_NSTARS(st))
end
# ST_DTWRITE -- Write the starlist to the database.
procedure st_dtwrite (dt, x, y, mag, nstars)
pointer dt # pointer to the output database
real x[ARB] # array of x coordinates
real y[ARB] # array of y coordinates
real mag[ARB] # array of magnitude values
int nstars # number of stars
int i, j
pointer sp, index
begin
call smark (sp)
call salloc (index, nstars, TY_INT)
call st_qsort (y, Memi[index], Memi[index], nstars)
do i = 1, nstars {
j = Memi[index+i-1]
call dtput (dt, "\t%8.3f %8.3f %7.3f\n")
call pargr (x[j])
call pargr (y[j])
call pargr (mag[j])
}
call sfree (sp)
end
# ST_DTGWRITE -- Procedure to write the galaxy list to the database
procedure st_dtgwrite (dt, x, y, mag, egal, axis, round, phi, nstars)
pointer dt # pointer to database
real x[ARB] # x values
real y[ARB] # y values
real mag[ARB] # magnitude values
int egal[ARB] # galaxy types
real axis[ARB] # galaxy diameters
real round[ARB] # galaxy roundness
real phi[ARB] # galaxy position angles
int nstars # number of stars
int i, j
pointer sp, index
begin
call smark (sp)
call salloc (index, nstars, TY_INT)
call st_qsort (y, Memi[index], Memi[index], nstars)
do i = 1, nstars {
j = Memi[index+i-1]
call dtput (dt,
"\t%8.3f %8.3f %7.3f %7s %7.2f %5.3f %5.1f\n")
call pargr (x[j])
call pargr (y[j])
call pargr (mag[j])
if (egal[j] == ST_DEVAUC)
call pargstr ("devauc")
else
call pargstr ("expdisk")
call pargr (axis[j])
call pargr (round[j])
call pargr (phi[j])
}
call sfree (sp)
end
# ST_QSORT -- Vector Quicksort. In this version the index array is
# sorted.
define LOGPTR 20 # log2(maxpts) (1e6)
procedure st_qsort (data, a, b, npix)
real data[ARB] # data array
int a[ARB], b[ARB] # index array
int npix # number of pixels
int i, j, lv[LOGPTR], p, uv[LOGPTR], temp
real pivot
begin
# Initialize the indices for an inplace sort.
do i = 1, npix
a[i] = i
call amovi (a, b, npix)
# Initialize.
p = 1
lv[1] = 1
uv[1] = npix
# Sort.
while (p > 0) {
# If only one elem in subset pop stack otherwise pivot line.
if (lv[p] >= uv[p])
p = p - 1
else {
i = lv[p] - 1
j = uv[p]
pivot = data[b[j]]
while (i < j) {
for (i=i+1; data[b[i]] < pivot; i=i+1)
;
for (j=j-1; j > i; j=j-1)
if (data[b[j]] <= pivot)
break
if (i < j) { # Out of order pair
temp = b[j] # Interchange elements
b[j] = b[i]
b[i] = temp
}
}
j = uv[p] # Move pivot to position i
temp = b[j] # Interchange elements
b[j] = b[i]
b[i] = temp
if (i-lv[p] < uv[p] - i) { # Stack so shorter done first
lv[p+1] = lv[p]
uv[p+1] = i - 1
lv[p] = i + 1
} else {
lv[p+1] = i + 1
uv[p+1] = uv[p]
uv[p] = i - 1
}
p = p + 1 # Push onto stack
}
}
end
|