source: tags/release-1.1.4/src/Utils/utils.hh @ 1441

Last change on this file since 1441 was 394, checked in by MatthewWhiting, 17 years ago

Fixing wcslib include calls so that it is a bit more robust.

File size: 4.2 KB
Line 
1// -----------------------------------------------------------------------
2// utils.hh: Prototypes for utility functions.
3// -----------------------------------------------------------------------
4// Copyright (C) 2006, Matthew Whiting, ATNF
5//
6// This program is free software; you can redistribute it and/or modify it
7// under the terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 2 of the License, or (at your
9// option) any later version.
10//
11// Duchamp is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14// for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Duchamp; if not, write to the Free Software Foundation,
18// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
19//
20// Correspondence concerning Duchamp may be directed to:
21//    Internet email: Matthew.Whiting [at] atnf.csiro.au
22//    Postal address: Dr. Matthew Whiting
23//                    Australia Telescope National Facility, CSIRO
24//                    PO Box 76
25//                    Epping NSW 1710
26//                    AUSTRALIA
27// -----------------------------------------------------------------------
28#ifndef UTILS_H
29#define UTILS_H
30
31#include <wcslib/wcs.h>
32#include <string>
33
34struct wcsprm; // just foreshadow this.
35
36// define the speed of light for WCS-related accessor functions
37const float C_kms = 299792.458;
38
39int linear_regression(int num, float *x, float *y, int ilow, int ihigh,
40                      float &slope, float &errSlope,
41                      float &intercept, float &errIntercept, float &r);
42void zscale(long imagesize, float *image, float &z1, float &z2);
43void zscale(long imagesize, float *image, float &z1, float &z2, float nullVal);
44template <class T> void sort(T *arr, int begin, int end);
45template <class T1, class T2> void sort(T1 *arr, T2 *matchingArray,
46                                        int begin, int end);
47
48// STATISTICS-RELATED ROUTINES
49template <class T> T absval(T value);
50template <class T> void findMinMax(const T *array, const int size,
51                                   T &min, T &max);
52template <class T> float findMean(T *array, int size);
53template <class T> float findStddev(T *array, int size);
54template <class T> T findMedian(T *array, int size);
55template <class T> T findMADFM(T *array, int size);
56template <class T> void findMedianStats(T *array, int size,
57                                        T &median, T &madfm);
58template <class T> void findMedianStats(T *array, int size, bool *isGood,
59                                        T &median, T &madfm);
60template <class T> void findNormalStats(T *array, int size,
61                                        float &mean, float &stddev);
62template <class T> void findNormalStats(T *array, int size, bool *isGood,
63                                        float &mean, float &stddev);
64template <class T> void findAllStats(T *array, int size,
65                                     float &mean, float &stddev,
66                                     T &median, T &madfm);
67template <class T> void findAllStats(T *array, int size, bool *mask,
68                                     float &mean, float &stddev,
69                                     T &median, T &madfm);
70
71
72// POSITION-RELATED ROUTINES
73std::string getIAUNameEQ(double ra, double dec, float equinox);
74std::string getIAUNameGAL(double ra, double dec);
75std::string decToDMS(double dec, std::string type);
76double dmsToDec(std::string dms);
77double angularSeparation(double &ra1, double &dec1, double &ra2, double &dec2);
78
79// WCS-RELATED ROUTINES
80int wcsToPixSingle(struct wcsprm *wcs, const double *world, double *pix);
81int pixToWCSSingle(struct wcsprm *wcs, const double *pix, double *world);
82int wcsToPixMulti(struct wcsprm *wcs, const double *world,
83                  double *pix, const int npts);
84int pixToWCSMulti(struct wcsprm *wcs, const double *pix,
85                  double *world, const int npts);
86double pixelToVelocity(struct wcsprm *wcs, double &x, double &y,
87                       double &z, std::string velUnits);
88double coordToVel(struct wcsprm *wcs, const double coord, std::string outputUnits);
89double velToCoord(struct wcsprm *wcs, const float velocity, std::string outputUnits);
90
91// FILTER SMOOTHING ROUTINES
92void waveletSmooth(int dim,float *array, int arraySize, float sigma);
93void hanningSmooth(float *array, int arraySize, int hanningSize);
94void tophatSmooth(float *array, int arraySize, int width);
95
96#endif
Note: See TracBrowser for help on using the repository browser.