[3] | 1 | #ifndef UTILS_H |
---|
| 2 | #define UTILS_H |
---|
| 3 | |
---|
[103] | 4 | #include <param.hh> |
---|
[3] | 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 | |
---|
[56] | 11 | // MENU ROUTINES FOR DIGANOSTIC/TEST PROGRAMS |
---|
[146] | 12 | std::string menu(); |
---|
| 13 | std::string specMenu(); |
---|
| 14 | std::string orionMenu(); |
---|
| 15 | std::string imageMenu(); |
---|
| 16 | std::string twoblMenu(); |
---|
[3] | 17 | |
---|
[146] | 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); |
---|
[3] | 21 | void zscale(long imagesize, float *image, float &z1, float &z2); |
---|
| 22 | void zscale(long imagesize, float *image, float &z1, float &z2, float nullVal); |
---|
[190] | 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); |
---|
[56] | 27 | |
---|
| 28 | // STATISTICS-RELATED ROUTINES |
---|
[190] | 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 | |
---|
[146] | 44 | void findTrimmedHistStats(float *array, const int size, |
---|
| 45 | float &tmean, float &tsigma); |
---|
[3] | 46 | void getRandomSpectrum(int length, float *x, float *y); |
---|
| 47 | void getRandomSpectrum(int length, float *x, double *y); |
---|
[146] | 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); |
---|
[3] | 52 | float getNormalRV(); |
---|
[70] | 53 | float getNormalRVtrunc(); |
---|
[3] | 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 | |
---|
[56] | 62 | |
---|
| 63 | // PLOTTING ROUTINES |
---|
[129] | 64 | extern "C" int cpgtest(); |
---|
[201] | 65 | extern "C" int cpgIsPS(); |
---|
[146] | 66 | extern "C" void cpgwedglog(const char* side, float disp, float width, |
---|
| 67 | float fg, float bg, const char *label); |
---|
| 68 | extern "C" void cpghistlog(int npts, float *data, float datamin, |
---|
| 69 | float datamax, int nbin, int pgflag); |
---|
| 70 | extern "C" void cpgcumul(int npts, float *data, float datamin, |
---|
| 71 | float datamax, int pgflag); |
---|
[56] | 72 | void plotLine(const float slope, const float intercept); |
---|
| 73 | void lineOfEquality(); |
---|
| 74 | void lineOfBestFit(int size, float *x, float *y); |
---|
| 75 | void lineOfBestFitPB(const int size, const float *x, const float *y); |
---|
| 76 | void plotVertLine(const float xval, const int colour, const int style); |
---|
| 77 | void plotVertLine(const float xval); |
---|
| 78 | void plotVertLine(const float xval, const int colour); |
---|
| 79 | void plotHorizLine(const float yval, const int colour, const int style); |
---|
| 80 | void plotHorizLine(const float yval); |
---|
| 81 | void plotHorizLine(const float yval, const int colour); |
---|
| 82 | void drawContours(const int size, const float *x, const float *y); |
---|
[129] | 83 | void drawBlankEdges(float *dataArray, int xdim, int ydim, Param &par); |
---|
[3] | 84 | |
---|
[56] | 85 | // POSITION-RELATED ROUTINES |
---|
[3] | 86 | string getIAUNameEQ(double ra, double dec, float equinox); |
---|
| 87 | string getIAUNameGAL(double ra, double dec); |
---|
[38] | 88 | string decToDMS(double dec, string type); |
---|
[3] | 89 | double dmsToDec(string dms); |
---|
| 90 | double angularSeparation(double &ra1, double &dec1, double &ra2, double &dec2); |
---|
| 91 | |
---|
[56] | 92 | // WCS-RELATED ROUTINES |
---|
[204] | 93 | int wcsToPixSingle(struct wcsprm *wcs, const double *world, double *pix); |
---|
| 94 | int pixToWCSSingle(struct wcsprm *wcs, const double *pix, double *world); |
---|
| 95 | int wcsToPixMulti(struct wcsprm *wcs, const double *world, |
---|
[146] | 96 | double *pix, const int npts); |
---|
[204] | 97 | int pixToWCSMulti(struct wcsprm *wcs, const double *pix, |
---|
[146] | 98 | double *world, const int npts); |
---|
[204] | 99 | double pixelToVelocity(struct wcsprm *wcs, double &x, double &y, |
---|
[146] | 100 | double &z, string velUnits); |
---|
[204] | 101 | double coordToVel(struct wcsprm *wcs, const double coord, string outputUnits); |
---|
| 102 | double velToCoord(struct wcsprm *wcs, const float velocity, string outputUnits); |
---|
[3] | 103 | |
---|
[56] | 104 | // FILTER SMOOTHING ROUTINES |
---|
| 105 | void waveletSmooth(int dim,float *array, int arraySize, float sigma); |
---|
| 106 | void hanningSmooth(float *array, int arraySize, int hanningSize); |
---|
| 107 | void tophatSmooth(float *array, int arraySize, int width); |
---|
[3] | 108 | |
---|
| 109 | #endif |
---|