VIRCAM Pipeline 2.3.12
apinit.c
1/* $Id: apinit.c,v 1.3 2015/08/12 11:16:55 jim Exp $
2 *
3 * This file is part of the CASU Pipeline utilities
4 * Copyright (C) 2015 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: jim $
23 * $Date: 2015/08/12 11:16:55 $
24 * $Revision: 1.3 $
25 * $Name: $
26 */
27
28
29#include <stdlib.h>
30#include <cpl.h>
31#include "imcore.h"
32
33#define freespace(_p) if (_p != NULL) {cpl_free(_p); _p = NULL;}
34
37/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65void imcore_apinit(ap_t *ap) {
66 int maxpa;
67
68 int i;
69
70 maxpa = ap->lsiz / 2; /* max possible parents */
71 ap->lastline = cpl_calloc(ap->lsiz + 1, sizeof(short int));
72 ap->maxip = 0;
73 ap->maxpa = maxpa;
74 ap->pstack = cpl_malloc(maxpa*sizeof(*ap->pstack));
75 ap->parent = cpl_malloc(maxpa*sizeof(*(ap->parent)));
76 for(i = 0; i < maxpa; i++) {
77 ap->pstack[i] = i;
78 ap->parent[i].pnop = -1; /* mark all parents inactive */
79 ap->parent[i].pnbp = -1; /* mark all parents inactive */
80 }
81 ap->ipstack = 1;
82 ap->maxbl = MAXBL;
83 ap->bstack = cpl_malloc(ap->maxbl*sizeof(*ap->bstack));
84 ap->blink = cpl_malloc(ap->maxbl*sizeof(*ap->blink));
85 ap->plessey = cpl_malloc(ap->maxbl*sizeof(*ap->plessey));
86 for (i = 0; i < MAXBL; i++)
87 ap->bstack[i] = i;
88 ap->ibstack = 2; /* block 1 will get overwritten; don't use it */
89 ap->nimages = 0;
90
91 /* set up exponential areal-profile levels: */
92
93 ap->areal[0] = 1;
94 for (i = 1; i < 8; i++)
95 ap->areal[i] = ap->areal[i-1]*2;
96
97 /* allocate some space for a processing array */
98
99 ap->npl = ap->lsiz;
100 ap->npl_pix = 0;
101 ap->plarray = cpl_malloc(ap->npl*sizeof(plstruct));
102
103 /* set these to null values as you may not need the background structure */
104
105 ap->backmap.nby = -1;
106 ap->backmap.bvals = NULL;
107
108 /* Initialise some info about the input images */
109
110 ap->indata = NULL;
111 ap->confdata = NULL;
112}
113
114/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142void imcore_apreinit(ap_t *ap) {
143 int i;
144
145 for (i = 0; i < ap->lsiz+1; i++)
146 ap->lastline[i] = 0;
147 ap->maxip = 0;
148 for(i = 0; i < ap->maxpa; i++) {
149 ap->pstack[i] = i;
150 ap->parent[i].pnop = -1; /* mark all parents inactive */
151 ap->parent[i].pnbp = -1; /* mark all parents inactive */
152 }
153 ap->ipstack = 1;
154 ap->ibstack = 2; /* block 1 will get overwritten; don't use it */
155 ap->nimages = 0;
156 ap->npl_pix = 0;
157
158}
159
160/*---------------------------------------------------------------------------*/
184/*---------------------------------------------------------------------------*/
185
186void imcore_apclose(ap_t *ap) {
187 int i;
188 freespace(ap->lastline);
189 freespace(ap->pstack);
190 freespace(ap->parent);
191 freespace(ap->bstack);
192 freespace(ap->blink);
193 freespace(ap->plessey);
194 freespace(ap->plarray);
195 if (ap->backmap.bvals != NULL) {
196 for (i = 0; i < ap->backmap.nby; i++)
197 freespace(ap->backmap.bvals[i]);
198 freespace(ap->backmap.bvals);
199 }
200}
201
202/*
203
204$Log: apinit.c,v $
205Revision 1.3 2015/08/12 11:16:55 jim
206Modified procedure names to protect namespace
207
208Revision 1.2 2015/08/07 13:06:54 jim
209Fixed copyright to ESO
210
211Revision 1.1.1.1 2015/06/12 10:44:32 jim
212Initial import
213
214Revision 1.2 2014/04/09 09:09:51 jim
215Detabbed
216
217Revision 1.1.1.1 2013/08/27 12:07:48 jim
218Imported
219
220
221*/
void imcore_apclose(ap_t *ap)
Close ap structure.
Definition: apinit.c:186
void imcore_apreinit(ap_t *ap)
Re-initialise the ap structure.
Definition: apinit.c:142
void imcore_apinit(ap_t *ap)
Initialise the ap structure.
Definition: apinit.c:65