create_table.c

00001 /* $Id: create_table.c,v 1.4 2010/09/09 12:09:57 jim Exp $
00002  *
00003  * This file is part of the VIRCAM Pipeline
00004  * Copyright (C) 2005 Cambridge Astronomy Survey Unit
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: jim $
00023  * $Date: 2010/09/09 12:09:57 $
00024  * $Revision: 1.4 $
00025  * $Name: v1-1-0 $
00026  */
00027 
00028 #include <stdio.h>
00029 #include <string.h>
00030 #include "imcore.h"
00031 
00032 static float *work = NULL;
00033 
00034 static void tidy(void);
00035 
00038 /*---------------------------------------------------------------------------*/
00063 /*---------------------------------------------------------------------------*/
00064 
00065 extern void tabinit(ap_t *ap) {
00066 
00067     switch (cattype) {
00068     case CAT_INTWFC:
00069         tabinit_1();
00070         break;
00071     case CAT_WFCAM:
00072         tabinit_2();
00073         break;
00074     case CAT_BASIC:
00075         tabinit_3();
00076         break;
00077     case CAT_OBJMASK:
00078         tabinit_4(ap);
00079         break;
00080     default:
00081         cpl_msg_error("tabinit","Option %d does not exist",cattype);
00082         tab = NULL;
00083         break;
00084     }
00085 }
00086 
00087 /*---------------------------------------------------------------------------*/
00114 /*---------------------------------------------------------------------------*/
00115 
00116 extern int do_seeing(ap_t *ap) {
00117     int status;
00118 
00119     switch (cattype) {
00120     case CAT_INTWFC:
00121         status = do_seeing_1(ap);
00122         break;
00123     case CAT_WFCAM:
00124         status = do_seeing_2(ap);
00125         break;
00126     case CAT_BASIC:
00127         status = do_seeing_3(ap);
00128         break;
00129     case CAT_OBJMASK:
00130         status = do_seeing_4(ap);
00131         break;
00132     default:
00133         status = VIR_FATAL;
00134         cpl_msg_error("do_seeing","Option %d does not exist",cattype);
00135         break;
00136     }
00137     return(status);
00138 }
00139 
00140 /*---------------------------------------------------------------------------*/
00167 /*---------------------------------------------------------------------------*/
00168 
00169 extern int process_results(ap_t *ap) {
00170     int status;
00171     
00172     switch (cattype) {
00173     case CAT_INTWFC:
00174         status = process_results_1(ap);
00175         break;
00176     case CAT_WFCAM:
00177         status = process_results_2(ap);
00178         break;
00179     case CAT_BASIC:
00180         status = process_results_3(ap);
00181         break;
00182     case CAT_OBJMASK:
00183         status = process_results_4(ap);
00184         break;
00185     default:
00186         status = VIR_FATAL;
00187         cpl_msg_error("process_result","Option %d does not exist",cattype);
00188         break;
00189     }
00190     return(status);
00191 }
00192 
00193 /*---------------------------------------------------------------------------*/
00220 /*---------------------------------------------------------------------------*/
00221 
00222 extern int tabclose(ap_t *ap) {
00223     int status;
00224 
00225     switch (cattype) {
00226     case CAT_OBJMASK:
00227         status = tabclose_4(ap);
00228         break;
00229     default:
00230         status = VIR_OK;
00231         break;
00232     }
00233     return(status);
00234 }
00235 
00236 /*---------------------------------------------------------------------------*/
00267 /*---------------------------------------------------------------------------*/
00268 
00269 extern void tabinit_gen(int ncols, const char *ttype[], const char *tunit[], 
00270                         cpl_type tform[]) {
00271     int i;
00272     const char *fctid = "tabinit_gen";
00273     
00274     /* First, create the table with a default number of rows. */
00275 
00276     if ((tab = cpl_table_new(0)) == NULL) {
00277         cpl_msg_error(fctid,"Unable to open cpl table!");
00278         return;
00279     }
00280 
00281     /* Now define all of the columns */
00282 
00283     for (i = 0; i < ncols; i++) {
00284         cpl_table_new_column(tab,ttype[i],tform[i]);
00285         cpl_table_set_column_unit(tab,ttype[i],tunit[i]);
00286     }
00287 
00288 }
00289 
00290 /*---------------------------------------------------------------------------*/
00320 /*---------------------------------------------------------------------------*/
00321 
00322 extern int do_seeing_gen(ap_t *ap, const char *col_ellipt, 
00323                          const char *col_pkht, char *col_areals[NAREAL]) {
00324     int i;
00325     float fwhm,*areal[NAREAL],*ellipt,*pkht;
00326 
00327     /* Get some space and read the relevant columns */
00328 
00329     if (nobjects >= 3) {
00330         ellipt = cpl_table_get_data_float(tab,col_ellipt);
00331         pkht = cpl_table_get_data_float(tab,col_pkht);
00332         work = cpl_malloc(nobjects*sizeof(*work));
00333         for (i = 0; i < NAREAL; i++)
00334             areal[i] = cpl_table_get_data_float(tab,col_areals[i]);
00335 
00336         /* Do the seeing calculation */
00337 
00338         seeing(ap,nobjects,ellipt,pkht,areal,work,&fwhm);
00339     } else 
00340         fwhm = 0.0;
00341     ap->fwhm = fwhm;
00342 
00343     /* Get out of here */
00344 
00345     tidy();
00346     return(VIR_OK);
00347 }
00348 
00349 static void tidy (void) {
00350 
00351     /* Free up workspace */
00352 
00353     freespace(work);
00354 }
00355 
00358 /*
00359 
00360 $Log: create_table.c,v $
00361 Revision 1.4  2010/09/09 12:09:57  jim
00362 Added docs
00363 
00364 Revision 1.3  2007/03/01 12:38:26  jim
00365 Small modifications after a bit of code checking
00366 
00367 Revision 1.2  2006/11/10 09:25:39  jim
00368 Modifed tabinit to only start with a single row
00369 
00370 Revision 1.1  2005/09/13 13:25:27  jim
00371 Initial entry after modifications to make cpl compliant
00372 
00373 
00374 */

Generated on 7 Feb 2011 for VIRCAM Pipeline by  doxygen 1.6.1