VIRCAM Pipeline  2.3.10
create_table.c
1 /* $Id: create_table.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 #include <stdio.h>
29 #include <string.h>
30 #include "imcore.h"
31 
32 
35 /*---------------------------------------------------------------------------*/
60 /*---------------------------------------------------------------------------*/
61 
62 extern void imcore_tabinit(ap_t *ap, int *xcol, int *ycol, int cattype,
63  cpl_table **tab) {
64 
65  switch (cattype) {
66  case CAT_INTWFC:
67  imcore_tabinit_1(xcol,ycol,tab);
68  break;
69  case CAT_WFCAM:
70  imcore_tabinit_2(xcol,ycol,tab);
71  break;
72  case CAT_BASIC:
73  imcore_tabinit_3(xcol,ycol,tab);
74  break;
75  case CAT_OBJMASK:
76  imcore_tabinit_4(ap,xcol,ycol,tab);
77  break;
78  case CAT_VIRCAM:
79  imcore_tabinit_6(xcol,ycol,tab);
80  break;
81  default:
82  cpl_msg_error("imcore_tabinit","Option %" CPL_SIZE_FORMAT " does not exist",
83  (cpl_size)cattype);
84  *tab = NULL;
85  break;
86  }
87 }
88 
89 /*---------------------------------------------------------------------------*/
116 /*---------------------------------------------------------------------------*/
117 
118 extern int imcore_do_seeing(ap_t *ap, int cattype, int nobjects,
119  cpl_table *tab) {
120  int status;
121 
122  switch (cattype) {
123  case CAT_INTWFC:
124  status = imcore_do_seeing_1(ap,nobjects,tab);
125  break;
126  case CAT_WFCAM:
127  status = imcore_do_seeing_2(ap,nobjects,tab);
128  break;
129  case CAT_BASIC:
130  status = imcore_do_seeing_3(ap,nobjects,tab);
131  break;
132  case CAT_OBJMASK:
133  status = imcore_do_seeing_4(ap);
134  break;
135  case CAT_VIRCAM:
136  status = imcore_do_seeing_6(ap,nobjects,tab);
137  break;
138  default:
139  status = CASU_FATAL;
140  cpl_msg_error("imcore_do_seeing","Option %" CPL_SIZE_FORMAT " does not exist",
141  (cpl_size)cattype);
142  break;
143  }
144  return(status);
145 }
146 
147 /*---------------------------------------------------------------------------*/
174 /*---------------------------------------------------------------------------*/
175 
176 extern int imcore_process_results(ap_t *ap, int cattype, float gain,
177  int *nobjects, cpl_table *tab) {
178  int status;
179 
180  switch (cattype) {
181  case CAT_INTWFC:
182  status = imcore_process_results_1(ap,nobjects,tab);
183  break;
184  case CAT_WFCAM:
185  status = imcore_process_results_2(ap,gain,nobjects,tab);
186  break;
187  case CAT_BASIC:
188  status = imcore_process_results_3(ap,nobjects,tab);
189  break;
190  case CAT_OBJMASK:
191  status = imcore_process_results_4(ap);
192  break;
193  case CAT_VIRCAM:
194  status = imcore_process_results_6(ap,gain,nobjects,tab);
195  break;
196  default:
197  status = CASU_FATAL;
198  cpl_msg_error("imcore_process_result","Option %" CPL_SIZE_FORMAT " does not exist",
199  (cpl_size)cattype);
200  break;
201  }
202  return(status);
203 }
204 
205 /*---------------------------------------------------------------------------*/
232 /*---------------------------------------------------------------------------*/
233 
234 extern int imcore_tabclose(ap_t *ap, int cattype) {
235  int status;
236 
237  switch (cattype) {
238  case CAT_OBJMASK:
239  status = imcore_tabclose_4(ap);
240  break;
241  default:
242  status = CASU_OK;
243  break;
244  }
245  return(status);
246 }
247 
248 /*---------------------------------------------------------------------------*/
279 /*---------------------------------------------------------------------------*/
280 
281 extern void imcore_tabinit_gen(int ncols, const char *ttype[],
282  const char *tunit[], cpl_type tform[],
283  cpl_table **tab) {
284  int i;
285  const char *fctid = "imcore_tabinit_gen";
286 
287  /* First, create the table with a default number of rows. */
288 
289  if ((*tab = cpl_table_new(0)) == NULL) {
290  cpl_msg_error(fctid,"Unable to open cpl table!");
291  return;
292  }
293 
294  /* Now define all of the columns */
295 
296  for (i = 0; i < ncols; i++) {
297  cpl_table_new_column(*tab,ttype[i],tform[i]);
298  cpl_table_set_column_unit(*tab,ttype[i],tunit[i]);
299  }
300 
301 }
302 
303 /*---------------------------------------------------------------------------*/
333 /*---------------------------------------------------------------------------*/
334 
335 extern int imcore_do_seeing_gen(ap_t *ap, const char *col_ellipt,
336  const char *col_pkht, char *col_areals[NAREAL],
337  int nobjects, cpl_table *tab) {
338  int i;
339  float fwhm,*areal[NAREAL],*ellipt,*pkht,*work;
340 
341  /* Get some space and read the relevant columns */
342 
343  work = NULL;
344  if (nobjects >= 3) {
345  ellipt = cpl_table_get_data_float(tab,col_ellipt);
346  pkht = cpl_table_get_data_float(tab,col_pkht);
347  work = cpl_malloc(nobjects*sizeof(*work));
348  for (i = 0; i < NAREAL; i++)
349  areal[i] = cpl_table_get_data_float(tab,col_areals[i]);
350 
351  /* Do the seeing calculation */
352 
353  imcore_seeing(ap,nobjects,ellipt,pkht,areal,work,&fwhm);
354  } else
355  fwhm = 0.0;
356  ap->fwhm = fwhm;
357 
358  /* Get out of here */
359 
360  freespace(work);
361  return(CASU_OK);
362 }
363 
366 /*
367 
368 $Log: create_table.c,v $
369 Revision 1.3 2015/08/12 11:16:55 jim
370 Modified procedure names to protect namespace
371 
372 Revision 1.2 2015/08/07 13:06:54 jim
373 Fixed copyright to ESO
374 
375 Revision 1.1.1.1 2015/06/12 10:44:32 jim
376 Initial import
377 
378 Revision 1.3 2015/01/09 11:42:36 jim
379 Fixed routines to remove globals
380 
381 Revision 1.2 2014/04/09 09:09:51 jim
382 Detabbed
383 
384 Revision 1.1.1.1 2013/08/27 12:07:48 jim
385 Imported
386 
387 
388 */
void imcore_tabinit(ap_t *ap, int *xcol, int *ycol, int cattype, cpl_table **tab)
Initialise catalogues.
Definition: create_table.c:62
void imcore_tabinit_4(ap_t *ap, int *imcore_xcol, int *imcore_ycol, cpl_table **tab)
Initialise type 4 catalogue (object mask)
int imcore_process_results_6(ap_t *ap, float gain, int *nobjects, cpl_table *tab)
Process results for type 6 catalogue.
int imcore_do_seeing_4(ap_t *ap)
Dummy seeing routine for type 4 catalogue (object mask)
void imcore_tabinit_6(int *imcore_xcol, int *imcore_ycol, cpl_table **tab)
Initialise type 6 catalogue.
int imcore_process_results_3(ap_t *ap, int *nobjects, cpl_table *tab)
Process results for type 3 catalogue.
int imcore_do_seeing_1(ap_t *ap, int nobjects, cpl_table *tab)
Do seeing estimate for type 1 catalogue.
int imcore_tabclose_4(ap_t *ap)
Close object mask.
int imcore_process_results_1(ap_t *ap, int *nobjects, cpl_table *tab)
Process results for type 1 catalogue.
int imcore_do_seeing_2(ap_t *ap, int nobjects, cpl_table *tab)
Do seeing estimate for type 2 catalogue.
int imcore_do_seeing_6(ap_t *ap, int nobjects, cpl_table *tab)
Do seeing estimate for type 6 catalogue.
int imcore_tabclose(ap_t *ap, int cattype)
Close the table structure.
Definition: create_table.c:234
void imcore_seeing(ap_t *ap, int nrows, float *ellipt, float *pkht, float **areal, float *work, float *fwhm)
Work out the median seeing.
Definition: seeing.c:80
int imcore_do_seeing_gen(ap_t *ap, const char *col_ellipt, const char *col_pkht, char *col_areals[NAREAL], int nobjects, cpl_table *tab)
Do seeing estimate (generic)
Definition: create_table.c:335
void imcore_tabinit_3(int *imcore_xcol, int *imcore_ycol, cpl_table **tab)
Initialise type 1 catalogue.
int imcore_process_results_2(ap_t *ap, float gain, int *nobjects, cpl_table *tab)
Process results for type 2 catalogue.
void imcore_tabinit_1(int *imcore_xcol, int *imcore_ycol, cpl_table **tab)
Initialise type 1 catalogue.
int imcore_do_seeing(ap_t *ap, int cattype, int nobjects, cpl_table *tab)
Do seeing estimate.
Definition: create_table.c:118
int imcore_do_seeing_3(ap_t *ap, int nobjects, cpl_table *tab)
Do seeing estimate for type 3 catalogue.
void imcore_tabinit_gen(int ncols, const char *ttype[], const char *tunit[], cpl_type tform[], cpl_table **tab)
Initialise tables (generic)
Definition: create_table.c:281
int imcore_process_results(ap_t *ap, int cattype, float gain, int *nobjects, cpl_table *tab)
Process results.
Definition: create_table.c:176
int imcore_process_results_4(ap_t *ap)
Process results for type 4 catalogue (object mask)
void imcore_tabinit_2(int *imcore_xcol, int *imcore_ycol, cpl_table **tab)
Initialise type 2 catalogue.