1 | #ifndef UTILS_H |
---|
2 | #define UTILS_H |
---|
3 | |
---|
4 | #include <param.hh> |
---|
5 | #include <wcs.h> |
---|
6 | #include <string> |
---|
7 | |
---|
8 | // define the speed of light for WCS-related accessor functions |
---|
9 | const float C_kms = 299792.458; |
---|
10 | |
---|
11 | // MENU ROUTINES FOR DIGANOSTIC/TEST PROGRAMS |
---|
12 | std::string menu(); |
---|
13 | std::string specMenu(); |
---|
14 | std::string orionMenu(); |
---|
15 | std::string imageMenu(); |
---|
16 | std::string twoblMenu(); |
---|
17 | |
---|
18 | int linear_regression(int num, float *x, float *y, int ilow, int ihigh, |
---|
19 | float &slope, float &errSlope, |
---|
20 | float &intercept, float &errIntercept, float &r); |
---|
21 | void zscale(long imagesize, float *image, float &z1, float &z2); |
---|
22 | void zscale(long imagesize, float *image, float &z1, float &z2, float nullVal); |
---|
23 | template <class T> void swap(T &a, T &b){T t=a;a=b;b=t;}; |
---|
24 | template <class T> void sort(T *arr, int begin, int end); |
---|
25 | template <class T1, class T2> void sort(T1 *arr, T2 *matchingArray, |
---|
26 | int begin, int end); |
---|
27 | |
---|
28 | // STATISTICS-RELATED ROUTINES |
---|
29 | template <class T> void findMinMax(const T *array, const int size, |
---|
30 | T &min, T &max); |
---|
31 | template <class T> float findMean(T *array, int size); |
---|
32 | template <class T> float findStddev(T *array, int size); |
---|
33 | template <class T> T findMedian(T *array, int size); |
---|
34 | template <class T> T findMADFM(T *array, int size); |
---|
35 | template <class T> void findMedianStats(T *array, int size, |
---|
36 | T &median, T &madfm); |
---|
37 | template <class T> void findMedianStats(T *array, int size, bool *isGood, |
---|
38 | T &median, T &madfm); |
---|
39 | template <class T> void findNormalStats(T *array, int size, |
---|
40 | float &mean, float &stddev); |
---|
41 | template <class T> void findNormalStats(T *array, int size, bool *isGood, |
---|
42 | float &mean, float &stddev); |
---|
43 | |
---|
44 | void findTrimmedHistStats(float *array, const int size, |
---|
45 | float &tmean, float &tsigma); |
---|
46 | void getRandomSpectrum(int length, float *x, float *y); |
---|
47 | void getRandomSpectrum(int length, float *x, double *y); |
---|
48 | void getRandomSpectrum(int length, float mean, float sigma, |
---|
49 | float *x, double *y); |
---|
50 | void getRandomSpectrum(int length, float mean, float sigma, |
---|
51 | float *x, float *y); |
---|
52 | float getNormalRV(); |
---|
53 | float getNormalRVtrunc(); |
---|
54 | float getNormalRV(float mean, float sigma); |
---|
55 | void getSigmaFactors(int &numScales, float *factors); |
---|
56 | void getSigmaFactors2D(int &numScales, float *factors); |
---|
57 | void getSigmaFactors3D(int &numScales, float *factors); |
---|
58 | void getSigmaFactors1DNew(int &numScales); |
---|
59 | void getSigmaFactors2DNew(int &numScales); |
---|
60 | void getSigmaFactors3DNew(int &numScales); |
---|
61 | |
---|
62 | |
---|
63 | // PLOTTING ROUTINES |
---|
64 | extern "C" int cpgtest(); |
---|
65 | extern "C" void cpgwedglog(const char* side, float disp, float width, |
---|
66 | float fg, float bg, const char *label); |
---|
67 | extern "C" void cpghistlog(int npts, float *data, float datamin, |
---|
68 | float datamax, int nbin, int pgflag); |
---|
69 | extern "C" void cpgcumul(int npts, float *data, float datamin, |
---|
70 | float datamax, int pgflag); |
---|
71 | void plotLine(const float slope, const float intercept); |
---|
72 | void lineOfEquality(); |
---|
73 | void lineOfBestFit(int size, float *x, float *y); |
---|
74 | void lineOfBestFitPB(const int size, const float *x, const float *y); |
---|
75 | void plotVertLine(const float xval, const int colour, const int style); |
---|
76 | void plotVertLine(const float xval); |
---|
77 | void plotVertLine(const float xval, const int colour); |
---|
78 | void plotHorizLine(const float yval, const int colour, const int style); |
---|
79 | void plotHorizLine(const float yval); |
---|
80 | void plotHorizLine(const float yval, const int colour); |
---|
81 | void drawContours(const int size, const float *x, const float *y); |
---|
82 | void drawBlankEdges(float *dataArray, int xdim, int ydim, Param &par); |
---|
83 | |
---|
84 | // POSITION-RELATED ROUTINES |
---|
85 | string getIAUNameEQ(double ra, double dec, float equinox); |
---|
86 | string getIAUNameGAL(double ra, double dec); |
---|
87 | string decToDMS(double dec, string type); |
---|
88 | double dmsToDec(string dms); |
---|
89 | double angularSeparation(double &ra1, double &dec1, double &ra2, double &dec2); |
---|
90 | |
---|
91 | // WCS-RELATED ROUTINES |
---|
92 | int wcsToPixSingle(wcsprm *wcs, const double *world, double *pix); |
---|
93 | int pixToWCSSingle(wcsprm *wcs, const double *pix, double *world); |
---|
94 | int wcsToPixMulti(wcsprm *wcs, const double *world, |
---|
95 | double *pix, const int npts); |
---|
96 | int pixToWCSMulti(wcsprm *wcs, const double *pix, |
---|
97 | double *world, const int npts); |
---|
98 | double pixelToVelocity(wcsprm *wcs, double &x, double &y, |
---|
99 | double &z, string velUnits); |
---|
100 | double coordToVel(wcsprm *wcs, const double coord, string outputUnits); |
---|
101 | double velToCoord(wcsprm *wcs, const float velocity, string outputUnits); |
---|
102 | |
---|
103 | // FILTER SMOOTHING ROUTINES |
---|
104 | void waveletSmooth(int dim,float *array, int arraySize, float sigma); |
---|
105 | void hanningSmooth(float *array, int arraySize, int hanningSize); |
---|
106 | void tophatSmooth(float *array, int arraySize, int width); |
---|
107 | |
---|
108 | #endif |
---|