create_table.c

00001 /* $Id: create_table.c,v 1.5 2012/01/15 17:40:09 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: 2012/01/15 17:40:09 $
00024  * $Revision: 1.5 $
00025  * $Name: vcam-1_3_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 %" CPL_SIZE_FORMAT " does not exist",
00082                       (cpl_size)cattype);
00083         tab = NULL;
00084         break;
00085     }
00086 }
00087 
00088 /*---------------------------------------------------------------------------*/
00115 /*---------------------------------------------------------------------------*/
00116 
00117 extern int do_seeing(ap_t *ap) {
00118     int status;
00119 
00120     switch (cattype) {
00121     case CAT_INTWFC:
00122         status = do_seeing_1(ap);
00123         break;
00124     case CAT_WFCAM:
00125         status = do_seeing_2(ap);
00126         break;
00127     case CAT_BASIC:
00128         status = do_seeing_3(ap);
00129         break;
00130     case CAT_OBJMASK:
00131         status = do_seeing_4(ap);
00132         break;
00133     default:
00134         status = VIR_FATAL;
00135         cpl_msg_error("do_seeing","Option %" CPL_SIZE_FORMAT " does not exist",
00136                       (cpl_size)cattype);
00137         break;
00138     }
00139     return(status);
00140 }
00141 
00142 /*---------------------------------------------------------------------------*/
00169 /*---------------------------------------------------------------------------*/
00170 
00171 extern int process_results(ap_t *ap) {
00172     int status;
00173     
00174     switch (cattype) {
00175     case CAT_INTWFC:
00176         status = process_results_1(ap);
00177         break;
00178     case CAT_WFCAM:
00179         status = process_results_2(ap);
00180         break;
00181     case CAT_BASIC:
00182         status = process_results_3(ap);
00183         break;
00184     case CAT_OBJMASK:
00185         status = process_results_4(ap);
00186         break;
00187     default:
00188         status = VIR_FATAL;
00189         cpl_msg_error("process_result","Option %" CPL_SIZE_FORMAT " does not exist",
00190                       (cpl_size)cattype);
00191         break;
00192     }
00193     return(status);
00194 }
00195 
00196 /*---------------------------------------------------------------------------*/
00223 /*---------------------------------------------------------------------------*/
00224 
00225 extern int tabclose(ap_t *ap) {
00226     int status;
00227 
00228     switch (cattype) {
00229     case CAT_OBJMASK:
00230         status = tabclose_4(ap);
00231         break;
00232     default:
00233         status = VIR_OK;
00234         break;
00235     }
00236     return(status);
00237 }
00238 
00239 /*---------------------------------------------------------------------------*/
00270 /*---------------------------------------------------------------------------*/
00271 
00272 extern void tabinit_gen(int ncols, const char *ttype[], const char *tunit[], 
00273                         cpl_type tform[]) {
00274     int i;
00275     const char *fctid = "tabinit_gen";
00276     
00277     /* First, create the table with a default number of rows. */
00278 
00279     if ((tab = cpl_table_new(0)) == NULL) {
00280         cpl_msg_error(fctid,"Unable to open cpl table!");
00281         return;
00282     }
00283 
00284     /* Now define all of the columns */
00285 
00286     for (i = 0; i < ncols; i++) {
00287         cpl_table_new_column(tab,ttype[i],tform[i]);
00288         cpl_table_set_column_unit(tab,ttype[i],tunit[i]);
00289     }
00290 
00291 }
00292 
00293 /*---------------------------------------------------------------------------*/
00323 /*---------------------------------------------------------------------------*/
00324 
00325 extern int do_seeing_gen(ap_t *ap, const char *col_ellipt, 
00326                          const char *col_pkht, char *col_areals[NAREAL]) {
00327     int i;
00328     float fwhm,*areal[NAREAL],*ellipt,*pkht;
00329 
00330     /* Get some space and read the relevant columns */
00331 
00332     if (nobjects >= 3) {
00333         ellipt = cpl_table_get_data_float(tab,col_ellipt);
00334         pkht = cpl_table_get_data_float(tab,col_pkht);
00335         work = cpl_malloc(nobjects*sizeof(*work));
00336         for (i = 0; i < NAREAL; i++)
00337             areal[i] = cpl_table_get_data_float(tab,col_areals[i]);
00338 
00339         /* Do the seeing calculation */
00340 
00341         seeing(ap,nobjects,ellipt,pkht,areal,work,&fwhm);
00342     } else 
00343         fwhm = 0.0;
00344     ap->fwhm = fwhm;
00345 
00346     /* Get out of here */
00347 
00348     tidy();
00349     return(VIR_OK);
00350 }
00351 
00352 static void tidy (void) {
00353 
00354     /* Free up workspace */
00355 
00356     freespace(work);
00357 }
00358 
00361 /*
00362 
00363 $Log: create_table.c,v $
00364 Revision 1.5  2012/01/15 17:40:09  jim
00365 Minor modifications to take into accout the changes in cpl API for v6
00366 
00367 Revision 1.4  2010/09/09 12:09:57  jim
00368 Added docs
00369 
00370 Revision 1.3  2007/03/01 12:38:26  jim
00371 Small modifications after a bit of code checking
00372 
00373 Revision 1.2  2006/11/10 09:25:39  jim
00374 Modifed tabinit to only start with a single row
00375 
00376 Revision 1.1  2005/09/13 13:25:27  jim
00377 Initial entry after modifications to make cpl compliant
00378 
00379 
00380 */

Generated on 15 Mar 2012 for VIRCAM Pipeline by  doxygen 1.6.1