1 | #ifndef UTILS_H |
---|
2 | #define UTILS_H |
---|
3 | |
---|
4 | #include <wcs.h> |
---|
5 | #include <string> |
---|
6 | |
---|
7 | struct wcsprm; // just foreshadow this. |
---|
8 | |
---|
9 | // define the speed of light for WCS-related accessor functions |
---|
10 | const float C_kms = 299792.458; |
---|
11 | |
---|
12 | int linear_regression(int num, float *x, float *y, int ilow, int ihigh, |
---|
13 | float &slope, float &errSlope, |
---|
14 | float &intercept, float &errIntercept, float &r); |
---|
15 | void zscale(long imagesize, float *image, float &z1, float &z2); |
---|
16 | void zscale(long imagesize, float *image, float &z1, float &z2, float nullVal); |
---|
17 | template <class T> void sort(T *arr, int begin, int end); |
---|
18 | template <class T1, class T2> void sort(T1 *arr, T2 *matchingArray, |
---|
19 | int begin, int end); |
---|
20 | |
---|
21 | // STATISTICS-RELATED ROUTINES |
---|
22 | template <class T> T absval(T value); |
---|
23 | template <class T> void findMinMax(const T *array, const int size, |
---|
24 | T &min, T &max); |
---|
25 | template <class T> float findMean(T *array, int size); |
---|
26 | template <class T> float findStddev(T *array, int size); |
---|
27 | template <class T> T findMedian(T *array, int size); |
---|
28 | template <class T> T findMADFM(T *array, int size); |
---|
29 | template <class T> void findMedianStats(T *array, int size, |
---|
30 | T &median, T &madfm); |
---|
31 | template <class T> void findMedianStats(T *array, int size, bool *isGood, |
---|
32 | T &median, T &madfm); |
---|
33 | template <class T> void findNormalStats(T *array, int size, |
---|
34 | float &mean, float &stddev); |
---|
35 | template <class T> void findNormalStats(T *array, int size, bool *isGood, |
---|
36 | float &mean, float &stddev); |
---|
37 | template <class T> void findAllStats(T *array, int size, |
---|
38 | float &mean, float &stddev, |
---|
39 | T &median, T &madfm); |
---|
40 | template <class T> void findAllStats(T *array, int size, bool *mask, |
---|
41 | float &mean, float &stddev, |
---|
42 | T &median, T &madfm); |
---|
43 | |
---|
44 | |
---|
45 | //-------------------- |
---|
46 | // PLOTTING ROUTINES |
---|
47 | //-------------------- |
---|
48 | // The following are in plottingUtilities.cc |
---|
49 | // |
---|
50 | void plotLine(const float slope, const float intercept); |
---|
51 | void lineOfEquality(); |
---|
52 | void lineOfBestFit(int size, float *x, float *y); |
---|
53 | void lineOfBestFitPB(const int size, const float *x, const float *y); |
---|
54 | void plotVertLine(const float xval, const int colour, const int style); |
---|
55 | void plotVertLine(const float xval); |
---|
56 | void plotVertLine(const float xval, const int colour); |
---|
57 | void plotHorizLine(const float yval, const int colour, const int style); |
---|
58 | void plotHorizLine(const float yval); |
---|
59 | void plotHorizLine(const float yval, const int colour); |
---|
60 | void drawContours(const int size, const float *x, const float *y); |
---|
61 | |
---|
62 | // POSITION-RELATED ROUTINES |
---|
63 | std::string getIAUNameEQ(double ra, double dec, float equinox); |
---|
64 | std::string getIAUNameGAL(double ra, double dec); |
---|
65 | std::string decToDMS(double dec, std::string type); |
---|
66 | double dmsToDec(std::string dms); |
---|
67 | double angularSeparation(double &ra1, double &dec1, double &ra2, double &dec2); |
---|
68 | |
---|
69 | // WCS-RELATED ROUTINES |
---|
70 | int wcsToPixSingle(struct wcsprm *wcs, const double *world, double *pix); |
---|
71 | int pixToWCSSingle(struct wcsprm *wcs, const double *pix, double *world); |
---|
72 | int wcsToPixMulti(struct wcsprm *wcs, const double *world, |
---|
73 | double *pix, const int npts); |
---|
74 | int pixToWCSMulti(struct wcsprm *wcs, const double *pix, |
---|
75 | double *world, const int npts); |
---|
76 | double pixelToVelocity(struct wcsprm *wcs, double &x, double &y, |
---|
77 | double &z, std::string velUnits); |
---|
78 | double coordToVel(struct wcsprm *wcs, const double coord, std::string outputUnits); |
---|
79 | double velToCoord(struct wcsprm *wcs, const float velocity, std::string outputUnits); |
---|
80 | |
---|
81 | // FILTER SMOOTHING ROUTINES |
---|
82 | void waveletSmooth(int dim,float *array, int arraySize, float sigma); |
---|
83 | void hanningSmooth(float *array, int arraySize, int hanningSize); |
---|
84 | void tophatSmooth(float *array, int arraySize, int width); |
---|
85 | |
---|
86 | #endif |
---|