OMEGA Pipeline Reference Manual  1.0.5
omega_utils.h
1 /* $Id: omega_utils.h,v 1.5 2012-01-12 12:05:09 agabasch Exp $
2  *
3  * This file is part of the OMEGA Pipeline
4  * Copyright (C) 2002,2003 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: agabasch $
23  * $Date: 2012-01-12 12:05:09 $
24  * $Revision: 1.5 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifndef OC_UTILS_H
29 #define OC_UTILS_H
30 
31 /*-----------------------------------------------------------------------------
32  Includes
33  -----------------------------------------------------------------------------*/
34 
35 #include <cpl.h>
36 #include "omega_dfs.h"
37 #include "omega_fits.h"
38 
39 #define VIR_OK 0
40 #define VIR_WARN 1
41 #define VIR_FATAL 2
42 
43 #if defined CPL_VERSION_CODE && CPL_VERSION_CODE <= CPL_VERSION(5, 5, 0)
44 typedef int cpl_size; /* The type as is was up to CPL 5.3 */
45 #define CPL_SIZE_FORMAT "d"
46 #endif
47 
48 /* Macros for freeing up space */
49 
50 #define freespace(_p) if (_p != NULL) {cpl_free(_p); _p = NULL;}
51 #define freeframe(_p) if (_p != NULL) {cpl_frame_delete(_p); _p = NULL;}
52 #define freeimage(_p) if (_p != NULL) {cpl_image_delete(_p); _p = NULL;}
53 #define freeilist(_p) if (_p != NULL) {cpl_imagelist_delete(_p); _p = NULL;}
54 #define freeframeset(_p) if (_p != NULL) {cpl_frameset_delete(_p); _p = NULL;}
55 #define freetable(_p) if (_p != NULL) {cpl_table_delete(_p); _p = NULL;}
56 #define freeplist(_p) if (_p != NULL) {cpl_propertylist_delete(_p); _p = NULL;}
57 #define freestats(_p) if (_p != NULL) {cpl_stats_delete(_p); _p = NULL;}
58 #define freefits(_p) if (_p != NULL) {omega_fits_delete(_p); _p = NULL;}
59 #define freelfits(_p,_n) if (_p != NULL) {omega_fits_delete_list(_p,_n); _p = NULL;}
60 #define freetfits(_p) if (_p != NULL) {omega_tfits_delete(_p); _p = NULL;}
61 #define freemask(_p) if (_p != NULL) {cpl_mask_delete(_p); _p = NULL;}
62 #define freematrix(_p) if (_p != NULL) {cpl_matrix_delete(_p); _p = NULL;}
63 #define freevector(_p) if (_p != NULL) {cpl_vector_delete(_p); _p = NULL;}
64 #define freebivector(_p) if (_p != NULL) {cpl_bivector_delete(_p); _p = NULL;}
65 #define freematrix(_p) if (_p != NULL) {cpl_matrix_delete(_p); _p = NULL;}
66 #define freewcs(_p) if (_p != NULL) {cpl_wcs_delete(_p); _p = NULL;}
67 #define freearray(_p) if (_p != NULL) {cpl_array_delete(_p); _p = NULL;}
68 
69 /* Prototypes */
70 const char * omega_get_license(void) ;
71 FILE * oc_paf_print_header(
72  char *,
73  char *,
74  char *);
75 
76 char * omega_get_root_name(const char * filename);
77 extern int omega_compare_tags(const cpl_frame *frame1, const cpl_frame *frame2);
78 extern void omega_exten_range(int inexten, int *out1, int *out2);
79 extern void omega_extensions(const cpl_frame *frame, int inexten, int *out1, int *out2);
80 extern cpl_frameset *omega_frameset_subgroup(cpl_frameset *frameset,
81  cpl_size *labels, cpl_size nlab,
82  const char *tag);
83 int omega_compare_reference(const cpl_image *master, const cpl_frame *refframe,
84  int ext, cpl_stats **diffstats);
85 
86 char * omega_get_pathname(const char * filename);
87 cpl_frame *omega_product_frame(const char *filename, const char *tag, cpl_frame_type type);
88 
89 int omega_save_dummy(cpl_frameset *set, cpl_parameterlist *parlist,cpl_frame_type type,
90  cpl_type_bpp bitpix, const char *outfile, const cpl_propertylist *plist,
91  const char *recipe, cpl_frame *product_frame);
92 
93 int omega_save_primary(cpl_frameset *set, const cpl_parameterlist *parlist,
94  const char *outfile, const char *recipe, const cpl_propertylist *plist,
95  cpl_frame *product_frame, const cpl_frame *inherit);
96 
97 cpl_image *omega_smooth_image(cpl_image *in, int size);
98 char *omega_create_name(const char *instrument, const char *name, const char *suffix);
99 int omega_biascor(cpl_image *image, const cpl_image *bias);
100 const char * omega_get_extension_chipid(int ext);
101 int omega_get_chip_orientation(int ext);
102 int omega_save_image(const cpl_image *img,cpl_frameset *set,const cpl_parameterlist *pars,
103  cpl_propertylist *alist, const cpl_propertylist *qclist,cpl_type_bpp bpp,
104  const char *name, const char *recipe, cpl_frame *frame,
105  const cpl_frame *inherit, int isfirst);
106 
107 int omega_save_table(const cpl_table *tbl,cpl_frameset *set,const cpl_parameterlist *pars,
108  cpl_propertylist *alist, const cpl_propertylist *qclist,const char *name,
109  const char *recipe, cpl_frame *frame,const cpl_frame *inherit, int isfirst);
110 
111 int omega_save_fits(omega_fits *scifits,cpl_frameset *set, const cpl_parameterlist *pars,
112  const cpl_propertylist *qclist, cpl_type_bpp bpp,const char *name,
113  const char *recipe,cpl_frame *product_frame, const cpl_frame *inherit,
114  const int isfirst);
115 cpl_error_code omega_get_pixelscale(cpl_propertylist *plist,
116  double * pixscale_x, double * pixscale_y);
117 
118 cpl_error_code omega_get_wcsshift(cpl_propertylist * wcslist1,
119  cpl_propertylist * wcslist2, double * xshift, double * yshift);
120 
121 #endif