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