cube_ops.h

00001 #ifndef CUBE_OPS_H
00002 #define CUBE_OPS_H
00003 /*******************************************************************************
00004 * E.S.O. - VLT project
00005 *
00006 * who       when      what
00007 * --------  --------  ----------------------------------------------
00008 * schreib  18/05/00  created
00009 */
00010 
00011 /************************************************************************
00012  * cube_ops.h
00013  * cube arithmetic routines
00014  *----------------------------------------------------------------------
00015  */
00016 
00017 /*
00018  * header files
00019  */
00020 
00021 /*
00022 #include <stdio.h>
00023 #include <cpl.h>
00024 
00025 #include "eclipse.h"
00026 #include "recipes.h"
00027 #include "spectrum_ops.h"
00028 #include <math.h>
00029 */
00030 #include "image_ops.h"
00031 #include <qfits.h>
00032 #include <cpl.h>
00033 
00034 
00035 /*----------------------------------------------------------------------------
00036  *                      Function ANSI C prototypes
00037  *--------------------------------------------------------------------------*/
00038 
00039 
00040 
00041 /*----------------------------------------------------------------------------
00042    Function     :       newCube()
00043    In           :       lx, ly, n_im
00044    Out          :       newly allocated cube
00045    Job          :       allocates a new cube structure
00046    Notice       :       object constructor
00047  ---------------------------------------------------------------------------*/
00048 /* <python> */
00049 OneCube *
00050 newCube(
00051     int     lx,
00052     int     ly,
00053     int     n_im);
00054 /* </python> */
00055 
00056 /*----------------------------------------------------------------------------
00057    Function :   cubeOps()
00058    In       :   2 cubes, operation to perform
00059    Out      :   result cube
00060    Job      :   4 operations between 2 cubes
00061  ---------------------------------------------------------------------------*/
00062 
00063 /* <python> */
00064 OneCube *
00065 cubeOps(
00066     OneCube *  cube1,
00067     OneCube *   cube2,
00068     int         operation);
00069 /* </python> */
00070 
00071 
00072 /*----------------------------------------------------------------------------
00073    Function :   cubeConstOps()
00074    In       :   1 cube, 1 constant, operation to perform
00075    Out      :   result cube
00076    Job      :   4 operations between a cube and a constant
00077    Notice   :   possible operations are:
00078                 Addition        '+'
00079                 Subtraction     '-'
00080                 Multiplication  '*'
00081                 Division        '/'
00082                 Logarithm       'l'
00083                 Power           '^'
00084                 Exponentiation  'e'
00085 
00086 
00087  ---------------------------------------------------------------------------*/
00088 
00089 /* <python> */
00090 OneCube *
00091 cubeConstOps(
00092     OneCube *  cube1,
00093     double     constant,
00094     int        operation);
00095 /* </python> */
00096 
00097 
00098 
00099 
00100 /*----------------------------------------------------------------------------
00101    Function :   cubeSub()
00102    In       :   two cubes
00103    Out      :   result cube 
00104    Job      :   subtract one cube from another
00105  ---------------------------------------------------------------------------*/
00106 
00107 OneCube *
00108 cubeSub(
00109     OneCube *   c1,
00110     OneCube *   c2
00111 ) ;
00112 
00113 
00114 
00115 /*----------------------------------------------------------------------------
00116    Function :   cubeAdd()
00117    In       :   two cubes
00118    Out      :   result cube 
00119    Job      :   add a cube to another
00120  ---------------------------------------------------------------------------*/
00121 
00122 OneCube *
00123 cubeAdd(
00124     OneCube *   c1,
00125     OneCube *   c2
00126 ) ;
00127 
00128 
00129 /*----------------------------------------------------------------------------
00130    Function :   cubeMul()
00131    In       :   two cubes
00132    Out      :   result cube 
00133    Job      :   multiply 2 cubes    
00134  ---------------------------------------------------------------------------*/
00135 
00136 OneCube *
00137 cubeMul(
00138     OneCube *   c1,
00139     OneCube *   c2
00140 ) ;
00141 
00142 
00143 /*----------------------------------------------------------------------------
00144    Function :   cubeDiv()
00145    In       :   two cubes
00146    Out      :   result cube
00147    Job      :   divide 2 cubes  
00148  ---------------------------------------------------------------------------*/
00149 
00150 OneCube *
00151 cubeDiv(
00152     OneCube *   c1,
00153     OneCube *   c2
00154 ) ;
00155 
00156 /*---------------------------------------------------------------------------
00157    Function :   addImageToCube()
00158    In       :   1 allocated cube, 1 allocated image
00159    Out      :   result cube
00160    Job      :   add an image to all planes in the cube
00161  ---------------------------------------------------------------------------*/
00162 
00163 /* <python> */
00164 OneCube * addImageToCube(OneCube * cu, OneImage * im);
00165 /* </python> */
00166 
00167 /*---------------------------------------------------------------------------
00168    Function :   subImageFromCube()
00169    In       :   1 allocated cube, 1 allocated image
00170    Out      :   result cube
00171    Job      :   subtract an image from all planes in the cube
00172  ---------------------------------------------------------------------------*/
00173 
00174 /* <python> */
00175 OneCube * subImageFromCube(OneCube * cu, OneImage * im);
00176 /* </python> */
00177 
00178 /*---------------------------------------------------------------------------
00179    Function :   mulImageToCube()
00180    In       :   1 allocated cube, 1 allocated image
00181    Out      :   result cube
00182    Job      :   multiply an image to all planes in the cube
00183  ---------------------------------------------------------------------------*/
00184 
00185 /* <python> */
00186 OneCube * mulImageToCube(OneCube * cu, OneImage * im);
00187 /* </python> */
00188 
00189 /*---------------------------------------------------------------------------
00190    Function :  divCubeByImage ()
00191    In       :   1 allocated cube, 1 allocated image
00192    Out      :   result cube
00193    Job      :   divide all planes in the cube by an image
00194  ---------------------------------------------------------------------------*/
00195 
00196 /* <python> */
00197 OneCube * divCubeByImage(OneCube * cu, OneImage * im);
00198 /* </python> */
00199 
00200 
00201 /*---------------------------------------------------------------------------
00202    Function     :       addSpectrumToCube()
00203    In           :       1 allocated cube, 1 allocated spectrum vector
00204    Out          :       result cube
00205    Job          :       adds a spectrum (in z-direction) from all data
00206                         points in a cube
00207  ---------------------------------------------------------------------------*/
00208 
00209 /* <python> */
00210 OneCube * addSpectrumToCube(OneCube *cu, Vector *spec);
00211 /* </python> */
00212 
00213 
00214 /*---------------------------------------------------------------------------
00215    Function     :       subSpectrumFromCube()
00216    In           :       1 allocated cube, 1 allocated spectrum vector
00217    Out          :       result cube
00218    Job          :       subtracts a spectrum (in z-direction) from all
00219                         data points in a cube
00220  ---------------------------------------------------------------------------*/
00221 
00222 /* <python> */
00223 OneCube * subSpectrumFromCube(OneCube *cu, Vector *spec);
00224 /* </python> */
00225 
00226 
00227 /*---------------------------------------------------------------------------
00228    Function     :       mulSpectrumToCube()
00229    In           :       1 allocated cube, 1 allocated spectrum vector
00230    Out          :       result cube
00231    Job          :       multiplies a spectrum (in z-direction) to all data
00232                         points in a cube
00233  ---------------------------------------------------------------------------*/
00234 
00235 /* <python> */
00236 OneCube * mulSpectrumToCube(OneCube *cu, Vector *spec);
00237 /* </python> */
00238 
00239 
00240 /*---------------------------------------------------------------------------
00241    Function     :       divCubeBySpectrum()
00242    In           :       1 allocated cube, 1 allocated spectrum vector
00243    Out          :       result cube
00244    Job          :       divides all data points of a cube by a spectrum i
00245                         (in z-direction)
00246  ---------------------------------------------------------------------------*/
00247 
00248 /* <python> */
00249 OneCube * divCubeBySpectrum(OneCube *cu, Vector *spec);
00250 /* </python> */
00251 
00252 /*---------------------------------------------------------------------------
00253    Function     :       cleanMeanOfSpectra()
00254    In           :       1 allocated cube, position of rectangle in x-y plane ,
00255                         low and high cut threshold
00256    Out          :       result spectrum vector
00257    Job          :       averaging routine to get a better spectral S/N, sorts
00258                         the values of the same z-position, cuts the lowest and
00259                         highest values according to given thresholds and then
00260                         takes the average within the x-y plane , cannot have
00261                         a sum of low and high rejected values greater than 90%
00262                         of all values
00263  ---------------------------------------------------------------------------*/
00264 
00265 /* <python> */
00266 Vector * cleanMeanOfSpectra(OneCube * cube, 
00267                              int llx, 
00268                              int lly, 
00269                              int urx, 
00270                              int ury,
00271                              double lo_reject,
00272                              double hi_reject);
00273 /* </python> */
00274 
00275 /*---------------------------------------------------------------------------
00276    Function     :       medianCube()
00277    In           :       1 allocated cube
00278    Out          :       result image
00279    Job          :       determines the median value in every pixel position
00280                         by considering all pixels along the third axis.
00281                         BLANK pixels in a plane are not considered. If all
00282                         pixels at a position are not valid the result will
00283                         be 'BLANK'.
00284  ---------------------------------------------------------------------------*/
00285 /* <python> */
00286 OneImage * medianCube(OneCube * cube) ;
00287 /* </python> */
00288 
00289 /*---------------------------------------------------------------------------
00290    Function     :       averageCubeToImage()
00291    In           :       1 allocated cube
00292    Out          :       result image
00293    Job          :       determines the average value in every pixel position
00294                         by considering all pixels along the third axis.
00295                         ZERO pixels in a plane are not considered. If all
00296                         pixels at a position are not valid the result will
00297                         be 'ZERO'.
00298  ---------------------------------------------------------------------------*/
00299 /* <python> */
00300 OneImage * averageCubeToImage(OneCube * cube) ;
00301 /* </python> */
00302 
00303 /*---------------------------------------------------------------------------
00304    Function     :       sumCubeToImage()
00305    In           :       1 allocated cube
00306    Out          :       result image
00307    Job          :       determines the sum value in every pixel position
00308                         by considering all pixels along the third axis.
00309                         ZERO pixels in a plane are not considered. If all
00310                         pixels at a position are not valid the result will
00311                         be 'ZERO'.
00312  ---------------------------------------------------------------------------*/
00313 /* <python> */
00314 OneImage * sumCubeToImage(OneCube * cube) ;
00315 /* </python> */
00316 
00317 /*---------------------------------------------------------------------------
00318    Function     :       averageCubeToImageBetweenWaves()
00319    In           :       cube: data cube to collapse
00320                         dispersion: dispersion per pixel in microns/pixel
00321                                     (derived from fits header information)
00322                         centralWave: central wavelength in the cube in microns
00323                                        (derived from fits header information)
00324                         initialLambda, finalLambda: wavelength values in microns
00325                                                     within which the cube is averaged
00326    Out          :       resulting averaged image
00327    Job          :       determines the average value in every pixel position
00328                         by considering only the pixels along the third axis
00329                         which lie between the given wavelength values.
00330                         These values are first recalculated to plane indices
00331                         by using the given dispersion and minimum wavelength in
00332                         the cube.
00333                         ZERO pixels in a plane are not considered. If all
00334                         pixels at a position are not valid the result will
00335                         be 'ZERO'.
00336  ---------------------------------------------------------------------------*/
00337 /* <python> */
00338 OneImage * averageCubeToImageBetweenWaves (OneCube * cube,
00339                                            float     dispersion,
00340                                            float     centralWave,
00341                                            float     initialLambda,
00342                                            float     finalLambda) ;
00343 /* </python> */
00344 
00345 /*---------------------------------------------------------------------------
00346    Function     :       extractImageFromCube()
00347    In           :       1 allocated cube
00348                         index of cube plane
00349    Out          :       extracted image
00350    Job          :       returns the wanted image plane of the cube
00351  ---------------------------------------------------------------------------*/
00352 /* <python> */
00353 OneImage * extractImageFromCube(OneCube * cube, int plane_index) ;
00354 /* </python> */
00355 
00356 /*---------------------------------------------------------------------------
00357    Function     :       extractSpectrumFromCube()
00358    In           :       cube: 1 allocated cube
00359                         x_pos, y_pos: x, y pixel position of the spectrum counted from 0
00360    Out          :       extracted spectral vector object
00361    Job          :       returns the wanted single spectrum of the cube
00362  ---------------------------------------------------------------------------*/
00363 /* <python> */
00364 Vector * extractSpectrumFromCube( OneCube * cube, int x_pos, int y_pos ) ;
00365 /* </python> */
00366 
00367 /*---------------------------------------------------------------------------
00368    Function     :       combineJitteredCubes()
00369    In           :       cubes: list of jittered cubes to mosaic
00370                         mergedCube: resulting merged cube containing the
00371                                     jittered cubes
00372                         n_cubes: number of cubes in the list to merge
00373                         cumoffsetx,y: array of relative x, y pixel offsets
00374                                       with respect to the first frame in the
00375                                       same sequence as the cube list.
00376                         exptimes: exposure times array giving the time
00377                                   in the same sequence as the cube list
00378                         kernel_type: the name of the interpolation kernel
00379                                      that you want to generate using the eclipse
00380                                      routine generate_interpolation_kernel()
00381                                      Supported kernels are:
00382                                      NULL:      default kernel, currently tanh
00383                                      "default": dito
00384                                      "tanh":    Hyperbolic tangent
00385                                      "sinc2":   Square sinc
00386                                      "lanczos": Lanczos2 kernel
00387                                      "hamming": Hamming kernel
00388                                      "hann":    Hann kernel
00389    Out          :       mask: cube of the same size as combinedCube
00390                               containing 0 for blank (ZERO pixels) and
00391                               the summed integration times for overlapping regions
00392                         mergedCube: final data cube containing the jittered cubes
00393    Job          :       merges jittered data cubes to one bigger cube
00394                         by averaging the overlap regions weighted by
00395                         the integration times. The x, y size of the final data
00396                         cube is user given, and should be between 32 and 64
00397                         pixels, while the relative pixel-offset (sub-pixel
00398                         accuracy) of the single cubes with respect to the
00399                         first cube in the list is read from the SEQ CUMOFFSETX,Y
00400                         fits header keyword.
00401  ---------------------------------------------------------------------------*/
00402 /*<python>*/
00403 OneCube * combineJitteredCubes ( OneCube ** cubes,
00404                                  OneCube *  mergedCube,
00405                                  int        n_cubes,
00406                                  float    * cumoffsetx,
00407                                  float    * cumoffsety,
00408                                  float    * exptimes,
00409                                  char     * kernel_type ) ;
00410 
00411 OneCube * combineJitteredCubesIt ( OneCube ** cubes,
00412                                  OneCube *  mergedCube,
00413                                  OneCube *  mask,
00414                                  int        n_cubes,
00415                                  float    * cumoffsetx,
00416                                  float    * cumoffsety,
00417                                  float    * exptimes,
00418                                  char     * kernel_type,
00419                                  const int z) ;
00420 /*</python>*/
00421 
00422 
00423 int combineJitteredCubesThomasRange(OneCube ** cubes,
00424                     OneCube  * mergedCube,
00425                     OneCube  * mask,
00426                     int        n_cubes,
00427                     float    * cumoffsetx,
00428                     float    * cumoffsety,
00429                     float    * exptimes,
00430                     char     * kernel_type,
00431                     const int z_min,
00432                     const int z_max,
00433                                     const double kappa );
00434 
00435 int combineJitteredCubesSkyRange (OneCube ** cubes,
00436                    OneCube  * mergedCube,
00437                    OneCube  * mask,
00438                    OneCube  * mergedSky,
00439                    OneCube  * mergedMsk,
00440                    OneCube  * mergeMed,
00441                    OneCube  * mergeAvg,
00442                    OneCube  * mergeStd,
00443                    OneCube  * mergeNc,
00444                    int        n_cubes,
00445                    float    * cumoffsetx,
00446                    float    * cumoffsety,
00447                    float    * exptimes,
00448                    char     * kernel_type,
00449                    const int z_min,
00450                    const int z_max);
00451 
00452 int combineJitteredCubesRange ( OneCube ** cubes,
00453                                  OneCube  * mergedCube,
00454                                  OneCube  * mask,
00455                                  int        n_cubes,
00456                                  float    * cumoffsetx,
00457                                  float    * cumoffsety,
00458                                  float    * exptimes,
00459                                  char     * kernel_type,
00460                                  const int z_min, const int z_max );
00461 
00462 int combineJitteredCubesSkyRange2 (OneCube ** cubes,
00463                    OneCube  * mergedCube,
00464                    OneCube  * mask,
00465                    OneCube  * mergedSky,
00466                    OneCube  * mergedMsk,
00467                    OneCube  * mergeMed,
00468                    OneCube  * mergeAvg,
00469                    OneCube  * mergeStd,
00470                    OneCube  * mergeNc,
00471                    int        n_cubes,
00472                    float    * cumoffsetx,
00473                    float    * cumoffsety,
00474                    float    * exptimes,
00475                    char     * kernel_type,
00476                    const int z_min,
00477                    const int z_max);
00478 
00479 
00480 /*---------------------------------------------------------------------------
00481    Function     :       interpolCubeSimple()
00482    In           :       cube: 1 allocated cube
00483                         badcube: bad pixel mask cube (0: bad, 1: good pixel)
00484                         maxdist: maximal pixel distance from bad pixel
00485                                  to search for good pixels, don't make this
00486                                  value too big!
00487    Out          :       interpolated cube, and corrected bad pixel mask cube
00488    Job          :       interpolates bad pixel of an object cube if a bad pixel
00489                         mask cube is available by using the nearest neighbors
00490                         in 3 dimensions.
00491  ---------------------------------------------------------------------------*/
00492 /*<python>*/
00493 OneCube * interpolCubeSimple( OneCube * cube,
00494                               OneCube * badcube,
00495                               int       maxdist ) ;
00496 /*</python>*/
00497 
00498 /*---------------------------------------------------------------------------
00499    Function     :       combineCubes()
00500    In           :       cubes: list of jittered cubes to mosaic
00501    In           :       cubes: list of jittered cubes to mosaic
00502                         mergedCube: resulting merged cube containing the
00503                                       jittered cubes
00504                         n_cubes: number of cubes in the list to merge
00505                         cumoffsetx,y: array of relative x, y pixel offsets
00506                                       with respect to the first frame in the
00507                                       same sequence as the cube list.
00508                         factor:      sigma factor beyond which pixels are
00509                                      thrown away.
00510                         kernel_type: the name of the interpolation kernel
00511                                      that you want to generate using the eclipse
00512                                      routine generate_interpolation_kernel()
00513                                      Supported kernels are:
00514                                      NULL:      default kernel, currently tanh
00515                                      "default": dito
00516                                      "tanh":    Hyperbolic tangent
00517                                      "sinc2":   Square sinc
00518                                      "lanczos": Lanczos2 kernel
00519                                      "hamming": Hamming kernel
00520                                      "hann":    Hann kernel
00521    Out          :       mask: cube of the same size as combinedCube
00522                               containing 0 for blank (ZERO pixels) and
00523                               n used pixels for overlapping regions
00524                         mergedCube: final data cube containing the jittered cubes
00525    Job          :       merges jittered data cubes to one bigger cube
00526                         by taking the median in each pixel and throw away the
00527                         high deviation pixels (bigger than factor * sigma)
00528                         The x, y size of the final data
00529                         cube is user given, and should be between 32 and 64
00530                         pixels, while the relative pixel-offset (sub-pixel
00531                         accuracy) of the single cubes with respect to the
00532                         first cube in the list is read from the SEQ CUMOFFSETX,Y
00533                         fits header keyword.
00534  ---------------------------------------------------------------------------*/
00535 /*<python>*/
00536 OneCube * combineCubes ( OneCube ** cubes,
00537                          OneCube  * mergedCube,
00538                          int        n_cubes,
00539                          float    * cumoffsetx,
00540                          float    * cumoffsety,
00541                          float      factor,
00542                          char     * kernel_type ) ;
00543 /*</python>*/
00544 
00545 /*<python>*/
00546 OneCube * binCube(OneCube *cu, int xscale, int yscale, int xmin, int xmax, int ymin, int ymax);
00547 /*</python>*/
00548 
00549 
00550 /*<python>*/
00551 OneCube * scaleCube(OneCube *cu, float xscale, float yscale, char * kernel_type);
00552 /*</python>*/
00553 
00554 
00555 #endif 
00557 /*--------------------------------------------------------------------------*/

Generated on Wed Oct 26 13:08:52 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001