aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/daophot/nstar/dpmemnstar.x
blob: 04bd25f436712a8e158f882283625f8346736f89 (plain) (blame)
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
include "../lib/daophotdef.h"
include "../lib/nstardef.h"

# DP_NSTARSETUP -- Procedure to set up the NSTAR parameters.

procedure dp_nstarsetup (dp)

pointer	dp		# pointer to daophot structure

pointer	nstar

begin
	# Allocate Memory
	call malloc (DP_NSTAR(dp), LEN_NSTARSTRUCT, TY_STRUCT)
	nstar = DP_NSTAR(dp)

	DP_NNPIX(nstar) = NULL
	DP_NNUMER(nstar) = NULL
	DP_NDENOM(nstar) = NULL
	DP_NRPIXSQ(nstar) = NULL
	DP_NSKIP(nstar) = NULL
	DP_NXCLAMP(nstar) = NULL
	DP_NXOLD(nstar) = NULL
	DP_NX(nstar) = NULL
	DP_NV(nstar) = NULL
	DP_NSUMWT(nstar) = NULL
	DP_NC(nstar) = NULL
	DP_NIER(nstar) = NULL
end


# DP_MEMNSTAR -- Procedure to allocate sufficient memory for NSTAR.

procedure dp_memnstar (dao, max_star)

pointer	dao			# pointer to daophot structure
int	max_star		# maximum number of stars

pointer	nstar

begin
	nstar = DP_NSTAR(dao)

	if (DP_NNPIX (nstar) != NULL)
	    call mfree (DP_NNPIX (nstar), TY_INT)
	call malloc (DP_NNPIX (nstar), max_star + 1, TY_INT)

	if (DP_NNUMER (nstar) != NULL)
	    call mfree (DP_NNUMER (nstar), TY_REAL)
	call malloc (DP_NNUMER (nstar), max_star + 1, TY_REAL)

	if (DP_NDENOM (nstar) != NULL)
	    call mfree (DP_NDENOM (nstar), TY_REAL)
	call malloc (DP_NDENOM (nstar), max_star + 1, TY_REAL)

	if (DP_NRPIXSQ (nstar) != NULL)
	    call mfree (DP_NRPIXSQ (nstar), TY_REAL)
	call malloc (DP_NRPIXSQ (nstar), max_star + 1, TY_REAL)

	if (DP_NSKIP (nstar) != NULL)
	    call mfree (DP_NSKIP (nstar), TY_INT)
	call malloc (DP_NSKIP (nstar), max_star + 1, TY_INT)

	if (DP_NIER (nstar) != NULL)
	    call mfree (DP_NIER (nstar), TY_INT)
	call malloc (DP_NIER(nstar), max_star + 1, TY_INT)

	if (DP_NSUMWT (nstar) != NULL)
	    call mfree (DP_NSUMWT (nstar), TY_REAL)
	call malloc (DP_NSUMWT (nstar), max_star + 1, TY_REAL)

	if (DP_RECENTER(dao) == YES) {

	    if (DP_NXCLAMP (nstar) != NULL)
	        call mfree (DP_NXCLAMP (nstar), TY_REAL)
	    call malloc (DP_NXCLAMP (nstar), 3 * max_star + 1, TY_REAL)

	    if (DP_NXOLD (nstar) != NULL)
	        call mfree (DP_NXOLD (nstar), TY_REAL)
	    call malloc (DP_NXOLD (nstar), 3 * max_star + 1, TY_REAL)

	    if (DP_NX (nstar) != NULL)
	        call mfree (DP_NX (nstar), TY_REAL)
	    call malloc (DP_NX (nstar), 3 * max_star + 1, TY_REAL)

	    if (DP_NC (nstar) != NULL)
	        call mfree (DP_NC (nstar), TY_REAL)
	    call malloc (DP_NC (nstar), (3 * max_star + 1) * (3 * max_star + 1),
	        TY_REAL)

	    if (DP_NV (nstar) != NULL)
	        call mfree (DP_NV (nstar), TY_REAL)
	    call malloc (DP_NV (nstar), 3 * max_star + 1, TY_REAL)

	} else {

	    if (DP_NXCLAMP (nstar) != NULL)
	        call mfree (DP_NXCLAMP (nstar), TY_REAL)
	    call malloc (DP_NXCLAMP (nstar), max_star + 1, TY_REAL)

	    if (DP_NXOLD (nstar) != NULL)
	        call mfree (DP_NXOLD (nstar), TY_REAL)
	    call malloc (DP_NXOLD (nstar), max_star + 1, TY_REAL)

	    if (DP_NX (nstar) != NULL)
	        call mfree (DP_NX (nstar), TY_REAL)
	    call malloc (DP_NX (nstar), max_star + 1, TY_REAL)

	    if (DP_NC (nstar) != NULL)
	        call mfree (DP_NC (nstar), TY_REAL)
	    call malloc (DP_NC (nstar), (max_star + 1) * (max_star + 1),
	        TY_REAL)

	    if (DP_NV (nstar) != NULL)
	        call mfree (DP_NV (nstar), TY_REAL)
	    call malloc (DP_NV (nstar), max_star + 1, TY_REAL)
	}
end


# DP_NSCLOSE -- Procedure to close up the NSTAR parameters.

procedure dp_nsclose (dp)

pointer	dp		# pointer to daophot structure

pointer	nstar

begin
	nstar = DP_NSTAR(dp)

	if (DP_NNPIX (nstar) != NULL)
	    call mfree (DP_NNPIX (nstar), TY_INT)
	if (DP_NNUMER (nstar) != NULL)
	    call mfree (DP_NNUMER (nstar), TY_REAL)
	if (DP_NDENOM (nstar) != NULL)
	    call mfree (DP_NDENOM (nstar), TY_REAL)
	if (DP_NRPIXSQ (nstar) != NULL)
	    call mfree (DP_NRPIXSQ (nstar), TY_REAL)
	if (DP_NSKIP (nstar) != NULL)
	    call mfree (DP_NSKIP (nstar), TY_INT)
	if (DP_NXCLAMP (nstar) != NULL)
	    call mfree (DP_NXCLAMP (nstar), TY_REAL)
	if (DP_NXOLD (nstar) != NULL)
	    call mfree (DP_NXOLD (nstar), TY_REAL)
	if (DP_NX (nstar) != NULL)
	    call mfree (DP_NX (nstar), TY_REAL)
	if (DP_NV (nstar) != NULL)
	    call mfree (DP_NV (nstar), TY_REAL)
	if (DP_NSUMWT (nstar) != NULL)
	    call mfree (DP_NSUMWT (nstar), TY_REAL)
	if (DP_NC (nstar) != NULL)
	    call mfree (DP_NC (nstar), TY_REAL)
	if (DP_NIER (nstar) != NULL)
	    call mfree (DP_NIER (nstar), TY_INT)

	call mfree (nstar, TY_STRUCT)
end